nrf_ppi.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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_PPI_H__
  41. #define NRF_PPI_H__
  42. #include <nrfx.h>
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. /**
  47. * @defgroup nrf_ppi_hal PPI HAL
  48. * @{
  49. * @ingroup nrf_ppi
  50. * @brief Hardware access layer for managing the Programmable Peripheral Interconnect (PPI)
  51. * channels.
  52. */
  53. #define NRF_PPI_TASK_SET (1UL)
  54. /**
  55. * @enum nrf_ppi_channel_t
  56. * @brief PPI channels.
  57. */
  58. typedef enum
  59. {
  60. NRF_PPI_CHANNEL0 = PPI_CHEN_CH0_Pos, /**< Channel 0. */
  61. NRF_PPI_CHANNEL1 = PPI_CHEN_CH1_Pos, /**< Channel 1. */
  62. NRF_PPI_CHANNEL2 = PPI_CHEN_CH2_Pos, /**< Channel 2. */
  63. NRF_PPI_CHANNEL3 = PPI_CHEN_CH3_Pos, /**< Channel 3. */
  64. NRF_PPI_CHANNEL4 = PPI_CHEN_CH4_Pos, /**< Channel 4. */
  65. NRF_PPI_CHANNEL5 = PPI_CHEN_CH5_Pos, /**< Channel 5. */
  66. NRF_PPI_CHANNEL6 = PPI_CHEN_CH6_Pos, /**< Channel 6. */
  67. NRF_PPI_CHANNEL7 = PPI_CHEN_CH7_Pos, /**< Channel 7. */
  68. NRF_PPI_CHANNEL8 = PPI_CHEN_CH8_Pos, /**< Channel 8. */
  69. NRF_PPI_CHANNEL9 = PPI_CHEN_CH9_Pos, /**< Channel 9. */
  70. NRF_PPI_CHANNEL10 = PPI_CHEN_CH10_Pos, /**< Channel 10. */
  71. NRF_PPI_CHANNEL11 = PPI_CHEN_CH11_Pos, /**< Channel 11. */
  72. NRF_PPI_CHANNEL12 = PPI_CHEN_CH12_Pos, /**< Channel 12. */
  73. NRF_PPI_CHANNEL13 = PPI_CHEN_CH13_Pos, /**< Channel 13. */
  74. NRF_PPI_CHANNEL14 = PPI_CHEN_CH14_Pos, /**< Channel 14. */
  75. NRF_PPI_CHANNEL15 = PPI_CHEN_CH15_Pos, /**< Channel 15. */
  76. #if (PPI_CH_NUM > 16) || defined(__NRFX_DOXYGEN__)
  77. NRF_PPI_CHANNEL16 = PPI_CHEN_CH16_Pos, /**< Channel 16. */
  78. NRF_PPI_CHANNEL17 = PPI_CHEN_CH17_Pos, /**< Channel 17. */
  79. NRF_PPI_CHANNEL18 = PPI_CHEN_CH18_Pos, /**< Channel 18. */
  80. NRF_PPI_CHANNEL19 = PPI_CHEN_CH19_Pos, /**< Channel 19. */
  81. #endif
  82. NRF_PPI_CHANNEL20 = PPI_CHEN_CH20_Pos, /**< Channel 20. */
  83. NRF_PPI_CHANNEL21 = PPI_CHEN_CH21_Pos, /**< Channel 21. */
  84. NRF_PPI_CHANNEL22 = PPI_CHEN_CH22_Pos, /**< Channel 22. */
  85. NRF_PPI_CHANNEL23 = PPI_CHEN_CH23_Pos, /**< Channel 23. */
  86. NRF_PPI_CHANNEL24 = PPI_CHEN_CH24_Pos, /**< Channel 24. */
  87. NRF_PPI_CHANNEL25 = PPI_CHEN_CH25_Pos, /**< Channel 25. */
  88. NRF_PPI_CHANNEL26 = PPI_CHEN_CH26_Pos, /**< Channel 26. */
  89. NRF_PPI_CHANNEL27 = PPI_CHEN_CH27_Pos, /**< Channel 27. */
  90. NRF_PPI_CHANNEL28 = PPI_CHEN_CH28_Pos, /**< Channel 28. */
  91. NRF_PPI_CHANNEL29 = PPI_CHEN_CH29_Pos, /**< Channel 29. */
  92. NRF_PPI_CHANNEL30 = PPI_CHEN_CH30_Pos, /**< Channel 30. */
  93. NRF_PPI_CHANNEL31 = PPI_CHEN_CH31_Pos /**< Channel 31. */
  94. } nrf_ppi_channel_t;
  95. /**
  96. * @enum nrf_ppi_channel_group_t
  97. * @brief PPI channel groups.
  98. */
  99. typedef enum
  100. {
  101. NRF_PPI_CHANNEL_GROUP0 = 0, /**< Channel group 0. */
  102. NRF_PPI_CHANNEL_GROUP1 = 1, /**< Channel group 1. */
  103. NRF_PPI_CHANNEL_GROUP2 = 2, /**< Channel group 2. */
  104. NRF_PPI_CHANNEL_GROUP3 = 3, /**< Channel group 3. */
  105. #if (PPI_GROUP_NUM > 4) || defined(__NRFX_DOXYGEN__)
  106. NRF_PPI_CHANNEL_GROUP4 = 4, /**< Channel group 4. */
  107. NRF_PPI_CHANNEL_GROUP5 = 5 /**< Channel group 5. */
  108. #endif
  109. } nrf_ppi_channel_group_t;
  110. /**
  111. * @enum nrf_ppi_channel_include_t
  112. * @brief Definition of which PPI channels belong to a group.
  113. */
  114. typedef enum
  115. {
  116. NRF_PPI_CHANNEL_EXCLUDE = PPI_CHG_CH0_Excluded, /**< Channel excluded from a group. */
  117. NRF_PPI_CHANNEL_INCLUDE = PPI_CHG_CH0_Included /**< Channel included in a group. */
  118. } nrf_ppi_channel_include_t;
  119. /**
  120. * @enum nrf_ppi_channel_enable_t
  121. * @brief Definition if a PPI channel is enabled.
  122. */
  123. typedef enum
  124. {
  125. NRF_PPI_CHANNEL_DISABLED = PPI_CHEN_CH0_Disabled, /**< Channel disabled. */
  126. NRF_PPI_CHANNEL_ENABLED = PPI_CHEN_CH0_Enabled /**< Channel enabled. */
  127. } nrf_ppi_channel_enable_t;
  128. /**
  129. * @enum nrf_ppi_task_t
  130. * @brief PPI tasks.
  131. */
  132. typedef enum
  133. {
  134. /*lint -save -e30 -esym(628,__INTADDR__)*/
  135. NRF_PPI_TASK_CHG0_EN = offsetof(NRF_PPI_Type, TASKS_CHG[0].EN), /**< Task for enabling channel group 0 */
  136. NRF_PPI_TASK_CHG0_DIS = offsetof(NRF_PPI_Type, TASKS_CHG[0].DIS), /**< Task for disabling channel group 0 */
  137. NRF_PPI_TASK_CHG1_EN = offsetof(NRF_PPI_Type, TASKS_CHG[1].EN), /**< Task for enabling channel group 1 */
  138. NRF_PPI_TASK_CHG1_DIS = offsetof(NRF_PPI_Type, TASKS_CHG[1].DIS), /**< Task for disabling channel group 1 */
  139. NRF_PPI_TASK_CHG2_EN = offsetof(NRF_PPI_Type, TASKS_CHG[2].EN), /**< Task for enabling channel group 2 */
  140. NRF_PPI_TASK_CHG2_DIS = offsetof(NRF_PPI_Type, TASKS_CHG[2].DIS), /**< Task for disabling channel group 2 */
  141. NRF_PPI_TASK_CHG3_EN = offsetof(NRF_PPI_Type, TASKS_CHG[3].EN), /**< Task for enabling channel group 3 */
  142. NRF_PPI_TASK_CHG3_DIS = offsetof(NRF_PPI_Type, TASKS_CHG[3].DIS), /**< Task for disabling channel group 3 */
  143. #if (PPI_GROUP_NUM > 4) || defined(__NRFX_DOXYGEN__)
  144. NRF_PPI_TASK_CHG4_EN = offsetof(NRF_PPI_Type, TASKS_CHG[4].EN), /**< Task for enabling channel group 4 */
  145. NRF_PPI_TASK_CHG4_DIS = offsetof(NRF_PPI_Type, TASKS_CHG[4].DIS), /**< Task for disabling channel group 4 */
  146. NRF_PPI_TASK_CHG5_EN = offsetof(NRF_PPI_Type, TASKS_CHG[5].EN), /**< Task for enabling channel group 5 */
  147. NRF_PPI_TASK_CHG5_DIS = offsetof(NRF_PPI_Type, TASKS_CHG[5].DIS) /**< Task for disabling channel group 5 */
  148. #endif
  149. /*lint -restore*/
  150. } nrf_ppi_task_t;
  151. /**
  152. * @brief Function for enabling a given PPI channel.
  153. *
  154. * @details This function enables only one channel.
  155. *
  156. * @param[in] channel Channel to enable.
  157. *
  158. * */
  159. __STATIC_INLINE void nrf_ppi_channel_enable(nrf_ppi_channel_t channel);
  160. /**
  161. * @brief Function for disabling a given PPI channel.
  162. *
  163. * @details This function disables only one channel.
  164. *
  165. * @param[in] channel Channel to disable.
  166. */
  167. __STATIC_INLINE void nrf_ppi_channel_disable(nrf_ppi_channel_t channel);
  168. /**
  169. * @brief Function for checking if a given PPI channel is enabled.
  170. *
  171. * @details This function checks only one channel.
  172. *
  173. * @param[in] channel Channel to check.
  174. *
  175. * @retval NRF_PPI_CHANNEL_ENABLED If the channel is enabled.
  176. * @retval NRF_PPI_CHANNEL_DISABLED If the channel is not enabled.
  177. *
  178. */
  179. __STATIC_INLINE nrf_ppi_channel_enable_t nrf_ppi_channel_enable_get(nrf_ppi_channel_t channel);
  180. /**
  181. * @brief Function for disabling all PPI channels.
  182. */
  183. __STATIC_INLINE void nrf_ppi_channel_disable_all(void);
  184. /**
  185. * @brief Function for enabling multiple PPI channels.
  186. *
  187. * @param[in] mask Channel mask.
  188. */
  189. __STATIC_INLINE void nrf_ppi_channels_enable(uint32_t mask);
  190. /**
  191. * @brief Function for disabling multiple PPI channels.
  192. *
  193. * @param[in] mask Channel mask.
  194. */
  195. __STATIC_INLINE void nrf_ppi_channels_disable(uint32_t mask);
  196. /**
  197. * @brief Function for setting up event and task endpoints for a given PPI channel.
  198. *
  199. * @param[in] eep Event register address.
  200. *
  201. * @param[in] tep Task register address.
  202. *
  203. * @param[in] channel Channel to which the given endpoints are assigned.
  204. */
  205. __STATIC_INLINE void nrf_ppi_channel_endpoint_setup(nrf_ppi_channel_t channel,
  206. uint32_t eep,
  207. uint32_t tep);
  208. /**
  209. * @brief Function for setting up the event endpoint for a given PPI channel.
  210. *
  211. * @param[in] eep Event register address.
  212. * @param[in] channel Channel to which the given endpoint is assigned.
  213. */
  214. __STATIC_INLINE void nrf_ppi_event_endpoint_setup(nrf_ppi_channel_t channel,
  215. uint32_t eep);
  216. /**
  217. * @brief Function for setting up the task endpoint for a given PPI channel.
  218. *
  219. * @param[in] tep Task register address.
  220. * @param[in] channel Channel to which the given endpoint is assigned.
  221. */
  222. __STATIC_INLINE void nrf_ppi_task_endpoint_setup(nrf_ppi_channel_t channel,
  223. uint32_t tep);
  224. #if defined(PPI_FEATURE_FORKS_PRESENT) || defined(__NRFX_DOXYGEN__)
  225. /**
  226. * @brief Function for setting up task endpoint for a given PPI fork.
  227. *
  228. * @param[in] fork_tep Task register address.
  229. *
  230. * @param[in] channel Channel to which the given fork endpoint is assigned.
  231. */
  232. __STATIC_INLINE void nrf_ppi_fork_endpoint_setup(nrf_ppi_channel_t channel,
  233. uint32_t fork_tep);
  234. /**
  235. * @brief Function for setting up event and task endpoints for a given PPI channel and fork.
  236. *
  237. * @param[in] eep Event register address.
  238. *
  239. * @param[in] tep Task register address.
  240. *
  241. * @param[in] fork_tep Fork task register address (register value).
  242. *
  243. * @param[in] channel Channel to which the given endpoints are assigned.
  244. */
  245. __STATIC_INLINE void nrf_ppi_channel_and_fork_endpoint_setup(nrf_ppi_channel_t channel,
  246. uint32_t eep,
  247. uint32_t tep,
  248. uint32_t fork_tep);
  249. #endif
  250. /**
  251. * @brief Function for including a PPI channel in a channel group.
  252. *
  253. * @details This function adds only one channel to the group.
  254. *
  255. * @param[in] channel Channel to be included in the group.
  256. *
  257. * @param[in] channel_group Channel group.
  258. *
  259. */
  260. __STATIC_INLINE void nrf_ppi_channel_include_in_group(nrf_ppi_channel_t channel,
  261. nrf_ppi_channel_group_t channel_group);
  262. /**
  263. * @brief Function for including multiple PPI channels in a channel group.
  264. *
  265. * @details This function adds all specified channels to the group.
  266. *
  267. * @param[in] channel_mask Channels to be included in the group.
  268. *
  269. * @param[in] channel_group Channel group.
  270. *
  271. */
  272. __STATIC_INLINE void nrf_ppi_channels_include_in_group(uint32_t channel_mask,
  273. nrf_ppi_channel_group_t channel_group);
  274. /**
  275. * @brief Function for removing a PPI channel from a channel group.
  276. *
  277. * @details This function removes only one channel from the group.
  278. *
  279. * @param[in] channel Channel to be removed from the group.
  280. *
  281. * @param[in] channel_group Channel group.
  282. */
  283. __STATIC_INLINE void nrf_ppi_channel_remove_from_group(nrf_ppi_channel_t channel,
  284. nrf_ppi_channel_group_t channel_group);
  285. /**
  286. * @brief Function for removing multiple PPI channels from a channel group.
  287. *
  288. * @details This function removes all specified channels from the group.
  289. *
  290. * @param[in] channel_mask Channels to be removed from the group.
  291. *
  292. * @param[in] channel_group Channel group.
  293. */
  294. __STATIC_INLINE void nrf_ppi_channels_remove_from_group(uint32_t channel_mask,
  295. nrf_ppi_channel_group_t channel_group);
  296. /**
  297. * @brief Function for removing all PPI channels from a channel group.
  298. *
  299. * @param[in] group Channel group.
  300. *
  301. */
  302. __STATIC_INLINE void nrf_ppi_channel_group_clear(nrf_ppi_channel_group_t group);
  303. /**
  304. * @brief Function for enabling a channel group.
  305. *
  306. * @param[in] group Channel group.
  307. *
  308. */
  309. __STATIC_INLINE void nrf_ppi_group_enable(nrf_ppi_channel_group_t group);
  310. /**
  311. * @brief Function for disabling a channel group.
  312. *
  313. * @param[in] group Channel group.
  314. *
  315. */
  316. __STATIC_INLINE void nrf_ppi_group_disable(nrf_ppi_channel_group_t group);
  317. /**
  318. * @brief Function for setting a PPI task.
  319. *
  320. * @param[in] ppi_task PPI task to set.
  321. */
  322. __STATIC_INLINE void nrf_ppi_task_trigger(nrf_ppi_task_t ppi_task);
  323. /**
  324. * @brief Function for returning the address of a specific PPI task register.
  325. *
  326. * @param[in] ppi_task PPI task.
  327. */
  328. __STATIC_INLINE uint32_t * nrf_ppi_task_address_get(nrf_ppi_task_t ppi_task);
  329. /**
  330. * @brief Function for returning the PPI enable task address of a specific group.
  331. *
  332. * @param[in] group PPI group.
  333. */
  334. __STATIC_INLINE uint32_t * nrf_ppi_task_group_enable_address_get(nrf_ppi_channel_group_t group);
  335. /**
  336. * @brief Function for returning the PPI disable task address of a specific group.
  337. *
  338. * @param[in] group PPI group.
  339. */
  340. __STATIC_INLINE uint32_t * nrf_ppi_task_group_disable_address_get(nrf_ppi_channel_group_t group);
  341. #ifndef SUPPRESS_INLINE_IMPLEMENTATION
  342. __STATIC_INLINE void nrf_ppi_channel_enable(nrf_ppi_channel_t channel)
  343. {
  344. NRF_PPI->CHENSET = PPI_CHENSET_CH0_Set << ((uint32_t) channel);
  345. }
  346. __STATIC_INLINE void nrf_ppi_channel_disable(nrf_ppi_channel_t channel)
  347. {
  348. NRF_PPI->CHENCLR = PPI_CHENCLR_CH0_Clear << ((uint32_t) channel);
  349. }
  350. __STATIC_INLINE nrf_ppi_channel_enable_t nrf_ppi_channel_enable_get(nrf_ppi_channel_t channel)
  351. {
  352. if (NRF_PPI->CHEN & (PPI_CHEN_CH0_Msk << ((uint32_t) channel)))
  353. {
  354. return NRF_PPI_CHANNEL_ENABLED;
  355. }
  356. else
  357. {
  358. return NRF_PPI_CHANNEL_DISABLED;
  359. }
  360. }
  361. __STATIC_INLINE void nrf_ppi_channel_disable_all(void)
  362. {
  363. NRF_PPI->CHENCLR = ((uint32_t)0xFFFFFFFFuL);
  364. }
  365. __STATIC_INLINE void nrf_ppi_channels_enable(uint32_t mask)
  366. {
  367. NRF_PPI->CHENSET = mask;
  368. }
  369. __STATIC_INLINE void nrf_ppi_channels_disable(uint32_t mask)
  370. {
  371. NRF_PPI->CHENCLR = mask;
  372. }
  373. __STATIC_INLINE void nrf_ppi_channel_endpoint_setup(nrf_ppi_channel_t channel,
  374. uint32_t eep,
  375. uint32_t tep)
  376. {
  377. NRF_PPI->CH[(uint32_t) channel].EEP = eep;
  378. NRF_PPI->CH[(uint32_t) channel].TEP = tep;
  379. }
  380. __STATIC_INLINE void nrf_ppi_event_endpoint_setup(nrf_ppi_channel_t channel,
  381. uint32_t eep)
  382. {
  383. NRF_PPI->CH[(uint32_t) channel].EEP = eep;
  384. }
  385. __STATIC_INLINE void nrf_ppi_task_endpoint_setup(nrf_ppi_channel_t channel,
  386. uint32_t tep)
  387. {
  388. NRF_PPI->CH[(uint32_t) channel].TEP = tep;
  389. }
  390. #if defined(PPI_FEATURE_FORKS_PRESENT)
  391. __STATIC_INLINE void nrf_ppi_fork_endpoint_setup(nrf_ppi_channel_t channel,
  392. uint32_t fork_tep)
  393. {
  394. NRF_PPI->FORK[(uint32_t) channel].TEP = fork_tep;
  395. }
  396. __STATIC_INLINE void nrf_ppi_channel_and_fork_endpoint_setup(nrf_ppi_channel_t channel,
  397. uint32_t eep,
  398. uint32_t tep,
  399. uint32_t fork_tep)
  400. {
  401. nrf_ppi_channel_endpoint_setup(channel, eep, tep);
  402. nrf_ppi_fork_endpoint_setup(channel, fork_tep);
  403. }
  404. #endif
  405. __STATIC_INLINE void nrf_ppi_channel_include_in_group(nrf_ppi_channel_t channel,
  406. nrf_ppi_channel_group_t channel_group)
  407. {
  408. NRF_PPI->CHG[(uint32_t) channel_group] =
  409. NRF_PPI->CHG[(uint32_t) channel_group] | (PPI_CHG_CH0_Included << ((uint32_t) channel));
  410. }
  411. __STATIC_INLINE void nrf_ppi_channels_include_in_group(uint32_t channel_mask,
  412. nrf_ppi_channel_group_t channel_group)
  413. {
  414. NRF_PPI->CHG[(uint32_t) channel_group] =
  415. NRF_PPI->CHG[(uint32_t) channel_group] | (channel_mask);
  416. }
  417. __STATIC_INLINE void nrf_ppi_channel_remove_from_group(nrf_ppi_channel_t channel,
  418. nrf_ppi_channel_group_t channel_group)
  419. {
  420. NRF_PPI->CHG[(uint32_t) channel_group] =
  421. NRF_PPI->CHG[(uint32_t) channel_group] & ~(PPI_CHG_CH0_Included << ((uint32_t) channel));
  422. }
  423. __STATIC_INLINE void nrf_ppi_channels_remove_from_group(uint32_t channel_mask,
  424. nrf_ppi_channel_group_t channel_group)
  425. {
  426. NRF_PPI->CHG[(uint32_t) channel_group] =
  427. NRF_PPI->CHG[(uint32_t) channel_group] & ~(channel_mask);
  428. }
  429. __STATIC_INLINE void nrf_ppi_channel_group_clear(nrf_ppi_channel_group_t group)
  430. {
  431. NRF_PPI->CHG[(uint32_t) group] = 0;
  432. }
  433. __STATIC_INLINE void nrf_ppi_group_enable(nrf_ppi_channel_group_t group)
  434. {
  435. NRF_PPI->TASKS_CHG[(uint32_t) group].EN = NRF_PPI_TASK_SET;
  436. }
  437. __STATIC_INLINE void nrf_ppi_group_disable(nrf_ppi_channel_group_t group)
  438. {
  439. NRF_PPI->TASKS_CHG[(uint32_t) group].DIS = NRF_PPI_TASK_SET;
  440. }
  441. __STATIC_INLINE void nrf_ppi_task_trigger(nrf_ppi_task_t ppi_task)
  442. {
  443. *((volatile uint32_t *) ((uint8_t *) NRF_PPI_BASE + (uint32_t) ppi_task)) = NRF_PPI_TASK_SET;
  444. }
  445. __STATIC_INLINE uint32_t * nrf_ppi_task_address_get(nrf_ppi_task_t ppi_task)
  446. {
  447. return (uint32_t *) ((uint8_t *) NRF_PPI_BASE + (uint32_t) ppi_task);
  448. }
  449. __STATIC_INLINE uint32_t * nrf_ppi_task_group_enable_address_get(nrf_ppi_channel_group_t group)
  450. {
  451. return (uint32_t *) &NRF_PPI->TASKS_CHG[(uint32_t) group].EN;
  452. }
  453. __STATIC_INLINE uint32_t * nrf_ppi_task_group_disable_address_get(nrf_ppi_channel_group_t group)
  454. {
  455. return (uint32_t *) &NRF_PPI->TASKS_CHG[(uint32_t) group].DIS;
  456. }
  457. #endif // SUPPRESS_INLINE_IMPLEMENTATION
  458. /** @} */
  459. #ifdef __cplusplus
  460. }
  461. #endif
  462. #endif // NRF_PPI_H__