amiro-os / core / inc / aos_rtcan.h @ 341cc329
History | View | Annotate | Download (1.312 KB)
1 |
#ifndef AOS_RTCAN
|
---|---|
2 |
#define AOS_RTCAN
|
3 |
|
4 |
#endif // AOS_RTCAN |
5 |
|
6 |
#include <hal.h> |
7 |
#include <hal_can.h> |
8 |
#include <hal_can_lld.h> |
9 |
#include <aos_thread.h> |
10 |
|
11 |
#include <stdint.h> |
12 |
|
13 |
|
14 |
/* include msg_types */
|
15 |
|
16 |
/* include rtcanconfig */
|
17 |
|
18 |
typedef uint16_t rtcan_id_t;
|
19 |
|
20 |
typedef struct rtcan_msg_t{ |
21 |
rtcan_id_t id; |
22 |
uint8_t* payload; |
23 |
uint8_t laxity:5;
|
24 |
uint8_t fragmentCounter:7;
|
25 |
uint8_t payloadSize; |
26 |
uint8_t msgType:2;
|
27 |
systime_t deadline; |
28 |
struct rtcan_msg_t *next;
|
29 |
|
30 |
|
31 |
}rtcan_msg_t; |
32 |
|
33 |
typedef struct { |
34 |
rtcan_msg_t *head; |
35 |
rtcan_msg_t *tail; |
36 |
uint8_t size; |
37 |
mutex_t mutex; |
38 |
|
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 |
bool enqueueMsg(uint8_t *payload,uint8_t msgType,aos_timestamp_t deadline);
|
62 |
#ifdef __cplusplus
|
63 |
} |
64 |
#endif
|
65 |
|
66 |
|
67 |
|
68 |
//TODO: public methods
|