sdk_validation.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /**
  2. * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #ifndef SDK_VALIDATION_H
  41. #define SDK_VALIDATION_H
  42. #include "nrf_peripherals.h"
  43. #include "sdk_config.h"
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. // Validate peripheral availibility
  48. #if ((defined(SAADC_ENABLED)) && (SAADC_ENABLED > 0) && (!defined(SAADC_PRESENT)))
  49. #error "SAADC not present in selected MCU."
  50. #endif
  51. #if ((defined(ADC_ENABLED)) && (ADC_ENABLED > 0) && (!defined(ADC_PRESENT)))
  52. #error "SAADC not present in selected MCU."
  53. #endif
  54. #if ((defined(I2S_ENABLED)) && (I2S_ENABLED > 0) && (!defined(I2S_PRESENT)))
  55. #error "I2S not present in selected MCU."
  56. #endif
  57. #if ((defined(COMP_ENABLED)) && (COMP_ENABLED > 0) && (!defined(COMP_PRESENT)))
  58. #error "COMP not present in selected MCU."
  59. #endif
  60. #if ((defined(LPCOMP_ENABLED)) && (LPCOMP_ENABLED > 0) && (!defined(LPCOMP_PRESENT)))
  61. #error "LPCOMP not present in selected MCU."
  62. #endif
  63. #if ((defined(SPIS0_ENABLED)) && (SPIS0_ENABLED > 0) && (!defined(SPIS_PRESENT)))
  64. #error "SPIS0 instance not present in selected MCU."
  65. #endif
  66. #if ((defined(EGU_ENABLED)) && (EGU_ENABLED > 0) && (!defined(EGU_PRESENT)))
  67. #error "EGU instance not present in selected MCU."
  68. #endif
  69. #if ((defined(NFC_HAL_ENABLED)) && (NFC_HAL_ENABLED > 0) && (!defined(NFCT_PRESENT)))
  70. #error "NFC TAG not present in selected MCU."
  71. #endif
  72. // Validate count of instances
  73. #if ((defined(RTC2_ENABLED)) && (RTC2_ENABLED > 0) && (RTC_COUNT < 2))
  74. #error "RTC2 not present in selected MCU."
  75. #endif
  76. #if ((defined(TWIS0_ENABLED) || defined(TWIS1_ENABLED)) &&\
  77. ((TWIS0_ENABLED + TWIS1_ENABLED) > 0) &&\
  78. (!defined(TWIS_PRESENT)))
  79. #error "TWIS not present in selected MCU."
  80. #endif
  81. #if ((defined(SPIS2_ENABLED)) && (SPIS2_ENABLED > 0) && (SPIS_COUNT < 2))
  82. #error "SPI2/SPIS2 instance not present in selected MCU."
  83. #endif
  84. #if ((defined(TIMER3_ENABLED) || defined(TIMER4_ENABLED)) &&\
  85. ((TIMER3_ENABLED + TIMER4_ENABLED ) > 0) &&\
  86. (TIMER_COUNT < 5))
  87. #error "TIMER3 and TIMER4 not present in selected MCU."
  88. #endif
  89. // Validate peripheral sharing feature
  90. #if !NRFX_CHECK(NRFX_PRS_ENABLED)
  91. #if ((defined(TWIM0_ENABLED) && defined(TWIS0_ENABLED)) &&\
  92. ((TWIM0_ENABLED + TWIS0_ENABLED) > 1))
  93. #error "Peripherals overlap. TWIM0, TWIS0 - only one of these can be enabled."
  94. #endif
  95. #if ((defined(TWIM0_ENABLED) && defined(SPIM0_ENABLED)) &&\
  96. ((TWIM0_ENABLED + SPIM0_ENABLED) > 1))
  97. #error "Peripherals overlap. TWIM0, SPIM0 - only one of these can be enabled."
  98. #endif
  99. #if ((defined(TWIM0_ENABLED) && defined(SPIS0_ENABLED)) &&\
  100. ((TWIM0_ENABLED + SPIS0_ENABLED) > 1))
  101. #error "Peripherals overlap. TWIM0, SPIS0 - only one of these can be enabled."
  102. #endif
  103. #if ((defined(TWIM0_ENABLED) && defined(SPI0_ENABLED)) &&\
  104. ((TWIM0_ENABLED + SPI0_ENABLED) > 1))
  105. #error "Peripherals overlap. TWIM0, SPI0 - only one of these can be enabled."
  106. #endif
  107. #if ((defined(TWIM0_ENABLED) && defined(TWI0_ENABLED)) &&\
  108. ((TWIM0_ENABLED + TWI0_ENABLED) > 1))
  109. #error "Peripherals overlap. TWIM0, TWI0 - only one of these can be enabled."
  110. #endif
  111. #if ((defined(TWIS0_ENABLED) && defined(SPIM0_ENABLED)) &&\
  112. ((TWIS0_ENABLED + SPIM0_ENABLED) > 1))
  113. #error "Peripherals overlap. TWIS0, SPIM0 - only one of these can be enabled."
  114. #endif
  115. #if ((defined(TWIS0_ENABLED) && defined(SPIS0_ENABLED)) &&\
  116. ((TWIS0_ENABLED + SPIS0_ENABLED) > 1))
  117. #error "Peripherals overlap. TWIS0, SPIS0 - only one of these can be enabled."
  118. #endif
  119. #if ((defined(TWIS0_ENABLED) && defined(SPI0_ENABLED)) &&\
  120. ((TWIS0_ENABLED + SPI0_ENABLED) > 1))
  121. #error "Peripherals overlap. TWIS0, SPI0 - only one of these can be enabled."
  122. #endif
  123. #if ((defined(TWIS0_ENABLED) && defined(TWI0_ENABLED)) &&\
  124. ((TWIS0_ENABLED + TWI0_ENABLED) > 1))
  125. #error "Peripherals overlap. TWIS0, TWI0 - only one of these can be enabled."
  126. #endif
  127. #if ((defined(SPIM0_ENABLED) && defined(SPIS0_ENABLED)) &&\
  128. ((SPIM0_ENABLED + SPIS0_ENABLED) > 1))
  129. #error "Peripherals overlap. SPIM0, SPIS0 - only one of these can be enabled."
  130. #endif
  131. #if ((defined(SPIM0_ENABLED) && defined(SPI0_ENABLED)) &&\
  132. ((SPIM0_ENABLED + SPI0_ENABLED) > 1))
  133. #error "Peripherals overlap. SPIM0, SPI0 - only one of these can be enabled."
  134. #endif
  135. #if ((defined(SPIM0_ENABLED) && defined(TWI0_ENABLED)) &&\
  136. ((SPIM0_ENABLED + TWI0_ENABLED) > 1))
  137. #error "Peripherals overlap. SPIM0, TWI0 - only one of these can be enabled."
  138. #endif
  139. #if ((defined(SPIS0_ENABLED) && defined(SPI0_ENABLED)) &&\
  140. ((SPIS0_ENABLED + SPI0_ENABLED) > 1))
  141. #error "Peripherals overlap. SPIS0, SPI0 - only one of these can be enabled."
  142. #endif
  143. #if ((defined(SPIS0_ENABLED) && defined(TWI0_ENABLED)) &&\
  144. ((SPIS0_ENABLED + TWI0_ENABLED) > 1))
  145. #error "Peripherals overlap. SPIS0, TWI0 - only one of these can be enabled."
  146. #endif
  147. #if ((defined(SPI0_ENABLED) && defined(TWI0_ENABLED)) &&\
  148. ((SPI0_ENABLED + TWI0_ENABLED) > 1))
  149. #error "Peripherals overlap. SPI0, TWI0 - only one of these can be enabled."
  150. #endif
  151. #if ((defined(TWIM1_ENABLED) && defined(TWIS1_ENABLED)) &&\
  152. ((TWIM1_ENABLED + TWIS1_ENABLED) > 1))
  153. #error "Peripherals overlap. TWIM1, TWIS1 - only one of these can be enabled."
  154. #endif
  155. #if ((defined(TWIM1_ENABLED) && defined(SPIM1_ENABLED)) &&\
  156. ((TWIM1_ENABLED + SPIM1_ENABLED) > 1))
  157. #error "Peripherals overlap. TWIM1, SPIM1 - only one of these can be enabled."
  158. #endif
  159. #if ((defined(TWIM1_ENABLED) && defined(SPIS1_ENABLED)) &&\
  160. ((TWIM1_ENABLED + SPIS1_ENABLED) > 1))
  161. #error "Peripherals overlap. TWIM1, SPIS1 - only one of these can be enabled."
  162. #endif
  163. #if ((defined(TWIM1_ENABLED) && defined(SPI1_ENABLED)) &&\
  164. ((TWIM1_ENABLED + SPI1_ENABLED) > 1))
  165. #error "Peripherals overlap. TWIM1, SPI1 - only one of these can be enabled."
  166. #endif
  167. #if ((defined(TWIM1_ENABLED) && defined(TWI1_ENABLED)) &&\
  168. ((TWIM1_ENABLED + TWI1_ENABLED) > 1))
  169. #error "Peripherals overlap. TWIM1, TWI1 - only one of these can be enabled."
  170. #endif
  171. #if ((defined(TWIS1_ENABLED) && defined(SPIM1_ENABLED)) &&\
  172. ((TWIS1_ENABLED + SPIM1_ENABLED) > 1))
  173. #error "Peripherals overlap. TWIS1, SPIM1 - only one of these can be enabled."
  174. #endif
  175. #if ((defined(TWIS1_ENABLED) && defined(SPIS1_ENABLED)) &&\
  176. ((TWIS1_ENABLED + SPIS1_ENABLED) > 1))
  177. #error "Peripherals overlap. TWIS1, SPIS1 - only one of these can be enabled."
  178. #endif
  179. #if ((defined(TWIS1_ENABLED) && defined(SPI1_ENABLED)) &&\
  180. ((TWIS1_ENABLED + SPI1_ENABLED) > 1))
  181. #error "Peripherals overlap. TWIS1, SPI1 - only one of these can be enabled."
  182. #endif
  183. #if ((defined(TWIS1_ENABLED) && defined(TWI1_ENABLED)) &&\
  184. ((TWIS1_ENABLED + TWI1_ENABLED) > 1))
  185. #error "Peripherals overlap. TWIS1, TWI1 - only one of these can be enabled."
  186. #endif
  187. #if ((defined(SPIM1_ENABLED) && defined(SPIS1_ENABLED)) &&\
  188. ((SPIM1_ENABLED + SPIS1_ENABLED) > 1))
  189. #error "Peripherals overlap. SPIM1, SPIS1 - only one of these can be enabled."
  190. #endif
  191. #if ((defined(SPIM1_ENABLED) && defined(SPI1_ENABLED)) &&\
  192. ((SPIM1_ENABLED + SPI1_ENABLED) > 1))
  193. #error "Peripherals overlap. SPIM1, SPI1 - only one of these can be enabled."
  194. #endif
  195. #if ((defined(SPIM1_ENABLED) && defined(TWI1_ENABLED)) &&\
  196. ((SPIM1_ENABLED + TWI1_ENABLED) > 1))
  197. #error "Peripherals overlap. SPIM1, TWI1 - only one of these can be enabled."
  198. #endif
  199. #if ((defined(SPIS1_ENABLED) && defined(SPI1_ENABLED)) &&\
  200. ((SPIS1_ENABLED + SPI1_ENABLED) > 1))
  201. #error "Peripherals overlap. SPIS1, SPI1 - only one of these can be enabled."
  202. #endif
  203. #if ((defined(SPIS1_ENABLED) && defined(TWI1_ENABLED)) &&\
  204. ((SPIS1_ENABLED + TWI1_ENABLED) > 1))
  205. #error "Peripherals overlap. SPIS1, TWI1 - only one of these can be enabled."
  206. #endif
  207. #if ((defined(SPI1_ENABLED) && defined(TWI1_ENABLED)) &&\
  208. ((SPI1_ENABLED + TWI1_ENABLED) > 1))
  209. #error "Peripherals overlap. SPI1, TWI1 - only one of these can be enabled."
  210. #endif
  211. #if ((defined(SPI2_ENABLED) && defined(SPIS2_ENABLED)) &&\
  212. ((SPI2_ENABLED + SPIS2_ENABLED) > 1))
  213. #error "Peripherals overlap. SPI2, SPIS2 - only one of these can be enabled."
  214. #endif
  215. #if ((defined(SPIM2_ENABLED) && defined(SPIS2_ENABLED)) &&\
  216. ((SPI2_ENABLED + SPIS2_ENABLED) > 1))
  217. #error "Peripherals overlap. SPIM2, SPIS2 - only one of these can be enabled."
  218. #endif
  219. #if ((defined(SPIM2_ENABLED) && defined(SPI2_ENABLED)) &&\
  220. ((SPI2_ENABLED + SPIS2_ENABLED) > 1))
  221. #error "Peripherals overlap. SPIM2, SPI2 - only one of these can be enabled."
  222. #endif
  223. #endif // !NRFX_CHECK(NRFX_PRS_ENABLED)
  224. #ifdef NFCT_PRESENT
  225. #if ((defined(NFC_HAL_ENABLED) && defined(NRF_CLOCK_ENABLED)) &&\
  226. ((NFC_HAL_ENABLED) && (!NRF_CLOCK_ENABLED)))
  227. #error "NFC_HAL requires CLOCK to work. NFC_HAL can not be enabled without CLOCK."
  228. #endif
  229. #if ((defined(NFC_HAL_ENABLED) && defined(TIMER4_ENABLED)) &&\
  230. ((NFC_HAL_ENABLED + TIMER4_ENABLED) > 1))
  231. #error "TIMER4 is used by NFC_HAL. NFC_HAL, TIMER4 - only one of these can be enabled."
  232. #endif
  233. #endif
  234. // Complex driver validation
  235. #ifdef LPCOMP_PRESENT
  236. #if ((defined(COMP_ENABLED) && defined(LPCOMP_ENABLED)) && \
  237. (!NRFX_CHECK(NRFX_PRS_ENABLED)) && \
  238. ((COMP_ENABLED + LPCOMP_ENABLED) > 1))
  239. #error "Peripherals overlap. COMP, LPCOMP - only one of these can be enabled."
  240. #endif
  241. #endif
  242. #ifdef __cplusplus
  243. }
  244. #endif
  245. #endif // SDK_VALIDATION_H