22 #ifndef __MSCAN_INT_H__ 23 #define __MSCAN_INT_H__ 31 #include <bsp/mscan.h> 33 #define MSCAN_RX_BUFF_NUM 4 34 #define MSCAN_TX_BUFF_NUM 3 36 #define MSCAN_NON_INITIALIZED_MODE 0 37 #define MSCAN_INITIALIZED_MODE 1 38 #define MSCAN_INIT_NORMAL_MODE 2 39 #define MSCAN_NORMAL_MODE 4 40 #define MSCAN_SLEEP_MODE 8 42 #define MSCAN_RX_BUFF_NOACTIVE (0 << 4) 43 #define MSCAN_RX_BUFF_EMPTY (1 << 6) 44 #define MSCAN_RX_BUFF_FULL (1 << 5) 45 #define MSCAN_RX_BUFF_OVERRUN ((MSCAN_RX_BUFF_EMPTY) | (MSCAN_RX_BUFF_FULL)) 46 #define MSCAN_RX_BUFF_BUSY (1 << 4) 48 #define MSCAN_MBUFF_MASK 0x07 50 #define MSCAN_TX_BUFF0 (1 << 0) 51 #define MSCAN_TX_BUFF1 (1 << 1) 52 #define MSCAN_TX_BUFF2 (1 << 2) 54 #define MSCAN_IDE (1 << 0) 55 #define MSCAN_RTR (1 << 1) 56 #define MSCAN_READ_RXBUFF_0 (1 << 2) 57 #define MSCAN_READ_RXBUFF_1 (1 << 2) 58 #define MSCAN_READ_RXBUFF_2 (1 << 2) 59 #define MSCAN_READ_RXBUFF_3 (1 << 2) 61 #define MSCAN_STATE_OK 0 62 #define MSCAN_STATE_ERR 1 63 #define MSCAN_STATE_WRN 2 64 #define MSCAN_STATE_BUSOFF 3 66 #define TX_MBUF_SEL(buf_no) (1 << (buf_no)) 67 #define TX_DATA_LEN(len) ((len) & 0x0F) 69 #define TX_MBUF_EMPTY(val) (1 << (val)) 71 #define ID_RTR (1 << 4) 73 #define SET_IDR0(u16) ((uint8_t)((u16) >> 3)) 74 #define SET_IDR1(u16) (MSCAN_MESS_ID_HAS_RTR(u16) ? ((uint8_t)(((u16) & 0x0007) << 5))|((uint8_t)(ID_RTR)) : ((uint8_t)(((u16) & 0x0007) << 5))) 76 #define SET_IDR2(u16) SET_IDR0(u16) 77 #define SET_IDR3(u16) SET_IDR1(u16) 79 #define SET_IDR4(u16) SET_IDR0(u16) 80 #define SET_IDR5(u16) SET_IDR1(u16) 82 #define SET_IDR6(u16) SET_IDR0(u16) 83 #define SET_IDR7(u16) SET_IDR1(u16) 85 #define GET_IDR0(u16) ((uint16_t) ((u16) << 3)) 86 #define GET_IDR1(u16) ((((u16)&(ID_RTR))==(ID_RTR)) ? (uint16_t) ((((u16) >> 5)&0x0007)|MSCAN_MESS_ID_RTR) : (uint16_t)(((u16) >> 5)&0x0007)) 88 #define GET_IDR2(u16) GET_IDR0(u16) 89 #define GET_IDR3(u16) GET_IDR1(u16) 91 #define GET_IDR4(u16) GET_IDR0(u16) 92 #define GET_IDR5(u16) GET_IDR1(u16) 94 #define GET_IDR6(u16) GET_IDR0(u16) 95 #define GET_IDR7(u16) GET_IDR1(u16) 97 #define SET_IDMR0(u16) ((uint8_t)((u16) >> 3)) 98 #define SET_IDMR1(u16) (MSCAN_MESS_ID_HAS_RTR(u16) ? ((uint8_t) (((((u16) & 0x0007) << 5)|((uint8_t)(ID_RTR)))|0x0007)) : ((uint8_t)((((u16) & 0x0007) << 5))|0x0007)) 100 #define SET_IDMR2(u16) SET_IDMR0(u16) 101 #define SET_IDMR3(u16) SET_IDMR1(u16) 103 #define SET_IDMR4(u16) SET_IDMR0(u16) 104 #define SET_IDMR5(u16) SET_IDMR1(u16) 106 #define SET_IDMR6(u16) SET_IDMR0(u16) 107 #define SET_IDMR7(u16) SET_IDMR1(u16) 109 #define GET_IDMR0(u16) ((uint16_t)((u16) << 3)) 110 #define GET_IDMR1(u16) ((((u16)&(ID_RTR))==(ID_RTR)) ? (uint16_t) ((((u16) >> 5)&0x0007)|MSCAN_MESS_ID_RTR) : (uint16_t)(((u16) >> 5)&0x0007)) 112 #define GET_IDMR2(u16) GET_IDMR0(u16) 113 #define GET_IDMR3(u16) GET_IDMR1(u16) 115 #define GET_IDMR4(u16) GET_IDMR0(u16) 116 #define GET_IDMR5(u16) GET_IDMR1(u16) 118 #define GET_IDMR6(u16) GET_IDMR0(u16) 119 #define GET_IDMR7(u16) GET_IDMR1(u16) 121 #define NO_OF_MSCAN_RX_BUFF 20 122 #define MSCAN_MESSAGE_SIZE(size) (((size)%CPU_ALIGNMENT) ? (((size) + CPU_ALIGNMENT)-((size) + CPU_ALIGNMENT)%CPU_ALIGNMENT) : (size)) 124 #define TX_BUFFER_0 0 125 #define TX_BUFFER_1 1 126 #define TX_BUFFER_2 2 128 #define RX_BUFFER_0 0 129 #define RX_BUFFER_1 1 130 #define RX_BUFFER_2 2 131 #define RX_BUFFER_3 3 133 #define NO_OF_MSCAN_TX_BUFF 20 134 #define RING_BUFFER_EMPTY(rbuff) ((((rbuff)->head) == ((rbuff)->tail)) ? TRUE : FALSE) 135 #define RING_BUFFER_FULL(rbuff) ((((rbuff)->head) == ((rbuff)->tail)) ? TRUE : FALSE) 140 uint8_t mscan_channel;
141 void (*toucan_callback)(int16_t);
153 struct can_message can_rx_message[MSCAN_RX_BUFF_NUM];
163 uint32_t tx_rb_sname;
170 extern void CanInterrupt_A(int16_t);
171 extern void CanInterrupt_B(int16_t);
174 void mscan_hardware_initialize(rtems_device_major_number, uint32_t,
void *);
175 void mpc5200_mscan_wait_sync(
mscan *);
176 void mpc5200_mscan_perform_init_mode_settings(
mscan *);
177 void mpc5200_mscan_perform_normal_mode_settings(
mscan *);
179 rtems_status_code mscan_channel_initialize(rtems_device_major_number, rtems_device_minor_number);
Definition: mscan_int.h:151
Definition: mscan_int.h:138
Definition: mscan_int.h:144
rtems_status_code
Classic API Status.
Definition: status.h:43
A CAN message represented of both forms.
Definition: can.h:66
Definition: mscan_int.h:156
MSCAN register definitions and support functions.
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:83
struct mpc5200_mscan mscan
MSCAN registers.
Definition: mscan-base.h:242