예제 #1
0
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;
}
예제 #2
0
파일: can.c 프로젝트: kjetilkjeka/byggern
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");
}