/*
 * Copyright (c) 2016 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/* Controlling LEDs through UART. Press 1-3 on your keyboard to toggle LEDS 1-3 on your development
 * kit */

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/sys/printk.h>

#include <zephyr/drivers/uart.h>

#define SLEEP_TIME_MS 1000
#define RECEIVE_BUFF_SIZE 10
#define RECEIVE_TIMEOUT 100

const struct device *uart = DEVICE_DT_GET(DT_NODELABEL(uart21));

static uint8_t tx_buf[] = {
	"nRF Connect SDK Fundamentals Course\r\n"
	"Press 0-2 on your keyboard to toggle LEDS 0-2 on your development kit\r\n"};

uint8_t uart21Buff[] = {"uart21 \n" };


int main(void){

	int ret;

	if (!device_is_ready(uart)) {
		printk("UART device not ready\n");
		return 1;
	}

	ret = uart_tx(uart, tx_buf, sizeof(tx_buf), SYS_FOREVER_MS);
	if (ret) {
		return 1;
	}

	while (1) {
		k_msleep(SLEEP_TIME_MS);
		//printk("console \n");
		ret = uart_tx(uart, uart21Buff, sizeof(uart21Buff), SYS_FOREVER_MS);
		if (ret) {
			return 1;
		}
	}
}