新手上路
- 积分
- 31
- 金钱
- 31
- 注册时间
- 2016-5-6
- 在线时间
- 4 小时
|
1金钱
我通过emwin画出“确认”按钮,想通过点击确认键无线发送数据,我的main中前半段是emwin例程中显示图形的代码, 后半段是NRF24L01无线发送数据的程序, 但好像进入不了第二段。请问应该怎样改?
int main(void)
{
OS_ERR err;
CPU_SR_ALLOC();
//ÎTÏßÄ£¿é
u8 key,mode;
u16 t=0;
u8 tmp_buf[33];
//ÎTÏßÄ£¿é
delay_init(168); //Ñóê±3õê¼»ˉ
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //ÖD¶Ï·Ö×éÅäÖÃ
uart_init(115200); //′®¿ú2¨ìØÂêéèÖÃ
TFTLCD_Init(); //3õê¼»ˉLCD
W25QXX_Init(); //3õê¼»ˉW25Q128
LED_Init(); //LED3õê¼»ˉ
FSMC_SRAM_Init(); //SRAM3õê¼»ˉ
mem_init(SRAMIN); //Äú2¿RAM3õê¼»ˉ
mem_init(SRAMEX); //ía2¿RAM3õê¼»ˉ
mem_init(SRAMCCM); //CCM3õê¼»ˉ
exfuns_init(); //ÎafatfsÎļtÏμí3·ÖÅäÄú′æ
f_mount(fs[0],"0:",1); //1òÔØSD¿¨
f_mount(fs[1],"1:",1); //1òÔØFLASH
while(font_init()) //3õê¼»ˉ×Ö¿a
{
LCD_ShowString(30,70,200,16,16,"Font Error!");
while(SD_Init()) //¼ì2aSD¿¨
{
LCD_ShowString(30,90,200,16,16,"SD Card Failed!");
delay_ms(200);
LCD_Fill(30,90,200+30,70+16,WHITE);
delay_ms(200);
}
update_font(30,90,16,"0:"); //èç1û×Ö¿a2»′æÔú¾í¸üDÂ×Ö¿a
delay_ms(2000);
LCD_Clear(WHITE); //ÇåÆá
break;
}
TP_Init(); //3õê¼»ˉ′¥ÃtÆá
OSInit(&err); //3õê¼»ˉUCOSIII
OS_CRITICAL_ENTER();//½øèëáù½çÇø
//′′½¨¿aê¼èÎÎñ
OSTaskCreate((OS_TCB * )&StartTaskTCB, //èÎÎñ¿ØÖÆ¿é
(CPU_CHAR * )"start task", //èÎÎñÃû×Ö
(OS_TASK_PTR )start_task, //èÎÎñoˉêy
(void * )0, //′«μY¸øèÎÎñoˉêyμÄ2Îêy
(OS_PRIO )START_TASK_PRIO, //èÎÎñóÅÏ輶
(CPU_STK * )&START_TASK_STK[0], //èÎÎñ¶ÑÕ»»ùμØÖ·
(CPU_STK_SIZE)START_STK_SIZE/10, //èÎÎñ¶ÑÕ»éî¶èÏTλ
(CPU_STK_SIZE)START_STK_SIZE, //èÎÎñ¶ÑÕ»′óD¡
(OS_MSG_QTY )0, //èÎÎñÄú2¿ÏûÏ¢¶óáDÄü1»½óêÕμÄ×î′óÏûÏ¢êyÄ¿,Îa0ê±½ûÖ1½óêÕÏûÏ¢
(OS_TICK )0, //μ±ê1Äüê±¼äƬÂÖ×aê±μÄê±¼äƬ3¤¶è£¬Îa0ê±ÎaĬèÏ3¤¶è£¬
(void * )0, //óû§213äμÄ′æ′¢Çø
(OS_OPT )OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR, //èÎÎñÑ¡Ïî
(OS_ERR * )&err); //′æ·Å¸Ãoˉêy′íÎóê±μÄ·μ»ØÖμ
OS_CRITICAL_EXIT(); //íË3öáù½çÇø
OSStart(&err); //¿aÆôUCOSIII
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//éèÖÃÏμí3ÖD¶ÏóÅÏ輶·Ö×é2
delay_init(168); //3õê¼»ˉÑóê±oˉêy
uart_init(115200); //3õê¼»ˉ′®¿ú2¨ìØÂêÎa115200
// LED_Init(); //3õê¼»ˉLED
TFTLCD_Init(); //LCD3õê¼»ˉ
KEY_Init(); //°′¼ü3õê¼»ˉ
NRF24L01_Init(); //3õê¼»ˉNRF24L01
//POINT_COLOR=RED;//éèÖÃ×ÖìåÎaoìé«
//LCD_ShowString(30,50,200,16,16,"Explorer STM32F4");
//LCD_ShowString(30,70,200,16,16,"NRF24L01 TEST");
//LCD_ShowString(30,90,200,16,16,"ATOM@ALIENTEK");
// LCD_ShowString(30,110,200,16,16,"2014/5/9");
while(NRF24L01_Check())
{
LCD_ShowString(30,130,200,16,16,"NRF24L01 Error");
delay_ms(200);
LCD_Fill(30,130,239,130+16,WHITE);
delay_ms(200);
}
// LCD_ShowString(30,130,200,16,16,"NRF24L01 OK");
while(okbutton==0); // ÅD¶Ïè·èÏ°′Å¥êÇ·ñ°′ÏÂ
mode=1;
// if(t==100)LCD_ShowString(10,150,230,16,16,"KEY0:RX_Mode KEY1:TX_Mode"); //éá˸ÏÔê¾ìáê¾DÅÏ¢
POINT_COLOR=BLUE;//éèÖÃ×ÖìåÎaà¶é«
if(mode==0)//RXÄ£ê½
{
LCD_ShowString(30,150,200,16,16,"NRF24L01 RX_Mode");
LCD_ShowString(30,170,200,16,16,"Received DATA:");
NRF24L01_RX_Mode();
while(1)
{
if(NRF24L01_RxPacket(tmp_buf)==0)//ò»μ©½óêÕμ½DÅÏ¢,ÔòÏÔê¾3öà′.
{
tmp_buf[32]=0;//¼óèë×Ö·û′®½áêø·û
LCD_ShowString(0,190,lcddev.width-1,32,16,tmp_buf);
}else delay_us(100);
t++;
if(t==10000)//′óÔ¼1sÖó¸Ä±äò»′Î×′ì¬
{
t=0;
LED0=!LED0;
}
};
}else//TXÄ£ê½
{
// LCD_ShowString(30,150,200,16,16,"NRF24L01 TX_Mode");
NRF24L01_TX_Mode();
mode=' ';//′ó¿Õ¸ñ¼ü¿aê¼
while(1)
{
if(NRF24L01_TxPacket(tmp_buf)==TX_OK)
{
LCD_ShowString(30,170,239,32,16,"Sended DATA:");
tmp_buf[0]=L;
tmp_buf[1]=vmax;
tmp_buf[2]=amax;
tmp_buf[3]=seitamax;
tmp_buf[4]=xf;
tmp_buf[5]=0;
}else
{
// LCD_Fill(0,170,lcddev.width,170+16*3,WHITE);//Çå¿ÕÏÔê¾
LCD_ShowString(30,170,lcddev.width-1,32,16,"Send Failed ");
};
LED0=!LED0;
delay_ms(1500);
while(1); // ¸Ä±äλÖÃ
}
|
|