amiro-os / core / inc / aos_rtcan.h @ 341cc329
History | View | Annotate | Download (1.312 KB)
1 | d2931db9 | Julian L | #ifndef AOS_RTCAN
|
---|---|---|---|
2 | #define AOS_RTCAN
|
||
3 | |||
4 | #endif // AOS_RTCAN |
||
5 | |||
6 | #include <hal.h> |
||
7 | #include <hal_can.h> |
||
8 | e7131d09 | Julian Leichert | #include <hal_can_lld.h> |
9 | 341cc329 | Julian Leichert | #include <aos_thread.h> |
10 | d2931db9 | Julian L | |
11 | #include <stdint.h> |
||
12 | |||
13 | |||
14 | /* include msg_types */
|
||
15 | |||
16 | /* include rtcanconfig */
|
||
17 | |||
18 | typedef uint16_t rtcan_id_t;
|
||
19 | |||
20 | e7131d09 | Julian Leichert | typedef struct rtcan_msg_t{ |
21 | d2931db9 | Julian L | rtcan_id_t id; |
22 | uint8_t* payload; |
||
23 | uint8_t laxity:5;
|
||
24 | uint8_t fragmentCounter:7;
|
||
25 | uint8_t payloadSize; |
||
26 | e7131d09 | Julian Leichert | uint8_t msgType:2;
|
27 | systime_t deadline; |
||
28 | struct rtcan_msg_t *next;
|
||
29 | |||
30 | d2931db9 | Julian L | |
31 | }rtcan_msg_t; |
||
32 | |||
33 | typedef struct { |
||
34 | e7131d09 | Julian Leichert | rtcan_msg_t *head; |
35 | rtcan_msg_t *tail; |
||
36 | d2931db9 | Julian L | uint8_t size; |
37 | 341cc329 | Julian Leichert | mutex_t mutex; |
38 | d2931db9 | Julian L | |
39 | }msgqueue_t; |
||
40 | |||
41 | typedef struct{ |
||
42 | uint8_t fragment:7;
|
||
43 | |||
44 | }rtcan_frame_t; |
||
45 | |||
46 | |||
47 | |||
48 | /*===========================================================================*/
|
||
49 | /* External declarations. */
|
||
50 | /*===========================================================================*/
|
||
51 | |||
52 | #ifdef __cplusplus
|
||
53 | extern "C" { |
||
54 | #endif
|
||
55 | msg_t rtcan_transmit(CANDriver *canp, |
||
56 | canmbx_t mailbox, |
||
57 | const CANTxFrame *ctfp);
|
||
58 | msg_t rtcan_receive(CANDriver *canp, |
||
59 | canmbx_t mailbox, |
||
60 | CANRxFrame *crfp); |
||
61 | 341cc329 | Julian Leichert | bool enqueueMsg(uint8_t *payload,uint8_t msgType,aos_timestamp_t deadline);
|
62 | d2931db9 | Julian L | #ifdef __cplusplus
|
63 | } |
||
64 | #endif
|
||
65 | |||
66 | |||
67 | |||
68 | //TODO: public methods |