[bsp] add led task to easy confirm kernel is running
This commit is contained in:
parent
47c7d94799
commit
96e9504438
@ -16,11 +16,20 @@
|
|||||||
#include <board.h>
|
#include <board.h>
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
#include "peri_driver.h"
|
||||||
|
|
||||||
|
#define INIT_STACK_SIZE 512
|
||||||
|
#define LED_STACK_SIZE 256
|
||||||
|
|
||||||
#ifndef RT_USING_HEAP
|
#ifndef RT_USING_HEAP
|
||||||
/* if there is not enable heap, we should use static thread and stack. */
|
/* if there is not enable heap, we should use static thread and stack. */
|
||||||
ALIGN(8)
|
ALIGN(8)
|
||||||
static rt_uint8_t init_stack[512];
|
static rt_uint8_t init_stack[INIT_STACK_SIZE];
|
||||||
static struct rt_thread init_thread;
|
static struct rt_thread init_thread;
|
||||||
|
|
||||||
|
ALIGN(8)
|
||||||
|
static rt_uint8_t led_stack[LED_STACK_SIZE];
|
||||||
|
static struct rt_thread led_thread;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void rt_init_thread_entry(void* parameter)
|
void rt_init_thread_entry(void* parameter)
|
||||||
@ -31,6 +40,24 @@ void rt_init_thread_entry(void* parameter)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rt_led_thread_entry(void *parameter)
|
||||||
|
{
|
||||||
|
/* Initialize GPIO */
|
||||||
|
Chip_GPIO_Init(LPC_GPIO_PORT);
|
||||||
|
Chip_GPIO_PinSetDIR(LPC_GPIO_PORT, 0, 7, 1);
|
||||||
|
Chip_GPIO_PinSetState(LPC_GPIO_PORT, 0, 7, true);
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
Chip_GPIO_PinSetState(LPC_GPIO_PORT, 0, 7, true);
|
||||||
|
rt_thread_delay(RT_TICK_PER_SECOND / 2);
|
||||||
|
|
||||||
|
Chip_GPIO_PinSetState(LPC_GPIO_PORT, 0, 7, false);
|
||||||
|
rt_thread_delay(RT_TICK_PER_SECOND / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int rt_application_init()
|
int rt_application_init()
|
||||||
{
|
{
|
||||||
rt_thread_t tid;
|
rt_thread_t tid;
|
||||||
@ -38,7 +65,7 @@ int rt_application_init()
|
|||||||
#ifdef RT_USING_HEAP
|
#ifdef RT_USING_HEAP
|
||||||
tid = rt_thread_create("init",
|
tid = rt_thread_create("init",
|
||||||
rt_init_thread_entry, RT_NULL,
|
rt_init_thread_entry, RT_NULL,
|
||||||
2048, RT_THREAD_PRIORITY_MAX/3, 20);
|
INIT_STACK_SIZE, RT_THREAD_PRIORITY_MAX/3, 20);
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -52,6 +79,24 @@ int rt_application_init()
|
|||||||
#endif
|
#endif
|
||||||
if (tid != RT_NULL)
|
if (tid != RT_NULL)
|
||||||
rt_thread_startup(tid);
|
rt_thread_startup(tid);
|
||||||
|
|
||||||
|
#ifdef RT_USING_HEAP
|
||||||
|
tid = rt_thread_create("led",
|
||||||
|
rt_led_thread_entry, RT_NULL,
|
||||||
|
LED_STACK_SIZE, RT_THREAD_PRIORITY_MAX/3, 20);
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
|
||||||
|
rt_err_t result;
|
||||||
|
|
||||||
|
tid = &led_thread;
|
||||||
|
result = rt_thread_init(tid, "led", rt_led_thread_entry, RT_NULL,
|
||||||
|
led_stack, sizeof(led_stack), RT_THREAD_PRIORITY_MAX / 4, 20);
|
||||||
|
RT_ASSERT(result == RT_EOK);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (tid != RT_NULL)
|
||||||
|
rt_thread_startup(tid);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user