am13e23019-canfd-transmit.ino
High-speed CAN FD frame configuration and transmission, essential for drone DShot/CAN interfaces.
Requires the CAN FD module from the TI SDK. BeagleConnect QuadESC exposes CAN lines via connectors. Ensure the CAN transceiver is powered. Test with a tool like CANalyzer or another CAN node.
am13e23019-canfd-transmit.ino
#include <ti/devices/am13e2x/inc/am13e2x.h>
#include <ti/drv/canfd/canfd.h>
#include <ti/drv/canfd/soc/canfd_soc.h>
#include <ti/drv/uart/UART_stdio.h>
CANFD_Handle canfdHandle;
CANFD_Frame frame;
void init_canfd(void) {
CANFD_Params params;
CANFD_Params_init(¶ms);
params.bitRate = 1000000; // 1 Mbps
params.dataBitRate = 5000000; // 5 Mbps
canfdHandle = CANFD_open(CANFD_INSTANCE_0, ¶ms);
if (canfdHandle == NULL) {
UART_printf("Erreur ouverture CAN FD\n");
while(1);
}
}
void send_can_frame(void) {
frame.id = 0x123;
frame.dlc = 4;
frame.data[0] = 0xDE;
frame.data[1] = 0xAD;
frame.data[2] = 0xBE;
frame.data[3] = 0xEF;
frame.frameType = CANFD_FRAME_DATA;
frame.isExtended = false;
if (CANFD_write(canfdHandle, &frame) != CANFD_STATUS_SUCCESS) {
UART_printf("Erreur envoi CAN\n");
}
}