中断函数:(可以正常进入) static void App_Spurious_ISR1 (void) //@ "ICODE" { CPU_INT08U key=2; OS_CPU_SR cpu_sr; EXTI_ClearFlag(EXTI_Line0); OS_ENTER_CRITICAL(); /* Tell uC/OS-II that we are starting an ISR */ OSIntNesting++; OS_EXIT_CRITICAL(); OSMboxPost(AppUserIFMbox, (void *)key);//发送信号量
OSIntExit(); } 任务(不是最高级的) : static void AppTaskUserIF (void *p_arg) { CPU_INT08U *msg; CPU_INT08U err; //CPU_INT32U nstate; CPU_INT32U pstate;
(void)p_arg;
AppDispScr_SignOn(); OSTimeDlyHMSM(0, 0, 1, 0); nstate = 1; pstate = 1;
while (DEF_TRUE) { msg = (CPU_INT08U *)(OSMboxPend(AppUserIFMbox, OS_TICKS_PER_SEC / 10, &err)); if (err == OS_NO_ERR) { nstate = (CPU_INT32U)msg; }
switch (nstate) { case 2: LED_On(0); OSTimeDlyHMSM(0, 0, 1, 50); break; } } } 为什么接受的信号量不对,应该说是0 而不是我中断里 发送的2 这个和AppUserIFMbox的定义有关系吗 楼上能帮我看看什么原因吗 |