nrf_egu.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. /**
  2. * Copyright (c) 2015 - 2019, 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_EGU_H__
  41. #define NRF_EGU_H__
  42. #include <nrfx.h>
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. /**
  47. * @defgroup nrf_egu_hal EGU HAL
  48. * @{
  49. * @ingroup nrf_swi_egu
  50. * @brief Hardware access layer for managing the Event Generator Unit (EGU) peripheral.
  51. */
  52. /**
  53. * @enum nrf_egu_task_t
  54. * @brief EGU tasks.
  55. */
  56. typedef enum
  57. {
  58. /*lint -save -e30 -esym(628,__INTADDR__)*/
  59. NRF_EGU_TASK_TRIGGER0 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[0]), /**< Trigger 0 for triggering the corresponding TRIGGERED[0] event. */
  60. NRF_EGU_TASK_TRIGGER1 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[1]), /**< Trigger 1 for triggering the corresponding TRIGGERED[1] event. */
  61. NRF_EGU_TASK_TRIGGER2 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[2]), /**< Trigger 2 for triggering the corresponding TRIGGERED[2] event. */
  62. NRF_EGU_TASK_TRIGGER3 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[3]), /**< Trigger 3 for triggering the corresponding TRIGGERED[3] event. */
  63. NRF_EGU_TASK_TRIGGER4 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[4]), /**< Trigger 4 for triggering the corresponding TRIGGERED[4] event. */
  64. NRF_EGU_TASK_TRIGGER5 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[5]), /**< Trigger 5 for triggering the corresponding TRIGGERED[5] event. */
  65. NRF_EGU_TASK_TRIGGER6 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[6]), /**< Trigger 6 for triggering the corresponding TRIGGERED[6] event. */
  66. NRF_EGU_TASK_TRIGGER7 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[7]), /**< Trigger 7 for triggering the corresponding TRIGGERED[7] event. */
  67. NRF_EGU_TASK_TRIGGER8 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[8]), /**< Trigger 8 for triggering the corresponding TRIGGERED[8] event. */
  68. NRF_EGU_TASK_TRIGGER9 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[9]), /**< Trigger 9 for triggering the corresponding TRIGGERED[9] event. */
  69. NRF_EGU_TASK_TRIGGER10 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[10]), /**< Trigger 10 for triggering the corresponding TRIGGERED[10] event. */
  70. NRF_EGU_TASK_TRIGGER11 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[11]), /**< Trigger 11 for triggering the corresponding TRIGGERED[11] event. */
  71. NRF_EGU_TASK_TRIGGER12 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[12]), /**< Trigger 12 for triggering the corresponding TRIGGERED[12] event. */
  72. NRF_EGU_TASK_TRIGGER13 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[13]), /**< Trigger 13 for triggering the corresponding TRIGGERED[13] event. */
  73. NRF_EGU_TASK_TRIGGER14 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[14]), /**< Trigger 14 for triggering the corresponding TRIGGERED[14] event. */
  74. NRF_EGU_TASK_TRIGGER15 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[15]) /**< Trigger 15 for triggering the corresponding TRIGGERED[15] event. */
  75. /*lint -restore*/
  76. } nrf_egu_task_t;
  77. /**
  78. * @enum nrf_egu_event_t
  79. * @brief EGU events.
  80. */
  81. typedef enum
  82. {
  83. /*lint -save -e30 -esym(628,__INTADDR__)*/
  84. NRF_EGU_EVENT_TRIGGERED0 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[0]), /**< Event number 0 generated by triggering the corresponding TRIGGER[0] task. */
  85. NRF_EGU_EVENT_TRIGGERED1 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[1]), /**< Event number 1 generated by triggering the corresponding TRIGGER[1] task. */
  86. NRF_EGU_EVENT_TRIGGERED2 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[2]), /**< Event number 2 generated by triggering the corresponding TRIGGER[2] task. */
  87. NRF_EGU_EVENT_TRIGGERED3 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[3]), /**< Event number 3 generated by triggering the corresponding TRIGGER[3] task. */
  88. NRF_EGU_EVENT_TRIGGERED4 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[4]), /**< Event number 4 generated by triggering the corresponding TRIGGER[4] task. */
  89. NRF_EGU_EVENT_TRIGGERED5 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[5]), /**< Event number 5 generated by triggering the corresponding TRIGGER[5] task. */
  90. NRF_EGU_EVENT_TRIGGERED6 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[6]), /**< Event number 6 generated by triggering the corresponding TRIGGER[6] task. */
  91. NRF_EGU_EVENT_TRIGGERED7 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[7]), /**< Event number 7 generated by triggering the corresponding TRIGGER[7] task. */
  92. NRF_EGU_EVENT_TRIGGERED8 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[8]), /**< Event number 8 generated by triggering the corresponding TRIGGER[8] task. */
  93. NRF_EGU_EVENT_TRIGGERED9 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[9]), /**< Event number 9 generated by triggering the corresponding TRIGGER[9] task. */
  94. NRF_EGU_EVENT_TRIGGERED10 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[10]), /**< Event number 10 generated by triggering the corresponding TRIGGER[10] task. */
  95. NRF_EGU_EVENT_TRIGGERED11 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[11]), /**< Event number 11 generated by triggering the corresponding TRIGGER[11] task. */
  96. NRF_EGU_EVENT_TRIGGERED12 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[12]), /**< Event number 12 generated by triggering the corresponding TRIGGER[12] task. */
  97. NRF_EGU_EVENT_TRIGGERED13 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[13]), /**< Event number 13 generated by triggering the corresponding TRIGGER[13] task. */
  98. NRF_EGU_EVENT_TRIGGERED14 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[14]), /**< Event number 14 generated by triggering the corresponding TRIGGER[14] task. */
  99. NRF_EGU_EVENT_TRIGGERED15 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[15]) /**< Event number 15 generated by triggering the corresponding TRIGGER[15] task. */
  100. /*lint -restore*/
  101. } nrf_egu_event_t;
  102. /**
  103. * @enum nrf_egu_int_mask_t
  104. * @brief EGU interrupts.
  105. */
  106. typedef enum
  107. {
  108. NRF_EGU_INT_TRIGGERED0 = EGU_INTENSET_TRIGGERED0_Msk, /**< Interrupt on EVENTS_TRIGGERED[0] event. */
  109. NRF_EGU_INT_TRIGGERED1 = EGU_INTENSET_TRIGGERED1_Msk, /**< Interrupt on EVENTS_TRIGGERED[1] event. */
  110. NRF_EGU_INT_TRIGGERED2 = EGU_INTENSET_TRIGGERED2_Msk, /**< Interrupt on EVENTS_TRIGGERED[2] event. */
  111. NRF_EGU_INT_TRIGGERED3 = EGU_INTENSET_TRIGGERED3_Msk, /**< Interrupt on EVENTS_TRIGGERED[3] event. */
  112. NRF_EGU_INT_TRIGGERED4 = EGU_INTENSET_TRIGGERED4_Msk, /**< Interrupt on EVENTS_TRIGGERED[4] event. */
  113. NRF_EGU_INT_TRIGGERED5 = EGU_INTENSET_TRIGGERED5_Msk, /**< Interrupt on EVENTS_TRIGGERED[5] event. */
  114. NRF_EGU_INT_TRIGGERED6 = EGU_INTENSET_TRIGGERED6_Msk, /**< Interrupt on EVENTS_TRIGGERED[6] event. */
  115. NRF_EGU_INT_TRIGGERED7 = EGU_INTENSET_TRIGGERED7_Msk, /**< Interrupt on EVENTS_TRIGGERED[7] event. */
  116. NRF_EGU_INT_TRIGGERED8 = EGU_INTENSET_TRIGGERED8_Msk, /**< Interrupt on EVENTS_TRIGGERED[8] event. */
  117. NRF_EGU_INT_TRIGGERED9 = EGU_INTENSET_TRIGGERED9_Msk, /**< Interrupt on EVENTS_TRIGGERED[9] event. */
  118. NRF_EGU_INT_TRIGGERED10 = EGU_INTENSET_TRIGGERED10_Msk, /**< Interrupt on EVENTS_TRIGGERED[10] event. */
  119. NRF_EGU_INT_TRIGGERED11 = EGU_INTENSET_TRIGGERED11_Msk, /**< Interrupt on EVENTS_TRIGGERED[11] event. */
  120. NRF_EGU_INT_TRIGGERED12 = EGU_INTENSET_TRIGGERED12_Msk, /**< Interrupt on EVENTS_TRIGGERED[12] event. */
  121. NRF_EGU_INT_TRIGGERED13 = EGU_INTENSET_TRIGGERED13_Msk, /**< Interrupt on EVENTS_TRIGGERED[13] event. */
  122. NRF_EGU_INT_TRIGGERED14 = EGU_INTENSET_TRIGGERED14_Msk, /**< Interrupt on EVENTS_TRIGGERED[14] event. */
  123. NRF_EGU_INT_TRIGGERED15 = EGU_INTENSET_TRIGGERED15_Msk, /**< Interrupt on EVENTS_TRIGGERED[15] event. */
  124. NRF_EGU_INT_ALL = 0xFFFFuL
  125. } nrf_egu_int_mask_t;
  126. /**@brief Function for getting max channel number of given EGU.
  127. *
  128. * @param NRF_EGUx EGU instance.
  129. *
  130. * @returns number of available channels.
  131. */
  132. __STATIC_INLINE uint32_t nrf_egu_channel_count(NRF_EGU_Type * NRF_EGUx);
  133. /**
  134. * @brief Function for triggering a specific EGU task.
  135. *
  136. * @param NRF_EGUx EGU instance.
  137. * @param egu_task EGU task.
  138. */
  139. __STATIC_INLINE void nrf_egu_task_trigger(NRF_EGU_Type * NRF_EGUx, nrf_egu_task_t egu_task);
  140. /**
  141. * @brief Function for returning the address of a specific EGU task register.
  142. *
  143. * @param NRF_EGUx EGU instance.
  144. * @param egu_task EGU task.
  145. */
  146. __STATIC_INLINE uint32_t * nrf_egu_task_address_get(NRF_EGU_Type * NRF_EGUx,
  147. nrf_egu_task_t egu_task);
  148. /**
  149. * @brief Function for returning the address of a specific EGU TRIGGER task register.
  150. *
  151. * @param NRF_EGUx EGU instance.
  152. * @param channel Channel number.
  153. */
  154. __STATIC_INLINE uint32_t * nrf_egu_task_trigger_address_get(NRF_EGU_Type * NRF_EGUx,
  155. uint8_t channel);
  156. /**
  157. * @brief Function for returning the specific EGU TRIGGER task.
  158. *
  159. * @param NRF_EGUx EGU instance.
  160. * @param channel Channel number.
  161. */
  162. __STATIC_INLINE nrf_egu_task_t nrf_egu_task_trigger_get(NRF_EGU_Type * NRF_EGUx, uint8_t channel);
  163. /**
  164. * @brief Function for returning the state of a specific EGU event.
  165. *
  166. * @param NRF_EGUx EGU instance.
  167. * @param egu_event EGU event to check.
  168. */
  169. __STATIC_INLINE bool nrf_egu_event_check(NRF_EGU_Type * NRF_EGUx,
  170. nrf_egu_event_t egu_event);
  171. /**
  172. * @brief Function for clearing a specific EGU event.
  173. *
  174. * @param NRF_EGUx EGU instance.
  175. * @param egu_event EGU event to clear.
  176. */
  177. __STATIC_INLINE void nrf_egu_event_clear(NRF_EGU_Type * NRF_EGUx,
  178. nrf_egu_event_t egu_event);
  179. /**
  180. * @brief Function for returning the address of a specific EGU event register.
  181. *
  182. * @param NRF_EGUx EGU instance.
  183. * @param egu_event EGU event.
  184. */
  185. __STATIC_INLINE uint32_t * nrf_egu_event_address_get(NRF_EGU_Type * NRF_EGUx,
  186. nrf_egu_event_t egu_event);
  187. /**
  188. * @brief Function for returning the address of a specific EGU TRIGGERED event register.
  189. *
  190. * @param NRF_EGUx EGU instance.
  191. * @param channel Channel number.
  192. */
  193. __STATIC_INLINE uint32_t * nrf_egu_event_triggered_address_get(NRF_EGU_Type * NRF_EGUx,
  194. uint8_t channel);
  195. /**
  196. * @brief Function for returning the specific EGU TRIGGERED event.
  197. *
  198. * @param NRF_EGUx EGU instance.
  199. * @param channel Channel number.
  200. */
  201. __STATIC_INLINE nrf_egu_event_t nrf_egu_event_triggered_get(NRF_EGU_Type * NRF_EGUx,
  202. uint8_t channel);
  203. /**
  204. * @brief Function for enabling one or more specific EGU interrupts.
  205. *
  206. * @param NRF_EGUx EGU instance.
  207. * @param egu_int_mask Interrupts to enable.
  208. */
  209. __STATIC_INLINE void nrf_egu_int_enable(NRF_EGU_Type * NRF_EGUx, uint32_t egu_int_mask);
  210. /**
  211. * @brief Function for retrieving the state of one or more EGU interrupts.
  212. *
  213. * @param NRF_EGUx EGU instance.
  214. * @param egu_int_mask Interrupts to check.
  215. *
  216. * @retval true If all of the specified interrupts are enabled.
  217. * @retval false If at least one of the specified interrupts is disabled.
  218. */
  219. __STATIC_INLINE bool nrf_egu_int_enable_check(NRF_EGU_Type * NRF_EGUx, uint32_t egu_int_mask);
  220. /**
  221. * @brief Function for disabling one or more specific EGU interrupts.
  222. *
  223. * @param NRF_EGUx EGU instance.
  224. * @param egu_int_mask Interrupts to disable.
  225. */
  226. __STATIC_INLINE void nrf_egu_int_disable(NRF_EGU_Type * NRF_EGUx, uint32_t egu_int_mask);
  227. /**
  228. * @brief Function for retrieving one or more specific EGU interrupts.
  229. *
  230. * @param NRF_EGUx EGU instance.
  231. * @param channel Channel number.
  232. *
  233. * @returns EGU interrupt mask.
  234. */
  235. __STATIC_INLINE nrf_egu_int_mask_t nrf_egu_int_get(NRF_EGU_Type * NRF_EGUx, uint8_t channel);
  236. #if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
  237. /**
  238. * @brief Function for setting the subscribe configuration for a given
  239. * EGU task.
  240. *
  241. * @param[in] p_reg Pointer to the structure of registers of the peripheral.
  242. * @param[in] task Task for which to set the configuration.
  243. * @param[in] channel Channel through which to subscribe events.
  244. */
  245. __STATIC_INLINE void nrf_egu_subscribe_set(NRF_EGU_Type * p_reg,
  246. nrf_egu_task_t task,
  247. uint8_t channel);
  248. /**
  249. * @brief Function for clearing the subscribe configuration for a given
  250. * EGU task.
  251. *
  252. * @param[in] p_reg Pointer to the structure of registers of the peripheral.
  253. * @param[in] task Task for which to clear the configuration.
  254. */
  255. __STATIC_INLINE void nrf_egu_subscribe_clear(NRF_EGU_Type * p_reg,
  256. nrf_egu_task_t task);
  257. /**
  258. * @brief Function for setting the publish configuration for a given
  259. * EGU event.
  260. *
  261. * @param[in] p_reg Pointer to the structure of registers of the peripheral.
  262. * @param[in] event Event for which to set the configuration.
  263. * @param[in] channel Channel through which to publish the event.
  264. */
  265. __STATIC_INLINE void nrf_egu_publish_set(NRF_EGU_Type * p_reg,
  266. nrf_egu_event_t event,
  267. uint8_t channel);
  268. /**
  269. * @brief Function for clearing the publish configuration for a given
  270. * EGU event.
  271. *
  272. * @param[in] p_reg Pointer to the structure of registers of the peripheral.
  273. * @param[in] event Event for which to clear the configuration.
  274. */
  275. __STATIC_INLINE void nrf_egu_publish_clear(NRF_EGU_Type * p_reg,
  276. nrf_egu_event_t event);
  277. #endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
  278. #ifndef SUPPRESS_INLINE_IMPLEMENTATION
  279. __STATIC_INLINE uint32_t nrf_egu_channel_count(NRF_EGU_Type * NRF_EGUx)
  280. {
  281. if (NRF_EGUx == NRF_EGU0){
  282. return EGU0_CH_NUM;
  283. }
  284. if (NRF_EGUx == NRF_EGU1){
  285. return EGU1_CH_NUM;
  286. }
  287. #if EGU_COUNT > 2
  288. if (NRF_EGUx == NRF_EGU2){
  289. return EGU2_CH_NUM;
  290. }
  291. if (NRF_EGUx == NRF_EGU3){
  292. return EGU3_CH_NUM;
  293. }
  294. if (NRF_EGUx == NRF_EGU4){
  295. return EGU4_CH_NUM;
  296. }
  297. if (NRF_EGUx == NRF_EGU5){
  298. return EGU5_CH_NUM;
  299. }
  300. #endif
  301. return 0;
  302. }
  303. __STATIC_INLINE void nrf_egu_task_trigger(NRF_EGU_Type * NRF_EGUx, nrf_egu_task_t egu_task)
  304. {
  305. NRFX_ASSERT(NRF_EGUx);
  306. *((volatile uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_task)) = 0x1UL;
  307. }
  308. __STATIC_INLINE uint32_t * nrf_egu_task_address_get(NRF_EGU_Type * NRF_EGUx,
  309. nrf_egu_task_t egu_task)
  310. {
  311. NRFX_ASSERT(NRF_EGUx);
  312. return (uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_task);
  313. }
  314. __STATIC_INLINE uint32_t * nrf_egu_task_trigger_address_get(NRF_EGU_Type * NRF_EGUx,
  315. uint8_t channel)
  316. {
  317. NRFX_ASSERT(NRF_EGUx);
  318. NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
  319. return (uint32_t*)&NRF_EGUx->TASKS_TRIGGER[channel];
  320. }
  321. __STATIC_INLINE nrf_egu_task_t nrf_egu_task_trigger_get(NRF_EGU_Type * NRF_EGUx, uint8_t channel)
  322. {
  323. NRFX_ASSERT(NRF_EGUx);
  324. NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
  325. return (nrf_egu_task_t)((uint32_t) NRF_EGU_TASK_TRIGGER0 + (channel * sizeof(uint32_t)));
  326. }
  327. __STATIC_INLINE bool nrf_egu_event_check(NRF_EGU_Type * NRF_EGUx,
  328. nrf_egu_event_t egu_event)
  329. {
  330. NRFX_ASSERT(NRF_EGUx);
  331. return (bool)*(volatile uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_event);
  332. }
  333. __STATIC_INLINE void nrf_egu_event_clear(NRF_EGU_Type * NRF_EGUx,
  334. nrf_egu_event_t egu_event)
  335. {
  336. NRFX_ASSERT(NRF_EGUx);
  337. *((volatile uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_event)) = 0x0UL;
  338. #if __CORTEX_M == 0x04
  339. volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_event));
  340. (void)dummy;
  341. #endif
  342. }
  343. __STATIC_INLINE uint32_t * nrf_egu_event_address_get(NRF_EGU_Type * NRF_EGUx,
  344. nrf_egu_event_t egu_event)
  345. {
  346. NRFX_ASSERT(NRF_EGUx);
  347. return (uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_event);
  348. }
  349. __STATIC_INLINE uint32_t * nrf_egu_event_triggered_address_get(NRF_EGU_Type * NRF_EGUx,
  350. uint8_t channel)
  351. {
  352. NRFX_ASSERT(NRF_EGUx);
  353. NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
  354. return (uint32_t*)&NRF_EGUx->EVENTS_TRIGGERED[channel];
  355. }
  356. __STATIC_INLINE nrf_egu_event_t nrf_egu_event_triggered_get(NRF_EGU_Type * NRF_EGUx,
  357. uint8_t channel)
  358. {
  359. NRFX_ASSERT(NRF_EGUx);
  360. NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
  361. return (nrf_egu_event_t)((uint32_t) NRF_EGU_EVENT_TRIGGERED0 + (channel * sizeof(uint32_t)));
  362. }
  363. __STATIC_INLINE void nrf_egu_int_enable(NRF_EGU_Type * NRF_EGUx, uint32_t egu_int_mask)
  364. {
  365. NRFX_ASSERT(NRF_EGUx);
  366. NRF_EGUx->INTENSET = egu_int_mask;
  367. }
  368. __STATIC_INLINE bool nrf_egu_int_enable_check(NRF_EGU_Type * NRF_EGUx, uint32_t egu_int_mask)
  369. {
  370. NRFX_ASSERT(NRF_EGUx);
  371. return (bool)(NRF_EGUx->INTENSET & egu_int_mask);
  372. }
  373. __STATIC_INLINE void nrf_egu_int_disable(NRF_EGU_Type * NRF_EGUx, uint32_t egu_int_mask)
  374. {
  375. NRFX_ASSERT(NRF_EGUx);
  376. NRF_EGUx->INTENCLR = egu_int_mask;
  377. }
  378. __STATIC_INLINE nrf_egu_int_mask_t nrf_egu_int_get(NRF_EGU_Type * NRF_EGUx, uint8_t channel)
  379. {
  380. NRFX_ASSERT(NRF_EGUx);
  381. NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
  382. return (nrf_egu_int_mask_t)((uint32_t) (EGU_INTENSET_TRIGGERED0_Msk << channel));
  383. }
  384. #if defined(DPPI_PRESENT)
  385. __STATIC_INLINE void nrf_egu_subscribe_set(NRF_EGU_Type * p_reg,
  386. nrf_egu_task_t task,
  387. uint8_t channel)
  388. {
  389. *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
  390. ((uint32_t)channel | EGU_SUBSCRIBE_TRIGGER_EN_Msk);
  391. }
  392. __STATIC_INLINE void nrf_egu_subscribe_clear(NRF_EGU_Type * p_reg,
  393. nrf_egu_task_t task)
  394. {
  395. *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
  396. }
  397. __STATIC_INLINE void nrf_egu_publish_set(NRF_EGU_Type * p_reg,
  398. nrf_egu_event_t event,
  399. uint8_t channel)
  400. {
  401. *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
  402. ((uint32_t)channel | EGU_PUBLISH_TRIGGERED_EN_Msk);
  403. }
  404. __STATIC_INLINE void nrf_egu_publish_clear(NRF_EGU_Type * p_reg,
  405. nrf_egu_event_t event)
  406. {
  407. *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
  408. }
  409. #endif // defined(DPPI_PRESENT)
  410. #endif // SUPPRESS_INLINE_IMPLEMENTATION
  411. /** @} */
  412. #ifdef __cplusplus
  413. }
  414. #endif
  415. #endif