#include "uart.h"

#include <zephyr/drivers/uart.h>
#include <zephyr/logging/log.h>

#include <string.h>

LOG_MODULE_REGISTER(uart);

#define UART_DEVICE_NODE DT_ALIAS(uart1)
static const struct device *const uart_dev = DEVICE_DT_GET(UART_DEVICE_NODE);

int uart_init(void) {
	int ret;

	if (!device_is_ready(uart_dev)) {
		LOG_ERR("UART device not ready");
		return -ENODEV;
	}

	LOG_INF("UART initialized");

	return 0;
}

void print_uart(char *buf) {
	int msg_len = strlen(buf);

	for (int i = 0; i < msg_len; i++) {
		uart_poll_out(uart_dev, buf[i]);
	}
}