hal_board_cfg.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. /**************************************************************************************************
  2. Filename: hal_board_cfg.h
  3. Revised: $Date: 2012-03-29 12:09:02 -0700 (Thu, 29 Mar 2012) $
  4. Revision: $Revision: 29943 $
  5. Description: Declarations for the CC2530EM used on the SmartRF05EB.
  6. Copyright 2006-2010 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED 揂S IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at https://aldsz.taobao.com
  32. **************************************************************************************************/
  33. #ifndef HAL_BOARD_CFG_H
  34. #define HAL_BOARD_CFG_H
  35. /* ------------------------------------------------------------------------------------------------
  36. * Includes
  37. * ------------------------------------------------------------------------------------------------
  38. */
  39. #include "hal_mcu.h"
  40. #include "hal_defs.h"
  41. #include "hal_types.h"
  42. /* ------------------------------------------------------------------------------------------------
  43. * CC2590/CC2591 support
  44. *
  45. * Define HAL_PA_LNA_CC2590 if CC2530+CC2590EM is used
  46. * Define HAL_PA_LNA if CC2530+CC2591EM is used
  47. * Note that only one of them can be defined
  48. * ------------------------------------------------------------------------------------------------
  49. */
  50. #define xHAL_PA_LNA
  51. #define xHAL_PA_LNA_CC2590
  52. /* ------------------------------------------------------------------------------------------------
  53. * Board Indentifier
  54. *
  55. * Define the Board Identifier to HAL_BOARD_CC2530EB_REV13 for SmartRF05 EB 1.3 board
  56. * ------------------------------------------------------------------------------------------------
  57. */
  58. #if !defined (HAL_BOARD_CC2530EB_REV17) && !defined (HAL_BOARD_CC2530EB_REV13)
  59. #define HAL_BOARD_CC2530EB_REV17
  60. #endif
  61. /* ------------------------------------------------------------------------------------------------
  62. * Clock Speed
  63. * ------------------------------------------------------------------------------------------------
  64. */
  65. #define HAL_CPU_CLOCK_MHZ 32
  66. /* This flag should be defined if the SoC uses the 32MHz crystal
  67. * as the main clock source (instead of DCO).
  68. */
  69. #define HAL_CLOCK_CRYSTAL
  70. /* 32 kHz clock source select in CLKCONCMD */
  71. #if !defined (OSC32K_CRYSTAL_INSTALLED) || (defined (OSC32K_CRYSTAL_INSTALLED) && (OSC32K_CRYSTAL_INSTALLED == TRUE))
  72. #define OSC_32KHZ 0x00 /* external 32 KHz xosc */
  73. #else
  74. #define OSC_32KHZ 0x80 /* internal 32 KHz rcosc */
  75. #endif
  76. #define HAL_CLOCK_STABLE() st( while (CLKCONSTA != (CLKCONCMD_32MHZ | OSC_32KHZ)); )
  77. /* ------------------------------------------------------------------------------------------------
  78. * LED Configuration
  79. * ------------------------------------------------------------------------------------------------
  80. */
  81. #if defined (HAL_BOARD_CC2530EB_REV17) && !defined (HAL_PA_LNA) && !defined (HAL_PA_LNA_CC2590)
  82. #define HAL_NUM_LEDS 3
  83. #elif defined (HAL_BOARD_CC2530EB_REV13) || defined (HAL_PA_LNA) || defined (HAL_PA_LNA_CC2590)
  84. #define HAL_NUM_LEDS 1
  85. #else
  86. #error Unknown Board Indentifier
  87. #endif
  88. #define HAL_LED_BLINK_DELAY() st( { volatile uint32 i; for (i=0; i<0x5800; i++) { }; } )
  89. /* 1 - Green */
  90. #define LED1_BV BV(0)
  91. #define LED1_SBIT P0_0 //定义IO口位
  92. #define LED1_DDR P0DIR//io 方向
  93. #define LED1_POLARITY ACTIVE_LOW //低电平有效
  94. #if defined (HAL_BOARD_CC2530EB_REV17)
  95. /* 2 - Red */
  96. #define LED2_BV BV(0)
  97. #define LED2_SBIT P0_0
  98. #define LED2_DDR P0DIR
  99. #define LED2_POLARITY ACTIVE_LOW
  100. /* 3 - Yellow */
  101. #define LED3_BV BV(0)
  102. #define LED3_SBIT P0_0
  103. #define LED3_DDR P0DIR
  104. #define LED3_POLARITY ACTIVE_LOW
  105. #endif
  106. /* ------------------------------------------------------------------------------------------------
  107. * Push Button Configuration
  108. * ------------------------------------------------------------------------------------------------
  109. */
  110. #define ACTIVE_LOW !
  111. #define ACTIVE_HIGH !! /* double negation forces result to be '1' */
  112. /* S1 */
  113. #define PUSH1_BV BV(0)
  114. #define PUSH1_SBIT P0_0
  115. #if defined (HAL_BOARD_CC2530EB_REV17)
  116. #define PUSH1_POLARITY ACTIVE_HIGH
  117. #elif defined (HAL_BOARD_CC2530EB_REV13)
  118. #define PUSH1_POLARITY ACTIVE_LOW
  119. #else
  120. #error Unknown Board Indentifier
  121. #endif
  122. /* Joystick Center Press */
  123. #define PUSH2_BV BV(0)
  124. #define PUSH2_SBIT P0_0
  125. #define PUSH2_POLARITY ACTIVE_HIGH
  126. /* ------------------------------------------------------------------------------------------------
  127. * OSAL NV implemented by internal flash pages.
  128. * ------------------------------------------------------------------------------------------------
  129. */
  130. // Flash is partitioned into 8 banks of 32 KB or 16 pages.
  131. #define HAL_FLASH_PAGE_PER_BANK 16
  132. // Flash is constructed of 128 pages of 2 KB.
  133. #define HAL_FLASH_PAGE_SIZE 2048
  134. #define HAL_FLASH_WORD_SIZE 4
  135. // CODE banks get mapped into the XDATA range 8000-FFFF.
  136. #define HAL_FLASH_PAGE_MAP 0x8000
  137. // The last 16 bytes of the last available page are reserved for flash lock bits.
  138. // NV page definitions must coincide with segment declaration in project *.xcl file.
  139. #if defined NON_BANKED
  140. #define HAL_FLASH_LOCK_BITS 16
  141. #define HAL_NV_PAGE_END 30
  142. #define HAL_NV_PAGE_CNT 2
  143. #else
  144. #define HAL_FLASH_LOCK_BITS 16
  145. #define HAL_NV_PAGE_END 126
  146. #define HAL_NV_PAGE_CNT 6
  147. #endif
  148. // Re-defining Z_EXTADDR_LEN here so as not to include a Z-Stack .h file.
  149. #define HAL_FLASH_IEEE_SIZE 8
  150. #define HAL_FLASH_IEEE_PAGE (HAL_NV_PAGE_END+1)
  151. #define HAL_FLASH_IEEE_OSET (HAL_FLASH_PAGE_SIZE - HAL_FLASH_LOCK_BITS - HAL_FLASH_IEEE_SIZE)
  152. #define HAL_INFOP_IEEE_OSET 0xC
  153. #define HAL_FLASH_DEV_PRIVATE_KEY_OSET 0x7D2
  154. #define HAL_FLASH_CA_PUBLIC_KEY_OSET 0x7BC
  155. #define HAL_FLASH_IMPLICIT_CERT_OSET 0x78C
  156. #define HAL_NV_PAGE_BEG (HAL_NV_PAGE_END-HAL_NV_PAGE_CNT+1)
  157. // Used by DMA macros to shift 1 to create a mask for DMA registers.
  158. #define HAL_NV_DMA_CH 0
  159. #define HAL_DMA_CH_RX 3
  160. #define HAL_DMA_CH_TX 4
  161. #define HAL_NV_DMA_GET_DESC() HAL_DMA_GET_DESC0()
  162. #define HAL_NV_DMA_SET_ADDR(a) HAL_DMA_SET_ADDR_DESC0((a))
  163. /* ------------------------------------------------------------------------------------------------
  164. * Serial Boot Loader: reserving the first 4 pages of flash and other memory in cc2530-sb.xcl.
  165. * ------------------------------------------------------------------------------------------------
  166. */
  167. #define HAL_SB_IMG_ADDR 0x2000
  168. #define HAL_SB_CRC_ADDR 0x2090
  169. // Size of internal flash less 4 pages for boot loader, 6 pages for NV, & 1 page for lock bits.
  170. #define HAL_SB_IMG_SIZE (0x40000 - 0x2000 - 0x3000 - 0x0800)
  171. /* ------------------------------------------------------------------------------------------------
  172. * Macros
  173. * ------------------------------------------------------------------------------------------------
  174. */
  175. /* ----------- RF-frontend Connection Initialization ---------- */
  176. #if defined HAL_PA_LNA || defined HAL_PA_LNA_CC2590
  177. extern void MAC_RfFrontendSetup(void);
  178. #define HAL_BOARD_RF_FRONTEND_SETUP() MAC_RfFrontendSetup()
  179. #else
  180. #define HAL_BOARD_RF_FRONTEND_SETUP()
  181. #endif
  182. /* ----------- Cache Prefetch control ---------- */
  183. #define PREFETCH_ENABLE() st( FCTL = 0x08; )
  184. #define PREFETCH_DISABLE() st( FCTL = 0x04; )
  185. /* ----------- Board Initialization ---------- */
  186. #if defined (HAL_BOARD_CC2530EB_REV17) && !defined (HAL_PA_LNA) && !defined (HAL_PA_LNA_CC2590)
  187. #define HAL_BOARD_INIT() \
  188. { \
  189. uint16 i; \
  190. \
  191. SLEEPCMD &= ~OSC_PD; /* turn on 16MHz RC and 32MHz XOSC */ \
  192. while (!(SLEEPSTA & XOSC_STB)); /* wait for 32MHz XOSC stable */ \
  193. asm("NOP"); /* chip bug workaround */ \
  194. for (i=0; i<504; i++) asm("NOP"); /* Require 63us delay for all revs */ \
  195. CLKCONCMD = (CLKCONCMD_32MHZ | OSC_32KHZ); /* Select 32MHz XOSC and the source for 32K clock */ \
  196. while (CLKCONSTA != (CLKCONCMD_32MHZ | OSC_32KHZ)); /* Wait for the change to be effective */ \
  197. SLEEPCMD |= OSC_PD; /* turn off 16MHz RC */ \
  198. \
  199. /* Turn on cache prefetch mode */ \
  200. PREFETCH_ENABLE(); \
  201. \
  202. HAL_TURN_OFF_LED1(); \
  203. LED1_DDR |= LED1_BV; \
  204. HAL_TURN_OFF_LED2(); \
  205. LED2_DDR |= LED2_BV; \
  206. HAL_TURN_OFF_LED3(); \
  207. LED3_DDR |= LED3_BV; \
  208. \
  209. /* configure tristates */ \
  210. P0INP |= PUSH2_BV; \
  211. }
  212. #elif defined (HAL_BOARD_CC2530EB_REV13) || defined (HAL_PA_LNA) || defined (HAL_PA_LNA_CC2590)
  213. #define HAL_BOARD_INIT() \
  214. { \
  215. uint16 i; \
  216. \
  217. SLEEPCMD &= ~OSC_PD; /* turn on 16MHz RC and 32MHz XOSC */ \
  218. while (!(SLEEPSTA & XOSC_STB)); /* wait for 32MHz XOSC stable */ \
  219. asm("NOP"); /* chip bug workaround */ \
  220. for (i=0; i<504; i++) asm("NOP"); /* Require 63us delay for all revs */ \
  221. CLKCONCMD = (CLKCONCMD_32MHZ | OSC_32KHZ); /* Select 32MHz XOSC and the source for 32K clock */ \
  222. while (CLKCONSTA != (CLKCONCMD_32MHZ | OSC_32KHZ)); /* Wait for the change to be effective */ \
  223. SLEEPCMD |= OSC_PD; /* turn off 16MHz RC */ \
  224. \
  225. /* Turn on cache prefetch mode */ \
  226. PREFETCH_ENABLE(); \
  227. \
  228. /* set direction for GPIO outputs */ \
  229. LED1_DDR |= LED1_BV; \
  230. \
  231. /* Set PA/LNA HGM control P0_7 */ \
  232. P0DIR |= BV(7); \
  233. \
  234. /* configure tristates */ \
  235. P0INP |= PUSH2_BV; \
  236. \
  237. /* setup RF frontend if necessary */ \
  238. HAL_BOARD_RF_FRONTEND_SETUP(); \
  239. }
  240. #endif
  241. /* ----------- Debounce ---------- */
  242. #define HAL_DEBOUNCE(expr) { int i; for (i=0; i<500; i++) { if (!(expr)) i = 0; } }
  243. /* ----------- Push Buttons ---------- */
  244. #define HAL_PUSH_BUTTON1() (PUSH1_POLARITY (PUSH1_SBIT))
  245. #define HAL_PUSH_BUTTON2() (PUSH2_POLARITY (PUSH2_SBIT))
  246. #define HAL_PUSH_BUTTON3() (0)
  247. #define HAL_PUSH_BUTTON4() (0)
  248. #define HAL_PUSH_BUTTON5() (0)
  249. #define HAL_PUSH_BUTTON6() (0)
  250. /* ----------- LED's ---------- */
  251. #if defined (HAL_BOARD_CC2530EB_REV17) && !defined (HAL_PA_LNA) && !defined (HAL_PA_LNA_CC2590)
  252. #define HAL_TURN_OFF_LED1() st( LED1_SBIT = LED1_POLARITY (0); )//关闭LED
  253. #define HAL_TURN_OFF_LED2() st( LED2_SBIT = LED2_POLARITY (0); )
  254. #define HAL_TURN_OFF_LED3() st( LED3_SBIT = LED3_POLARITY (0); )
  255. #define HAL_TURN_OFF_LED4() HAL_TURN_OFF_LED1()
  256. #define HAL_TURN_ON_LED1() st( LED1_SBIT = LED1_POLARITY (1); )//点亮LED
  257. #define HAL_TURN_ON_LED2() st( LED2_SBIT = LED2_POLARITY (1); )
  258. #define HAL_TURN_ON_LED3() st( LED3_SBIT = LED3_POLARITY (1); )
  259. #define HAL_TURN_ON_LED4() HAL_TURN_ON_LED1()
  260. #define HAL_TOGGLE_LED1() st( if (LED1_SBIT) { LED1_SBIT = 0; } else { LED1_SBIT = 1;} )//LED灯状态切换
  261. #define HAL_TOGGLE_LED2() st( if (LED2_SBIT) { LED2_SBIT = 0; } else { LED2_SBIT = 1;} )
  262. #define HAL_TOGGLE_LED3() st( if (LED3_SBIT) { LED3_SBIT = 0; } else { LED3_SBIT = 1;} )
  263. #define HAL_TOGGLE_LED4() HAL_TOGGLE_LED1()
  264. #define HAL_STATE_LED1() (LED1_POLARITY (LED1_SBIT))//LED状态
  265. #define HAL_STATE_LED2() (LED2_POLARITY (LED2_SBIT))
  266. #define HAL_STATE_LED3() (LED3_POLARITY (LED3_SBIT))
  267. #define HAL_STATE_LED4() HAL_STATE_LED1()
  268. #elif defined (HAL_BOARD_CC2530EB_REV13) || defined (HAL_PA_LNA) || defined (HAL_PA_LNA_CC2590)
  269. #define HAL_TURN_OFF_LED1() st( LED1_SBIT = LED1_POLARITY (0); )
  270. #define HAL_TURN_OFF_LED2() HAL_TURN_OFF_LED1()
  271. #define HAL_TURN_OFF_LED3() HAL_TURN_OFF_LED1()
  272. #define HAL_TURN_OFF_LED4() HAL_TURN_OFF_LED1()
  273. #define HAL_TURN_ON_LED1() st( LED1_SBIT = LED1_POLARITY (1); )
  274. #define HAL_TURN_ON_LED2() HAL_TURN_ON_LED1()
  275. #define HAL_TURN_ON_LED3() HAL_TURN_ON_LED1()
  276. #define HAL_TURN_ON_LED4() HAL_TURN_ON_LED1()
  277. #define HAL_TOGGLE_LED1() st( if (LED1_SBIT) { LED1_SBIT = 0; } else { LED1_SBIT = 1;} )
  278. #define HAL_TOGGLE_LED2() HAL_TOGGLE_LED1()
  279. #define HAL_TOGGLE_LED3() HAL_TOGGLE_LED1()
  280. #define HAL_TOGGLE_LED4() HAL_TOGGLE_LED1()
  281. #define HAL_STATE_LED1() (LED1_POLARITY (LED1_SBIT))
  282. #define HAL_STATE_LED2() HAL_STATE_LED1()
  283. #define HAL_STATE_LED3() HAL_STATE_LED1()
  284. #define HAL_STATE_LED4() HAL_STATE_LED1()
  285. #endif
  286. /* ----------- XNV ---------- */
  287. #define XNV_SPI_BEGIN() st(P1_3 = 0;)
  288. #define XNV_SPI_TX(x) st(U1CSR &= ~0x02; U1DBUF = (x);)
  289. #define XNV_SPI_RX() U1DBUF
  290. #define XNV_SPI_WAIT_RXRDY() st(while (!(U1CSR & 0x02));)
  291. #define XNV_SPI_END() st(P1_3 = 1;)
  292. // The TI reference design uses UART1 Alt. 2 in SPI mode.
  293. #define XNV_SPI_INIT() \
  294. st( \
  295. /* Mode select UART1 SPI Mode as master. */\
  296. U1CSR = 0; \
  297. \
  298. /* Setup for 115200 baud. */\
  299. U1GCR = 11; \
  300. U1BAUD = 216; \
  301. \
  302. /* Set bit order to MSB */\
  303. U1GCR |= BV(5); \
  304. \
  305. /* Set UART1 I/O to alternate 2 location on P1 pins. */\
  306. PERCFG |= 0x02; /* U1CFG */\
  307. \
  308. /* Select peripheral function on I/O pins but SS is left as GPIO for separate control. */\
  309. P1SEL |= 0xE0; /* SELP1_[7:4] */\
  310. /* P1.1,2,3: reset, LCD CS, XNV CS. */\
  311. P1SEL &= ~0x0E; \
  312. P1 |= 0x0E; \
  313. P1_1 = 0; \
  314. P1DIR |= 0x0E; \
  315. \
  316. /* Give UART1 priority over Timer3. */\
  317. P2SEL &= ~0x20; /* PRI2P1 */\
  318. \
  319. /* When SPI config is complete, enable it. */\
  320. U1CSR |= 0x40; \
  321. /* Release XNV reset. */\
  322. P1_1 = 1; \
  323. )
  324. /* ----------- Minimum safe bus voltage ---------- */
  325. // Vdd/3 / Internal Reference X ENOB --> (Vdd / 3) / 1.15 X 127
  326. #define VDD_2_0 74 // 2.0 V required to safely read/write internal flash.
  327. #define VDD_2_7 100 // 2.7 V required for the Numonyx device.
  328. #define VDD_MIN_RUN VDD_2_0
  329. #define VDD_MIN_NV (VDD_2_0+4) // 5% margin over minimum to survive a page erase and compaction.
  330. #define VDD_MIN_XNV (VDD_2_7+5) // 5% margin over minimum to survive a page erase and compaction.
  331. /* ------------------------------------------------------------------------------------------------
  332. * Driver Configuration
  333. * ------------------------------------------------------------------------------------------------
  334. */
  335. /* Set to TRUE enable H/W TIMER usage, FALSE disable it */
  336. #ifndef HAL_TIMER
  337. #define HAL_TIMER FALSE
  338. #endif
  339. /* Set to TRUE enable ADC usage, FALSE disable it */
  340. #ifndef HAL_ADC
  341. #define HAL_ADC TRUE
  342. #endif
  343. /* Set to TRUE enable DMA usage, FALSE disable it */
  344. #ifndef HAL_DMA
  345. #define HAL_DMA TRUE
  346. #endif
  347. /* Set to TRUE enable Flash access, FALSE disable it */
  348. #ifndef HAL_FLASH
  349. #define HAL_FLASH TRUE
  350. #endif
  351. /* Set to TRUE enable AES usage, FALSE disable it */
  352. #ifndef HAL_AES
  353. #define HAL_AES TRUE
  354. #endif
  355. #ifndef HAL_AES_DMA
  356. #define HAL_AES_DMA TRUE
  357. #endif
  358. /* Set to TRUE enable LCD usage, FALSE disable it */
  359. #ifndef HAL_LCD
  360. #define HAL_LCD TRUE
  361. #endif
  362. /* Set to TRUE enable LED usage, FALSE disable it */
  363. #ifndef HAL_LED
  364. #define HAL_LED TRUE
  365. #endif
  366. #if (!defined BLINK_LEDS) && (HAL_LED == TRUE)
  367. #define BLINK_LEDS
  368. #endif
  369. /* Set to TRUE enable KEY usage, FALSE disable it */
  370. #ifndef HAL_KEY
  371. #define HAL_KEY TRUE
  372. #endif
  373. /* Set to TRUE enable UART usage, FALSE disable it */
  374. #ifndef HAL_UART
  375. #if (defined ZAPP_P1) || (defined ZAPP_P2) || (defined ZTOOL_P1) || (defined ZTOOL_P2)
  376. #define HAL_UART TRUE
  377. #else
  378. #define HAL_UART FALSE
  379. #endif
  380. #endif
  381. #if HAL_UART
  382. #ifndef HAL_UART_DMA
  383. #if HAL_DMA
  384. #if (defined ZAPP_P2) || (defined ZTOOL_P2)
  385. #define HAL_UART_DMA 2
  386. #else
  387. #define HAL_UART_DMA 1
  388. #endif
  389. #else
  390. #define HAL_UART_DMA 0
  391. #endif
  392. #endif
  393. #ifndef HAL_UART_ISR
  394. #if HAL_UART_DMA // Default preference for DMA over ISR.
  395. #define HAL_UART_ISR 0
  396. #elif (defined ZAPP_P2) || (defined ZTOOL_P2)
  397. #define HAL_UART_ISR 2
  398. #else
  399. #define HAL_UART_ISR 1
  400. #endif
  401. #endif
  402. #if (HAL_UART_DMA && (HAL_UART_DMA == HAL_UART_ISR))
  403. #error HAL_UART_DMA & HAL_UART_ISR must be different.
  404. #endif
  405. // Used to set P2 priority - USART0 over USART1 if both are defined.
  406. #if ((HAL_UART_DMA == 1) || (HAL_UART_ISR == 1))
  407. #define HAL_UART_PRIPO 0x00
  408. #else
  409. #define HAL_UART_PRIPO 0x40
  410. #endif
  411. #else
  412. #define HAL_UART_DMA 0
  413. #define HAL_UART_ISR 0
  414. #endif
  415. /* USB is not used for CC2530 configuration */
  416. #define HAL_UART_USB 0
  417. #endif
  418. /*******************************************************************************************************
  419. */