#pragma once #include <stdint.h> #include <stdbool.h> #define BUFFER_LENGTH 10 static bool debug = true; #define DEBUG_ON 1 enum { FIRST_PASS = 0, OLD = 0, SECOND_PASS = 1, LASTPASS = 1 }; typedef struct{ uint8_t alarm : 1; uint8_t direction : 1; uint8_t msgType : 4; uint16_t auxId : 5; } ID; typedef struct { ID id; uint8_t data [6]; } Message; /* typedef struct { int writeHead; int readHead; int indexesLeft; Message buffer [BUFFER_LENGTH]; } ReceiveMessageBuffer;*/ bool CAN_init(bool isCentralUnit); bool CAN_send(uint16_t auxId, uint8_t msgType, uint8_t* data, uint32_t dataLength); bool CAN_registerMessageHandler(uint8_t msgType, void (*callback)(Message*)); bool CAN_centralSetInit(uint16_t auxId, uint32_t tempId); bool CAN_auxRequestInit(uint8_t auxType); #ifdef DEBUG_ON void generatePasswordPair(uint16_t seed, uint16_t auxId); bool can_init(); #endif