第十六節(jié)BLE協(xié)議棧LED實(shí)驗(yàn)_第1頁
第十六節(jié)BLE協(xié)議棧LED實(shí)驗(yàn)_第2頁
第十六節(jié)BLE協(xié)議棧LED實(shí)驗(yàn)_第3頁
第十六節(jié)BLE協(xié)議棧LED實(shí)驗(yàn)_第4頁
第十六節(jié)BLE協(xié)議棧LED實(shí)驗(yàn)_第5頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、第十六節(jié)ble協(xié)議棧led實(shí)驗(yàn)ti的協(xié)議棧中在hal層已經(jīng)有了 led的驅(qū)動(dòng),我們只需要針對(duì)我 們的開發(fā)板進(jìn)行配置即可,我們的開發(fā)板有兩個(gè)led,分別對(duì)應(yīng)p1.0 和p1.1。這個(gè)在裸機(jī)幵發(fā)的時(shí)候已經(jīng)介紹了。為了保持協(xié)議棧原有的代碼不變,我們?cè)赽le-cc254x-1.4.0componentshaltarget 目錄下新建一個(gè)文件夾,使它適應(yīng)我們的開發(fā)板。名稱罐改曰明加 cc2540eb2014/5/23 1002文賊.cc2540usb2014/5/23 1002文件夾“ cc2541arc2014/5/23 1002文賊m cc2541st2014/5/23 1002文賊mt2s4xbo

2、ard2014/7/2 20:24文峽大小打開led實(shí)驗(yàn)工程ledexample,選擇mt254xboard,并且在工 程配置屮要定義hal_led=true,下載到開發(fā)板運(yùn)行,可以看到兩個(gè)led同時(shí)在閃爍。workspacem254xboardfiles 0 ledexomple - mt254xboordh=lclapp-q 已 osal_simple巳leperipheral.c -q icib simple巳leperipheral.h -q 0 simplebleperipheral_main.c(5 c3 target l-qqmt;h3c3hal ffl c3 common qc

3、lincludemt254xboard-qc includeh3c3libh3c3npi-qc3osal h3o profiles -0d tools lq outputi preprocessor 1diagnosticsextra(礞categocy:custom bum buu actions unto debugger third-party onvcr texas instrvmenb fs2 system navig. infineon nordc semconduc rom-monitor analog devices sfabs s<nulatorfactory setb

4、ngsdefined symbols: (one per line)xpower.saving xplus broadcasterll*. !|hal:led=true| | preprocessor output to filepreserve commentsgenerate «iine directivesok:mufette compiabondisced unuted pubfesoptimizations output list匚;ignore standard include directorieiadditional include directories: (one

5、 per line)$proj.oir$.,-commonsproj.dirsvx.includesproj.dir$.vwcomponentsh«linclude$proj.dirswwcomponentsh«itargetmt2s4xboard$proj.dir$.*wacomponcnt$h«kurgetmt2s4xbo«rdu$blibpreincludecancel那我們的實(shí)現(xiàn)代碼在哪里呢?其實(shí)在協(xié)議棧中實(shí)現(xiàn)這個(gè)很簡單,在啟動(dòng)事件屮我們調(diào)用了一個(gè)halledset函數(shù),并且設(shè)置了兩個(gè)led同時(shí)閃爍。if ( events & s8p s

6、tart device evt )/ start the devicevoid gaprole_$tartoevicc( hsi»plebleperipheral_peripberal(bs/ start bond managerhdlledset( (hatjed一 1 | kal3eort什卿,pfhw/h fvf”return ( events a sbp start device evt、osalstartti»erex( sioplebleporipheral-taskio> s8pj>eri00ic_evt, s8p.peri00ic一evtj>

7、;erioo );就是這么簡單,協(xié)議棧已經(jīng)把其它事情做好了,只需要我們調(diào)用設(shè)置函數(shù)即可。設(shè)置的模式總共有5種?12345define hal_led_mode_ofe fidefine hal_led_mode_on #define hal_led_mode_blink define hal_lrd_modr_flash ttdefine hal led mode toggle0x000x010x020x040x08/關(guān)閉led /打開led/閃爍一次/不斷的閃爍,最多255次 /翻轉(zhuǎn)led狀態(tài)為了適應(yīng)不同的需求,我們可能需要更改led的 輸出引腳,如圖板級(jí)配置在hal_board_cfg.h

8、文件中。files 3 ledexomple - mt254xboardhiciapp0 osal_simplebleperipheral.c q 0 simplebleperipheral c0 simplebleperipheral.h b simplebleperipheral.main.c -9c3hal common cl include c3 targetc3mt254xboord confighal board cfq.hh=lc drivers 43 el hal_odc.c 0 0 hal_aes.c q 0 hal_crc.c 43 0 hal_dma.c -ffl 0 h

9、aljlash.c -q 0 halkey c q (cl hal icd.c/ configurationdefine hal nuh leos2define kai j cobl ink oc l ay()st( ( volatile ulnt)2 i; for (i»e; i<oxs800; !) j; )/ ! green v define le01 bv define led1一s8it define leolzoor define leolpotaritybvpl 一 0p1diractive j4i0h/. 2 /define le02bv define l«)2二s8it define le02z(x)r define lewlpolaritybvpl 一 1p10iractive-high/ pu$/>

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論