Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00050
00051 #ifndef _SJA1000_H_
00052 #define _SJA1000_H_
00053
00054 #include <stdint.h>
00055
00056
00057
00058
00059 #define SJA1000_MODECTRL (*(volatile uint8_t*) (sja_base+0))
00060 #define RM_RR_Bit 0x01 // reset mode (request) bit
00061
00062 #define LOM_Bit 0x02 // listen only mode bit
00063 #define STM_Bit 0x04 // self test mode bit
00064 #define AFM_Bit 0x08 // acceptance filter mode bit
00065 #define SM_Bit 0x10 // enter sleep mode bit
00066
00067
00068 #define SJA1000_IEN (*(volatile uint8_t*) (sja_base+4)) // PeliCAN mode
00069 #define RIE_Bit 0x01 // receive interrupt enable bit
00070 #define TIE_Bit 0x02 // transmit interrupt enable bit
00071 #define EIE_Bit 0x04 // error warning interrupt enable bit
00072 #define DOIE_Bit 0x08 // data overrun interrupt enable bit
00073 #define WUIE_Bit 0x10 // wake-up interrupt enable bit
00074 #define EPIE_Bit 0x20 // error passive interrupt enable bit
00075 #define ALIE_Bit 0x40 // arbitration lost interr. enable bit
00076 #define BEIE_Bit 0x80 // bus error interrupt enable bit
00077
00078
00079 #define SJA1000_CMD (*(volatile uint8_t*) (sja_base+1))
00080 #define TR_Bit 0x01 // transmission request bit
00081 #define AT_Bit 0x02 // abort transmission bit
00082 #define RRB_Bit 0x04 // release receive buffer bit
00083 #define CDO_Bit 0x08 // clear data overrun bit
00084 #define SRR_Bit 0x10 // self reception request bit
00085
00086
00087 #define SJA1000_STATUS (*(volatile uint8_t*) (sja_base+2))
00088 #define RBS_Bit 0x01 // receive buffer status bit
00089 #define DOS_Bit 0x02 // data overrun status bit
00090 #define TBS_Bit 0x04 // transmit buffer status bit
00091 #define TCS_Bit 0x08 // transmission complete status bit
00092 #define RS_Bit 0x10 // receive status bit
00093 #define TS_Bit 0x20 // transmit status bit
00094 #define ES_Bit 0x40 // error status bit
00095 #define BS_Bit 0x80 // bus status bit
00096
00097
00098 #define SJA1000_INT (*(volatile uint8_t*) (sja_base+3))
00099 #define RI_Bit 0x01 // receive interrupt bit
00100 #define TI_Bit 0x02 // transmit interrupt bit
00101 #define EI_Bit 0x04 // error warning interrupt bit
00102 #define DOI_Bit 0x08 // data overrun interrupt bit
00103 #define WUI_Bit 0x10 // wake-up interrupt bit
00104
00105 #define EPI_Bit 0x20 // error passive interrupt bit
00106 #define ALI_Bit 0x40 // arbitration lost interrupt bit
00107 #define BEI_Bit 0x80 // bus error interrupt bit
00108
00109
00110 #define SJA1000_BT0 (*(volatile uint8_t*) (sja_base+6))
00111 #define SJA1000_BT1 (*(volatile uint8_t*) (sja_base+7))
00112 #define SAM_Bit 0x80 // sample mode bit
00113
00114
00115
00116
00117 #define SJA1000_OUTCTRL (*(volatile uint8_t*) (sja_base+8))
00118
00119 #define BiPhaseMode 0x00 // bi-phase output mode
00120 #define NormalMode 0x02 // normal output mode
00121 #define ClkOutMode 0x03 // clock output mode
00122
00123 #define OCPOL1_Bit 0x20 // output polarity control bit
00124 #define Tx1Float 0x00 // configured as float
00125 #define Tx1PullDn 0x40 // configured as pull-down
00126 #define Tx1PullUp 0x80 // configured as pull-up
00127 #define Tx1PshPull 0xC0 // configured as push/pull
00128
00129 #define OCPOLO_Bit 0x04 // output polarity control bit
00130 #define Tx0Float 0x00 // configured as float
00131 #define Tx0PullDn 0x08 // configured as pull-down
00132 #define Tx0PullUp 0x10 // configured as pull-up
00133 #define Tx0PshPull 0x18 // configured as push/pull
00134
00135
00136 #define SJA1000_AC0 (*(volatile uint8_t*) (sja_base+16))
00137 #define SJA1000_AC1 (*(volatile uint8_t*) (sja_base+17))
00138 #define SJA1000_AC2 (*(volatile uint8_t*) (sja_base+18))
00139 #define SJA1000_AC3 (*(volatile uint8_t*) (sja_base+19))
00140 #define SJA1000_AM0 (*(volatile uint8_t*) (sja_base+20))
00141 #define SJA1000_AM1 (*(volatile uint8_t*) (sja_base+21))
00142 #define SJA1000_AM2 (*(volatile uint8_t*) (sja_base+22))
00143 #define SJA1000_AM3 (*(volatile uint8_t*) (sja_base+23))
00144
00145
00146 #define SJA1000_RxFrameInfo (*(volatile uint8_t*) (sja_base+16))
00147 #define SJA1000_Rx1 (*(volatile uint8_t*) (sja_base+17))
00148 #define SJA1000_Rx2 (*(volatile uint8_t*) (sja_base+18))
00149 #define SJA1000_Rx3 (*(volatile uint8_t*) (sja_base+19))
00150 #define SJA1000_Rx4 (*(volatile uint8_t*) (sja_base+20))
00151 #define SJA1000_Rx5 (*(volatile uint8_t*) (sja_base+21))
00152 #define SJA1000_Rx6 (*(volatile uint8_t*) (sja_base+22))
00153 #define SJA1000_Rx7 (*(volatile uint8_t*) (sja_base+23))
00154 #define SJA1000_Rx8 (*(volatile uint8_t*) (sja_base+24))
00155 #define SJA1000_Rx9 (*(volatile uint8_t*) (sja_base+25))
00156 #define SJA1000_Rx10 (*(volatile uint8_t*) (sja_base+26))
00157 #define SJA1000_Rx11 (*(volatile uint8_t*) (sja_base+27))
00158 #define SJA1000_Rx12 (*(volatile uint8_t*) (sja_base+28))
00159
00160
00161
00162 #define TestReg (*(volatile uint8_t*) (sja_base+9))
00163
00164 #define SJA1000_TxFrameInfo (*(volatile uint8_t*) (sja_base+16))
00165 #define SJA1000_Tx1 (*(volatile uint8_t*) (sja_base+17))
00166 #define SJA1000_Tx2 (*(volatile uint8_t*) (sja_base+18))
00167 #define SJA1000_Tx3 (*(volatile uint8_t*) (sja_base+19))
00168 #define SJA1000_Tx4 (*(volatile uint8_t*) (sja_base+20))
00169 #define SJA1000_Tx5 (*(volatile uint8_t*) (sja_base+21))
00170 #define SJA1000_Tx6 (*(volatile uint8_t*) (sja_base+22))
00171 #define SJA1000_Tx7 (*(volatile uint8_t*) (sja_base+23))
00172 #define SJA1000_Tx8 (*(volatile uint8_t*) (sja_base+24))
00173 #define SJA1000_Tx9 (*(volatile uint8_t*) (sja_base+25))
00174 #define SJA1000_Tx10 (*(volatile uint8_t*) (sja_base+26))
00175 #define SJA1000_Tx11 (*(volatile uint8_t*) (sja_base+27))
00176 #define SJA1000_Tx12 (*(volatile uint8_t*) (sja_base+28))
00177
00178
00179 #define SJA1000_TxFrameInfoRd (*(volatile uint8_t*) (sja_base+96))
00180 #define SJA1000_TxRd1 (*(volatile uint8_t*) (sja_base+97))
00181 #define SJA1000_TxRd2 (*(volatile uint8_t*) (sja_base+98))
00182 #define SJA1000_TxRd3 (*(volatile uint8_t*) (sja_base+99))
00183 #define SJA1000_TxRd4 (*(volatile uint8_t*) (sja_base+100))
00184 #define SJA1000_TxRd5 (*(volatile uint8_t*) (sja_base+101))
00185 #define SJA1000_TxRd6 (*(volatile uint8_t*) (sja_base+102))
00186 #define SJA1000_TxRd7 (*(volatile uint8_t*) (sja_base+103))
00187 #define SJA1000_TxRd8 (*(volatile uint8_t*) (sja_base+104))
00188 #define SJA1000_TxRd9 (*(volatile uint8_t*) (sja_base+105))
00189 #define SJA1000_TxRd10 (*(volatile uint8_t*) (sja_base+106))
00190 #define SJA1000_TxRd11 (*(volatile uint8_t*) (sja_base+107))
00191 #define SJA1000_TxRd12 (*(volatile uint8_t*) (sja_base+108))
00192
00193
00194 #define SJA1000_ArbLostCap (*(volatile uint8_t*) (sja_base+11))
00195 #define SJA1000_ErrCodeCap (*(volatile uint8_t*) (sja_base+12))
00196 #define SJA1000_ErrWarnLimit (*(volatile uint8_t*) (sja_base+13))
00197 #define SJA1000_RxErrCount (*(volatile uint8_t*) (sja_base+14))
00198 #define SJA1000_TxErrCount (*(volatile uint8_t*) (sja_base+15))
00199 #define SJA1000_RxMsgCount (*(volatile uint8_t*) (sja_base+29))
00200 #define SJA1000_RxBufStartAdr (*(volatile uint8_t*) (sja_base+30))
00201
00202
00203 #define SJA1000_CLK_DIV (*(volatile uint8_t*) (sja_base+31))
00204 #define DivBy1 0x07 // CLKOUT = oscillator frequency
00205 #define DivBy2 0x00 // CLKOUT = 1/2 oscillator frequency
00206 #define ClkOff_Bit 0x08 // clock off bit, control of the CLK OUT pin
00207 #define RXINTEN_Bit 0x20 // pin TX1 used for receive interrupt
00208 #define CBP_Bit 0x40 // CAN comparator bypass control bit
00209 #define CANMode_Bit 0x80 // CAN mode definition bit
00210 #define ClkOutMode 0x03 // clock output mode
00211
00212
00213 #define OCPOL1_Bit 0x20 // output polarity control bit
00214 #define Tx1Float 0x00 // configured as float
00215 #define Tx1PullDn 0x40 // configured as pull-down
00216 #define Tx1PullUp 0x80 // configured as pull-up
00217 #define Tx1PshPull 0xC0 // configured as push/pull
00218
00219
00220 #define OCPOL0_Bit 0x04 // output polarity control bit
00221 #define Tx0Float 0x00 // configured as float
00222 #define Tx0PullDn 0x08 // configured as pull-down
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233 #define Presc_MB_16 0x00 // baud rate prescaler : 1
00234 #define SJW_MB_16 0x00 // SJW : 1
00235 #define TSEG1_MB_16 0x04 // TSEG1 : 5
00236 #define TSEG2_MB_16 0x10 // TSEG2 : 2
00237
00238
00239
00240
00241 #define errCAN_INVALID_BAUD 7
00242 #define CAN_OK 0
00243 #define CAN_ERR 1
00244 #define CAN_INIT_SPEED_ERR 1
00245 #define CAN_NOT_INITIATED 1
00246 #define CAN_NOT_STARTED 1
00247 #define CAN_TXBUF_FULL 2
00248 #define CAN_RXBUF_EMPTY 2
00249
00250
00251
00252 #define CAN_LOST_FRAME 0x01
00253 #define CAN_BUS_OFF 0x02
00254
00255
00256
00257 #define CAN_29 0x80
00258 #define CAN_RTR 0x40
00259
00260 #define ClrIntEnSJA 0x00
00261
00262 extern NUTDEVICE devSJA1000;
00263
00264 #endif
00265