int MCP_init(){ //Start SPI driver SPI_init(); //Reset MPC to enter configuration mode MCP_reset(); // Self-test uint8_t value = MCP_read(MCP_CANSTAT); if ((value & MODE_MASK) != MODE_CONFIG) { return 1; } return 0; }
void CAN_init() { printf("CAN is initializing\n\r"); CAN_interuptInit(); MCP_reset(); MCP_write(CANINTE, (1<<RX0IE)|(1<<RX1IE)); //only interupt on RX MCP_write(CANINTF, 0x00); CAN_initRecieve(); CAN_modeSelect(NORMAL_MODE); printf("CAN initialization is complete \n\r"); }