-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#149] Reorganised arm code into new file structure
- Loading branch information
1 parent
d5c1569
commit 56a39ae
Showing
4,271 changed files
with
9,636 additions
and
44 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
73 changes: 73 additions & 0 deletions
73
receivers/generic-c++/arduino/src/main/c++/arduino/i2c-module/I2cModule-basic.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Zscript Library - Command System for Microcontrollers) | ||
* Copyright (c) 2022 Zscript team (Susan Witts, Alicia Witts) | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#ifndef SRC_MAIN_CPP_ARDUINO_I2C_MODULE_ZSCRIPTI2CMODULE_HPP_ | ||
#define SRC_MAIN_CPP_ARDUINO_I2C_MODULE_ZSCRIPTI2CMODULE_HPP_ | ||
|
||
|
||
#include <zscript/modules/ZscriptModule.hpp> | ||
#include <zscript/execution/ZscriptCommandContext.hpp> | ||
|
||
|
||
#include "commands/I2cSetupCommand.hpp" | ||
#include "commands/GeneralI2cAction.hpp" | ||
|
||
#include "commands/I2cCapabilitiesCommand.hpp" | ||
|
||
#ifdef ZSCRIPT_HPP_INCLUDED | ||
#error Must be included before Zscript.hpp | ||
#endif | ||
|
||
#define MODULE_EXISTS_005 EXISTENCE_MARKER_UTIL | ||
#define MODULE_SWITCH_005 MODULE_SWITCH_UTIL(i2c_module::I2cModule<ZP>::execute) | ||
|
||
|
||
namespace Zscript { | ||
namespace i2c_module { | ||
|
||
template<class ZP> | ||
class I2cModule : public ZscriptModule<ZP> { | ||
|
||
public: | ||
|
||
|
||
static void setup() { | ||
Wire.begin(); | ||
} | ||
|
||
static void poll() { | ||
} | ||
|
||
static void execute(ZscriptCommandContext <ZP> ctx, uint8_t bottomBits) { | ||
switch (bottomBits) { | ||
case ZscriptI2cCapabilitiesCommand<ZP>::CODE: | ||
ZscriptI2cCapabilitiesCommand<ZP>::execute(ctx, MODULE_CAPABILITIES(005)); | ||
break; | ||
case ZscriptI2cSetupCommand<ZP>::CODE: | ||
ZscriptI2cSetupCommand<ZP>::execute(ctx); | ||
break; | ||
case GeneralI2cAction<ZP>::SEND_CODE: | ||
GeneralI2cAction<ZP>::executeSendReceive(ctx, GeneralI2cAction<ZP>::ActionType::SEND); | ||
break; | ||
case GeneralI2cAction<ZP>::RECEIVE_CODE: | ||
GeneralI2cAction<ZP>::executeSendReceive(ctx, GeneralI2cAction<ZP>::ActionType::RECEIVE); | ||
break; | ||
case GeneralI2cAction<ZP>::SEND_RECEIVE_CODE: | ||
GeneralI2cAction<ZP>::executeSendReceive(ctx, GeneralI2cAction<ZP>::ActionType::SEND_RECEIVE); | ||
break; | ||
default: | ||
ctx.status(ResponseStatus::COMMAND_NOT_FOUND); | ||
break; | ||
} | ||
} | ||
|
||
}; | ||
|
||
} | ||
} | ||
|
||
#endif /* SRC_MAIN_CPP_ARDUINO_I2C_MODULE_ZSCRIPTI2CMODULE_HPP_ */ |
87 changes: 87 additions & 0 deletions
87
...vers/generic-c++/arduino/src/main/c++/arduino/i2c-module/I2cModule-channelAndCommands.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Zscript Library - Command System for Microcontrollers) | ||
* Copyright (c) 2022 Zscript team (Susan Witts, Alicia Witts) | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#ifndef SRC_MAIN_CPP_ARDUINO_I2C_MODULE_ZSCRIPTI2CMODULE_HPP_ | ||
#define SRC_MAIN_CPP_ARDUINO_I2C_MODULE_ZSCRIPTI2CMODULE_HPP_ | ||
|
||
|
||
#include <zscript/modules/ZscriptModule.hpp> | ||
#include <zscript/execution/ZscriptCommandContext.hpp> | ||
|
||
|
||
#include "commands/I2cChannelInfo.hpp" | ||
#include "commands/I2cChannelSetup.hpp" | ||
|
||
#include "commands/I2cSetupCommand.hpp" | ||
#include "commands/GeneralI2cAction.hpp" | ||
|
||
#include "commands/I2cCapabilitiesCommand.hpp" | ||
|
||
#ifdef ZSCRIPT_HPP_INCLUDED | ||
#error Must be included before Zscript.hpp | ||
#endif | ||
|
||
#define MODULE_EXISTS_005 EXISTENCE_MARKER_UTIL | ||
#define MODULE_SWITCH_005 MODULE_SWITCH_UTIL(i2c_module::I2cModule<ZP>::execute) | ||
|
||
|
||
namespace Zscript { | ||
namespace i2c_module { | ||
|
||
template<class ZP> | ||
class I2cModule : public ZscriptModule<ZP> { | ||
|
||
public: | ||
static I2cChannel<ZP> channel; | ||
|
||
|
||
static void setup() { | ||
channel.setup(); | ||
channel.setAddress(ZscriptParams::i2cChannelAddress); | ||
} | ||
|
||
static void poll() { | ||
} | ||
|
||
static void execute(ZscriptCommandContext <ZP> ctx, uint8_t bottomBits) { | ||
switch (bottomBits) { | ||
case ZscriptI2cCapabilitiesCommand<ZP>::CODE: | ||
ZscriptI2cCapabilitiesCommand<ZP>::execute(ctx, MODULE_CAPABILITIES(005)); | ||
break; | ||
case ZscriptI2cSetupCommand<ZP>::CODE: | ||
ZscriptI2cSetupCommand<ZP>::execute(ctx); | ||
break; | ||
case GeneralI2cAction<ZP>::SEND_CODE: | ||
GeneralI2cAction<ZP>::executeSendReceive(ctx, GeneralI2cAction<ZP>::ActionType::SEND); | ||
break; | ||
case GeneralI2cAction<ZP>::RECEIVE_CODE: | ||
GeneralI2cAction<ZP>::executeSendReceive(ctx, GeneralI2cAction<ZP>::ActionType::RECEIVE); | ||
break; | ||
case GeneralI2cAction<ZP>::SEND_RECEIVE_CODE: | ||
GeneralI2cAction<ZP>::executeSendReceive(ctx, GeneralI2cAction<ZP>::ActionType::SEND_RECEIVE); | ||
break; | ||
case ZscriptI2cChannelInfoCommand<ZP>::CODE: | ||
ZscriptI2cChannelInfoCommand<ZP>::execute(ctx); | ||
break; | ||
case ZscriptI2cChannelSetupCommand<ZP>::CODE: | ||
ZscriptI2cChannelSetupCommand<ZP>::execute(ctx); | ||
break; | ||
default: | ||
ctx.status(ResponseStatus::COMMAND_NOT_FOUND); | ||
break; | ||
} | ||
} | ||
|
||
}; | ||
|
||
template<class ZP> | ||
I2cChannel<ZP> I2cModule<ZP>::channel; | ||
|
||
} | ||
} | ||
|
||
#endif /* SRC_MAIN_CPP_ARDUINO_I2C_MODULE_ZSCRIPTI2CMODULE_HPP_ */ |
144 changes: 144 additions & 0 deletions
144
.../generic-c++/arduino/src/main/c++/arduino/i2c-module/I2cModule-channelAndNotification.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* | ||
* Zscript Library - Command System for Microcontrollers) | ||
* Copyright (c) 2022 Zscript team (Susan Witts, Alicia Witts) | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#ifndef SRC_MAIN_CPP_ARDUINO_I2C_MODULE_ZSCRIPTI2CMODULE_HPP_ | ||
#define SRC_MAIN_CPP_ARDUINO_I2C_MODULE_ZSCRIPTI2CMODULE_HPP_ | ||
|
||
#define ZSCRIPT_HAVE_I2C_MODULE | ||
|
||
#include <zscript/modules/ZscriptModule.hpp> | ||
#include <zscript/execution/ZscriptCommandContext.hpp> | ||
|
||
#if defined(ZSCRIPT_SUPPORT_ADDRESSING) | ||
#include <zscript/execution/ZscriptAddressingContext.hpp> | ||
#endif | ||
|
||
#if defined(ZSCRIPT_SUPPORT_NOTIFICATIONS) | ||
#include <zscript/notifications/ZscriptNotificationSource.hpp> | ||
#include <zscript/execution/ZscriptNotificationContext.hpp> | ||
#include "notifications/I2cNotification.hpp" | ||
#endif | ||
|
||
#include "commands/I2cChannelInfo.hpp" | ||
#include "commands/I2cChannelSetup.hpp" | ||
|
||
#include "commands/I2cSetupCommand.hpp" | ||
#include "commands/GeneralI2cAction.hpp" | ||
|
||
#include "commands/I2cCapabilitiesCommand.hpp" | ||
|
||
#ifdef ZSCRIPT_HPP_INCLUDED | ||
#error Must be included before Zscript.hpp | ||
#endif | ||
|
||
#define MODULE_EXISTS_005 EXISTENCE_MARKER_UTIL | ||
#define MODULE_SWITCH_005 MODULE_SWITCH_UTIL(i2c_module::I2cModule<ZP>::execute) | ||
|
||
#if defined(ZSCRIPT_SUPPORT_ADDRESSING) | ||
#define MODULE_ADDRESS_EXISTS_005 EXISTENCE_MARKER_UTIL | ||
#define MODULE_ADDRESS_SWITCH_005 ADDRESS_SWITCH_UTIL(i2c_module::I2cModule<ZP>::address) | ||
#endif | ||
#define MODULE_NOTIFICATION_EXISTS_005 EXISTENCE_MARKER_UTIL | ||
#define MODULE_NOTIFICATION_SWITCH_005 NOTIFICATION_SWITCH_UTIL(i2c_module::I2cModule<ZP>::notification) | ||
|
||
namespace Zscript { | ||
|
||
namespace i2c_module { | ||
|
||
template<class ZP> | ||
class I2cModule : public ZscriptModule<ZP> { | ||
static bool isAddressing; | ||
static bool giveNotifs; | ||
|
||
static void smBusAlertReceived() { | ||
if (giveNotifs) { | ||
notifSrc.set(NULL, 0x50, isAddressing); | ||
} | ||
} | ||
|
||
|
||
public: | ||
static I2cChannel<ZP> channel; | ||
|
||
|
||
static GenericCore::ZscriptNotificationSource <ZP> notifSrc; | ||
|
||
static void setup() { | ||
pinMode(ZP::i2cAlertInPin, INPUT_PULLUP); | ||
attachInterrupt(digitalPinToInterrupt(ZP::i2cAlertInPin), &smBusAlertReceived, FALLING); | ||
pinMode(ZP::i2cAlertInPin, INPUT_PULLUP); | ||
channel.setup(); | ||
channel.setAddress(ZscriptParams::i2cChannelAddress); | ||
} | ||
|
||
static void poll() { | ||
if (digitalRead(ZP::i2cAlertInPin) == LOW) { | ||
smBusAlertReceived(); | ||
} | ||
} | ||
|
||
static void execute(ZscriptCommandContext <ZP> ctx, uint8_t bottomBits) { | ||
switch (bottomBits) { | ||
case ZscriptI2cCapabilitiesCommand<ZP>::CODE: | ||
ZscriptI2cCapabilitiesCommand<ZP>::execute(ctx, MODULE_CAPABILITIES(005)); | ||
break; | ||
case ZscriptI2cSetupCommand<ZP>::CODE: | ||
ZscriptI2cSetupCommand<ZP>::execute(ctx, &isAddressing, &giveNotifs | ||
); | ||
break; | ||
case GeneralI2cAction<ZP>::SEND_CODE: | ||
GeneralI2cAction<ZP>::executeSendReceive(ctx, GeneralI2cAction<ZP>::ActionType::SEND); | ||
break; | ||
case GeneralI2cAction<ZP>::RECEIVE_CODE: | ||
GeneralI2cAction<ZP>::executeSendReceive(ctx, GeneralI2cAction<ZP>::ActionType::RECEIVE); | ||
break; | ||
case GeneralI2cAction<ZP>::SEND_RECEIVE_CODE: | ||
GeneralI2cAction<ZP>::executeSendReceive(ctx, GeneralI2cAction<ZP>::ActionType::SEND_RECEIVE); | ||
break; | ||
case ZscriptI2cChannelInfoCommand<ZP>::CODE: | ||
ZscriptI2cChannelInfoCommand<ZP>::execute(ctx); | ||
break; | ||
case ZscriptI2cChannelSetupCommand<ZP>::CODE: | ||
ZscriptI2cChannelSetupCommand<ZP>::execute(ctx); | ||
break; | ||
default: | ||
ctx.status(ResponseStatus::COMMAND_NOT_FOUND); | ||
break; | ||
} | ||
} | ||
|
||
#if defined(ZSCRIPT_SUPPORT_ADDRESSING) | ||
static void address(ZscriptAddressingContext<ZP> ctx) { | ||
if (!isAddressing) { | ||
ctx.status(ResponseStatus::ADDRESS_NOT_FOUND); | ||
return; | ||
} | ||
GeneralI2cAction<ZP>::executeAddressing(ctx); | ||
} | ||
#endif | ||
|
||
static void notification(ZscriptNotificationContext <ZP> ctx, bool moveAlong) { | ||
ZscriptI2cNotification<ZP>::notification(ctx, moveAlong, isAddressing); | ||
} | ||
}; | ||
|
||
template<class ZP> | ||
I2cChannel<ZP> I2cModule<ZP>::channel; | ||
|
||
template<class ZP> | ||
bool I2cModule<ZP>::isAddressing = false; | ||
|
||
template<class ZP> | ||
bool I2cModule<ZP>::giveNotifs = false; | ||
|
||
template<class ZP> | ||
GenericCore::ZscriptNotificationSource <ZP> I2cModule<ZP>::notifSrc; | ||
} | ||
|
||
} | ||
|
||
#endif /* SRC_MAIN_CPP_ARDUINO_I2C_MODULE_ZSCRIPTI2CMODULE_HPP_ */ |
72 changes: 72 additions & 0 deletions
72
receivers/generic-c++/arduino/src/main/c++/arduino/i2c-module/I2cModule-channelOnly.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Zscript Library - Command System for Microcontrollers) | ||
* Copyright (c) 2022 Zscript team (Susan Witts, Alicia Witts) | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#ifndef SRC_MAIN_CPP_ARDUINO_I2C_MODULE_ZSCRIPTI2CMODULE_HPP_ | ||
#define SRC_MAIN_CPP_ARDUINO_I2C_MODULE_ZSCRIPTI2CMODULE_HPP_ | ||
|
||
|
||
#include <zscript/modules/ZscriptModule.hpp> | ||
#include <zscript/execution/ZscriptCommandContext.hpp> | ||
|
||
|
||
#include "commands/I2cChannelInfo.hpp" | ||
#include "commands/I2cChannelSetup.hpp" | ||
|
||
#include "commands/I2cCapabilitiesCommand.hpp" | ||
|
||
#ifdef ZSCRIPT_HPP_INCLUDED | ||
#error Must be included before Zscript.hpp | ||
#endif | ||
|
||
#define MODULE_EXISTS_005 EXISTENCE_MARKER_UTIL | ||
#define MODULE_SWITCH_005 MODULE_SWITCH_UTIL(i2c_module::I2cModule<ZP>::execute) | ||
|
||
|
||
namespace Zscript { | ||
namespace i2c_module { | ||
|
||
template<class ZP> | ||
class I2cModule : public ZscriptModule<ZP> { | ||
|
||
public: | ||
static I2cChannel <ZP> channel; | ||
|
||
|
||
static void setup() { | ||
channel.setup(); | ||
channel.setAddress(ZscriptParams::i2cChannelAddress); | ||
} | ||
|
||
static void poll() { | ||
} | ||
|
||
static void execute(ZscriptCommandContext <ZP> ctx, uint8_t bottomBits) { | ||
switch (bottomBits) { | ||
case ZscriptI2cCapabilitiesCommand<ZP>::CODE: | ||
ZscriptI2cCapabilitiesCommand<ZP>::execute(ctx, MODULE_CAPABILITIES(005)); | ||
break; | ||
case ZscriptI2cChannelInfoCommand<ZP>::CODE: | ||
ZscriptI2cChannelInfoCommand<ZP>::execute(ctx); | ||
break; | ||
case ZscriptI2cChannelSetupCommand<ZP>::CODE: | ||
ZscriptI2cChannelSetupCommand<ZP>::execute(ctx); | ||
break; | ||
default: | ||
ctx.status(ResponseStatus::COMMAND_NOT_FOUND); | ||
break; | ||
} | ||
} | ||
|
||
}; | ||
|
||
template<class ZP> | ||
I2cChannel <ZP> I2cModule<ZP>::channel; | ||
|
||
} | ||
} | ||
|
||
#endif /* SRC_MAIN_CPP_ARDUINO_I2C_MODULE_ZSCRIPTI2CMODULE_HPP_ */ |
Oops, something went wrong.