Update UP to V5

This commit is contained in:
Meydin87
2023-01-23 06:21:41 +01:00
parent 864f3f0faf
commit 441414a125
14 changed files with 45 additions and 152 deletions

View File

@@ -3,10 +3,10 @@
struct can_frame _frame;
MCP2515 mcp2515(PIN_PA3);
MCP2515 mcp2515(PIN_PD4);
const byte SoftwareVersionHigh = 1;
const byte SoftwareVersionLow = 0;
const byte HardwareVersionHigh = 2;
const byte HardwareVersionHigh = 3;
const byte HardwareVersionLow = 0;
typedef struct
@@ -35,32 +35,33 @@ void setup() {
PinPD2[0] = PinState();
PinPD2[0].Init(PIN_PC7, (byte) 1);
PinPD2[0].Init(PIN_PD0, (byte) 1);
PinPD2[1] = PinState();
PinPD2[1].Init(PIN_PD0, (byte) 2);
PinPD2[1].Init(PIN_PD2, (byte) 2);
PinPD2[2] = PinState();
PinPD2[2].Init(PIN_PD1, (byte) 3);
PinPD2[2].Init(PIN_PD5, (byte) 3);
PinPD2[3] = PinState();
PinPD2[3].Init(PIN_PD2, (byte) 4);
PinPD2[3].Init(PIN_PD7, (byte) 4);
PinPD2[4] = PinState();
PinPD2[4].Init(PIN_PD6, (byte) 5);
PinPD2[4].Init(PIN_PC7, (byte) 5);
PinPD2[5] = PinState();
PinPD2[5].Init(PIN_PD5, (byte) 6);
PinPD2[5].Init(PIN_PD1, (byte) 6);
PinPD2[6] = PinState();
PinPD2[6].Init(PIN_PD4, (byte) 7);
PinPD2[6].Init(PIN_PD3, (byte) 7);
PinPD2[7] = PinState();
PinPD2[7].Init(PIN_PD3, (byte) 8);
PinPD2[7].Init(PIN_PD6, (byte) 8);
_PROTECTED_WRITE(CLKCTRL.MCLKCTRLA, CLKCTRL.MCLKCTRLA | 1 << 7);
delay(10);
mcp2515.reset();
mcp2515.setBitrate(CAN_500KBPS, MCP_8MHZ); //Sets CAN at speed 500KBPS and Clock 8MHz
mcp2515.setNormalMode();
@@ -81,7 +82,7 @@ void setup() {
void loop()
{
for (int i = 0; i <= PinCount - 1; i++)
for (int i = 0; i <= PinCount - 1; i++)
{
if (CheckPinStatus(&PinPD2[i]))
SendSwitchedTriggeredCanPackage(PinPD2[i].meyPinId, PinPD2[i].pin_state);
@@ -124,12 +125,14 @@ void loop()
void SendSerialPackage()
{
_frame.can_id = CreateCanId(0xFFFF);
_frame.can_dlc = 4;
_frame.can_dlc = 6;
_frame.data[0] = SoftwareVersionHigh;
_frame.data[1] = SoftwareVersionLow;
_frame.data[2] = HardwareVersionHigh;
_frame.data[3] = HardwareVersionLow;
_frame.data[4] = DeviceId[0];
_frame.data[5] = DeviceId[1];
mcp2515.sendMessage(MCP2515::TXB1, &_frame);
}