rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
link_can.h
Go to the documentation of this file.
1
32
33#ifndef RCBENCH_LINK_CAN_H
34#define RCBENCH_LINK_CAN_H
35
36#include <stdbool.h>
37#include <stddef.h>
38#include <stdint.h>
39
40#include "link_msg.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
57#define LINK_CAN_PRIO_SHIFT 26
58#define LINK_CAN_OP_SHIFT 22
59#define LINK_CAN_PAGE_SHIFT 14
60#define LINK_CAN_OFFSET_SHIFT 6
61#define LINK_CAN_COUNT_SHIFT 0
62
66#define LINK_CAN_PRIO_MASK 0x7u
67#define LINK_CAN_OP_MASK 0xFu
68#define LINK_CAN_PAGE_MASK 0xFFu
69#define LINK_CAN_OFFSET_MASK 0xFFu
70#define LINK_CAN_COUNT_MASK 0x3Fu
71
73#define LINK_CAN_REGS_PER_FRAME 4
74
76#define LINK_CAN_MAX_FRAMES (LINK_MAX_REGS / LINK_CAN_REGS_PER_FRAME)
77
89
93typedef struct {
94 uint32_t id;
95 uint8_t dlc;
96 uint8_t data[8];
98
114link_can_prio_t link_can_priority(uint8_t page, uint8_t op);
115
128uint32_t link_can_id(link_can_prio_t prio, uint8_t op, uint8_t page,
129 uint8_t offset, uint8_t count);
130
143void link_can_id_split(uint32_t id, link_can_prio_t *prio, uint8_t *op,
144 uint8_t *page, uint8_t *offset, uint8_t *count);
145
157size_t link_can_encode(const link_msg_t *msg, link_can_frame_t *out,
158 size_t cap);
159
173bool link_can_decode(const link_can_frame_t *f, link_msg_t *out);
174
189 uint32_t *refused);
190
191#ifdef __cplusplus
192}
193#endif
194
195#endif /* RCBENCH_LINK_CAN_H */