/***************************************************************************** 
* 
* File Name : main.c
* 
* Description: main 
* 
* Copyright (c) 2014 Winner Micro Electronic Design Co., Ltd. 
* All rights reserved. 
* 
* Author : dave
* 
* Date : 2014-6-14
*****************************************************************************/ 
#include "wm_include.h"
#include "nano_shell.h"

extern s16 uart0_rx_callback(u16 len, void *user_data);

#define NANO_SHELL_TASK_STK_SIZE 1024
#define STATUS_LED WM_IO_PB_18

void user_main(void)
{
	//We create a task for the nano_shell process
	u8 *nano_shell_task_stack = NULL;
	tls_os_task_t nano_shell_task_handle = NULL;

	tls_uart_rx_callback_register(TLS_UART_0, &(uart0_rx_callback), NULL);

	nano_shell_task_stack = tls_mem_alloc(sizeof(u32) * NANO_SHELL_TASK_STK_SIZE);
	if(nano_shell_task_stack != NULL)
	{
		tls_os_task_create(
			&nano_shell_task_handle,
			"na_shell",
			&(nano_shell_loop),
			NULL,
			(void*) nano_shell_task_stack,
			NANO_SHELL_TASK_STK_SIZE * sizeof(u32),
			62,
			0
		);
	}

	tls_gpio_cfg(STATUS_LED, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);

	for(;;)
	{
		tls_gpio_write(STATUS_LED, !tls_gpio_read(STATUS_LED));
		tls_os_time_delay(500);
	}
}

