Version_1

Dependencies:   LSM9DS0 mbed

Committer:
noname001
Date:
Mon Sep 05 02:02:19 2016 +0000
Revision:
1:235bfa26c5c1
Parent:
0:0b8d14ed499f
Version_2 (Date:2016-09-05)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
noname001 0:0b8d14ed499f 1 /********************************************************************
noname001 0:0b8d14ed499f 2 Header for CAN module library functions
noname001 0:0b8d14ed499f 3 *********************************************************************/
noname001 0:0b8d14ed499f 4
noname001 0:0b8d14ed499f 5 #if defined(__dsPIC30F__)
noname001 0:0b8d14ed499f 6 #include <p30fxxxx.h>
noname001 0:0b8d14ed499f 7 #else
noname001 0:0b8d14ed499f 8 #error "Does not build on this target"
noname001 0:0b8d14ed499f 9 #endif
noname001 0:0b8d14ed499f 10
noname001 0:0b8d14ed499f 11 #ifdef _C1IF
noname001 0:0b8d14ed499f 12
noname001 0:0b8d14ed499f 13 #ifndef __CAN_H
noname001 0:0b8d14ed499f 14 #define __CAN_H
noname001 0:0b8d14ed499f 15
noname001 0:0b8d14ed499f 16 /* List of SFRs for CAN */
noname001 0:0b8d14ed499f 17 /* This list contains the SFRs with default (POR) values to be used for configuring CAN */
noname001 0:0b8d14ed499f 18 /* The user can modify this based on the requirement */
noname001 0:0b8d14ed499f 19 #define CxRXF0SID_VALUE 0x0000
noname001 0:0b8d14ed499f 20 #define CxRXF0EIDH_VALUE 0x0000
noname001 0:0b8d14ed499f 21 #define CxRXF0EIDL_VALUE 0x0000
noname001 0:0b8d14ed499f 22 #define CxRXF1SID_VALUE 0x0000
noname001 0:0b8d14ed499f 23 #define CxRXF1EIDH_VALUE 0x0000
noname001 0:0b8d14ed499f 24 #define CxRXF1EIDL_VALUE 0x0000
noname001 0:0b8d14ed499f 25 #define CxRXF2SID_VALUE 0x0000
noname001 0:0b8d14ed499f 26 #define CxRXF2EIDH_VALUE 0x0000
noname001 0:0b8d14ed499f 27 #define CxRXF2EIDH_VALUE 0x0000
noname001 0:0b8d14ed499f 28 #define CxRXF3SID_VALUE 0x0000
noname001 0:0b8d14ed499f 29 #define CxRXF3EIDH_VALUE 0x0000
noname001 0:0b8d14ed499f 30 #define CxRXF3EIDH_VALUE 0x0000
noname001 0:0b8d14ed499f 31 #define CxRXF4SID_VALUE 0x0000
noname001 0:0b8d14ed499f 32 #define CxRXF4EIDH_VALUE 0x0000
noname001 0:0b8d14ed499f 33 #define CxRXF4EIDL_VALUE 0x0000
noname001 0:0b8d14ed499f 34 #define CxRXF5SID_VALUE 0x0000
noname001 0:0b8d14ed499f 35 #define CxRXF5EIDH_VALUE 0x0000
noname001 0:0b8d14ed499f 36 #define CxRXF5EIDL_VALUE 0x0000
noname001 0:0b8d14ed499f 37 #define CxRXM0SID_VALUE 0x0000
noname001 0:0b8d14ed499f 38 #define CxRXM0EIDH_VALUE 0x0000
noname001 0:0b8d14ed499f 39 #define CxRXM0EIDL_VALUE 0x0000
noname001 0:0b8d14ed499f 40 #define CxRXM1SID_VALUE 0x0000
noname001 0:0b8d14ed499f 41 #define CxRXM1EIDH_VALUE 0x0000
noname001 0:0b8d14ed499f 42 #define CxRXM1EIDL_VALUE 0x0000
noname001 0:0b8d14ed499f 43 #define CxTX2CON_VALUE 0x0000
noname001 0:0b8d14ed499f 44 #define CxTX2SID_VALUE 0x0000
noname001 0:0b8d14ed499f 45 #define CxTX2EID_VALUE 0x0000
noname001 0:0b8d14ed499f 46 #define CxTX2DLC_VALUE 0x0000
noname001 0:0b8d14ed499f 47 #define CxTX2B1_VALUE 0x0000
noname001 0:0b8d14ed499f 48 #define CxTX2B2_VALUE 0x0000
noname001 0:0b8d14ed499f 49 #define CxTX2B3_VALUE 0x0000
noname001 0:0b8d14ed499f 50 #define CxTX2B4_VALUE 0x0000
noname001 0:0b8d14ed499f 51 #define CxTX1CON_VALUE 0x0000
noname001 0:0b8d14ed499f 52 #define CxTX1SID_VALUE 0x0000
noname001 0:0b8d14ed499f 53 #define CxTX1EID_VALUE 0x0000
noname001 0:0b8d14ed499f 54 #define CxTX1DLC_VALUE 0x0000
noname001 0:0b8d14ed499f 55 #define CxTX1B1_VALUE 0x0000
noname001 0:0b8d14ed499f 56 #define CxTX1B2_VALUE 0x0000
noname001 0:0b8d14ed499f 57 #define CxTX1B3_VALUE 0x0000
noname001 0:0b8d14ed499f 58 #define CxTX1B4_VALUE 0x0000
noname001 0:0b8d14ed499f 59 #define CxTX0CON_VALUE 0x0000
noname001 0:0b8d14ed499f 60 #define CxTX0SID_VALUE 0x0000
noname001 0:0b8d14ed499f 61 #define CxTX0EID_VALUE 0x0000
noname001 0:0b8d14ed499f 62 #define CxTX0DLC_VALUE 0x0000
noname001 0:0b8d14ed499f 63 #define CxTX0B1_VALUE 0x0000
noname001 0:0b8d14ed499f 64 #define CxTX0B2_VALUE 0x0000
noname001 0:0b8d14ed499f 65 #define CxTX0B3_VALUE 0x0000
noname001 0:0b8d14ed499f 66 #define CxTX0B4_VALUE 0x0000
noname001 0:0b8d14ed499f 67 #define CxRX1CON_VALUE 0x0000
noname001 0:0b8d14ed499f 68 #define CxRX1SID_VALUE 0x0000
noname001 0:0b8d14ed499f 69 #define CxRX1EID_VALUE 0x0000
noname001 0:0b8d14ed499f 70 #define CxRX1DLC_VALUE 0x0000
noname001 0:0b8d14ed499f 71 #define CxRX1B1_VALUE 0x0000
noname001 0:0b8d14ed499f 72 #define CxRX1B2_VALUE 0x0000
noname001 0:0b8d14ed499f 73 #define CxRX1B3_VALUE 0x0000
noname001 0:0b8d14ed499f 74 #define CxRX1B4_VALUE 0x0000
noname001 0:0b8d14ed499f 75 #define CxRX0CON_VALUE 0x0000
noname001 0:0b8d14ed499f 76 #define CxRX0SID_VALUE 0x0000
noname001 0:0b8d14ed499f 77 #define CxRX0EID_VALUE 0x0000
noname001 0:0b8d14ed499f 78 #define CxRX0DLC_VALUE 0x0000
noname001 0:0b8d14ed499f 79 #define CxRX0B1_VALUE 0x0000
noname001 0:0b8d14ed499f 80 #define CxRX0B2_VALUE 0x0000
noname001 0:0b8d14ed499f 81 #define CxRX0B3_VALUE 0x0000
noname001 0:0b8d14ed499f 82 #define CxRX0B4_VALUE 0x0000
noname001 0:0b8d14ed499f 83 #define CxCTRL_VALUE 0x0480
noname001 0:0b8d14ed499f 84 #define CxCFG1_VALUE 0x0000
noname001 0:0b8d14ed499f 85 #define CxCFG2_VALUE 0x0000
noname001 0:0b8d14ed499f 86 #define CxINTF_VALUE 0x0000
noname001 0:0b8d14ed499f 87 #define CxINTE_VALUE 0x0000
noname001 0:0b8d14ed499f 88 #define CxEC_VALUE 0x0000
noname001 0:0b8d14ed499f 89
noname001 0:0b8d14ed499f 90 /*****************Masks for bit opern***************/
noname001 0:0b8d14ed499f 91 #define CAN_ABAT 0x1000
noname001 0:0b8d14ed499f 92 #define CAN_TXBO 0x2000
noname001 0:0b8d14ed499f 93 #define CAN_RXEP 0x0800
noname001 0:0b8d14ed499f 94 #define CAN_TXEP 0x1000
noname001 0:0b8d14ed499f 95 #define CAN_RXFUL 0x0080
noname001 0:0b8d14ed499f 96 #define CAN_TXREQ 0x0008
noname001 0:0b8d14ed499f 97
noname001 0:0b8d14ed499f 98 /* defines for CiCTRL (to be used for CANiSetOperationMode functions) */
noname001 0:0b8d14ed499f 99 /* these defines are such that, when used will clear ABAT bit */
noname001 0:0b8d14ed499f 100
noname001 0:0b8d14ed499f 101 #define CAN_CAPTURE_EN 0xAF00
noname001 0:0b8d14ed499f 102 #define CAN_CAPTURE_DIS 0x2F00
noname001 0:0b8d14ed499f 103
noname001 0:0b8d14ed499f 104 #define CAN_IDLE_STOP 0xAF00
noname001 0:0b8d14ed499f 105 #define CAN_IDLE_CON 0x8F00
noname001 0:0b8d14ed499f 106
noname001 0:0b8d14ed499f 107 #define CAN_MASTERCLOCK_1 0xAF00
noname001 0:0b8d14ed499f 108 #define CAN_MASTERCLOCK_0 0xA700
noname001 0:0b8d14ed499f 109
noname001 0:0b8d14ed499f 110 #define CAN_REQ_OPERMODE_NOR 0xA800
noname001 0:0b8d14ed499f 111 #define CAN_REQ_OPERMODE_DIS 0xA900
noname001 0:0b8d14ed499f 112 #define CAN_REQ_OPERMODE_LOOPBK 0xAA00
noname001 0:0b8d14ed499f 113 #define CAN_REQ_OPERMODE_LISTENONLY 0xAB00
noname001 0:0b8d14ed499f 114 #define CAN_REQ_OPERMODE_CONFIG 0xAC00
noname001 0:0b8d14ed499f 115 #define CAN_REQ_OPERMODE_LISTENALL 0xAF00
noname001 0:0b8d14ed499f 116
noname001 0:0b8d14ed499f 117 /* defines for CiCTRL (to be used for CANiSetOperationModeNoWait functions) */
noname001 0:0b8d14ed499f 118 /* these defines are such that, when used will set ABAT bit */
noname001 0:0b8d14ed499f 119
noname001 0:0b8d14ed499f 120 #define CAN_CAPTURE_EN_NO_WAIT 0xBF00
noname001 0:0b8d14ed499f 121 #define CAN_CAPTURE_DIS_NO_WAIT 0x3F00
noname001 0:0b8d14ed499f 122
noname001 0:0b8d14ed499f 123 #define CAN_IDLE_STOP_NO_WAIT 0xBF00
noname001 0:0b8d14ed499f 124 #define CAN_IDLE_CON_NO_WAIT 0x9F00
noname001 0:0b8d14ed499f 125
noname001 0:0b8d14ed499f 126 #define CAN_MASTERCLOCK_1_NO_WAIT 0xBF00
noname001 0:0b8d14ed499f 127 #define CAN_MASTERCLOCK_0_NO_WAIT 0xB700
noname001 0:0b8d14ed499f 128
noname001 0:0b8d14ed499f 129 #define CAN_REQ_OPERMODE_NOR_NO_WAIT 0xB800
noname001 0:0b8d14ed499f 130 #define CAN_REQ_OPERMODE_DIS_NO_WAIT 0xB900
noname001 0:0b8d14ed499f 131 #define CAN_REQ_OPERMODE_LOOPBK_NO_WAIT 0xBA00
noname001 0:0b8d14ed499f 132 #define CAN_REQ_OPERMODE_LISTENONLY_NO_WAIT 0xBB00
noname001 0:0b8d14ed499f 133 #define CAN_REQ_OPERMODE_CONFIG_NO_WAIT 0xBC00
noname001 0:0b8d14ed499f 134 #define CAN_REQ_OPERMODE_LISTENALL_NO_WAIT 0xBF00
noname001 0:0b8d14ed499f 135
noname001 0:0b8d14ed499f 136 /*configuration of CiRXMnSID */
noname001 0:0b8d14ed499f 137
noname001 0:0b8d14ed499f 138 #define CAN_MASK_SID(x) ( ((x & 0x07C0) << 2) | ((x & 0x003F) << 2) | 0x0001 )
noname001 0:0b8d14ed499f 139
noname001 0:0b8d14ed499f 140 #define CAN_MATCH_FILTER_TYPE 0x1FFD
noname001 0:0b8d14ed499f 141 #define CAN_IGNORE_FILTER_TYPE 0x1FFC
noname001 0:0b8d14ed499f 142
noname001 0:0b8d14ed499f 143 /*configuration of CiRXMnEIDH and CiRXMnEIDL */
noname001 0:0b8d14ed499f 144
noname001 0:0b8d14ed499f 145 #define CAN_MASK_EID(x) ( (((unsigned long)x & 0x3C000) << 10) | (((unsigned long)x & 0x03FC0) << 10) | (((unsigned long)x & 0x0003F) << 10) )
noname001 0:0b8d14ed499f 146
noname001 0:0b8d14ed499f 147 /* configuration of CiRXFnSID */
noname001 0:0b8d14ed499f 148
noname001 0:0b8d14ed499f 149 #define CAN_FILTER_SID(x) ( ((x & 0x07C0) << 2) | ((x & 0x003F) << 2) | 0x0001 )
noname001 0:0b8d14ed499f 150
noname001 0:0b8d14ed499f 151 #define CAN_RX_EID_EN 0x1FFD
noname001 0:0b8d14ed499f 152 #define CAN_RX_EID_DIS 0x1FFC
noname001 0:0b8d14ed499f 153
noname001 0:0b8d14ed499f 154 /* configuration of CiRXFnEIDH and C1RXFnEIDL */
noname001 0:0b8d14ed499f 155
noname001 0:0b8d14ed499f 156 #define CAN_FILTER_EID(x) ( (((unsigned long)x & 0x3C000) << 10) | (((unsigned long)x & 0x03FC0) << 10) | (((unsigned long)x & 0x0003F) << 10) )
noname001 0:0b8d14ed499f 157
noname001 0:0b8d14ed499f 158 /* configuration of CiTXxSID */
noname001 0:0b8d14ed499f 159
noname001 0:0b8d14ed499f 160 #define CAN_TX_SID(x) ( ((x & 0x07C0) << 5) | ((x & 0x003F) << 2) | 0x0003 )
noname001 0:0b8d14ed499f 161
noname001 0:0b8d14ed499f 162 #define CAN_SUB_REM_TX_REQ 0xF8FF
noname001 0:0b8d14ed499f 163 #define CAN_SUB_NOR_TX_REQ 0xF8FD
noname001 0:0b8d14ed499f 164
noname001 0:0b8d14ed499f 165 #define CAN_TX_EID_EN 0xF8FF
noname001 0:0b8d14ed499f 166 #define CAN_TX_EID_DIS 0xF8FE
noname001 0:0b8d14ed499f 167
noname001 0:0b8d14ed499f 168 /* configuration of CiTXxEID and CiTXxDLC */
noname001 0:0b8d14ed499f 169
noname001 0:0b8d14ed499f 170 #define CAN_TX_EID(x) ( (((unsigned long)x & 0x3C000) << 14) | (((unsigned long)x & 0x03FC0) << 10) | (((unsigned long)x & 0x0003F) << 10) | 0x000003F8 )
noname001 0:0b8d14ed499f 171
noname001 0:0b8d14ed499f 172 #define CAN_REM_TX_REQ 0xF0FFFFF8
noname001 0:0b8d14ed499f 173 #define CAN_NOR_TX_REQ 0xF0FFFDF8
noname001 0:0b8d14ed499f 174
noname001 0:0b8d14ed499f 175 #define CAN_DATALEN_0 0xF0FFFF80
noname001 0:0b8d14ed499f 176 #define CAN_DATALEN_1 0xF0FFFF88
noname001 0:0b8d14ed499f 177 #define CAN_DATALEN_2 0xF0FFFF90
noname001 0:0b8d14ed499f 178 #define CAN_DATALEN_3 0xF0FFFF98
noname001 0:0b8d14ed499f 179 #define CAN_DATALEN_4 0xF0FFFFA0
noname001 0:0b8d14ed499f 180 #define CAN_DATALEN_5 0xF0FFFFA8
noname001 0:0b8d14ed499f 181 #define CAN_DATALEN_6 0xF0FFFFB0
noname001 0:0b8d14ed499f 182 #define CAN_DATALEN_7 0xF0FFFFB8
noname001 0:0b8d14ed499f 183 #define CAN_DATALEN_8 0xF0FFFFC0
noname001 0:0b8d14ed499f 184
noname001 0:0b8d14ed499f 185 /* CiCFG1 */
noname001 0:0b8d14ed499f 186 #define CAN_SYNC_JUMP_WIDTH1 0x003F
noname001 0:0b8d14ed499f 187 #define CAN_SYNC_JUMP_WIDTH2 0x007F
noname001 0:0b8d14ed499f 188 #define CAN_SYNC_JUMP_WIDTH3 0x00BF
noname001 0:0b8d14ed499f 189 #define CAN_SYNC_JUMP_WIDTH4 0x00FF
noname001 0:0b8d14ed499f 190
noname001 0:0b8d14ed499f 191 #define CAN_BAUD_PRE_SCALE(x) (((x-1) & 0x3f) | 0xC0)
noname001 0:0b8d14ed499f 192
noname001 0:0b8d14ed499f 193 /* CiCFG2 */
noname001 0:0b8d14ed499f 194 #define CAN_WAKEUP_BY_FILTER_EN 0x47FF
noname001 0:0b8d14ed499f 195 #define CAN_WAKEUP_BY_FILTER_DIS 0x07FF
noname001 0:0b8d14ed499f 196
noname001 0:0b8d14ed499f 197 #define CAN_PHASE_SEG2_TQ(x) ((((x-1) & 0x7) << 8) | 0x40FF)
noname001 0:0b8d14ed499f 198
noname001 0:0b8d14ed499f 199 #define CAN_PHASE_SEG1_TQ(x) ((((x-1) & 0x7) << 3) | 0x47C7)
noname001 0:0b8d14ed499f 200
noname001 0:0b8d14ed499f 201 #define CAN_PROPAGATIONTIME_SEG_TQ(x) (((x-1) & 0x7) | 0x47F8)
noname001 0:0b8d14ed499f 202
noname001 0:0b8d14ed499f 203 #define CAN_SEG2_FREE_PROG 0x47FF
noname001 0:0b8d14ed499f 204 #define CAN_SEG2_TIME_LIMIT_SET 0x477F
noname001 0:0b8d14ed499f 205
noname001 0:0b8d14ed499f 206 #define CAN_SAMPLE3TIMES 0x47FF
noname001 0:0b8d14ed499f 207 #define CAN_SAMPLE1TIME 0x47BF
noname001 0:0b8d14ed499f 208
noname001 0:0b8d14ed499f 209 /* CiRXnCON */
noname001 0:0b8d14ed499f 210 #define CAN_BUF0_DBLBUFFER_EN 0x0084
noname001 0:0b8d14ed499f 211 #define CAN_BUF0_DBLBUFFER_DIS 0x0080
noname001 0:0b8d14ed499f 212 #define CAN_RXFUL_CLEAR 0x0004
noname001 0:0b8d14ed499f 213
noname001 0:0b8d14ed499f 214 /* CiTXnCON */
noname001 0:0b8d14ed499f 215 #define CAN_TX_REQ 0x000B
noname001 0:0b8d14ed499f 216 #define CAN_TX_STOP_REQ 0x0003
noname001 0:0b8d14ed499f 217
noname001 0:0b8d14ed499f 218 #define CAN_TX_PRIORITY_HIGH 0x000B
noname001 0:0b8d14ed499f 219 #define CAN_TX_PRIORITY_HIGH_INTER 0x000A
noname001 0:0b8d14ed499f 220 #define CAN_TX_PRIORITY_LOW_INTER 0x0009
noname001 0:0b8d14ed499f 221 #define CAN_TX_PRIORITY_LOW 0x0008
noname001 0:0b8d14ed499f 222
noname001 0:0b8d14ed499f 223 /* CiINTE */
noname001 0:0b8d14ed499f 224 #define CAN_INDI_INVMESS_EN 0x00FF
noname001 0:0b8d14ed499f 225 #define CAN_INDI_WAK_EN 0x00FF
noname001 0:0b8d14ed499f 226 #define CAN_INDI_ERR_EN 0x00FF
noname001 0:0b8d14ed499f 227 #define CAN_INDI_TXB2_EN 0x00FF
noname001 0:0b8d14ed499f 228 #define CAN_INDI_TXB1_EN 0x00FF
noname001 0:0b8d14ed499f 229 #define CAN_INDI_TXB0_EN 0x00FF
noname001 0:0b8d14ed499f 230 #define CAN_INDI_RXB1_EN 0x00FF
noname001 0:0b8d14ed499f 231 #define CAN_INDI_RXB0_EN 0x00FF
noname001 0:0b8d14ed499f 232
noname001 0:0b8d14ed499f 233 #define CAN_INDI_INVMESS_DIS 0x007F
noname001 0:0b8d14ed499f 234 #define CAN_INDI_WAK_DIS 0x00BF
noname001 0:0b8d14ed499f 235 #define CAN_INDI_ERR_DIS 0x00DF
noname001 0:0b8d14ed499f 236 #define CAN_INDI_TXB2_DIS 0x00EF
noname001 0:0b8d14ed499f 237 #define CAN_INDI_TXB1_DIS 0x00F7
noname001 0:0b8d14ed499f 238 #define CAN_INDI_TXB0_DIS 0x00FB
noname001 0:0b8d14ed499f 239 #define CAN_INDI_RXB1_DIS 0x00FD
noname001 0:0b8d14ed499f 240 #define CAN_INDI_RXB0_DIS 0x00FE
noname001 0:0b8d14ed499f 241
noname001 0:0b8d14ed499f 242 /* defines for CAN interrupts */
noname001 0:0b8d14ed499f 243
noname001 0:0b8d14ed499f 244 /* Setting the priority of CAN interrupt */
noname001 0:0b8d14ed499f 245 #define CAN_INT_PRI_0 0xFFF8
noname001 0:0b8d14ed499f 246 #define CAN_INT_PRI_1 0xFFF9
noname001 0:0b8d14ed499f 247 #define CAN_INT_PRI_2 0xFFFA
noname001 0:0b8d14ed499f 248 #define CAN_INT_PRI_3 0xFFFB
noname001 0:0b8d14ed499f 249 #define CAN_INT_PRI_4 0xFFFC
noname001 0:0b8d14ed499f 250 #define CAN_INT_PRI_5 0xFFFD
noname001 0:0b8d14ed499f 251 #define CAN_INT_PRI_6 0xFFFE
noname001 0:0b8d14ed499f 252 #define CAN_INT_PRI_7 0xFFFF
noname001 0:0b8d14ed499f 253
noname001 0:0b8d14ed499f 254 /* enable / disable interrupts */
noname001 0:0b8d14ed499f 255 #define CAN_INT_ENABLE 0xFFFF
noname001 0:0b8d14ed499f 256 #define CAN_INT_DISABLE 0xFFF7
noname001 0:0b8d14ed499f 257
noname001 0:0b8d14ed499f 258 /*********************Function definitions*******************/
noname001 0:0b8d14ed499f 259
noname001 0:0b8d14ed499f 260 /* Macros to Enable/Disable interrupts and set Interrupt priority of CAN 1 module*/
noname001 0:0b8d14ed499f 261 #define EnableIntCAN1 IEC1bits.C1IE = 1
noname001 0:0b8d14ed499f 262 #define DisableIntCAN1 IEC1bits.C1IE = 0
noname001 0:0b8d14ed499f 263 #define SetPriorityIntCAN1(priority) IPC6bits.C1IP = (priority)
noname001 0:0b8d14ed499f 264
noname001 0:0b8d14ed499f 265 void ConfigIntCAN1(unsigned int config1, unsigned int config2) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 266
noname001 0:0b8d14ed499f 267 void CAN1SetTXMode(char buffno, unsigned int config) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 268
noname001 0:0b8d14ed499f 269 void CAN1SetRXMode(char buffno, unsigned int config) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 270
noname001 0:0b8d14ed499f 271 void CAN1SetOperationModeNoWait(unsigned int config) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 272
noname001 0:0b8d14ed499f 273 void CAN1AbortAll(void) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 274
noname001 0:0b8d14ed499f 275 void CAN1SetMask(char mask_no, unsigned int sid, unsigned long eid) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 276
noname001 0:0b8d14ed499f 277 void CAN1SetFilter(char filter_no, unsigned int sid, unsigned long eid) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 278
noname001 0:0b8d14ed499f 279 void CAN1SendMessage(unsigned int sid, unsigned long eid, unsigned char * data, unsigned char datalen, char MsgFlag) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 280
noname001 0:0b8d14ed499f 281 void CAN1ReceiveMessage(unsigned char * data, unsigned char datalen, char MsgFlag) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 282
noname001 0:0b8d14ed499f 283 char CAN1IsTXReady(char buffno) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 284
noname001 0:0b8d14ed499f 285 char CAN1IsTXPassive(void) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 286
noname001 0:0b8d14ed499f 287 char CAN1IsRXReady(char buffno) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 288
noname001 0:0b8d14ed499f 289 char CAN1IsRXPassive(void) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 290
noname001 0:0b8d14ed499f 291 char CAN1IsBusOff(void) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 292
noname001 0:0b8d14ed499f 293 void CAN1Initialize(unsigned int config1, unsigned int config2) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 294
noname001 0:0b8d14ed499f 295 unsigned char CAN1GetTXErrorCount(void) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 296
noname001 0:0b8d14ed499f 297 unsigned char CAN1GetRXErrorCount(void) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 298
noname001 0:0b8d14ed499f 299 void CAN1SetOperationMode(unsigned int config) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 300
noname001 0:0b8d14ed499f 301 #ifdef _C2IF
noname001 0:0b8d14ed499f 302
noname001 0:0b8d14ed499f 303 /* Macros to Enable/Disable interrupts and set Interrupt priority of CAN 2 module*/
noname001 0:0b8d14ed499f 304 #define EnableIntCAN2 IEC2bits.C2IE = 1
noname001 0:0b8d14ed499f 305 #define DisableIntCAN2 IEC2bits.C2IE = 0
noname001 0:0b8d14ed499f 306 #define SetPriorityIntCAN2(priority) IPC9bits.C2IP = (priority)
noname001 0:0b8d14ed499f 307
noname001 0:0b8d14ed499f 308 void ConfigIntCAN2(unsigned int config1, unsigned int config2) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 309
noname001 0:0b8d14ed499f 310 void CAN2SetTXMode(char buffno, unsigned int config) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 311
noname001 0:0b8d14ed499f 312 void CAN2SetRXMode(char buffno, unsigned int config) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 313
noname001 0:0b8d14ed499f 314 void CAN2SetOperationModeNoWait(unsigned int config) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 315
noname001 0:0b8d14ed499f 316 void CAN2AbortAll(void) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 317
noname001 0:0b8d14ed499f 318 void CAN2SetMask(char mask_no, unsigned int sid, unsigned long eid) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 319
noname001 0:0b8d14ed499f 320 void CAN2SetFilter(char filter_no, unsigned int sid, unsigned long eid) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 321
noname001 0:0b8d14ed499f 322 void CAN2SendMessage(unsigned int sid, unsigned long eid, unsigned char * data, unsigned char datalen, char MsgFlag) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 323
noname001 0:0b8d14ed499f 324 void CAN2ReceiveMessage(unsigned char * data, unsigned char datalen, char MsgFlag) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 325
noname001 0:0b8d14ed499f 326 char CAN2IsTXReady(char buffno) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 327
noname001 0:0b8d14ed499f 328 char CAN2IsTXPassive(void) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 329
noname001 0:0b8d14ed499f 330 char CAN2IsRXReady(char buffno) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 331
noname001 0:0b8d14ed499f 332 char CAN2IsRXPassive(void) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 333
noname001 0:0b8d14ed499f 334 char CAN2IsBusOff(void) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 335
noname001 0:0b8d14ed499f 336 void CAN2Initialize(unsigned int config1, unsigned int config2) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 337
noname001 0:0b8d14ed499f 338 unsigned char CAN2GetTXErrorCount(void) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 339
noname001 0:0b8d14ed499f 340 unsigned char CAN2GetRXErrorCount(void) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 341
noname001 0:0b8d14ed499f 342 void CAN2SetOperationMode(unsigned int config) __attribute__ ((section (".libperi")));
noname001 0:0b8d14ed499f 343
noname001 0:0b8d14ed499f 344 #endif
noname001 0:0b8d14ed499f 345
noname001 0:0b8d14ed499f 346 #endif
noname001 0:0b8d14ed499f 347
noname001 0:0b8d14ed499f 348 #endif