aboutsummaryrefslogtreecommitdiffstats
path: root/src/generic/canbus.h
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2022-06-10 14:13:39 -0400
committerKevin O'Connor <kevin@koconnor.net>2022-06-16 11:00:15 -0400
commit84d798f516c4a67f21d8c25e02157e79d5497cce (patch)
tree673e69e809b9a2cac4ecf9cd657925746a36a577 /src/generic/canbus.h
parentda755c3c1b0288c6ea488a56be615b5878904fa6 (diff)
downloadkutter-84d798f516c4a67f21d8c25e02157e79d5497cce.tar.gz
kutter-84d798f516c4a67f21d8c25e02157e79d5497cce.tar.xz
kutter-84d798f516c4a67f21d8c25e02157e79d5497cce.zip
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>
Diffstat (limited to 'src/generic/canbus.h')
-rw-r--r--src/generic/canbus.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/generic/canbus.h b/src/generic/canbus.h
index a7df077d..a6463246 100644
--- a/src/generic/canbus.h
+++ b/src/generic/canbus.h
@@ -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