#include "uos.h"
#include "board.h"
#if defined(__CODE_RED)
# include <cr_section_macros.h>
# include <NXP/crp.h>
__CRP const unsigned int CRP_WORD = CRP_NO_CRP;
#endif
static void task_led(void)
{
while (1) {
board_led(1);
uos_task_sleep(500);
board_led(0);
uos_task_sleep(500);
}
}
static void sxo(char *p)
{
while (*p) {
while (board_uart_putc(*p) != *p) {
uos_task_yield();
}
p++;
}
}
static void task_con(void)
{
unsigned int timer = 0;
while (1) {
int c = board_uart_getc();
if (0 <= c) {
if (timer == 0) {
sxo("\r\n");
sxo("Yeah. It's your turn.\r\n");
}
if (c == '\r') {
sxo("\r\n");
} else {
char tmp[2] = { c, 0x00 };
sxo(tmp);
}
timer = 500;
}
if (0 < timer) {
timer--;
}
if (0 == timer) {
sxo("The quick brown fox jumps over the lazy dog.\r\n");
}
uos_task_yield();
}
}
int main(void)
{
board_init();
uos_kernel_init();
uos_task_setup(1, task_led, 10);
uos_task_setup(2, task_con, 20);
uos_kernel_start();
return 0;
}