RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mscan.h
1/*===============================================================*\
2| Project: RTEMS generic MPC5200 BSP |
3+-----------------------------------------------------------------+
4| Partially based on the code references which are named below. |
5| Adaptions, modifications, enhancements and any recent parts of |
6| the code are: |
7| Copyright (c) 2005 |
8| Embedded Brains GmbH |
9| Obere Lagerstr. 30 |
10| D-82178 Puchheim |
11| Germany |
12| rtems@embedded-brains.de |
13+-----------------------------------------------------------------+
14| The license and distribution terms for this file may be |
15| found in the file LICENSE in this distribution or at |
16| |
17| http://www.rtems.org/license/LICENSE. |
18| |
19+-----------------------------------------------------------------+
20| this file has to be included by application when using mscan |
21\*===============================================================*/
22#ifndef __MSCAN_H__
23#define __MSCAN_H__
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#define MSCAN_A_DEV_NAME "/dev/mscana"
30#define MSCAN_B_DEV_NAME "/dev/mscanb"
31#define MSCAN_0_DEV_NAME "/dev/mscan0"
32#define MSCAN_1_DEV_NAME "/dev/mscan1"
33#define MSCAN_A 0
34#define MSCAN_B 1
35
36#define MSCAN_MAX_DATA_BYTES 8
37
38#define MSCAN_MESS_ID_RTR (1 << 15)
39#define MSCAN_MESS_ID_RTR_MASK (1 << 15)
40#define MSCAN_MESS_ID_ID_MASK ((1 << 11)-1)
41#define MSCAN_MESS_ID_HAS_RTR(id) (((id)&MSCAN_MESS_ID_RTR_MASK)==MSCAN_MESS_ID_RTR)
42
43#define MSCAN_SET_RX_ID 1
44#define MSCAN_GET_RX_ID 2
45#define MSCAN_SET_RX_ID_MASK 3
46#define MSCAN_GET_RX_ID_MASK 4
47#define MSCAN_SET_TX_ID 5
48#define MSCAN_GET_TX_ID 6
49#define TOUCAN_MSCAN_INIT 7
50#define MSCAN_SET_BAUDRATE 8
51#define SET_TX_BUF_NO 9
52
53struct can_message
54 {
55 /* uint16_t mess_len; */
56 uint16_t mess_id;
57 uint16_t mess_time_stamp;
58 uint8_t mess_data[MSCAN_MAX_DATA_BYTES];
59 uint8_t mess_len;
60 uint8_t mess_rtr;
61 uint32_t toucan_tx_idx;
62 };
63
65 {
66 struct can_message *rx_mess;
67 uint32_t rx_timeout;
68 uint8_t rx_flags;
69 };
70
72 {
73 struct can_message *tx_mess;
74 uint32_t tx_idx;
75 };
76
78 {
79 uint32_t ctrl_id;
80 uint32_t ctrl_id_mask;
81 uint8_t ctrl_reg_no;
82 uint8_t ctrl_tx_buf_no;
83 uint32_t ctrl_can_bitrate;
84 void (*toucan_cb_fnc)(int16_t);
85 };
86
87
88rtems_device_driver mscan_initialize( rtems_device_major_number,
89 rtems_device_minor_number,
90 void *
91 );
92
93rtems_device_driver mscan_open( rtems_device_major_number,
94 rtems_device_minor_number,
95 void *
96 );
97
98rtems_device_driver mscan_close( rtems_device_major_number,
99 rtems_device_minor_number,
100 void *
101 );
102
103rtems_device_driver mscan_read( rtems_device_major_number,
104 rtems_device_minor_number,
105 void *
106 );
107
108rtems_device_driver mscan_write( rtems_device_major_number,
109 rtems_device_minor_number,
110 void *
111 );
112
113rtems_device_driver mscan_control( rtems_device_major_number,
114 rtems_device_minor_number,
115 void *
116 );
117
118
119#define MSCAN_DRIVER_TABLE_ENTRY \
120 { mscan_initialize, mscan_open, mscan_close, \
121 mscan_read, mscan_write, mscan_control }
122
123#ifdef __cplusplus
124}
125#endif
126
127#endif /* __MSCAN_H__ */
rtems_status_code
Classic API Status.
Definition: status.h:43
Definition: mscan.h:78
Definition: mscan.h:65
Definition: mscan.h:72
A CAN message represented of both forms.
Definition: can.h:66