資源描述:
《Jennic-WSN專業(yè)綜合訓(xùn)練文檔-基礎(chǔ)通信實(shí)驗(yàn)2》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、WSN基礎(chǔ)通信實(shí)驗(yàn)講義2GPIO及LCD使用實(shí)驗(yàn)四、基本實(shí)驗(yàn)1.按鍵控制LED將如下給定代碼添加到工程程序框架中,并給予注釋,然后編譯、下載、運(yùn)行,分別按動(dòng)按鍵,觀測(cè)實(shí)驗(yàn)現(xiàn)象。//Includefiles#include#include//MacroDefinitions#defineAPP_TICK_PERIOD_ms500//LocalFunctionPrototypesPRIVATEvoidvAppTick(void*pvMsg,uint8u8Param);PRIVATEvoidvProcessSplash
2、KeyPress(uint8u8KeyMap);PRIVATEvoidvAppTickLED(void*pvMsg,uint8u8Param);//LocalVariablesPRIVATEbool_tbNwkStarted=FALSE;PRIVATEbool_tNextReadStart=TRUE;PRIVATEuint8u8Msg;PRIVATEuint8u8TimerId;PRIVATEuint8LED=3;PRIVATEbool_tbToggle;PRIVATEvoidvInit(void){(void)JZS_u32InitSystem(TRUE);
3、vLedInitFfd();vLedControl(0,TRUE);vLedControl(1,FALSE);vLedControl(2,FALSE);vLedControl(3,FALSE);vButtonInitFfd();(void)bBosRun(TRUE);}PRIVATEvoidvAppTick(void*pvMsg,uint8u8Param){NextReadStart=TRUE;}PRIVATEvoidvProcessSplashKeyPress(uint8u8KeyMap){switch(u8KeyMap)第5頁,共5頁WSN基礎(chǔ)通信實(shí)驗(yàn)講義
4、2GPIO及LCD使用實(shí)驗(yàn){caseBUTTON_0_MASK:LED=0;break;caseBUTTON_1_MASK:LED=1;break;caseBUTTON_2_MASK:LED=2;break;caseBUTTON_3_MASK:LED=3;break;default:break;}vLedControl(0,FALSE);vLedControl(1,FALSE);vLedControl(2,FALSE);vLedControl(3,FALSE);}PRIVATEvoidvAppTickLED(void*pvMsg,uint8u8Param){b
5、Toggle=!bToggle;vLedControl(LED,bToggle);(void)bBosCreateTimer(vAppTickLED,&u8Msg,0,(APP_TICK_PERIOD_ms/10),&u8TimerId);}voidJZA_vAppEventHandler(void){uint8u8ReadButton=0;if(!bNwkStarted)return;u8ReadButton=u8ButtonReadFfd();if(bNwkStarted&&NextReadStart&&u8ReadButton){NextReadStar
6、t=FALSE;vProcessSplashKeyPress(u8ReadButton);(void)bBosCreateTimer(vAppTick,&u8Msg,0,(APP_TICK_PERIOD_ms/10),&u8TimerId);}}PUBLICvoidJZA_vStackEvent(teJZS_EventIdentifiereEventId,第5頁,共5頁WSN基礎(chǔ)通信實(shí)驗(yàn)講義2GPIO及LCD使用實(shí)驗(yàn)tuJZS_StackEvent*puStackEvent){if(eEventId==JZS_EVENT_NWK_STARTED){bNwkSt
7、arted=TRUE;vLedControl(0,FALSE);(void)bBosCreateTimer(vAppTickLED,&u8Msg,0,(APP_TICK_PERIOD_ms/10),&u8TimerId);}}2.按鍵控制LCD將如下給定代碼添加到工程程序框架中,并給予注釋,然后編譯、下載、運(yùn)行,分別按動(dòng)按鍵,觀測(cè)實(shí)驗(yàn)現(xiàn)象。``//Includefiles#include"Lcd_JM12864_Driver.h"http://MacroDefinitions#defineLCD//PRIVATEvoidvInit(void)#ifdefLCDvLcdI
8、nit();#endifPRIVATE