資源描述:
《串口,按鍵,消息,定時(shí)器.docx》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在學(xué)術(shù)論文-天天文庫(kù)。
1、zigbee3-zstack串口,按鍵,消息,定時(shí)器協(xié)議棧中的串口接收流程串口在底層使用的是中斷,輪詢還是DMA呢??答案從下面這個(gè)文件定義的宏可以得知在C:TexasInstrumentsZStack-CC2530-2.3.0-1.4.0ComponentshaltargetCC2530EBhal_board_cfg.h[cpp]?viewplaincopy1.//默認(rèn)開(kāi)啟DMA??2.#ifndef?HAL_DMA??3.???????#define?HAL_DMA?TRUE??4.#endif??5.??6.//只要
2、定義了以下4個(gè)宏,就相當(dāng)于需要使用串口??7.#ifndef?HAL_UART??8.????#if?(defined?ZAPP_P1)?
3、
4、?(defined?ZAPP_P2)?
5、
6、?(defined?ZTOOL_P1)?
7、
8、?(defined?ZTOOL_P2)??9.????????#define?HAL_UART?TRUE??10.????#else??11.????????#define?HAL_UART?FALSE??12.????#endif??13.#endif??14.??15.//?HAL_UART和HAL_DMA都
9、已經(jīng)定義過(guò)了,所以協(xié)議棧里的串口默認(rèn)使用的是DMA,而不是中斷??16.#if?HAL_UART??17.????//?Always?prefer?to?use?DMA?over?ISR.??18.????#if?HAL_DMA??19.????????#ifndef?HAL_UART_DMA??20.????????????#if?(defined?ZAPP_P1)?
10、
11、?(defined?ZTOOL_P1)??21.????????????????#define?HAL_UART_DMA??1??22.????????????#el
12、if?(defined?ZAPP_P2)?
13、
14、?(defined?ZTOOL_P2)??23.????????????????#define?HAL_UART_DMA??2??24.????????????#else??25.????????????????#define?HAL_UART_DMA??1??26.????????????#endif??27.????????#endif??28.????????#define?HAL_UART_ISR??0??29.????#else??30.????????#ifndef?HAL_UA
15、RT_ISR??31.????????????#if?(defined?ZAPP_P1)?
16、
17、?(defined?ZTOOL_P1)??1.????????????#define?HAL_UART_ISR??1??2.????????????#elif?(defined?ZAPP_P2)?
18、
19、?(defined?ZTOOL_P2)??3.????????????#define?HAL_UART_ISR??2??4.????????????#else??5.????????????#define?HAL_UART_ISR??1??6.??
20、??????????#endif??7.????????#endif??8.????????#define?HAL_UART_DMA??0??9.????#endif??10.??11.????//?Used?to?set?P2?priority?-?USART0?over?USART1?if?both?are?defined.??12.????#if?((HAL_UART_DMA?==?1)?
21、
22、?(HAL_UART_ISR?==?1))??13.????????#define?HAL_UART_PRIPO?????????????0
23、x00??14.????????#else??15.????????#define?HAL_UART_PRIPO?????????????0x40??16.????#endif??17.??18.#else//否則??19.????#define?HAL_UART_DMA??0??20.????#define?HAL_UART_ISR??0??21.#endif??在某個(gè)應(yīng)用的初始化函數(shù)中順序執(zhí)行下面兩個(gè)函數(shù),比如在SampleApp_Init函數(shù)中,?MT_UartInit();?MT_UartRegisterTaskID(task_
24、id);MT_UartRegisterTaskID//用于給SampleApp注冊(cè)串口,這樣當(dāng)串口在MT_UartProcessZToolData(mt_uart.c)發(fā)數(shù)據(jù)到上層時(shí),會(huì)發(fā)到SampleAp