Dtynin
Dtynin
DIIDevHeads IoT Integration Server
Created by Dtynin on 7/8/2024 in #code-review
How can I resolve the "CAN message send failed" error in my AVR microcontroller project using Zephyr
@Middleware & OS hey guys, I am working on an AVR microcontroller project using Zephyr OS for an IoT device that controls motors via CAN Bus/SPI. The initial error I encountered was "CAN Bus initialization failed." To address this, I verified the wiring and configuration settings in the Zephyr device tree. Despite this, the error "CAN message send failed" persists. I have studied the Zephyr documentation and relevant AVR datasheets extensively, yet the issue remains unresolved. the outcome should be able to send and receive message via the CAN Bus. Here is a sample code snippet of it:
#include <zephyr.h>
#include <device.h>
#include <drivers/can.h>
#include <drivers/spi.h>

// Function prototypes
void can_init(void);
int can_send(const struct zcan_frame *msg);
int can_receive(struct zcan_frame *msg);
void spi_init(void);
#include <zephyr.h>
#include <device.h>
#include <drivers/can.h>
#include <drivers/spi.h>

// Function prototypes
void can_init(void);
int can_send(const struct zcan_frame *msg);
int can_receive(struct zcan_frame *msg);
void spi_init(void);
4 replies