代码:
S_EVENT *MmiMsgMbox;
uint8_t err1;
uint8_t led_status = 0;
uint32_t value;
uint32_t *number;
uint32_t FeedValue;
void task1(void *pdata)
{
pdata=pdata;
for(;;)
{
LED_Off(LED_GPIO_PORT_B,LED_HL4_PIN);
// EXT485_Transmit_CMD(ENABLE);
// USART_PutChar( EXT485_USART, 0xAA);
// EXT485_Transmit_CMD(DISABLE);
//uint8_t ReData[]={0xAA,0x55,0x01,0x00,0xff,0xff,0xff,0xff,0x02};
FeedValue=0xAA;
OSMboxPost(MmiMsgMbox,&FeedValue);
OSTimeDlyHMSM(0,0,0,600);
}
}
void task2(void *pdata)
{
pdata=pdata;
for(;;)
{
number = OSMboxPend(MmiMsgMbox,10,&err1);
if(number == 0)
{}
else
{
value = *number;
if(value == 0xAA)
LED_On(LED_GPIO_PORT_B,LED_HL4_PIN);
}
OSTimeDlyHMSM(0,0,0,600);
}
}
int main(void)
{
Target_Init(); /* Ä¿±ê»ù±¾³õʼ»¯ */
OSInit(); /* ³õʼ»¯OS */
Tmr_TickInit(); /* ³õʼ»¯OS Tick */
init_task_core();
// OSTaskCreateExt(init_task_core, (void *)0, (OS_STK *)&InitTaskStk[OS_INIT_TASK_STACK_SIZE - 1],
// OS_TASK_INIT_PRIO,
// OS_TASK_INIT_PRIO,
// (OS_STK *)&InitTaskStk[0],
// OS_INIT_TASK_STACK_SIZE,
// (void *)0,
// OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
OSStart(); /* Æô¶¯¶àÈÎÎñ»·¾³ */
return(0);
}
static void init_task_core(void)
{
//pdata = pdata; /* ·ÀÖ¹±àÒëÆ÷¾¯¸æ*/
application_init();
//create_os_semphore(); /* ´´½¨Ó¦ÓÃÖеĴó¶àÊýÐźÅÁ¿*/
create_os_mailbox(); /* ´´½¨Ó¦ÓÃÖеĴó¶àÊýÓÊÏäÏûÏ¢*/
create_os_task();
}
static void application_init (void)
{
//UART_onfiguration();
LED_GPIO_Init();
LED_Off(LED_GPIO_PORT_B,LED_GREEN_PIN|LED_HL4_PIN | LED_HL3_PIN);
ADC_GPIO_Configuration();
DMA_Config();
TIM1_Configuration();
ADC1_config();
}
void create_os_mailbox(void)
{
/* ÏûÏ¢ÓÊÏä´´½¨ */
mmi_create_msg_mbox();
}
void create_os_task(void)
{
OSTaskCreate(task1, (void *)0, (OS_STK *)&commuTaskStk[OS_485_TASK_STACK_SIZE-1],OS_485_TASK_PRIO);
OSTaskCreate(task2, (void *)0, (OS_STK *)&LEDTaskStk[0],OS_LED_TASK_PRIO);
}
void mmi_create_msg_mbox(void)
{
MmiMsgMbox = OSMboxCreate((void*)0);
}
单步跑LED会出现亮灭,但是连续跑就一直亮,停下时候在OS_EXIT_CRITICAL里面的 STRB R2, [R1]这里,大家帮忙讲解下,谢谢! |