nrfx_gppi.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. /**
  2. * Copyright (c) 2019 - 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 NRFX_GPPI_H
  41. #define NRFX_GPPI_H
  42. #include <nrfx.h>
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. /**
  47. * @defgroup nrfx_gppi Generic PPI layer
  48. * @{
  49. * @ingroup nrfx
  50. * @ingroup nrf_dppi
  51. * @ingroup nrf_ppi
  52. *
  53. * @brief Helper layer that provides the common functionality of PPI and DPPI drivers.
  54. *
  55. * Use PPI and DPPI drivers directly.
  56. * This layer is provided only to help create generic code that can be built
  57. * for SoCs equipped with either of these peripherals. When using this layer,
  58. * take into account that there are significant differences between the PPI and DPPI
  59. * interfaces that affect the behavior of this layer.
  60. *
  61. * One difference is that PPI allows associating of one task or event with
  62. * more than one channel, whereas DPPI does not allow this. In DPPI, the second
  63. * association overwrites the first one. Consequently, this helper layer cannot
  64. * be used in applications that need to connect a task or event to multiple
  65. * channels.
  66. *
  67. * Another difference is that in DPPI one channel can be associated with
  68. * multiple tasks and multiple events, while in PPI this is not possible (with
  69. * the exception of the association of a second task as a fork). Because of
  70. * this difference, it is important to clear the previous endpoints of the channel that
  71. * is to be reused with some different ones. Otherwise, the behavior of this
  72. * helper layer will be different, depending on the actual interface used:
  73. * in DPPI the channel configuration will be extended with the new endpoints, and
  74. * in PPI the new endpoints will replace the previous ones.
  75. */
  76. #if defined(PPI_PRESENT)
  77. #include <hal/nrf_ppi.h>
  78. typedef enum
  79. {
  80. NRFX_GPPI_CHANNEL_GROUP0 = NRF_PPI_CHANNEL_GROUP0,
  81. NRFX_GPPI_CHANNEL_GROUP1 = NRF_PPI_CHANNEL_GROUP1,
  82. NRFX_GPPI_CHANNEL_GROUP2 = NRF_PPI_CHANNEL_GROUP2,
  83. NRFX_GPPI_CHANNEL_GROUP3 = NRF_PPI_CHANNEL_GROUP3,
  84. #if (PPI_GROUP_NUM > 4)
  85. NRFX_GPPI_CHANNEL_GROUP4 = NRF_PPI_CHANNEL_GROUP4,
  86. NRFX_GPPI_CHANNEL_GROUP5 = NRF_PPI_CHANNEL_GROUP5,
  87. #endif
  88. } nrfx_gppi_channel_group_t;
  89. typedef enum
  90. {
  91. NRFX_GPPI_TASK_CHG0_EN = NRF_PPI_TASK_CHG0_EN,
  92. NRFX_GPPI_TASK_CHG0_DIS = NRF_PPI_TASK_CHG0_DIS,
  93. NRFX_GPPI_TASK_CHG1_EN = NRF_PPI_TASK_CHG1_EN,
  94. NRFX_GPPI_TASK_CHG1_DIS = NRF_PPI_TASK_CHG1_DIS,
  95. NRFX_GPPI_TASK_CHG2_EN = NRF_PPI_TASK_CHG2_EN,
  96. NRFX_GPPI_TASK_CHG2_DIS = NRF_PPI_TASK_CHG2_DIS,
  97. NRFX_GPPI_TASK_CHG3_EN = NRF_PPI_TASK_CHG3_EN,
  98. NRFX_GPPI_TASK_CHG3_DIS = NRF_PPI_TASK_CHG3_DIS,
  99. #if (PPI_GROUP_NUM > 4)
  100. NRFX_GPPI_TASK_CHG4_EN = NRF_PPI_TASK_CHG4_EN,
  101. NRFX_GPPI_TASK_CHG4_DIS = NRF_PPI_TASK_CHG4_DIS,
  102. NRFX_GPPI_TASK_CHG5_EN = NRF_PPI_TASK_CHG5_EN,
  103. NRFX_GPPI_TASK_CHG5_DIS = NRF_PPI_TASK_CHG5_DIS
  104. #endif
  105. } nrfx_gppi_task_t;
  106. #elif defined(DPPI_PRESENT)
  107. #include <hal/nrf_dppi.h>
  108. typedef enum
  109. {
  110. NRFX_GPPI_CHANNEL_GROUP0 = NRF_DPPI_CHANNEL_GROUP0,
  111. NRFX_GPPI_CHANNEL_GROUP1 = NRF_DPPI_CHANNEL_GROUP1,
  112. NRFX_GPPI_CHANNEL_GROUP2 = NRF_DPPI_CHANNEL_GROUP2,
  113. NRFX_GPPI_CHANNEL_GROUP3 = NRF_DPPI_CHANNEL_GROUP3,
  114. NRFX_GPPI_CHANNEL_GROUP4 = NRF_DPPI_CHANNEL_GROUP4,
  115. NRFX_GPPI_CHANNEL_GROUP5 = NRF_DPPI_CHANNEL_GROUP5,
  116. } nrfx_gppi_channel_group_t;
  117. typedef enum
  118. {
  119. NRFX_GPPI_TASK_CHG0_EN = NRF_DPPI_TASK_CHG0_EN,
  120. NRFX_GPPI_TASK_CHG0_DIS = NRF_DPPI_TASK_CHG0_DIS,
  121. NRFX_GPPI_TASK_CHG1_EN = NRF_DPPI_TASK_CHG1_EN,
  122. NRFX_GPPI_TASK_CHG1_DIS = NRF_DPPI_TASK_CHG1_DIS,
  123. NRFX_GPPI_TASK_CHG2_EN = NRF_DPPI_TASK_CHG2_EN,
  124. NRFX_GPPI_TASK_CHG2_DIS = NRF_DPPI_TASK_CHG2_DIS,
  125. NRFX_GPPI_TASK_CHG3_EN = NRF_DPPI_TASK_CHG3_EN,
  126. NRFX_GPPI_TASK_CHG3_DIS = NRF_DPPI_TASK_CHG3_DIS,
  127. NRFX_GPPI_TASK_CHG4_EN = NRF_DPPI_TASK_CHG4_EN,
  128. NRFX_GPPI_TASK_CHG4_DIS = NRF_DPPI_TASK_CHG4_DIS,
  129. NRFX_GPPI_TASK_CHG5_EN = NRF_DPPI_TASK_CHG5_EN,
  130. NRFX_GPPI_TASK_CHG5_DIS = NRF_DPPI_TASK_CHG5_DIS
  131. } nrfx_gppi_task_t;
  132. #elif defined(__NRFX_DOXYGEN__)
  133. /** @brief Generic PPI channel groups. */
  134. typedef enum
  135. {
  136. NRFX_GPPI_CHANNEL_GROUP0, /**< Channel group 0.*/
  137. NRFX_GPPI_CHANNEL_GROUP1, /**< Channel group 1.*/
  138. NRFX_GPPI_CHANNEL_GROUP2, /**< Channel group 2.*/
  139. NRFX_GPPI_CHANNEL_GROUP3, /**< Channel group 3.*/
  140. NRFX_GPPI_CHANNEL_GROUP4, /**< Channel group 4.*/
  141. NRFX_GPPI_CHANNEL_GROUP5, /**< Channel group 5.*/
  142. } nrfx_gppi_channel_group_t;
  143. /** @brief Generic PPI tasks. */
  144. typedef enum
  145. {
  146. NRFX_GPPI_TASK_CHG0_EN, /**< Task for enabling channel group 0 */
  147. NRFX_GPPI_TASK_CHG0_DIS, /**< Task for disabling channel group 0 */
  148. NRFX_GPPI_TASK_CHG1_EN, /**< Task for enabling channel group 1 */
  149. NRFX_GPPI_TASK_CHG1_DIS, /**< Task for disabling channel group 1 */
  150. NRFX_GPPI_TASK_CHG2_EN, /**< Task for enabling channel group 2 */
  151. NRFX_GPPI_TASK_CHG2_DIS, /**< Task for disabling channel group 2 */
  152. NRFX_GPPI_TASK_CHG3_EN, /**< Task for enabling channel group 3 */
  153. NRFX_GPPI_TASK_CHG3_DIS, /**< Task for disabling channel group 3 */
  154. NRFX_GPPI_TASK_CHG4_EN, /**< Task for enabling channel group 4 */
  155. NRFX_GPPI_TASK_CHG4_DIS, /**< Task for disabling channel group 4 */
  156. NRFX_GPPI_TASK_CHG5_EN, /**< Task for enabling channel group 5 */
  157. NRFX_GPPI_TASK_CHG5_DIS, /**< Task for disabling channel group 5 */
  158. } nrfx_gppi_task_t;
  159. #endif // defined(__NRFX_DOXYGEN__)
  160. /**
  161. * @brief Function for checking if a given channel is enabled.
  162. *
  163. * @param[in] channel Channel to check.
  164. *
  165. * @retval true The channel is enabled.
  166. * @retval false The channel is not enabled.
  167. */
  168. __STATIC_INLINE bool nrfx_gppi_channel_check(uint8_t channel);
  169. /** @brief Function for disabling all channels. */
  170. __STATIC_INLINE void nrfx_gppi_channels_disable_all(void);
  171. /**
  172. * @brief Function for enabling multiple channels.
  173. *
  174. * The bits in @c mask value correspond to particular channels. This means that
  175. * writing 1 to bit 0 enables channel 0, writing 1 to bit 1 enables channel 1, etc.
  176. *
  177. * @param[in] mask Channel mask.
  178. */
  179. __STATIC_INLINE void nrfx_gppi_channels_enable(uint32_t mask);
  180. /**
  181. * @brief Function for disabling multiple channels.
  182. *
  183. * The bits in @c mask value correspond to particular channels. This means that
  184. * writing 1 to bit 0 disables channel 0, writing 1 to bit 1 disables channel 1, etc.
  185. *
  186. * @param[in] mask Channel mask.
  187. */
  188. __STATIC_INLINE void nrfx_gppi_channels_disable(uint32_t mask);
  189. /**
  190. * @brief Function for associating a given channel with the specified event register.
  191. *
  192. * This function sets the DPPI publish configuration for a given event
  193. * or sets the PPI event endpoint register.
  194. *
  195. * @param[in] channel Channel to which to assign the event.
  196. * @param[in] eep Address of the event register.
  197. */
  198. __STATIC_INLINE void nrfx_gppi_event_endpoint_setup(uint8_t channel, uint32_t eep);
  199. /**
  200. * @brief Function for associating a given channel with the specified task register.
  201. *
  202. * This function sets the DPPI subscribe configuration for a given task
  203. * or sets the PPI task endpoint register.
  204. *
  205. * @param[in] channel Channel to which to assign the task.
  206. * @param[in] tep Address of the task register.
  207. */
  208. __STATIC_INLINE void nrfx_gppi_task_endpoint_setup(uint8_t channel, uint32_t tep);
  209. /**
  210. * @brief Function for setting up the event and task endpoints for a given channel.
  211. *
  212. * @param[in] channel Channel to which the given endpoints are assigned.
  213. * @param[in] eep Address of the event register.
  214. * @param[in] tep Address of the task register.
  215. */
  216. __STATIC_INLINE void nrfx_gppi_channel_endpoints_setup(uint8_t channel,
  217. uint32_t eep,
  218. uint32_t tep);
  219. /**
  220. * @brief Function for clearing the DPPI publish configuration for a given event
  221. * register or for clearing the PPI event endpoint register.
  222. *
  223. * @param[in] channel Channel for which to clear the event endpoint. Not used in DPPI.
  224. * @param[in] eep Address of the event register. Not used in PPI.
  225. */
  226. __STATIC_INLINE void nrfx_gppi_event_endpoint_clear(uint8_t channel, uint32_t eep);
  227. /**
  228. * @brief Function for clearing the DPPI subscribe configuration for a given task
  229. * register or for clearing the PPI task endpoint register.
  230. *
  231. * @param[in] channel Channel from which to disconnect the task enpoint. Not used in DPPI.
  232. * @param[in] tep Address of the task register. Not used in PPI.
  233. */
  234. __STATIC_INLINE void nrfx_gppi_task_endpoint_clear(uint8_t channel, uint32_t tep);
  235. #if defined(PPI_FEATURE_FORKS_PRESENT) || defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
  236. /**
  237. * @brief Function for setting up the task endpoint for a given PPI fork or for
  238. * associating the DPPI channel with an additional task register.
  239. *
  240. * @param[in] channel Channel to which the given fork endpoint is assigned.
  241. * @param[in] fork_tep Address of the task register.
  242. */
  243. __STATIC_INLINE void nrfx_gppi_fork_endpoint_setup(uint8_t channel, uint32_t fork_tep);
  244. /**
  245. * @brief Function for clearing the task endpoint for a given PPI fork or for clearing
  246. * the DPPI subscribe register.
  247. *
  248. * @param[in] channel Channel for which to clear the fork endpoint. Not used in DPPI.
  249. * @param[in] fork_tep Address of the task register. Not used in PPI.
  250. */
  251. __STATIC_INLINE void nrfx_gppi_fork_endpoint_clear(uint8_t channel, uint32_t fork_tep);
  252. #endif // defined(PPI_FEATURE_FORKS_PRESENT) || defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
  253. /**
  254. * @brief Function for including multiple channels in a channel group.
  255. *
  256. * @param[in] channel_mask Channels to be included in the group.
  257. * @param[in] channel_group Channel group.
  258. */
  259. __STATIC_INLINE void nrfx_gppi_channels_include_in_group(uint32_t channel_mask,
  260. nrfx_gppi_channel_group_t channel_group);
  261. /**
  262. * @brief Function for removing multiple channels from a channel group.
  263. *
  264. * @param[in] channel_mask Channels to be removed from the group.
  265. * @param[in] channel_group Channel group.
  266. */
  267. __STATIC_INLINE void nrfx_gppi_channels_remove_from_group(uint32_t channel_mask,
  268. nrfx_gppi_channel_group_t channel_group);
  269. /**
  270. * @brief Function for removing all channels from a channel group.
  271. *
  272. * @param[in] channel_group Channel group.
  273. */
  274. __STATIC_INLINE void nrfx_gppi_group_clear(nrfx_gppi_channel_group_t channel_group);
  275. /**
  276. * @brief Function for enabling a channel group.
  277. *
  278. * @param[in] channel_group Channel group.
  279. */
  280. __STATIC_INLINE void nrfx_gppi_group_enable(nrfx_gppi_channel_group_t channel_group);
  281. /**
  282. * @brief Function for disabling a group.
  283. *
  284. * @param[in] channel_group Channel group.
  285. */
  286. __STATIC_INLINE void nrfx_gppi_group_disable(nrfx_gppi_channel_group_t channel_group);
  287. /**
  288. * @brief Function for activating a task.
  289. *
  290. * @param[in] task Task to be activated.
  291. */
  292. __STATIC_INLINE void nrfx_gppi_task_trigger(nrfx_gppi_task_t task);
  293. /**
  294. * @brief Function for returning the address of a specific task register.
  295. *
  296. * @param[in] task PPI or DPPI task.
  297. *
  298. * @return Address of the requested task register.
  299. */
  300. __STATIC_INLINE uint32_t nrfx_gppi_task_address_get(nrfx_gppi_task_t task);
  301. /**
  302. * @brief Function for returning the address of a channel group disable task.
  303. *
  304. * @param[in] group Channel group.
  305. *
  306. * @return Disable task address of the specified group.
  307. */
  308. __STATIC_INLINE nrfx_gppi_task_t nrfx_gppi_group_disable_task_get(nrfx_gppi_channel_group_t group);
  309. /**
  310. * @brief Function for returning the address of a channel group enable task.
  311. *
  312. * @param[in] group Channel group.
  313. *
  314. * @return Enable task address of the specified group.
  315. */
  316. __STATIC_INLINE nrfx_gppi_task_t nrfx_gppi_group_enable_task_get(nrfx_gppi_channel_group_t group);
  317. /** @} */
  318. #if defined(PPI_PRESENT)
  319. __STATIC_INLINE bool nrfx_gppi_channel_check(uint8_t channel)
  320. {
  321. return (nrf_ppi_channel_enable_get((nrf_ppi_channel_t)channel) == NRF_PPI_CHANNEL_ENABLED);
  322. }
  323. __STATIC_INLINE void nrfx_gppi_channels_disable_all(void)
  324. {
  325. nrf_ppi_channel_disable_all();
  326. }
  327. __STATIC_INLINE void nrfx_gppi_channels_enable(uint32_t mask)
  328. {
  329. nrf_ppi_channels_enable(mask);
  330. }
  331. __STATIC_INLINE void nrfx_gppi_channels_disable(uint32_t mask)
  332. {
  333. nrf_ppi_channels_disable(mask);
  334. }
  335. __STATIC_INLINE void nrfx_gppi_event_endpoint_setup(uint8_t channel, uint32_t eep)
  336. {
  337. nrf_ppi_event_endpoint_setup((nrf_ppi_channel_t)channel, eep);
  338. }
  339. __STATIC_INLINE void nrfx_gppi_task_endpoint_setup(uint8_t channel, uint32_t tep)
  340. {
  341. nrf_ppi_task_endpoint_setup((nrf_ppi_channel_t)channel, tep);
  342. }
  343. __STATIC_INLINE void nrfx_gppi_channel_endpoints_setup(uint8_t channel,
  344. uint32_t eep,
  345. uint32_t tep)
  346. {
  347. nrf_ppi_channel_endpoint_setup((nrf_ppi_channel_t)channel, eep, tep);
  348. }
  349. __STATIC_INLINE void nrfx_gppi_event_endpoint_clear(uint8_t channel, uint32_t eep)
  350. {
  351. (void)eep;
  352. nrf_ppi_event_endpoint_setup((nrf_ppi_channel_t)channel, 0);
  353. }
  354. __STATIC_INLINE void nrfx_gppi_task_endpoint_clear(uint8_t channel, uint32_t tep)
  355. {
  356. (void)tep;
  357. nrf_ppi_task_endpoint_setup((nrf_ppi_channel_t)channel, 0);
  358. }
  359. #if defined(PPI_FEATURE_FORKS_PRESENT)
  360. __STATIC_INLINE void nrfx_gppi_fork_endpoint_setup(uint8_t channel, uint32_t fork_tep)
  361. {
  362. nrf_ppi_fork_endpoint_setup((nrf_ppi_channel_t)channel, fork_tep);
  363. }
  364. __STATIC_INLINE void nrfx_gppi_fork_endpoint_clear(uint8_t channel, uint32_t fork_tep)
  365. {
  366. (void)fork_tep;
  367. nrf_ppi_fork_endpoint_setup((nrf_ppi_channel_t)channel, 0);
  368. }
  369. #endif
  370. __STATIC_INLINE void nrfx_gppi_channels_include_in_group(uint32_t channel_mask,
  371. nrfx_gppi_channel_group_t channel_group)
  372. {
  373. nrf_ppi_channels_include_in_group(channel_mask, channel_group);
  374. }
  375. __STATIC_INLINE void nrfx_gppi_channels_remove_from_group(uint32_t channel_mask,
  376. nrfx_gppi_channel_group_t channel_group)
  377. {
  378. nrf_ppi_channels_remove_from_group(channel_mask, channel_group);
  379. }
  380. __STATIC_INLINE void nrfx_gppi_group_clear(nrfx_gppi_channel_group_t channel_group)
  381. {
  382. nrf_ppi_channel_group_clear(channel_group);
  383. }
  384. __STATIC_INLINE void nrfx_gppi_group_enable(nrfx_gppi_channel_group_t channel_group)
  385. {
  386. nrf_ppi_group_enable(channel_group);
  387. }
  388. __STATIC_INLINE void nrfx_gppi_group_disable(nrfx_gppi_channel_group_t channel_group)
  389. {
  390. nrf_ppi_group_disable(channel_group);
  391. }
  392. __STATIC_INLINE void nrfx_gppi_task_trigger(nrfx_gppi_task_t task)
  393. {
  394. nrf_ppi_task_trigger(task);
  395. }
  396. __STATIC_INLINE uint32_t nrfx_gppi_task_address_get(nrfx_gppi_task_t task)
  397. {
  398. return (uint32_t)nrf_ppi_task_address_get(task);
  399. }
  400. __STATIC_INLINE nrfx_gppi_task_t nrfx_gppi_group_disable_task_get(nrfx_gppi_channel_group_t group)
  401. {
  402. return (nrfx_gppi_task_t)nrf_ppi_group_disable_task_get((uint8_t)group);
  403. }
  404. __STATIC_INLINE nrfx_gppi_task_t nrfx_gppi_group_enable_task_get(nrfx_gppi_channel_group_t group)
  405. {
  406. return (nrfx_gppi_task_t)nrf_ppi_group_enable_task_get((uint8_t)group);
  407. }
  408. #elif defined(DPPI_PRESENT)
  409. __STATIC_INLINE bool nrfx_gppi_channel_check(uint8_t channel)
  410. {
  411. return nrf_dppi_channel_check(NRF_DPPIC, channel);
  412. }
  413. __STATIC_INLINE void nrfx_gppi_channels_disable_all(void)
  414. {
  415. nrf_dppi_channels_disable_all(NRF_DPPIC);
  416. }
  417. __STATIC_INLINE void nrfx_gppi_channels_enable(uint32_t mask)
  418. {
  419. nrf_dppi_channels_enable(NRF_DPPIC, mask);
  420. }
  421. __STATIC_INLINE void nrfx_gppi_channels_disable(uint32_t mask)
  422. {
  423. nrf_dppi_channels_disable(NRF_DPPIC, mask);
  424. }
  425. __STATIC_INLINE void nrfx_gppi_task_trigger(nrfx_gppi_task_t task)
  426. {
  427. nrf_dppi_task_trigger(NRF_DPPIC, task);
  428. }
  429. __STATIC_INLINE void nrfx_gppi_event_endpoint_setup(uint8_t channel, uint32_t eep)
  430. {
  431. NRFX_ASSERT(eep);
  432. *((volatile uint32_t *)(eep + 0x80uL)) = ((uint32_t)channel | DPPIC_SUBSCRIBE_CHG_EN_EN_Msk);
  433. }
  434. __STATIC_INLINE void nrfx_gppi_task_endpoint_setup(uint8_t channel, uint32_t tep)
  435. {
  436. NRFX_ASSERT(tep);
  437. *((volatile uint32_t *)(tep + 0x80uL)) = ((uint32_t)channel | DPPIC_SUBSCRIBE_CHG_EN_EN_Msk);
  438. }
  439. __STATIC_INLINE void nrfx_gppi_channel_endpoints_setup(uint8_t channel,
  440. uint32_t eep,
  441. uint32_t tep)
  442. {
  443. nrfx_gppi_event_endpoint_setup(channel, eep);
  444. nrfx_gppi_task_endpoint_setup(channel, tep);
  445. }
  446. __STATIC_INLINE void nrfx_gppi_event_endpoint_clear(uint8_t channel, uint32_t eep)
  447. {
  448. NRFX_ASSERT(eep);
  449. (void)channel;
  450. *((volatile uint32_t *)(eep + 0x80uL)) = 0;
  451. }
  452. __STATIC_INLINE void nrfx_gppi_task_endpoint_clear(uint8_t channel, uint32_t tep)
  453. {
  454. NRFX_ASSERT(tep);
  455. (void)channel;
  456. *((volatile uint32_t *)(tep + 0x80uL)) = 0;
  457. }
  458. __STATIC_INLINE void nrfx_gppi_fork_endpoint_setup(uint8_t channel, uint32_t fork_tep)
  459. {
  460. nrfx_gppi_task_endpoint_setup(channel, fork_tep);
  461. }
  462. __STATIC_INLINE void nrfx_gppi_fork_endpoint_clear(uint8_t channel, uint32_t fork_tep)
  463. {
  464. nrfx_gppi_task_endpoint_clear(channel, fork_tep);
  465. }
  466. __STATIC_INLINE void nrfx_gppi_channels_include_in_group(uint32_t channel_mask,
  467. nrfx_gppi_channel_group_t channel_group)
  468. {
  469. nrf_dppi_channels_include_in_group(NRF_DPPIC, channel_mask, channel_group);
  470. }
  471. __STATIC_INLINE void nrfx_gppi_channels_remove_from_group(uint32_t channel_mask,
  472. nrfx_gppi_channel_group_t channel_group)
  473. {
  474. nrf_dppi_channels_remove_from_group(NRF_DPPIC, channel_mask, channel_group);
  475. }
  476. __STATIC_INLINE void nrfx_gppi_group_clear(nrfx_gppi_channel_group_t channel_group)
  477. {
  478. nrf_dppi_group_clear(NRF_DPPIC, channel_group);
  479. }
  480. __STATIC_INLINE void nrfx_gppi_group_enable(nrfx_gppi_channel_group_t channel_group)
  481. {
  482. nrf_dppi_group_enable(NRF_DPPIC, channel_group);
  483. }
  484. __STATIC_INLINE void nrfx_gppi_group_disable(nrfx_gppi_channel_group_t channel_group)
  485. {
  486. nrf_dppi_group_disable(NRF_DPPIC, channel_group);
  487. }
  488. __STATIC_INLINE uint32_t nrfx_gppi_task_address_get(nrfx_gppi_task_t gppi_task)
  489. {
  490. return (uint32_t) ((uint8_t *) NRF_DPPIC + (uint32_t) gppi_task);
  491. }
  492. __STATIC_INLINE nrfx_gppi_task_t nrfx_gppi_group_disable_task_get(nrfx_gppi_channel_group_t group)
  493. {
  494. return (nrfx_gppi_task_t) nrf_dppi_group_disable_task_get((uint8_t)group);
  495. }
  496. __STATIC_INLINE nrfx_gppi_task_t nrfx_gppi_group_enable_task_get(nrfx_gppi_channel_group_t group)
  497. {
  498. return (nrfx_gppi_task_t) nrf_dppi_group_enable_task_get((uint8_t)group);
  499. }
  500. #else
  501. #error "Neither PPI nor DPPI is present in the SoC currently in use."
  502. #endif
  503. #ifdef __cplusplus
  504. }
  505. #endif
  506. #endif // NRFX_GPPI_H