nrf_lpcomp.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. /**
  2. * Copyright (c) 2014 - 2018, 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 NRF_LPCOMP_H_
  41. #define NRF_LPCOMP_H_
  42. #include <nrfx.h>
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. /**
  47. * @defgroup nrf_lpcomp_hal LPCOMP HAL
  48. * @{
  49. * @ingroup nrf_lpcomp
  50. * @brief Hardware access layer for managing the Low Power Comparator (LPCOMP) peripheral.
  51. */
  52. /**
  53. * @enum nrf_lpcomp_ref_t
  54. * @brief LPCOMP reference selection.
  55. */
  56. typedef enum
  57. {
  58. #if (LPCOMP_REFSEL_RESOLUTION == 8) || defined(__NRFX_DOXYGEN__)
  59. NRF_LPCOMP_REF_SUPPLY_1_8 = LPCOMP_REFSEL_REFSEL_SupplyOneEighthPrescaling, /**< Use supply with a 1/8 prescaler as reference. */
  60. NRF_LPCOMP_REF_SUPPLY_2_8 = LPCOMP_REFSEL_REFSEL_SupplyTwoEighthsPrescaling, /**< Use supply with a 2/8 prescaler as reference. */
  61. NRF_LPCOMP_REF_SUPPLY_3_8 = LPCOMP_REFSEL_REFSEL_SupplyThreeEighthsPrescaling, /**< Use supply with a 3/8 prescaler as reference. */
  62. NRF_LPCOMP_REF_SUPPLY_4_8 = LPCOMP_REFSEL_REFSEL_SupplyFourEighthsPrescaling, /**< Use supply with a 4/8 prescaler as reference. */
  63. NRF_LPCOMP_REF_SUPPLY_5_8 = LPCOMP_REFSEL_REFSEL_SupplyFiveEighthsPrescaling, /**< Use supply with a 5/8 prescaler as reference. */
  64. NRF_LPCOMP_REF_SUPPLY_6_8 = LPCOMP_REFSEL_REFSEL_SupplySixEighthsPrescaling, /**< Use supply with a 6/8 prescaler as reference. */
  65. NRF_LPCOMP_REF_SUPPLY_7_8 = LPCOMP_REFSEL_REFSEL_SupplySevenEighthsPrescaling, /**< Use supply with a 7/8 prescaler as reference. */
  66. #elif (LPCOMP_REFSEL_RESOLUTION == 16) || defined(__NRFX_DOXYGEN__)
  67. NRF_LPCOMP_REF_SUPPLY_1_8 = LPCOMP_REFSEL_REFSEL_Ref1_8Vdd, /**< Use supply with a 1/8 prescaler as reference. */
  68. NRF_LPCOMP_REF_SUPPLY_2_8 = LPCOMP_REFSEL_REFSEL_Ref2_8Vdd, /**< Use supply with a 2/8 prescaler as reference. */
  69. NRF_LPCOMP_REF_SUPPLY_3_8 = LPCOMP_REFSEL_REFSEL_Ref3_8Vdd, /**< Use supply with a 3/8 prescaler as reference. */
  70. NRF_LPCOMP_REF_SUPPLY_4_8 = LPCOMP_REFSEL_REFSEL_Ref4_8Vdd, /**< Use supply with a 4/8 prescaler as reference. */
  71. NRF_LPCOMP_REF_SUPPLY_5_8 = LPCOMP_REFSEL_REFSEL_Ref5_8Vdd, /**< Use supply with a 5/8 prescaler as reference. */
  72. NRF_LPCOMP_REF_SUPPLY_6_8 = LPCOMP_REFSEL_REFSEL_Ref6_8Vdd, /**< Use supply with a 6/8 prescaler as reference. */
  73. NRF_LPCOMP_REF_SUPPLY_7_8 = LPCOMP_REFSEL_REFSEL_Ref7_8Vdd, /**< Use supply with a 7/8 prescaler as reference. */
  74. NRF_LPCOMP_REF_SUPPLY_1_16 = LPCOMP_REFSEL_REFSEL_Ref1_16Vdd, /**< Use supply with a 1/16 prescaler as reference. */
  75. NRF_LPCOMP_REF_SUPPLY_3_16 = LPCOMP_REFSEL_REFSEL_Ref3_16Vdd, /**< Use supply with a 3/16 prescaler as reference. */
  76. NRF_LPCOMP_REF_SUPPLY_5_16 = LPCOMP_REFSEL_REFSEL_Ref5_16Vdd, /**< Use supply with a 5/16 prescaler as reference. */
  77. NRF_LPCOMP_REF_SUPPLY_7_16 = LPCOMP_REFSEL_REFSEL_Ref7_16Vdd, /**< Use supply with a 7/16 prescaler as reference. */
  78. NRF_LPCOMP_REF_SUPPLY_9_16 = LPCOMP_REFSEL_REFSEL_Ref9_16Vdd, /**< Use supply with a 9/16 prescaler as reference. */
  79. NRF_LPCOMP_REF_SUPPLY_11_16 = LPCOMP_REFSEL_REFSEL_Ref11_16Vdd, /**< Use supply with a 11/16 prescaler as reference. */
  80. NRF_LPCOMP_REF_SUPPLY_13_16 = LPCOMP_REFSEL_REFSEL_Ref13_16Vdd, /**< Use supply with a 13/16 prescaler as reference. */
  81. NRF_LPCOMP_REF_SUPPLY_15_16 = LPCOMP_REFSEL_REFSEL_Ref15_16Vdd, /**< Use supply with a 15/16 prescaler as reference. */
  82. #endif
  83. NRF_LPCOMP_REF_EXT_REF0 = LPCOMP_REFSEL_REFSEL_ARef |
  84. (LPCOMP_EXTREFSEL_EXTREFSEL_AnalogReference0 << 16), /**< External reference 0. */
  85. NRF_LPCOMP_CONFIG_REF_EXT_REF1 = LPCOMP_REFSEL_REFSEL_ARef |
  86. (LPCOMP_EXTREFSEL_EXTREFSEL_AnalogReference1 << 16), /**< External reference 1. */
  87. } nrf_lpcomp_ref_t;
  88. /**
  89. * @enum nrf_lpcomp_input_t
  90. * @brief LPCOMP input selection.
  91. */
  92. typedef enum
  93. {
  94. NRF_LPCOMP_INPUT_0 = LPCOMP_PSEL_PSEL_AnalogInput0, /**< Input 0. */
  95. NRF_LPCOMP_INPUT_1 = LPCOMP_PSEL_PSEL_AnalogInput1, /**< Input 1. */
  96. NRF_LPCOMP_INPUT_2 = LPCOMP_PSEL_PSEL_AnalogInput2, /**< Input 2. */
  97. NRF_LPCOMP_INPUT_3 = LPCOMP_PSEL_PSEL_AnalogInput3, /**< Input 3. */
  98. NRF_LPCOMP_INPUT_4 = LPCOMP_PSEL_PSEL_AnalogInput4, /**< Input 4. */
  99. NRF_LPCOMP_INPUT_5 = LPCOMP_PSEL_PSEL_AnalogInput5, /**< Input 5. */
  100. NRF_LPCOMP_INPUT_6 = LPCOMP_PSEL_PSEL_AnalogInput6, /**< Input 6. */
  101. NRF_LPCOMP_INPUT_7 = LPCOMP_PSEL_PSEL_AnalogInput7 /**< Input 7. */
  102. } nrf_lpcomp_input_t;
  103. /**
  104. * @enum nrf_lpcomp_detect_t
  105. * @brief LPCOMP detection type selection.
  106. */
  107. typedef enum
  108. {
  109. NRF_LPCOMP_DETECT_CROSS = LPCOMP_ANADETECT_ANADETECT_Cross, /**< Generate ANADETEC on crossing, both upwards and downwards crossing. */
  110. NRF_LPCOMP_DETECT_UP = LPCOMP_ANADETECT_ANADETECT_Up, /**< Generate ANADETEC on upwards crossing only. */
  111. NRF_LPCOMP_DETECT_DOWN = LPCOMP_ANADETECT_ANADETECT_Down /**< Generate ANADETEC on downwards crossing only. */
  112. } nrf_lpcomp_detect_t;
  113. /**
  114. * @enum nrf_lpcomp_task_t
  115. * @brief LPCOMP tasks.
  116. */
  117. typedef enum /*lint -save -e30 -esym(628,__INTADDR__) */
  118. {
  119. NRF_LPCOMP_TASK_START = offsetof(NRF_LPCOMP_Type, TASKS_START), /**< LPCOMP start sampling task. */
  120. NRF_LPCOMP_TASK_STOP = offsetof(NRF_LPCOMP_Type, TASKS_STOP), /**< LPCOMP stop sampling task. */
  121. NRF_LPCOMP_TASK_SAMPLE = offsetof(NRF_LPCOMP_Type, TASKS_SAMPLE) /**< Sample comparator value. */
  122. } nrf_lpcomp_task_t; /*lint -restore*/
  123. /**
  124. * @enum nrf_lpcomp_event_t
  125. * @brief LPCOMP events.
  126. */
  127. typedef enum /*lint -save -e30 -esym(628,__INTADDR__) */
  128. {
  129. NRF_LPCOMP_EVENT_READY = offsetof(NRF_LPCOMP_Type, EVENTS_READY), /**< LPCOMP is ready and output is valid. */
  130. NRF_LPCOMP_EVENT_DOWN = offsetof(NRF_LPCOMP_Type, EVENTS_DOWN), /**< Input voltage crossed the threshold going down. */
  131. NRF_LPCOMP_EVENT_UP = offsetof(NRF_LPCOMP_Type, EVENTS_UP), /**< Input voltage crossed the threshold going up. */
  132. NRF_LPCOMP_EVENT_CROSS = offsetof(NRF_LPCOMP_Type, EVENTS_CROSS) /**< Input voltage crossed the threshold in any direction. */
  133. } nrf_lpcomp_event_t; /*lint -restore*/
  134. /**
  135. * @enum nrf_lpcomp_short_mask_t
  136. * @brief LPCOMP shorts masks.
  137. */
  138. typedef enum
  139. {
  140. NRF_LPCOMP_SHORT_CROSS_STOP_MASK = LPCOMP_SHORTS_CROSS_STOP_Msk, /*!< Short between CROSS event and STOP task. */
  141. NRF_LPCOMP_SHORT_UP_STOP_MASK = LPCOMP_SHORTS_UP_STOP_Msk, /*!< Short between UP event and STOP task. */
  142. NRF_LPCOMP_SHORT_DOWN_STOP_MASK = LPCOMP_SHORTS_DOWN_STOP_Msk, /*!< Short between DOWN event and STOP task. */
  143. NRF_LPCOMP_SHORT_READY_STOP_MASK = LPCOMP_SHORTS_READY_STOP_Msk, /*!< Short between READY event and STOP task. */
  144. NRF_LPCOMP_SHORT_READY_SAMPLE_MASK = LPCOMP_SHORTS_READY_SAMPLE_Msk /*!< Short between READY event and SAMPLE task. */
  145. } nrf_lpcomp_short_mask_t;
  146. #ifdef LPCOMP_FEATURE_HYST_PRESENT
  147. /**
  148. * @enum nrf_lpcomp_hysteresis_t
  149. * @brief LPCOMP hysteresis.
  150. */
  151. typedef enum
  152. {
  153. NRF_LPCOMP_HYST_NOHYST = LPCOMP_HYST_HYST_NoHyst, /**< Comparator hysteresis disabled. */
  154. NRF_LPCOMP_HYST_50mV = LPCOMP_HYST_HYST_Hyst50mV /**< Comparator hysteresis enabled (typ. 50 mV). */
  155. }nrf_lpcomp_hysteresis_t;
  156. #endif // LPCOMP_FEATURE_HYST_PRESENT
  157. /** @brief LPCOMP configuration. */
  158. typedef struct
  159. {
  160. nrf_lpcomp_ref_t reference; /**< LPCOMP reference. */
  161. nrf_lpcomp_detect_t detection; /**< LPCOMP detection type. */
  162. #ifdef LPCOMP_FEATURE_HYST_PRESENT
  163. nrf_lpcomp_hysteresis_t hyst; /**< LPCOMP hysteresis. */
  164. #endif // LPCOMP_FEATURE_HYST_PRESENT
  165. } nrf_lpcomp_config_t;
  166. /** Default LPCOMP configuration. */
  167. #define NRF_LPCOMP_CONFIG_DEFAULT { NRF_LPCOMP_REF_SUPPLY_FOUR_EIGHT, NRF_LPCOMP_DETECT_DOWN }
  168. /**
  169. * @brief Function for configuring LPCOMP.
  170. *
  171. * This function powers on LPCOMP and configures it. LPCOMP is in DISABLE state after configuration,
  172. * so it must be enabled before using it. All shorts are inactive, events are cleared, and LPCOMP is stopped.
  173. *
  174. * @param[in] p_config Configuration.
  175. */
  176. __STATIC_INLINE void nrf_lpcomp_configure(const nrf_lpcomp_config_t * p_config)
  177. {
  178. NRF_LPCOMP->TASKS_STOP = 1;
  179. NRF_LPCOMP->ENABLE = LPCOMP_ENABLE_ENABLE_Disabled << LPCOMP_ENABLE_ENABLE_Pos;
  180. NRF_LPCOMP->REFSEL =
  181. (p_config->reference << LPCOMP_REFSEL_REFSEL_Pos) & LPCOMP_REFSEL_REFSEL_Msk;
  182. //If external source is choosen extract analog reference index.
  183. if ((p_config->reference & LPCOMP_REFSEL_REFSEL_ARef)==LPCOMP_REFSEL_REFSEL_ARef)
  184. {
  185. uint32_t extref = p_config->reference >> 16;
  186. NRF_LPCOMP->EXTREFSEL = (extref << LPCOMP_EXTREFSEL_EXTREFSEL_Pos) & LPCOMP_EXTREFSEL_EXTREFSEL_Msk;
  187. }
  188. NRF_LPCOMP->ANADETECT =
  189. (p_config->detection << LPCOMP_ANADETECT_ANADETECT_Pos) & LPCOMP_ANADETECT_ANADETECT_Msk;
  190. #ifdef LPCOMP_FEATURE_HYST_PRESENT
  191. NRF_LPCOMP->HYST = ((p_config->hyst) << LPCOMP_HYST_HYST_Pos) & LPCOMP_HYST_HYST_Msk;
  192. #endif //LPCOMP_FEATURE_HYST_PRESENT
  193. NRF_LPCOMP->SHORTS = 0;
  194. NRF_LPCOMP->INTENCLR = LPCOMP_INTENCLR_CROSS_Msk | LPCOMP_INTENCLR_UP_Msk |
  195. LPCOMP_INTENCLR_DOWN_Msk | LPCOMP_INTENCLR_READY_Msk;
  196. }
  197. /**
  198. * @brief Function for selecting the LPCOMP input.
  199. *
  200. * This function selects the active input of LPCOMP.
  201. *
  202. * @param[in] input Input to be selected.
  203. */
  204. __STATIC_INLINE void nrf_lpcomp_input_select(nrf_lpcomp_input_t input)
  205. {
  206. uint32_t lpcomp_enable_state = NRF_LPCOMP->ENABLE;
  207. NRF_LPCOMP->ENABLE = LPCOMP_ENABLE_ENABLE_Disabled << LPCOMP_ENABLE_ENABLE_Pos;
  208. NRF_LPCOMP->PSEL =
  209. ((uint32_t)input << LPCOMP_PSEL_PSEL_Pos) | (NRF_LPCOMP->PSEL & ~LPCOMP_PSEL_PSEL_Msk);
  210. NRF_LPCOMP->ENABLE = lpcomp_enable_state;
  211. }
  212. /**
  213. * @brief Function for enabling the Low Power Comparator.
  214. *
  215. * This function enables LPCOMP.
  216. *
  217. */
  218. __STATIC_INLINE void nrf_lpcomp_enable(void)
  219. {
  220. NRF_LPCOMP->ENABLE = LPCOMP_ENABLE_ENABLE_Enabled << LPCOMP_ENABLE_ENABLE_Pos;
  221. NRF_LPCOMP->EVENTS_READY = 0;
  222. NRF_LPCOMP->EVENTS_DOWN = 0;
  223. NRF_LPCOMP->EVENTS_UP = 0;
  224. NRF_LPCOMP->EVENTS_CROSS = 0;
  225. }
  226. /**
  227. * @brief Function for disabling the Low Power Comparator.
  228. *
  229. * This function disables LPCOMP.
  230. *
  231. */
  232. __STATIC_INLINE void nrf_lpcomp_disable(void)
  233. {
  234. NRF_LPCOMP->ENABLE = LPCOMP_ENABLE_ENABLE_Disabled << LPCOMP_ENABLE_ENABLE_Pos;
  235. }
  236. /**
  237. * @brief Function for getting the last LPCOMP compare result.
  238. *
  239. * @return The last compare result. If 0 then VIN+ < VIN-, if 1 then the opposite.
  240. */
  241. __STATIC_INLINE uint32_t nrf_lpcomp_result_get(void)
  242. {
  243. return (uint32_t)NRF_LPCOMP->RESULT;
  244. }
  245. /**
  246. * @brief Function for enabling interrupts from LPCOMP.
  247. *
  248. * @param[in] lpcomp_int_mask Mask of interrupts to be enabled.
  249. *
  250. * @sa nrf_lpcomp_int_disable()
  251. * @sa nrf_lpcomp_int_enable_check()
  252. */
  253. __STATIC_INLINE void nrf_lpcomp_int_enable(uint32_t lpcomp_int_mask)
  254. {
  255. NRF_LPCOMP->INTENSET = lpcomp_int_mask;
  256. }
  257. /**
  258. * @brief Function for disabling interrupts from LPCOMP.
  259. *
  260. * @param[in] lpcomp_int_mask Mask of interrupts to be disabled.
  261. *
  262. * @sa nrf_lpcomp_int_enable()
  263. * @sa nrf_lpcomp_int_enable_check()
  264. */
  265. __STATIC_INLINE void nrf_lpcomp_int_disable(uint32_t lpcomp_int_mask)
  266. {
  267. NRF_LPCOMP->INTENCLR = lpcomp_int_mask;
  268. }
  269. /**
  270. * @brief Function for getting the enabled interrupts of LPCOMP.
  271. *
  272. * @param[in] lpcomp_int_mask Mask of interrupts to be checked.
  273. *
  274. * @retval true If any of interrupts of the specified mask are enabled.
  275. *
  276. * @sa nrf_lpcomp_int_enable()
  277. * @sa nrf_lpcomp_int_disable()
  278. */
  279. __STATIC_INLINE bool nrf_lpcomp_int_enable_check(uint32_t lpcomp_int_mask)
  280. {
  281. return (NRF_LPCOMP->INTENSET & lpcomp_int_mask); // when read this register will return the value of INTEN.
  282. }
  283. /**
  284. * @brief Function for getting the address of a specific LPCOMP task register.
  285. *
  286. * @param[in] lpcomp_task LPCOMP task.
  287. *
  288. * @return The address of the specified LPCOMP task.
  289. */
  290. __STATIC_INLINE uint32_t * nrf_lpcomp_task_address_get(nrf_lpcomp_task_t lpcomp_task)
  291. {
  292. return (uint32_t *)((uint8_t *)NRF_LPCOMP + lpcomp_task);
  293. }
  294. /**
  295. * @brief Function for getting the address of a specific LPCOMP event register.
  296. *
  297. * @param[in] lpcomp_event LPCOMP event.
  298. *
  299. * @return The address of the specified LPCOMP event.
  300. */
  301. __STATIC_INLINE uint32_t * nrf_lpcomp_event_address_get(nrf_lpcomp_event_t lpcomp_event)
  302. {
  303. return (uint32_t *)((uint8_t *)NRF_LPCOMP + lpcomp_event);
  304. }
  305. /**
  306. * @brief Function for setting LPCOMP shorts.
  307. *
  308. * @param[in] lpcomp_short_mask LPCOMP shorts by mask.
  309. *
  310. */
  311. __STATIC_INLINE void nrf_lpcomp_shorts_enable(uint32_t lpcomp_short_mask)
  312. {
  313. NRF_LPCOMP->SHORTS |= lpcomp_short_mask;
  314. }
  315. /**
  316. * @brief Function for clearing LPCOMP shorts by mask.
  317. *
  318. * @param[in] lpcomp_short_mask LPCOMP shorts to be cleared.
  319. *
  320. */
  321. __STATIC_INLINE void nrf_lpcomp_shorts_disable(uint32_t lpcomp_short_mask)
  322. {
  323. NRF_LPCOMP->SHORTS &= ~lpcomp_short_mask;
  324. }
  325. /**
  326. * @brief Function for setting a specific LPCOMP task.
  327. *
  328. * @param[in] lpcomp_task LPCOMP task to be set.
  329. *
  330. */
  331. __STATIC_INLINE void nrf_lpcomp_task_trigger(nrf_lpcomp_task_t lpcomp_task)
  332. {
  333. *( (volatile uint32_t *)( (uint8_t *)NRF_LPCOMP + lpcomp_task) ) = 1;
  334. }
  335. /**
  336. * @brief Function for clearing a specific LPCOMP event.
  337. *
  338. * @param[in] lpcomp_event LPCOMP event to be cleared.
  339. *
  340. */
  341. __STATIC_INLINE void nrf_lpcomp_event_clear(nrf_lpcomp_event_t lpcomp_event)
  342. {
  343. *( (volatile uint32_t *)( (uint8_t *)NRF_LPCOMP + lpcomp_event) ) = 0;
  344. #if __CORTEX_M == 0x04
  345. volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_LPCOMP + lpcomp_event));
  346. (void)dummy;
  347. #endif
  348. }
  349. /**
  350. * @brief Function for getting the state of a specific LPCOMP event.
  351. *
  352. * @retval true If the specified LPCOMP event is active.
  353. *
  354. */
  355. __STATIC_INLINE bool nrf_lpcomp_event_check(nrf_lpcomp_event_t lpcomp_event)
  356. {
  357. return (bool) (*(volatile uint32_t *)( (uint8_t *)NRF_LPCOMP + lpcomp_event));
  358. }
  359. /** @} */
  360. #ifdef __cplusplus
  361. }
  362. #endif
  363. #endif /* NRF_LPCOMP_H_ */