WIP
This commit is contained in:
@@ -74,16 +74,8 @@ void setup() {
|
||||
}
|
||||
|
||||
|
||||
DeviceId[0] = (SIGROW.SERNUM0 ^
|
||||
CircularShift(SIGROW.SERNUM2) << 1 ^
|
||||
CircularShift( CircularShift(SIGROW.SERNUM4)) ^
|
||||
CircularShift( CircularShift( CircularShift(SIGROW.SERNUM6))) ^
|
||||
CircularShift( CircularShift( CircularShift( CircularShift(SIGROW.SERNUM8)))));
|
||||
DeviceId[1] = (SIGROW.SERNUM1 ^
|
||||
CircularShift(SIGROW.SERNUM3) << 1 ^
|
||||
CircularShift( CircularShift(SIGROW.SERNUM5)) ^
|
||||
CircularShift( CircularShift( CircularShift(SIGROW.SERNUM7))) ^
|
||||
CircularShift( CircularShift( CircularShift( CircularShift(SIGROW.SERNUM9)))));
|
||||
DeviceId[0] = GetDeviceIdLow();
|
||||
DeviceId[1] = GetDeviceIdHigh();
|
||||
|
||||
SendSerialPackage();
|
||||
}
|
||||
@@ -111,7 +103,7 @@ void loop()
|
||||
for (int i = 0; i <= PinCount - 1; i++)
|
||||
{
|
||||
if (CheckPinStatus(&PinPD2[i]))
|
||||
SendSwitchedTriggeredCanPackage(&PinPD2[i]);
|
||||
SendSwitchedTriggeredCanPackage(PinPD2[i].meyPinId, PinPD2[i].pin_state);
|
||||
}
|
||||
|
||||
if (mcp2515.readMessage(&_frame) == MCP2515::ERROR_OK)
|
||||
@@ -159,15 +151,16 @@ void SendSerialPackage()
|
||||
mcp2515.sendMessage(MCP2515::TXB1, &_frame);
|
||||
}
|
||||
|
||||
void SendSwitchedTriggeredCanPackage(PinState * state)
|
||||
void SendSwitchedTriggeredCanPackage(byte pinId, int state)
|
||||
{
|
||||
_frame.can_id = CreateCanId(0x050);
|
||||
_frame.can_dlc = 2;
|
||||
_frame.data[0] = state->meyPinId;
|
||||
_frame.data[1] = state->pin_state;
|
||||
_frame.data[0] = pinId;
|
||||
_frame.data[1] = state;
|
||||
mcp2515.sendMessage(MCP2515::TXB1, &_frame);
|
||||
}
|
||||
|
||||
|
||||
void SendDoTriggerSwitchCanPackage(uint32_t targetCanId, byte pinId, byte state)
|
||||
{
|
||||
_frame.can_id = CreateCanId(0x050);
|
||||
@@ -201,6 +194,22 @@ bool ReadPin(PinState * state)
|
||||
return digitalRead(state->pin_id);
|
||||
}
|
||||
|
||||
byte GetDeviceIdLow(){
|
||||
return (SIGROW.SERNUM0 ^
|
||||
CircularShift(SIGROW.SERNUM2) << 1 ^
|
||||
CircularShift( CircularShift(SIGROW.SERNUM4)) ^
|
||||
CircularShift( CircularShift( CircularShift(SIGROW.SERNUM6))) ^
|
||||
CircularShift( CircularShift( CircularShift( CircularShift(SIGROW.SERNUM8)))));
|
||||
}
|
||||
|
||||
byte GetDeviceIdHigh(){
|
||||
return (SIGROW.SERNUM1 ^
|
||||
CircularShift(SIGROW.SERNUM3) << 1 ^
|
||||
CircularShift( CircularShift(SIGROW.SERNUM5)) ^
|
||||
CircularShift( CircularShift( CircularShift(SIGROW.SERNUM7))) ^
|
||||
CircularShift( CircularShift( CircularShift( CircularShift(SIGROW.SERNUM9)))));
|
||||
}
|
||||
|
||||
bool CheckPinStatus(PinState * state)
|
||||
{
|
||||
if (!state->is_input)
|
||||
@@ -222,4 +231,3 @@ bool CheckPinStatus(PinState * state)
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user