2017-09-15 18:10:51 +08:00
|
|
|
/*
|
2017-09-20 11:14:45 +08:00
|
|
|
* File : main.c
|
2017-09-15 18:10:51 +08:00
|
|
|
* This file is part of RT-Thread RTOS
|
2017-09-18 17:45:46 +08:00
|
|
|
* COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
|
2017-09-15 18:10:51 +08:00
|
|
|
*
|
2017-09-18 17:45:46 +08:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2017-09-15 18:10:51 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2017-09-14 Haley the first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
2017-09-20 11:14:45 +08:00
|
|
|
|
2017-09-15 18:10:51 +08:00
|
|
|
#ifdef RT_USING_FINSH
|
|
|
|
#include <finsh.h>
|
|
|
|
#include <shell.h>
|
|
|
|
#endif
|
|
|
|
|
2017-09-18 17:45:46 +08:00
|
|
|
#include "led.h"
|
2017-09-15 18:10:51 +08:00
|
|
|
|
|
|
|
static rt_uint8_t led_stack[ 512 ];
|
|
|
|
static struct rt_thread led_thread;
|
|
|
|
|
|
|
|
static void led_thread_entry(void* parameter)
|
|
|
|
{
|
|
|
|
unsigned int count=0;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
/* led1 on */
|
|
|
|
#ifndef RT_USING_FINSH
|
|
|
|
rt_kprintf("led on, count : %d\r\n",count);
|
|
|
|
#endif
|
|
|
|
count++;
|
|
|
|
rt_hw_led_on(0);
|
|
|
|
rt_thread_delay( RT_TICK_PER_SECOND/2 ); /* sleep 0.5 second and switch to other thread */
|
|
|
|
|
|
|
|
/* led1 off */
|
|
|
|
#ifndef RT_USING_FINSH
|
|
|
|
rt_kprintf("led off\r\n");
|
|
|
|
#endif
|
|
|
|
rt_hw_led_off(0);
|
|
|
|
rt_thread_delay( RT_TICK_PER_SECOND/2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:45:46 +08:00
|
|
|
int main(void)
|
2017-09-15 18:10:51 +08:00
|
|
|
{
|
|
|
|
rt_err_t result;
|
|
|
|
|
|
|
|
/* init led thread */
|
|
|
|
result = rt_thread_init(&led_thread,
|
|
|
|
"led",
|
|
|
|
led_thread_entry,
|
|
|
|
RT_NULL,
|
|
|
|
(rt_uint8_t*)&led_stack[0],
|
|
|
|
sizeof(led_stack),
|
2017-09-18 17:45:46 +08:00
|
|
|
RT_THREAD_PRIORITY_MAX/3,
|
2017-09-15 18:10:51 +08:00
|
|
|
5);
|
|
|
|
if (result == RT_EOK)
|
|
|
|
{
|
|
|
|
rt_thread_startup(&led_thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*@}*/
|