canbus: Use single method for reading canbus messages
Previously the code had canbus_read() which was called from task context (for admin messages), and canbus_process_data() which was called from irq context (used for data messages). Change that to a single canbus_process_data() function that is called from irq context (used for all messages). This simplifies the low-level hardware specific canbus code and should make it easier to support other hardware implementations. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -7,15 +7,24 @@
|
||||
#define CANBUS_ID_ADMIN_RESP 0x3f1
|
||||
#define CANBUS_UUID_LEN 6
|
||||
|
||||
struct canbus_msg {
|
||||
uint32_t id;
|
||||
uint32_t dlc;
|
||||
union {
|
||||
uint8_t data[8];
|
||||
uint32_t data32[2];
|
||||
};
|
||||
};
|
||||
|
||||
#define CANMSG_DATA_LEN(msg) ((msg)->dlc > 8 ? 8 : (msg)->dlc)
|
||||
|
||||
// callbacks provided by board specific code
|
||||
int canbus_read(uint32_t *id, uint8_t *data);
|
||||
int canbus_send(uint32_t id, uint32_t len, uint8_t *data);
|
||||
int canbus_send(struct canbus_msg *msg);
|
||||
void canbus_set_filter(uint32_t id);
|
||||
|
||||
// canbus.c
|
||||
void canbus_notify_tx(void);
|
||||
void canbus_notify_rx(void);
|
||||
void canbus_process_data(uint32_t id, uint32_t len, uint8_t *data);
|
||||
void canbus_process_data(struct canbus_msg *msg);
|
||||
void canbus_set_uuid(void *data);
|
||||
|
||||
#endif // canbus.h
|
||||
|
||||
Reference in New Issue
Block a user