The nearly complete sources are there: http://www.canexperts.de/software/xc164.c But this snipped shows how it looks like:
/* (c) 2003 port GmbH? Halle/Saale http://www.port.de service@port.de *------------------------------------------------------------------------*/ DrvError_t? Init_CAN? (UNSIGNED16 wBaudRate) { UNSIGNED8 bN; /* loop counter */ UNSIGNED8 Bit0, Bit1; /* bit timing parameter */ /* used with TwinCAN CAN line 0 or 1; A or B */ int line = 0; /* optional line argument */ /* Set CAN Controller to INIT mode */ CAN_WRITE?(CAN_ControlReg, CAN_CNTL_INIT + CAN_CNTL_CONFIG_CHANGE_ENABLE?); /* Set Timing Register values */ switch (wBaudRate) { //case 10: Bit0 = CAN_BTR0_10K?; Bit1 = CAN_BTR1_10K?; break; //case 20: Bit0 = CAN_BTR0_20K?; Bit1 = CAN_BTR1_20K?; break; //case 50: Bit0 = CAN_BTR0_50K?; Bit1 = CAN_BTR1_50K?; break; //case 100: Bit0 = CAN_BTR0_100K?; Bit1 = CAN_BTR1_100K?; break; case 125: Bit0 = CAN_BTR0_125K?; Bit1 = CAN_BTR1_125K?; break; case 250: Bit0 = CAN_BTR0_250K?; Bit1 = CAN_BTR1_250K?; break; case 500: Bit0 = CAN_BTR0_500K?; Bit1 = CAN_BTR1_500K?; break; case 1000: Bit0 = CAN_BTR0_1000K?; Bit1 = CAN_BTR1_1000K; break; default : return (eCanDrvErrBdRate); } CAN_WRITE?(CAN_BitTiming0Reg, Bit0); CAN_WRITE?(CAN_BitTiming1Reg, Bit1); /* Mark all Message Objects as not valid (MSGVAL = Reset) */ for (bN = 0; (bN < 32); bN++) { /* chn, register, value */ CAN_WRITE_OBJ?(bN, CAN_OBJ_MCR?(0), ( CAN_MSG_VAL_RESET? & CAN_MSG_TXIE_RESET? & CAN_MSG_RXIE_RESET? & CAN_MSG_IntPnd_RESET?)); CAN_WRITE_OBJ?(bN, CAN_OBJ_MCR?(1), ( CAN_MSG_RmtPnd_RESET? & CAN_MSG_TxRqst_RESET? & CAN_MSG_CPUUpd_RESET? & CAN_MSG_NewDat_RESET?)); } /* Configure CAN-Transmit-Object (used to transmit ALL messages) */ Create_CAN_Tx? (CAN_TRANSMIT_OBJ?, TRINP_NODE?, 0); /* Configure CAN-Node-Receive-Objects */ /* object, int node, id, mask */ /* Assign ID later, masks now are all set to inhibit reception */ Create_CAN_Rx? (CAN_1_RECEIVE_OBJ?, TRINP_NODE?, 0xFFFFFFFF, 0xFFFFFFFF); /* Configure CAN-Broadcast-Receive-Object */ /* Fixed mask - not overwritten later */ Create_CAN_Rx? (CAN_2_RECEIVE_OBJ?, TRINP_NODE?, (MY_PROTOCOL_FLAG? + 0L), 0x100007FF); /* TRINP EINP */ CAN_WRITEW?(CAN_GlobalINPReg, ((TRINP_NODE? << 8) + (EINP_NODE? << 0))); /* -----------------------------------------------*/ /* Configuration of Service Request Nodes 0 - 7: */ /* -----------------------------------------------*/ /* SRN0 service request node configuration: * GPX IR IE ILVL GLVL 8 | 7 | 6 | 5 .....2 | 1 0 * - SRN0 interrupt priority level (ILVL) = 1 * - SRN0 interrupt group level (GLVL) = 2 * - SRN0 group priority extension (GPX) = 0 * 0 is always lowest priority */ /* CAN_0IC_? = 0x0046; */ /* IE ILVL GLVL */ CAN_0IC_? = (1 << 6) + ( 1 << 2 ) + 2; /* Power Down Message */ CAN_1IC_? = (1 << 6) + ( 2 << 2 ) + 2; ......