#ifndef MCP2515_CFG_H #define MCP2515_CFG_H // SPI port definition #define P_MOSI B,2 #define P_MISO B,3 #define P_SCK B,1 #define MCP2515_CS B,0 #define MCP2515_INT E,5 // bit timing definition // this are the register values written! Observe the formulas // CAN baud rate 125kbit/s // Prescaler 10MHz/8 = 1,25MHz // T_BIT = 10 * TQ #define CFG_SJW 0 // 1, not part of fixed bit timing #define CFG_BRP 3 // TQ = (2 * (BRP + 1)) / F_CPU // TQ // SyncSEG constant 1 #define CFG_PRSEG 0 // t_PropSeg = TQ * (PRSEG + 1) 1 #define CFG_PHSEG1 3 // t_PS1 = TQ * (PHSEG1 + 1) 4 #define CFG_PHSEG2 3 // t_PS2 = TQ * (PHSEG2 + 1) 4 // --- // total 10 // ---------------------------------------------------------------------------- #define RESET(x) _XRS(x) #define SET(x) _XS(x) #define TOGGLE(x) _XT(x) #define SET_OUTPUT(x) _XSO(x) #define SET_INPUT(x) _XSI(x) #define IS_SET(x) _XR(x) #define PORT(x) _port2(x) #define DDR(x) _ddr2(x) #define PIN(x) _pin2(x) #define _XRS(x,y) PORT(x) &= ~(1<