118 lines
1.9 KiB
C
118 lines
1.9 KiB
C
#include "SWM320.h"
|
|
#include "debug.h"
|
|
#include "userTimer.h"
|
|
#include "BoardCfg.h"
|
|
static void task1()
|
|
{
|
|
// Printf(".");
|
|
}
|
|
/**
|
|
* @brief 统计系统空闲了多久
|
|
*
|
|
*/
|
|
static u32 sysWaitCnt[1] = {0};
|
|
static u32 sysWaitCnt2[1] = {0};
|
|
static void task2()
|
|
{
|
|
Printf("[Idle:%d]\n", sysWaitCnt2[0]);
|
|
}
|
|
/**
|
|
* @brief 空闲任务
|
|
*
|
|
*/
|
|
void TaskIdle(void)
|
|
{
|
|
static u32 Systick = 0;
|
|
extern volatile u32 ptSysTick;
|
|
while (ptSysTick <= Systick)
|
|
{
|
|
//系统空闲情况检测
|
|
sysWaitCnt[0]++;
|
|
}
|
|
//拷贝系统检测结果
|
|
sysWaitCnt2[0] = sysWaitCnt[0];
|
|
//开启新一轮监测
|
|
static u32 CoreCnt = 0;
|
|
CoreCnt++;
|
|
if (CoreCnt == 1000)
|
|
{
|
|
CoreCnt = 0;
|
|
sysWaitCnt[0] = 0;
|
|
}
|
|
//如果有个任务时间特别长,那么就尽快追上任务
|
|
if (Systick < ptSysTick)
|
|
Systick++;
|
|
//如果有个任务时间特别长,还是要重新等待时间,因为系统认为只过了1个时间片
|
|
// Systick = ptSysTick;
|
|
}
|
|
static void TestLCD()
|
|
{
|
|
for (u32 i = 0; i < 480; i++)
|
|
{
|
|
LCD_DrawWholeLine2(i, C_RED);
|
|
}
|
|
for (u32 i = 0; i < 480; i++)
|
|
{
|
|
LCD_DrawWholeLine2(i, C_GREEN);
|
|
}
|
|
for (u32 i = 0; i < 480; i++)
|
|
{
|
|
LCD_DrawWholeLine2(i, C_BLUE);
|
|
}
|
|
}
|
|
void GUI_Task()
|
|
{
|
|
lv_task_handler();
|
|
// Printf(".");
|
|
}
|
|
void XPT()
|
|
{
|
|
extern u8 TP_Read_XY(u16 * x, u16 * y);
|
|
u16 x, y;
|
|
TP_Read_XY(&x, &y);
|
|
Printf("X:%d,Y:%d\n", x, y);
|
|
}
|
|
int main(void)
|
|
{
|
|
uint32_t chr;
|
|
uint32_t err;
|
|
SystemInit();
|
|
DebugInit();
|
|
BoardInit();
|
|
Printf("\nSystemInit\n");
|
|
UserTimerAdd(task1, NULL, 1000);
|
|
UserTimerAdd(GUI_Task, NULL, 1);
|
|
UserTimerAdd(task2, NULL, 1000);
|
|
// UserTimerAdd(XPT, NULL, 1000);
|
|
//设置系统定时器为1ms
|
|
SysTick_Config(SystemCoreClock / 1000);
|
|
|
|
while (1)
|
|
{
|
|
// 1个时间片任务
|
|
UserTimerTask();
|
|
// GUI_Task();
|
|
TaskIdle();
|
|
}
|
|
}
|
|
/**
|
|
* @brief 系统定时器中断
|
|
*
|
|
*/
|
|
void SysTick_Handler(void)
|
|
{
|
|
extern volatile u32 ptSysTick;
|
|
ptSysTick++;
|
|
lv_tick_inc(1);
|
|
}
|
|
// /**
|
|
// * @brief time0定时器中断
|
|
// *
|
|
// */
|
|
// void TIMR0_Handler(void)
|
|
// {
|
|
// TIMR_INTClr(TIMR0);
|
|
// extern volatile u32 ptSysTick;
|
|
// ptSysTick++;
|
|
// }
|