nrf_drv_config.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. /* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. #ifndef NRF_DRV_CONFIG_H
  13. #define NRF_DRV_CONFIG_H
  14. /**
  15. * Provide a non-zero value here in applications that need to use several
  16. * peripherals with the same ID that are sharing certain resources
  17. * (for example, SPI0 and TWI0). Obviously, such peripherals cannot be used
  18. * simultaneously. Therefore, this definition allows to initialize the driver
  19. * for another peripheral from a given group only after the previously used one
  20. * is uninitialized. Normally, this is not possible, because interrupt handlers
  21. * are implemented in individual drivers.
  22. * This functionality requires a more complicated interrupt handling and driver
  23. * initialization, hence it is not always desirable to use it.
  24. */
  25. #define PERIPHERAL_RESOURCE_SHARING_ENABLED 0
  26. /* CLOCK */
  27. #define CLOCK_ENABLED 0
  28. #if (CLOCK_ENABLED == 1)
  29. #define CLOCK_CONFIG_XTAL_FREQ NRF_CLOCK_XTALFREQ_Default
  30. #define CLOCK_CONFIG_LF_SRC NRF_CLOCK_LFCLK_Xtal
  31. #define CLOCK_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  32. #endif
  33. /* GPIOTE */
  34. #define GPIOTE_ENABLED 0
  35. #if (GPIOTE_ENABLED == 1)
  36. #define GPIOTE_CONFIG_USE_SWI_EGU false
  37. #define GPIOTE_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  38. #define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1
  39. #endif
  40. /* TIMER */
  41. #define TIMER0_ENABLED 0
  42. #if (TIMER0_ENABLED == 1)
  43. #define TIMER0_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
  44. #define TIMER0_CONFIG_MODE TIMER_MODE_MODE_Timer
  45. #define TIMER0_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_32Bit
  46. #define TIMER0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  47. #define TIMER0_INSTANCE_INDEX 0
  48. #endif
  49. #define TIMER1_ENABLED 0
  50. #if (TIMER1_ENABLED == 1)
  51. #define TIMER1_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
  52. #define TIMER1_CONFIG_MODE TIMER_MODE_MODE_Timer
  53. #define TIMER1_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
  54. #define TIMER1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  55. #define TIMER1_INSTANCE_INDEX (TIMER0_ENABLED)
  56. #endif
  57. #define TIMER2_ENABLED 0
  58. #if (TIMER2_ENABLED == 1)
  59. #define TIMER2_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
  60. #define TIMER2_CONFIG_MODE TIMER_MODE_MODE_Timer
  61. #define TIMER2_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
  62. #define TIMER2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  63. #define TIMER2_INSTANCE_INDEX (TIMER1_ENABLED+TIMER0_ENABLED)
  64. #endif
  65. #define TIMER3_ENABLED 0
  66. #if (TIMER3_ENABLED == 1)
  67. #define TIMER3_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
  68. #define TIMER3_CONFIG_MODE TIMER_MODE_MODE_Timer
  69. #define TIMER3_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
  70. #define TIMER3_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  71. #define TIMER3_INSTANCE_INDEX (TIMER2_ENABLED+TIMER1_ENABLED+TIMER0_ENABLED)
  72. #endif
  73. #define TIMER4_ENABLED 0
  74. #if (TIMER4_ENABLED == 1)
  75. #define TIMER4_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
  76. #define TIMER4_CONFIG_MODE TIMER_MODE_MODE_Timer
  77. #define TIMER4_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
  78. #define TIMER4_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  79. #define TIMER4_INSTANCE_INDEX (TIMER3_ENABLED+TIMER2_ENABLED+TIMER1_ENABLED+TIMER0_ENABLED)
  80. #endif
  81. #define TIMER_COUNT (TIMER0_ENABLED + TIMER1_ENABLED + TIMER2_ENABLED + TIMER3_ENABLED + TIMER4_ENABLED)
  82. /* RTC */
  83. #define RTC0_ENABLED 0
  84. #if (RTC0_ENABLED == 1)
  85. #define RTC0_CONFIG_FREQUENCY 32678
  86. #define RTC0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  87. #define RTC0_CONFIG_RELIABLE false
  88. #define RTC0_INSTANCE_INDEX 0
  89. #endif
  90. #define RTC1_ENABLED 0
  91. #if (RTC1_ENABLED == 1)
  92. #define RTC1_CONFIG_FREQUENCY 32768
  93. #define RTC1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  94. #define RTC1_CONFIG_RELIABLE false
  95. #define RTC1_INSTANCE_INDEX (RTC0_ENABLED)
  96. #endif
  97. #define RTC2_ENABLED 0
  98. #if (RTC2_ENABLED == 1)
  99. #define RTC2_CONFIG_FREQUENCY 32768
  100. #define RTC2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  101. #define RTC2_CONFIG_RELIABLE false
  102. #define RTC2_INSTANCE_INDEX (RTC0_ENABLED+RTC1_ENABLED)
  103. #endif
  104. #define RTC_COUNT (RTC0_ENABLED+RTC1_ENABLED+RTC2_ENABLED)
  105. #define NRF_MAXIMUM_LATENCY_US 2000
  106. /* RNG */
  107. #define RNG_ENABLED 0
  108. #if (RNG_ENABLED == 1)
  109. #define RNG_CONFIG_ERROR_CORRECTION true
  110. #define RNG_CONFIG_POOL_SIZE 8
  111. #define RNG_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  112. #endif
  113. /* PWM */
  114. #define PWM0_ENABLED 0
  115. #if (PWM0_ENABLED == 1)
  116. #define PWM0_CONFIG_OUT0_PIN 2
  117. #define PWM0_CONFIG_OUT1_PIN 3
  118. #define PWM0_CONFIG_OUT2_PIN 4
  119. #define PWM0_CONFIG_OUT3_PIN 5
  120. #define PWM0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  121. #define PWM0_CONFIG_BASE_CLOCK NRF_PWM_CLK_1MHz
  122. #define PWM0_CONFIG_COUNT_MODE NRF_PWM_MODE_UP
  123. #define PWM0_CONFIG_TOP_VALUE 1000
  124. #define PWM0_CONFIG_LOAD_MODE NRF_PWM_LOAD_COMMON
  125. #define PWM0_CONFIG_STEP_MODE NRF_PWM_STEP_AUTO
  126. #define PWM0_INSTANCE_INDEX 0
  127. #endif
  128. #define PWM1_ENABLED 0
  129. #if (PWM1_ENABLED == 1)
  130. #define PWM1_CONFIG_OUT0_PIN 2
  131. #define PWM1_CONFIG_OUT1_PIN 3
  132. #define PWM1_CONFIG_OUT2_PIN 4
  133. #define PWM1_CONFIG_OUT3_PIN 5
  134. #define PWM1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  135. #define PWM1_CONFIG_BASE_CLOCK NRF_PWM_CLK_1MHz
  136. #define PWM1_CONFIG_COUNT_MODE NRF_PWM_MODE_UP
  137. #define PWM1_CONFIG_TOP_VALUE 1000
  138. #define PWM1_CONFIG_LOAD_MODE NRF_PWM_LOAD_COMMON
  139. #define PWM1_CONFIG_STEP_MODE NRF_PWM_STEP_AUTO
  140. #define PWM1_INSTANCE_INDEX (PWM0_ENABLED)
  141. #endif
  142. #define PWM2_ENABLED 0
  143. #if (PWM2_ENABLED == 1)
  144. #define PWM2_CONFIG_OUT0_PIN 2
  145. #define PWM2_CONFIG_OUT1_PIN 3
  146. #define PWM2_CONFIG_OUT2_PIN 4
  147. #define PWM2_CONFIG_OUT3_PIN 5
  148. #define PWM2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  149. #define PWM2_CONFIG_BASE_CLOCK NRF_PWM_CLK_1MHz
  150. #define PWM2_CONFIG_COUNT_MODE NRF_PWM_MODE_UP
  151. #define PWM2_CONFIG_TOP_VALUE 1000
  152. #define PWM2_CONFIG_LOAD_MODE NRF_PWM_LOAD_COMMON
  153. #define PWM2_CONFIG_STEP_MODE NRF_PWM_STEP_AUTO
  154. #define PWM2_INSTANCE_INDEX (PWM0_ENABLED + PWM1_ENABLED)
  155. #endif
  156. #define PWM_COUNT (PWM0_ENABLED + PWM1_ENABLED + PWM2_ENABLED)
  157. /* SPI */
  158. #define SPI0_ENABLED 0
  159. #if (SPI0_ENABLED == 1)
  160. #define SPI0_USE_EASY_DMA 0
  161. #define SPI0_CONFIG_SCK_PIN 2
  162. #define SPI0_CONFIG_MOSI_PIN 3
  163. #define SPI0_CONFIG_MISO_PIN 4
  164. #define SPI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  165. #define SPI0_INSTANCE_INDEX 0
  166. #endif
  167. #define SPI1_ENABLED 0
  168. #if (SPI1_ENABLED == 1)
  169. #define SPI1_USE_EASY_DMA 0
  170. #define SPI1_CONFIG_SCK_PIN 2
  171. #define SPI1_CONFIG_MOSI_PIN 3
  172. #define SPI1_CONFIG_MISO_PIN 4
  173. #define SPI1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  174. #define SPI1_INSTANCE_INDEX (SPI0_ENABLED)
  175. #endif
  176. #define SPI2_ENABLED 0
  177. #if (SPI2_ENABLED == 1)
  178. #define SPI2_USE_EASY_DMA 0
  179. #define SPI2_CONFIG_SCK_PIN 2
  180. #define SPI2_CONFIG_MOSI_PIN 3
  181. #define SPI2_CONFIG_MISO_PIN 4
  182. #define SPI2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  183. #define SPI2_INSTANCE_INDEX (SPI0_ENABLED + SPI1_ENABLED)
  184. #endif
  185. #define SPI_COUNT (SPI0_ENABLED + SPI1_ENABLED + SPI2_ENABLED)
  186. /* SPIS */
  187. #define SPIS0_ENABLED 0
  188. #if (SPIS0_ENABLED == 1)
  189. #define SPIS0_CONFIG_SCK_PIN 2
  190. #define SPIS0_CONFIG_MOSI_PIN 3
  191. #define SPIS0_CONFIG_MISO_PIN 4
  192. #define SPIS0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  193. #define SPIS0_INSTANCE_INDEX 0
  194. #endif
  195. #define SPIS1_ENABLED 0
  196. #if (SPIS1_ENABLED == 1)
  197. #define SPIS1_CONFIG_SCK_PIN 2
  198. #define SPIS1_CONFIG_MOSI_PIN 3
  199. #define SPIS1_CONFIG_MISO_PIN 4
  200. #define SPIS1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  201. #define SPIS1_INSTANCE_INDEX SPIS0_ENABLED
  202. #endif
  203. #define SPIS2_ENABLED 0
  204. #if (SPIS2_ENABLED == 1)
  205. #define SPIS2_CONFIG_SCK_PIN 2
  206. #define SPIS2_CONFIG_MOSI_PIN 3
  207. #define SPIS2_CONFIG_MISO_PIN 4
  208. #define SPIS2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  209. #define SPIS2_INSTANCE_INDEX (SPIS0_ENABLED + SPIS1_ENABLED)
  210. #endif
  211. #define SPIS_COUNT (SPIS0_ENABLED + SPIS1_ENABLED + SPIS2_ENABLED)
  212. /* UART */
  213. #define UART0_ENABLED 1
  214. #if (UART0_ENABLED == 1)
  215. #define UART0_CONFIG_HWFC NRF_UART_HWFC_DISABLED
  216. #define UART0_CONFIG_PARITY NRF_UART_PARITY_EXCLUDED
  217. #define UART0_CONFIG_BAUDRATE NRF_UART_BAUDRATE_115200
  218. #define UART0_CONFIG_PSEL_TXD 0
  219. #define UART0_CONFIG_PSEL_RXD 0
  220. #define UART0_CONFIG_PSEL_CTS 0
  221. #define UART0_CONFIG_PSEL_RTS 0
  222. #define UART0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  223. #ifdef NRF52
  224. #define UART0_CONFIG_USE_EASY_DMA false
  225. //Compile time flag
  226. #define UART_EASY_DMA_SUPPORT 1
  227. #define UART_LEGACY_SUPPORT 1
  228. #endif //NRF52
  229. #endif
  230. #define TWI0_ENABLED 0
  231. #if (TWI0_ENABLED == 1)
  232. #define TWI0_USE_EASY_DMA 0
  233. #define TWI0_CONFIG_FREQUENCY NRF_TWI_FREQ_100K
  234. #define TWI0_CONFIG_SCL 0
  235. #define TWI0_CONFIG_SDA 1
  236. #define TWI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  237. #define TWI0_INSTANCE_INDEX 0
  238. #endif
  239. #define TWI1_ENABLED 0
  240. #if (TWI1_ENABLED == 1)
  241. #define TWI1_USE_EASY_DMA 0
  242. #define TWI1_CONFIG_FREQUENCY NRF_TWI_FREQ_100K
  243. #define TWI1_CONFIG_SCL 0
  244. #define TWI1_CONFIG_SDA 1
  245. #define TWI1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  246. #define TWI1_INSTANCE_INDEX (TWI0_ENABLED)
  247. #endif
  248. #define TWI_COUNT (TWI0_ENABLED + TWI1_ENABLED)
  249. /* TWIS */
  250. #define TWIS0_ENABLED 0
  251. #if (TWIS0_ENABLED == 1)
  252. #define TWIS0_CONFIG_ADDR0 0
  253. #define TWIS0_CONFIG_ADDR1 0 /* 0: Disabled */
  254. #define TWIS0_CONFIG_SCL 0
  255. #define TWIS0_CONFIG_SDA 1
  256. #define TWIS0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  257. #define TWIS0_INSTANCE_INDEX 0
  258. #endif
  259. #define TWIS1_ENABLED 0
  260. #if (TWIS1_ENABLED == 1)
  261. #define TWIS1_CONFIG_ADDR0 0
  262. #define TWIS1_CONFIG_ADDR1 0 /* 0: Disabled */
  263. #define TWIS1_CONFIG_SCL 0
  264. #define TWIS1_CONFIG_SDA 1
  265. #define TWIS1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  266. #define TWIS1_INSTANCE_INDEX (TWIS0_ENABLED)
  267. #endif
  268. #define TWIS_COUNT (TWIS0_ENABLED + TWIS1_ENABLED)
  269. /* For more documentation see nrf_drv_twis.h file */
  270. #define TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0
  271. /* For more documentation see nrf_drv_twis.h file */
  272. #define TWIS_NO_SYNC_MODE 0
  273. /* QDEC */
  274. #define QDEC_ENABLED 0
  275. #if (QDEC_ENABLED == 1)
  276. #define QDEC_CONFIG_REPORTPER NRF_QDEC_REPORTPER_10
  277. #define QDEC_CONFIG_SAMPLEPER NRF_QDEC_SAMPLEPER_16384us
  278. #define QDEC_CONFIG_PIO_A 1
  279. #define QDEC_CONFIG_PIO_B 2
  280. #define QDEC_CONFIG_PIO_LED 3
  281. #define QDEC_CONFIG_LEDPRE 511
  282. #define QDEC_CONFIG_LEDPOL NRF_QDEC_LEPOL_ACTIVE_HIGH
  283. #define QDEC_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  284. #define QDEC_CONFIG_DBFEN false
  285. #define QDEC_CONFIG_SAMPLE_INTEN false
  286. #endif
  287. /* ADC */
  288. #define ADC_ENABLED 0
  289. #if (ADC_ENABLED == 1)
  290. #define ADC_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  291. #endif
  292. /* SAADC */
  293. #define SAADC_ENABLED 0
  294. #if (SAADC_ENABLED == 1)
  295. #define SAADC_CONFIG_RESOLUTION NRF_SAADC_RESOLUTION_10BIT
  296. #define SAADC_CONFIG_OVERSAMPLE NRF_SAADC_OVERSAMPLE_DISABLED
  297. #define SAADC_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  298. #endif
  299. /* PDM */
  300. #define PDM_ENABLED 0
  301. #if (PDM_ENABLED == 1)
  302. #define PDM_CONFIG_MODE NRF_PDM_MODE_MONO
  303. #define PDM_CONFIG_EDGE NRF_PDM_EDGE_LEFTFALLING
  304. #define PDM_CONFIG_CLOCK_FREQ NRF_PDM_FREQ_1032K
  305. #define PDM_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  306. #endif
  307. /* COMP */
  308. #define COMP_ENABLED 0
  309. #if (COMP_ENABLED == 1)
  310. #define COMP_CONFIG_REF NRF_COMP_REF_Int1V8
  311. #define COMP_CONFIG_MAIN_MODE NRF_COMP_MAIN_MODE_SE
  312. #define COMP_CONFIG_SPEED_MODE NRF_COMP_SP_MODE_High
  313. #define COMP_CONFIG_HYST NRF_COMP_HYST_NoHyst
  314. #define COMP_CONFIG_ISOURCE NRF_COMP_ISOURCE_Off
  315. #define COMP_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  316. #define COMP_CONFIG_INPUT NRF_COMP_INPUT_0
  317. #endif
  318. /* LPCOMP */
  319. #define LPCOMP_ENABLED 0
  320. #if (LPCOMP_ENABLED == 1)
  321. #define LPCOMP_CONFIG_REFERENCE NRF_LPCOMP_REF_SUPPLY_4_8
  322. #define LPCOMP_CONFIG_DETECTION NRF_LPCOMP_DETECT_DOWN
  323. #define LPCOMP_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
  324. #define LPCOMP_CONFIG_INPUT NRF_LPCOMP_INPUT_0
  325. #endif
  326. /* WDT */
  327. #define WDT_ENABLED 0
  328. #if (WDT_ENABLED == 1)
  329. #define WDT_CONFIG_BEHAVIOUR NRF_WDT_BEHAVIOUR_RUN_SLEEP
  330. #define WDT_CONFIG_RELOAD_VALUE 2000
  331. #define WDT_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
  332. #endif
  333. /* SWI EGU */
  334. #ifdef NRF52
  335. #define EGU_ENABLED 0
  336. #endif
  337. /* I2S */
  338. #define I2S_ENABLED 0
  339. #if (I2S_ENABLED == 1)
  340. #define I2S_CONFIG_SCK_PIN 22
  341. #define I2S_CONFIG_LRCK_PIN 23
  342. #define I2S_CONFIG_MCK_PIN NRF_DRV_I2S_PIN_NOT_USED
  343. #define I2S_CONFIG_SDOUT_PIN 24
  344. #define I2S_CONFIG_SDIN_PIN 25
  345. #define I2S_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
  346. #define I2S_CONFIG_MASTER NRF_I2S_MODE_MASTER
  347. #define I2S_CONFIG_FORMAT NRF_I2S_FORMAT_I2S
  348. #define I2S_CONFIG_ALIGN NRF_I2S_ALIGN_LEFT
  349. #define I2S_CONFIG_SWIDTH NRF_I2S_SWIDTH_16BIT
  350. #define I2S_CONFIG_CHANNELS NRF_I2S_CHANNELS_STEREO
  351. #define I2S_CONFIG_MCK_SETUP NRF_I2S_MCK_32MDIV8
  352. #define I2S_CONFIG_RATIO NRF_I2S_RATIO_256X
  353. #endif
  354. #include "nrf_drv_config_validation.h"
  355. #endif // NRF_DRV_CONFIG_H