aboutsummaryrefslogtreecommitdiffstats
path: root/fw/can.h
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-10-23 15:18:11 -0400
committerSam Anthony <sam@samanthony.xyz>2025-10-23 15:18:11 -0400
commit7fab1a08e546953f9f601cc108b1bb981316b344 (patch)
tree704d79b9e28be9819dc02b383937a0b5c561c056 /fw/can.h
parent1605e7aa30e6a8db6d623413c42efa4339057653 (diff)
downloadcan-gauge-interface-7fab1a08e546953f9f601cc108b1bb981316b344.zip
canTx()
Diffstat (limited to 'fw/can.h')
-rw-r--r--fw/can.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/fw/can.h b/fw/can.h
index c7a6c18..8e0cfff 100644
--- a/fw/can.h
+++ b/fw/can.h
@@ -49,6 +49,14 @@ typedef struct {
};
} CanId;
+// CAN frame
+typedef struct {
+ CanId id;
+ U8 dlc; // data length code
+ U8 data[8];
+ bool rtr; // remote transmission request
+} CanFrame;
+
// Initialize the MCP2515.
// Initial mode is Config.
void canInit(void);
@@ -61,7 +69,7 @@ void canSetMode(CanMode mode);
// The MCP2515 must be in Config mode.
void canSetBitTiming(U8 cnf1, U8 cnf2, U8 cnf3);
-// Enable/disable interrupts on the MCP2515's INT pin.
+// Enable/disable RX-buffer-full interrupts on the MCP2515's INT pin.
void canIE(bool enable);
// Read RX status with RX STATUS instruction.
@@ -73,6 +81,9 @@ void canReadRxb0Data(U8 data[8u]);
// Read the DATA field of RXB1.
void canReadRxb1Data(U8 data[8u]);
+// Transmit a frame to the CAN bus
+Status canTx(const CanFrame *frame);
+
// Set the message acceptance mask of RXB0.
// The MCP2515 must be in Config mode.
void canSetMask0(const CanId *mask);