求大神:
初次接触ucos+emWin,能够跑起来stm32f4和GUI ,我想做个多任务轮换调度执行,看看任务切换情况,我给GUI的优先级分配为4,LED灯的优先级为3,想做个屏幕一直亮着而且LED灯闪烁来看到任务切换,但是LED只是闪一下就灭了,屏幕一直亮着,不知道哪儿出问题了,求解答,我附上main.c的部分代码,求原子哥和大神级别的人物来回答,,谢谢,,
[mw_shl_code=c,true]/*
*********************************************************************************************************
* TASK PRIORITIES
*********************************************************************************************************
*/
/*?¨????????????*/
#define APP_TASK_START_PRIO 10 //3
#define APP_TASK_KBD_PRIO 5 //5
#define APP_TASK_GUI_PRIO 4 //4
#define APP_TASK_LEDD_PRIO 3 //6
#define OS_TASK_TMR_PRIO (OS_LOWEST_PRIO - 2)
/*
*********************************************************************************************************
* TASK STACK SIZES
* Size of the task stacks (# of OS_STK entries)
*********************************************************************************************************
*/
/*?¨???????????ó??*/
#define APP_TASK_GUI_STK_SIZE 1024
#define APP_TASK_START_STK_SIZE 512
#define APP_TASK_KBD_STK_SIZE 1024
#define APP_TASK_LEDD_STK_SIZE 1024
/*
*********************************************************************************************************
* LOCAL DEFINES
*********************************************************************************************************
*/
#define LED_DLYCOUNT_MAX 1000
#define LED_DLYCOUNT_MIN 50
#define LED_DLYCOUNT_STEP 50
/*
*********************************************************************************************************
* LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/
/*?¨???????????????ó??*/
static OS_STK App_TaskGuiStk[APP_TASK_GUI_STK_SIZE];
static OS_STK App_TaskStartStk[APP_TASK_START_STK_SIZE];
static OS_STK App_TaskKbdStk[APP_TASK_KBD_STK_SIZE];
static OS_STK App_TaskLeddStk[APP_TASK_LEDD_STK_SIZE];
static uint16_t led_dly_cout = 100;
/*
*********************************************************************************************************
* LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/
static void App_TaskCreate (void);
static void App_EventCreate (void);
static void App_TaskGui (void *p_arg);
static void App_TaskStart (void *p_arg);
static void App_TaskKbd (void *p_arg);
static void App_TaskLedd (void *p_arg);
static void Delaly1s(void)
{
uint16_t i;
for (i = 0; i < 50000; i++);
}
/*
*********************************************************************************************************
* ?? ?? ??: main
* ???????÷: c???ò????
* ?? ??????
* ·? ?? ??: ?í?ó?ú??(???è???í)
*********************************************************************************************************
*/
int main (void)
{
uint8_t os_err;
//delay_init(); //??????ucos????
//__disable_irq(); //?????ù????????
OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel". */
// os_err = OSTaskCreate((void (*)(void *)) App_TaskStart, /*?¨??????????*/
// (void * ) 0,
// (OS_STK * )&App_TaskStartStk[APP_TASK_START_STK_SIZE - 1],
// (INT8U ) APP_TASK_START_PRIO);
os_err = OSTaskCreateExt((void (*)(void *)) App_TaskStart, /* Create the start task. */
(void * ) 0,
(OS_STK * )&App_TaskStartStk[APP_TASK_START_STK_SIZE - 1],
(INT8U ) APP_TASK_START_PRIO,
(INT16U ) APP_TASK_START_PRIO,
(OS_STK * )&App_TaskStartStk[0],
(INT32U ) APP_TASK_START_STK_SIZE,
(void * )0,
(INT16U )(OS_TASK_OPT_STK_CLR | OS_TASK_OPT_STK_CHK));
#if (OS_TASK_NAME_SIZE >= 11)
OSTaskNameSet(APP_TASK_START_PRIO, (CPU_INT08U *)"Start Task", &os_err);
#endif
// PC_VectSet(0x08, OSTickISR); /* Install uC/OS-II's clock tick ISR */
// PC_SetTickRate(OS_TICKS_PER_SEC); /* Reprogram tick rate */
OSStart(); /* Start multitasking (i.e. give control to uC/OS-II). */
return (0);
}
static void App_TaskStart (void *p_arg)
{
OS_CPU_SR cpu_sr=0;
(void)p_arg;
OS_ENTER_CRITICAL(); //??????????????·¨±??????ò??
OS_CPU_SysTickInit(); /* Initialize the SysTick. */
#if (OS_TASK_STAT_EN > 0)
OSStatInit(); /* Determine CPU capacity. */
#endif
bsp_InitTimer();
RA8875_InitHard();
BUZZER_GPIO_Config();
//GPIO_SetBits(GPIOA, GPIO_Pin_4);
GPIO_SetBits(GPIOA, GPIO_Pin_5);
//GPIO_SetBits(GPIOC, GPIO_Pin_2);
GPIO_SetBits(GPIOC, GPIO_Pin_1);
GPIO_SetBits(GPIOC, GPIO_Pin_4);
RA8875_SetBackColor(0xFFFF);
RA8875_ClrScr(0xFFE0); /* ?????????????? */
GUI_Init();
App_EventCreate(); /* Create application events. */
App_TaskCreate(); /* Create application tasks. */
OS_EXIT_CRITICAL(); //????????????????±??????ò??
while (1)
{
OSTimeDlyHMSM(0, 0, 0, 50);
}
}
static void App_TaskCreate (void)
{
uint8_t os_err;
os_err = OSTaskCreateExt((void (*)(void *)) App_TaskGui,
(void * ) 0,
(OS_STK * )&App_TaskGuiStk[APP_TASK_GUI_STK_SIZE - 1],
(INT8U ) APP_TASK_GUI_PRIO,
(INT16U ) APP_TASK_GUI_PRIO,
(OS_STK * )&App_TaskGuiStk[0],
(INT32U ) APP_TASK_GUI_STK_SIZE,
(void * ) 0,
(INT16U )(OS_TASK_OPT_STK_CLR | OS_TASK_OPT_STK_CHK));
#if (OS_TASK_NAME_SIZE >= 9)
OSTaskNameSet(APP_TASK_GUI_PRIO, "GUI", &os_err);
#endif
os_err = OSTaskCreateExt((void (*)(void *)) App_TaskKbd,
(void * ) 0,
(OS_STK * )&App_TaskKbdStk[APP_TASK_KBD_STK_SIZE - 1],
(INT8U ) APP_TASK_KBD_PRIO,
(INT16U ) APP_TASK_KBD_PRIO,
(OS_STK * )&App_TaskKbdStk[0],
(INT32U ) APP_TASK_KBD_STK_SIZE,
(void * ) 0,
(INT16U )(OS_TASK_OPT_STK_CLR | OS_TASK_OPT_STK_CHK));
#if (OS_TASK_NAME_SIZE >= 9)
OSTaskNameSet(APP_TASK_KBD_PRIO, "Keyboard", &os_err);
#endif
os_err = OSTaskCreateExt((void (*)(void *)) App_TaskLedd,
(void * ) 0,
(OS_STK * )&App_TaskLeddStk[APP_TASK_LEDD_STK_SIZE - 1],
(INT8U ) APP_TASK_LEDD_PRIO,
(INT16U ) APP_TASK_LEDD_PRIO,
(OS_STK * )&App_TaskLeddStk[0],
(INT32U ) APP_TASK_LEDD_STK_SIZE,
(void * ) 0,
(INT16U )(OS_TASK_OPT_STK_CLR | OS_TASK_OPT_STK_CHK));
#if (OS_TASK_NAME_SIZE >= 9)
OSTaskNameSet(APP_TASK_LEDD_PRIO, "Ledd", &os_err);
#endif
}
static void App_TaskGui (void *p_arg)
{
int i;
WM_HWIN hWin;
//GUI_PID_STATE Button_State; //?????è±?×???
OS_CPU_SR cpu_sr=0;
(void)p_arg;
OS_ENTER_CRITICAL(); //??????????????·¨±??????ò??
OS_EXIT_CRITICAL(); //????????????????±??????ò??
while (1)
{
// test();
MainTask();
// hWin = GUI_ExecDialogBox(aDialogCreate, GUI_COUNTOF(aDialogCreate), _cbCallback, 0, 50, 0);
// GUI_Exec();
// GUI_TOUCH_GetState(&Button_State); //?????????è±?×???
// GUI_TOUCH_StoreStateEx(&Button_State); //?????????è±?×???
// GUI_DispDecAt(Button_State.x,300,0,4); //?????è±??±?°x×?±ê
// GUI_DispDecAt(Button_State.y,300,20,4); //?????è±??±?°y×?±ê
// GUI_DispDecAt(Button_State.Pressed,300,40,4); //??·?°???
OSTimeDlyHMSM(0, 0, 0, 50);
}
}
static void App_TaskKbd (void *p_arg)
{
//WM_HWIN hWin;
while(1)
{
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
STM_EVAL_LEDToggle(LED3);
STM_EVAL_LEDToggle(LED4);
//GUI_Exec();
GUI_TOUCH_Exec();
// GUI_DispDecAt(GUI_TOUCH_X_MeasureX(),400,0,6);
//
// GUI_DispDecAt(GUI_TOUCH_X_MeasureY(),400,20,6);
//
// GUI_DispDecAt(GUI_GetKey(),400,40,6);
OSTimeDlyHMSM(0, 0, 0, 20);
}
}
static void App_TaskLedd (void *p_arg)
{
OS_CPU_SR cpu_sr=0;
(void)p_arg;
OS_ENTER_CRITICAL(); //??????????????·¨±??????ò??
OS_EXIT_CRITICAL(); //????????????????±??????ò??
while(1)
{
GPIO_SetBits(GPIOA, GPIO_Pin_4);
Delaly1s();
GPIO_ResetBits(GPIOA, GPIO_Pin_4);
Delaly1s();
//OSTaskSuspend(OS_PRIO_SELF); // ????????
OSTimeDlyHMSM(0, 0, 0, 50);
}
}[/mw_shl_code]
|