34#ifndef __MSCAN_INT_H__
35#define __MSCAN_INT_H__
45#define MSCAN_RX_BUFF_NUM 4
46#define MSCAN_TX_BUFF_NUM 3
48#define MSCAN_NON_INITIALIZED_MODE 0
49#define MSCAN_INITIALIZED_MODE 1
50#define MSCAN_INIT_NORMAL_MODE 2
51#define MSCAN_NORMAL_MODE 4
52#define MSCAN_SLEEP_MODE 8
54#define MSCAN_RX_BUFF_NOACTIVE (0 << 4)
55#define MSCAN_RX_BUFF_EMPTY (1 << 6)
56#define MSCAN_RX_BUFF_FULL (1 << 5)
57#define MSCAN_RX_BUFF_OVERRUN ((MSCAN_RX_BUFF_EMPTY) | (MSCAN_RX_BUFF_FULL))
58#define MSCAN_RX_BUFF_BUSY (1 << 4)
60#define MSCAN_MBUFF_MASK 0x07
62#define MSCAN_TX_BUFF0 (1 << 0)
63#define MSCAN_TX_BUFF1 (1 << 1)
64#define MSCAN_TX_BUFF2 (1 << 2)
66#define MSCAN_IDE (1 << 0)
67#define MSCAN_RTR (1 << 1)
68#define MSCAN_READ_RXBUFF_0 (1 << 2)
69#define MSCAN_READ_RXBUFF_1 (1 << 2)
70#define MSCAN_READ_RXBUFF_2 (1 << 2)
71#define MSCAN_READ_RXBUFF_3 (1 << 2)
73#define MSCAN_STATE_OK 0
74#define MSCAN_STATE_ERR 1
75#define MSCAN_STATE_WRN 2
76#define MSCAN_STATE_BUSOFF 3
78#define TX_MBUF_SEL(buf_no) (1 << (buf_no))
79#define TX_DATA_LEN(len) ((len) & 0x0F)
81#define TX_MBUF_EMPTY(val) (1 << (val))
83#define ID_RTR (1 << 4)
85#define SET_IDR0(u16) ((uint8_t)((u16) >> 3))
86#define SET_IDR1(u16) (MSCAN_MESS_ID_HAS_RTR(u16) ? ((uint8_t)(((u16) & 0x0007) << 5))|((uint8_t)(ID_RTR)) : ((uint8_t)(((u16) & 0x0007) << 5)))
88#define SET_IDR2(u16) SET_IDR0(u16)
89#define SET_IDR3(u16) SET_IDR1(u16)
91#define SET_IDR4(u16) SET_IDR0(u16)
92#define SET_IDR5(u16) SET_IDR1(u16)
94#define SET_IDR6(u16) SET_IDR0(u16)
95#define SET_IDR7(u16) SET_IDR1(u16)
97#define GET_IDR0(u16) ((uint16_t) ((u16) << 3))
98#define GET_IDR1(u16) ((((u16)&(ID_RTR))==(ID_RTR)) ? (uint16_t) ((((u16) >> 5)&0x0007)|MSCAN_MESS_ID_RTR) : (uint16_t)(((u16) >> 5)&0x0007))
100#define GET_IDR2(u16) GET_IDR0(u16)
101#define GET_IDR3(u16) GET_IDR1(u16)
103#define GET_IDR4(u16) GET_IDR0(u16)
104#define GET_IDR5(u16) GET_IDR1(u16)
106#define GET_IDR6(u16) GET_IDR0(u16)
107#define GET_IDR7(u16) GET_IDR1(u16)
109#define SET_IDMR0(u16) ((uint8_t)((u16) >> 3))
110#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))
112#define SET_IDMR2(u16) SET_IDMR0(u16)
113#define SET_IDMR3(u16) SET_IDMR1(u16)
115#define SET_IDMR4(u16) SET_IDMR0(u16)
116#define SET_IDMR5(u16) SET_IDMR1(u16)
118#define SET_IDMR6(u16) SET_IDMR0(u16)
119#define SET_IDMR7(u16) SET_IDMR1(u16)
121#define GET_IDMR0(u16) ((uint16_t)((u16) << 3))
122#define GET_IDMR1(u16) ((((u16)&(ID_RTR))==(ID_RTR)) ? (uint16_t) ((((u16) >> 5)&0x0007)|MSCAN_MESS_ID_RTR) : (uint16_t)(((u16) >> 5)&0x0007))
124#define GET_IDMR2(u16) GET_IDMR0(u16)
125#define GET_IDMR3(u16) GET_IDMR1(u16)
127#define GET_IDMR4(u16) GET_IDMR0(u16)
128#define GET_IDMR5(u16) GET_IDMR1(u16)
130#define GET_IDMR6(u16) GET_IDMR0(u16)
131#define GET_IDMR7(u16) GET_IDMR1(u16)
133#define NO_OF_MSCAN_RX_BUFF 20
134#define MSCAN_MESSAGE_SIZE(size) (((size)%CPU_ALIGNMENT) ? (((size) + CPU_ALIGNMENT)-((size) + CPU_ALIGNMENT)%CPU_ALIGNMENT) : (size))
145#define NO_OF_MSCAN_TX_BUFF 20
146#define RING_BUFFER_EMPTY(rbuff) ((((rbuff)->head) == ((rbuff)->tail)) ? TRUE : FALSE)
147#define RING_BUFFER_FULL(rbuff) ((((rbuff)->head) == ((rbuff)->tail)) ? TRUE : FALSE)
152 uint8_t mscan_channel;
153 void (*toucan_callback)(int16_t);
165 struct can_message can_rx_message[MSCAN_RX_BUFF_NUM];
175 uint32_t tx_rb_sname;
182extern void CanInterrupt_A(int16_t);
183extern void CanInterrupt_B(int16_t);
187void mpc5200_mscan_wait_sync(
mscan *);
188void mpc5200_mscan_perform_init_mode_settings(
mscan *);
189void mpc5200_mscan_perform_normal_mode_settings(
mscan *);
uint32_t rtems_device_major_number
This integer type represents the major number of devices.
Definition: io.h:103
uint32_t rtems_device_minor_number
This integer type represents the minor number of devices.
Definition: io.h:115
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
struct mpc5200_mscan mscan
MSCAN registers.
Definition: mscan-base.h:255
MSCAN register definitions and support functions.
Definition: mscan_int.h:151
Definition: mscan_int.h:164
Definition: mscan_int.h:169
Definition: mscan_int.h:157
A CAN message represented of both forms.
Definition: can.h:66