DataMarshaller::DataMarshaller(void) { resetInputs(); resetOutputs(); }
void main(void) { unsigned char swTrig = 0; byte l3 = 1; lDelay(); Wait4NN = FALSE; isLearning = FALSE; led1timer = 0; doSOD = 0; ioIdx = 0; doEV = 0; evIdx = 0; NV1 = eeRead(EE_NV); initIO(); resetOutputs(); NN_temp = eeRead(EE_NN) * 256; NN_temp += eeRead(EE_NN + 1); if (NN_temp == 0 || NN_temp == 0xFFFF) NN_temp = DEFAULT_NN; CANID = eeRead(EE_CANID); if (CANID == 0 || CANID == 0xFF) CANID = NN_temp & 0xFF; initCAN(); delay(); restoreOutputStates(); delay(); SOD = eeRead(EE_SOD) * 256; SOD += eeRead(EE_SOD + 1); if (SOD == 0 || SOD == 0xFFFF) SOD = DEFAULT_SOD; // Loop forever (nothing lasts forever...) while (1) { CANMsg cmsg; unsigned char txed = 0; LED3 = PORT_ON; l3 ^= 1; // Check for Rx packet and setup pointer to it while (canbusRecv(&cmsg)) { // Decode the new command LED1 = 1; led1timer = 20; txed = parseCmd(&cmsg); } LED3 = PORT_OFF; doTimedOff(ioIdx); if (checkInput(ioIdx, doSOD)) { ioIdx++; if (ioIdx >= 16) { ioIdx = 0; doSOD = 0; } } if (l3) { if (doPortEvent(evIdx)) { evIdx++; if (evIdx >= 16) { evIdx = 0; doEV = 0; } } } if (checkFlimSwitch() && !swTrig) { swTrig = 1; } else if (!checkFlimSwitch() && swTrig) { swTrig = 0; if (Wait4NN) { Wait4NN = 0; LED2 = 0; } else { CANMsg canmsg; LED2 = 1; canmsg.b[d0] = OPC_RQNN; canmsg.b[d1] = NN_temp / 256; canmsg.b[d2] = NN_temp % 256; canmsg.b[dlc] = 3; canbusSend(&canmsg); Wait4NN = 1; } } } }