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