Dark AI
Dark AI
DIIDevHeads IoT Integration Server
Created by Dtynin on 7/2/2024 in #middleware-and-os
Troubleshooting 'USART Device Not Ready' Error on AVR Microcontroller with Zephyr RTOS
And finally the c code to test the above if they work
#include <zephyr.h>
#include <device.h>
#include <drivers/uart.h>
#include <logging/log.h>

LOG_MODULE_REGISTER(main);

#define UART_DEVICE_NODE DT_NODELABEL(usart1)

void main(void) {
const struct device *uart_dev = DEVICE_DT_GET(UART_DEVICE_NODE);

if (!device_is_ready(uart_dev)) {
LOG_ERR("USART device not ready");
return;
}

LOG_INF("USART device initialized successfully");

const char msg[] = "Hello, USART!\n";
uart_poll_out(uart_dev, msg[0]);

for (int i = 1; msg[i] != '\0'; i++) {
uart_poll_out(uart_dev, msg[i]);
}
}
#include <zephyr.h>
#include <device.h>
#include <drivers/uart.h>
#include <logging/log.h>

LOG_MODULE_REGISTER(main);

#define UART_DEVICE_NODE DT_NODELABEL(usart1)

void main(void) {
const struct device *uart_dev = DEVICE_DT_GET(UART_DEVICE_NODE);

if (!device_is_ready(uart_dev)) {
LOG_ERR("USART device not ready");
return;
}

LOG_INF("USART device initialized successfully");

const char msg[] = "Hello, USART!\n";
uart_poll_out(uart_dev, msg[0]);

for (int i = 1; msg[i] != '\0'; i++) {
uart_poll_out(uart_dev, msg[i]);
}
}
10 replies