|
// FreeRTOS.org V4.0.2 - Copyright (C) 2003-2006 Richard Barry.
/*
5月30日
1:30 内核调试成功。之前一直不工作是由于startup.S中的初始化参数设置有问题。
注意软中断vPortYieldProcessor。
3:10 FreeRTOS串口驱动调试成功,之前不工作的原因是自己已经把硬件初始化
程序移到了startup.S中,而没有将GPIO相应管脚设置为串口;波特率设置
也要作一点改动。为了串口稳定工作,建议初始化时缓冲区设置不少于128字节。
*/
// Scheduler includes.
#include "FreeRTOS.h"
#include "task.h"
#include "lpc214x.h"
// Demo application includes.
#include "serial.h"
#include "rtc.h"
#include "lcd_hardware.h"
#include "lcd_text.h"
#define LED_RED(b) SET_PIN1(30,b)
#define LED_GREEN(b) SET_PIN1(31,b)
#define Task_Uart_PRIO tskIDLE_PRIORITY+1
#define Task_RF_PRIO tskIDLE_PRIORITY+2
#define Task_GUI_PRIO tskIDLE_PRIORITY+1
xTaskHandle RF_Handle,
Uart_Handle,
GUI_Handle;
/*----------------------idle hook----------------------------*/
void vApplicationIdleHook( void )
{
PCON = 0x1;
}
void Task_Uart( void *pvParameters )
{
/* The parameters are not used in this function. */
( void ) pvParameters;
signed portCHAR cByteRxed=0;
for(;;)
{
if(xSerialGetChar(&cByteRxed, 0))
{
switch(cByteRxed)
{
case 'l':
break;
case 'd':
break;
case 'q':
break;
case 'w':
break;
case 'r':
break;
case 'f':
break;
default: rprintf("unknown command:%x\r\n",cByteRxed);
break;
}
}
}
}
void Task_RF( void *pvParameters )
{
/* The parameters are not used in this function. */
( void ) pvParameters;
for(;;)
{
vTaskDelay(50);
}
}
void Task_GUI( void *pvParameters )
{
/* The parameters are not used in this function. */
( void ) pvParameters;
lcd_init();
for(;;)
{
vTaskDelay(50);
lcd_printf( 0,4, "%2u-%2u-%2u %2u:%2u:%2u",
Rtc.year,
Rtc.mon,
Rtc.day,
Rtc.hour,
Rtc.min,
Rtc.sec);
lcd_flush_screen(0,0,0);// 刷屏需要9ms */
LED_RED(2);
}
}
void PortInit(void)
{
IO1DIR |= (1<<30)|(1<<31);
LED_RED(0);
LED_GREEN(0);
}
//Starts all the other tasks, then starts the scheduler.
int main( void )
{
PortInit();
InitRTC();
rprintf("System starting...\r\n");
vTaskStartScheduler();
return 0;
}
/*-----------------------------------------------------------*/