Skip to main content

<alp/can.h> — CAN / CAN-FD

Controller Area Network bus support, including CAN-FD on hardware that supports it.

#include <alp/can.h>

Send and receive

alp_can_t *can = alp_can_open(&(alp_can_config_t){
.bus_id = E1M_CAN0,
.bitrate_hz = 500000, // classical CAN
.data_bitrate_hz = 2000000, // CAN-FD data phase
.mode = ALP_CAN_MODE_FD,
});

alp_can_frame_t tx = {
.id = 0x123,
.is_extended = false,
.dlc = 8,
.data = { 1, 2, 3, 4, 5, 6, 7, 8 },
};
alp_can_send(can, &tx, K_NO_WAIT);

void on_frame(const alp_can_frame_t *f, void *user) { /* ... */ }
alp_can_subscribe(can, /* mask */ 0x7FF, /* id */ 0x123, on_frame, NULL);

See also

Questions about this page? Discuss in Community Forum