The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 143:86740a56073b 1 /*
AnnaBridge 143:86740a56073b 2 * Copyright (c) 2015 Nordic Semiconductor ASA
AnnaBridge 143:86740a56073b 3 * All rights reserved.
AnnaBridge 143:86740a56073b 4 *
AnnaBridge 143:86740a56073b 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 143:86740a56073b 6 * are permitted provided that the following conditions are met:
AnnaBridge 143:86740a56073b 7 *
AnnaBridge 143:86740a56073b 8 * 1. Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 143:86740a56073b 9 * of conditions and the following disclaimer.
AnnaBridge 143:86740a56073b 10 *
AnnaBridge 143:86740a56073b 11 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
AnnaBridge 143:86740a56073b 12 * integrated circuit in a product or a software update for such product, must reproduce
AnnaBridge 143:86740a56073b 13 * the above copyright notice, this list of conditions and the following disclaimer in
AnnaBridge 143:86740a56073b 14 * the documentation and/or other materials provided with the distribution.
AnnaBridge 143:86740a56073b 15 *
AnnaBridge 143:86740a56073b 16 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
AnnaBridge 143:86740a56073b 17 * used to endorse or promote products derived from this software without specific prior
AnnaBridge 143:86740a56073b 18 * written permission.
AnnaBridge 143:86740a56073b 19 *
AnnaBridge 143:86740a56073b 20 * 4. This software, with or without modification, must only be used with a
AnnaBridge 143:86740a56073b 21 * Nordic Semiconductor ASA integrated circuit.
AnnaBridge 143:86740a56073b 22 *
AnnaBridge 143:86740a56073b 23 * 5. Any software provided in binary or object form under this license must not be reverse
AnnaBridge 143:86740a56073b 24 * engineered, decompiled, modified and/or disassembled.
AnnaBridge 143:86740a56073b 25 *
AnnaBridge 143:86740a56073b 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 143:86740a56073b 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 143:86740a56073b 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 143:86740a56073b 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 143:86740a56073b 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 143:86740a56073b 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 143:86740a56073b 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 143:86740a56073b 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 143:86740a56073b 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 143:86740a56073b 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 143:86740a56073b 36 *
AnnaBridge 143:86740a56073b 37 */
AnnaBridge 143:86740a56073b 38
AnnaBridge 143:86740a56073b 39
AnnaBridge 143:86740a56073b 40 #ifndef NRF_PPI_H__
AnnaBridge 143:86740a56073b 41 #define NRF_PPI_H__
AnnaBridge 143:86740a56073b 42
AnnaBridge 143:86740a56073b 43 #include <stddef.h>
AnnaBridge 143:86740a56073b 44 #include "nrf.h"
AnnaBridge 143:86740a56073b 45
AnnaBridge 143:86740a56073b 46 /**
AnnaBridge 143:86740a56073b 47 * @defgroup nrf_ppi_hal PPI HAL
AnnaBridge 143:86740a56073b 48 * @{
AnnaBridge 143:86740a56073b 49 * @ingroup nrf_ppi
AnnaBridge 143:86740a56073b 50 * @brief Hardware access layer for setting up Programmable Peripheral Interconnect (PPI) channels.
AnnaBridge 143:86740a56073b 51 */
AnnaBridge 143:86740a56073b 52
AnnaBridge 143:86740a56073b 53 #define NRF_PPI_TASK_SET (1UL)
AnnaBridge 143:86740a56073b 54
AnnaBridge 143:86740a56073b 55 /**
AnnaBridge 143:86740a56073b 56 * @enum nrf_ppi_channel_t
AnnaBridge 143:86740a56073b 57 * @brief PPI channels.
AnnaBridge 143:86740a56073b 58 */
AnnaBridge 143:86740a56073b 59 typedef enum
AnnaBridge 143:86740a56073b 60 {
AnnaBridge 143:86740a56073b 61 NRF_PPI_CHANNEL0 = PPI_CHEN_CH0_Pos, /**< Channel 0. */
AnnaBridge 143:86740a56073b 62 NRF_PPI_CHANNEL1 = PPI_CHEN_CH1_Pos, /**< Channel 1. */
AnnaBridge 143:86740a56073b 63 NRF_PPI_CHANNEL2 = PPI_CHEN_CH2_Pos, /**< Channel 2. */
AnnaBridge 143:86740a56073b 64 NRF_PPI_CHANNEL3 = PPI_CHEN_CH3_Pos, /**< Channel 3. */
AnnaBridge 143:86740a56073b 65 NRF_PPI_CHANNEL4 = PPI_CHEN_CH4_Pos, /**< Channel 4. */
AnnaBridge 143:86740a56073b 66 NRF_PPI_CHANNEL5 = PPI_CHEN_CH5_Pos, /**< Channel 5. */
AnnaBridge 143:86740a56073b 67 NRF_PPI_CHANNEL6 = PPI_CHEN_CH6_Pos, /**< Channel 6. */
AnnaBridge 143:86740a56073b 68 NRF_PPI_CHANNEL7 = PPI_CHEN_CH7_Pos, /**< Channel 7. */
AnnaBridge 143:86740a56073b 69 NRF_PPI_CHANNEL8 = PPI_CHEN_CH8_Pos, /**< Channel 8. */
AnnaBridge 143:86740a56073b 70 NRF_PPI_CHANNEL9 = PPI_CHEN_CH9_Pos, /**< Channel 9. */
AnnaBridge 143:86740a56073b 71 NRF_PPI_CHANNEL10 = PPI_CHEN_CH10_Pos, /**< Channel 10. */
AnnaBridge 143:86740a56073b 72 NRF_PPI_CHANNEL11 = PPI_CHEN_CH11_Pos, /**< Channel 11. */
AnnaBridge 143:86740a56073b 73 NRF_PPI_CHANNEL12 = PPI_CHEN_CH12_Pos, /**< Channel 12. */
AnnaBridge 143:86740a56073b 74 NRF_PPI_CHANNEL13 = PPI_CHEN_CH13_Pos, /**< Channel 13. */
AnnaBridge 143:86740a56073b 75 NRF_PPI_CHANNEL14 = PPI_CHEN_CH14_Pos, /**< Channel 14. */
AnnaBridge 143:86740a56073b 76 NRF_PPI_CHANNEL15 = PPI_CHEN_CH15_Pos, /**< Channel 15. */
AnnaBridge 143:86740a56073b 77 #ifdef NRF52
AnnaBridge 143:86740a56073b 78 NRF_PPI_CHANNEL16 = PPI_CHEN_CH16_Pos, /**< Channel 16. */
AnnaBridge 143:86740a56073b 79 NRF_PPI_CHANNEL17 = PPI_CHEN_CH17_Pos, /**< Channel 17. */
AnnaBridge 143:86740a56073b 80 NRF_PPI_CHANNEL18 = PPI_CHEN_CH18_Pos, /**< Channel 18. */
AnnaBridge 143:86740a56073b 81 NRF_PPI_CHANNEL19 = PPI_CHEN_CH19_Pos, /**< Channel 19. */
AnnaBridge 143:86740a56073b 82 #endif
AnnaBridge 143:86740a56073b 83 NRF_PPI_CHANNEL20 = PPI_CHEN_CH20_Pos, /**< Channel 20. */
AnnaBridge 143:86740a56073b 84 NRF_PPI_CHANNEL21 = PPI_CHEN_CH21_Pos, /**< Channel 21. */
AnnaBridge 143:86740a56073b 85 NRF_PPI_CHANNEL22 = PPI_CHEN_CH22_Pos, /**< Channel 22. */
AnnaBridge 143:86740a56073b 86 NRF_PPI_CHANNEL23 = PPI_CHEN_CH23_Pos, /**< Channel 23. */
AnnaBridge 143:86740a56073b 87 NRF_PPI_CHANNEL24 = PPI_CHEN_CH24_Pos, /**< Channel 24. */
AnnaBridge 143:86740a56073b 88 NRF_PPI_CHANNEL25 = PPI_CHEN_CH25_Pos, /**< Channel 25. */
AnnaBridge 143:86740a56073b 89 NRF_PPI_CHANNEL26 = PPI_CHEN_CH26_Pos, /**< Channel 26. */
AnnaBridge 143:86740a56073b 90 NRF_PPI_CHANNEL27 = PPI_CHEN_CH27_Pos, /**< Channel 27. */
AnnaBridge 143:86740a56073b 91 NRF_PPI_CHANNEL28 = PPI_CHEN_CH28_Pos, /**< Channel 28. */
AnnaBridge 143:86740a56073b 92 NRF_PPI_CHANNEL29 = PPI_CHEN_CH29_Pos, /**< Channel 29. */
AnnaBridge 143:86740a56073b 93 NRF_PPI_CHANNEL30 = PPI_CHEN_CH30_Pos, /**< Channel 30. */
AnnaBridge 143:86740a56073b 94 NRF_PPI_CHANNEL31 = PPI_CHEN_CH31_Pos /**< Channel 31. */
AnnaBridge 143:86740a56073b 95 } nrf_ppi_channel_t;
AnnaBridge 143:86740a56073b 96
AnnaBridge 143:86740a56073b 97 /**
AnnaBridge 143:86740a56073b 98 * @enum nrf_ppi_channel_group_t
AnnaBridge 143:86740a56073b 99 * @brief PPI channel groups.
AnnaBridge 143:86740a56073b 100 */
AnnaBridge 143:86740a56073b 101 typedef enum
AnnaBridge 143:86740a56073b 102 {
AnnaBridge 143:86740a56073b 103 NRF_PPI_CHANNEL_GROUP0 = 0, /**< Channel group 0. */
AnnaBridge 143:86740a56073b 104 NRF_PPI_CHANNEL_GROUP1 = 1, /**< Channel group 1. */
AnnaBridge 143:86740a56073b 105 NRF_PPI_CHANNEL_GROUP2 = 2, /**< Channel group 2. */
AnnaBridge 143:86740a56073b 106 NRF_PPI_CHANNEL_GROUP3 = 3, /**< Channel group 3. */
AnnaBridge 143:86740a56073b 107 #ifdef NRF52
AnnaBridge 143:86740a56073b 108 NRF_PPI_CHANNEL_GROUP4 = 4, /**< Channel group 4. */
AnnaBridge 143:86740a56073b 109 NRF_PPI_CHANNEL_GROUP5 = 5 /**< Channel group 5. */
AnnaBridge 143:86740a56073b 110 #endif
AnnaBridge 143:86740a56073b 111 } nrf_ppi_channel_group_t;
AnnaBridge 143:86740a56073b 112
AnnaBridge 143:86740a56073b 113 /**
AnnaBridge 143:86740a56073b 114 * @enum nrf_ppi_channel_include_t
AnnaBridge 143:86740a56073b 115 * @brief Definition of which PPI channels belong to a group.
AnnaBridge 143:86740a56073b 116 */
AnnaBridge 143:86740a56073b 117 typedef enum
AnnaBridge 143:86740a56073b 118 {
AnnaBridge 143:86740a56073b 119 NRF_PPI_CHANNEL_EXCLUDE = PPI_CHG_CH0_Excluded, /**< Channel excluded from a group. */
AnnaBridge 143:86740a56073b 120 NRF_PPI_CHANNEL_INCLUDE = PPI_CHG_CH0_Included /**< Channel included in a group. */
AnnaBridge 143:86740a56073b 121 } nrf_ppi_channel_include_t;
AnnaBridge 143:86740a56073b 122
AnnaBridge 143:86740a56073b 123 /**
AnnaBridge 143:86740a56073b 124 * @enum nrf_ppi_channel_enable_t
AnnaBridge 143:86740a56073b 125 * @brief Definition if a PPI channel is enabled.
AnnaBridge 143:86740a56073b 126 */
AnnaBridge 143:86740a56073b 127 typedef enum
AnnaBridge 143:86740a56073b 128 {
AnnaBridge 143:86740a56073b 129 NRF_PPI_CHANNEL_DISABLED = PPI_CHEN_CH0_Disabled, /**< Channel disabled. */
AnnaBridge 143:86740a56073b 130 NRF_PPI_CHANNEL_ENABLED = PPI_CHEN_CH0_Enabled /**< Channel enabled. */
AnnaBridge 143:86740a56073b 131 } nrf_ppi_channel_enable_t;
AnnaBridge 143:86740a56073b 132
AnnaBridge 143:86740a56073b 133 /**
AnnaBridge 143:86740a56073b 134 * @enum nrf_ppi_task_t
AnnaBridge 143:86740a56073b 135 * @brief PPI tasks.
AnnaBridge 143:86740a56073b 136 */
AnnaBridge 143:86740a56073b 137 typedef enum
AnnaBridge 143:86740a56073b 138 {
AnnaBridge 143:86740a56073b 139 /*lint -save -e30 -esym(628,__INTADDR__)*/
AnnaBridge 143:86740a56073b 140 NRF_PPI_TASK_CHG0_EN = offsetof(NRF_PPI_Type, TASKS_CHG[0].EN), /**< Task for enabling channel group 0 */
AnnaBridge 143:86740a56073b 141 NRF_PPI_TASK_CHG0_DIS = offsetof(NRF_PPI_Type, TASKS_CHG[0].DIS), /**< Task for disabling channel group 0 */
AnnaBridge 143:86740a56073b 142 NRF_PPI_TASK_CHG1_EN = offsetof(NRF_PPI_Type, TASKS_CHG[1].EN), /**< Task for enabling channel group 1 */
AnnaBridge 143:86740a56073b 143 NRF_PPI_TASK_CHG1_DIS = offsetof(NRF_PPI_Type, TASKS_CHG[1].DIS), /**< Task for disabling channel group 1 */
AnnaBridge 143:86740a56073b 144 NRF_PPI_TASK_CHG2_EN = offsetof(NRF_PPI_Type, TASKS_CHG[2].EN), /**< Task for enabling channel group 2 */
AnnaBridge 143:86740a56073b 145 NRF_PPI_TASK_CHG2_DIS = offsetof(NRF_PPI_Type, TASKS_CHG[2].DIS), /**< Task for disabling channel group 2 */
AnnaBridge 143:86740a56073b 146 NRF_PPI_TASK_CHG3_EN = offsetof(NRF_PPI_Type, TASKS_CHG[3].EN), /**< Task for enabling channel group 3 */
AnnaBridge 143:86740a56073b 147 NRF_PPI_TASK_CHG3_DIS = offsetof(NRF_PPI_Type, TASKS_CHG[3].DIS), /**< Task for disabling channel group 3 */
AnnaBridge 143:86740a56073b 148 #ifdef NRF52
AnnaBridge 143:86740a56073b 149 NRF_PPI_TASK_CHG4_EN = offsetof(NRF_PPI_Type, TASKS_CHG[4].EN), /**< Task for enabling channel group 4 */
AnnaBridge 143:86740a56073b 150 NRF_PPI_TASK_CHG4_DIS = offsetof(NRF_PPI_Type, TASKS_CHG[4].DIS), /**< Task for disabling channel group 4 */
AnnaBridge 143:86740a56073b 151 NRF_PPI_TASK_CHG5_EN = offsetof(NRF_PPI_Type, TASKS_CHG[5].EN), /**< Task for enabling channel group 5 */
AnnaBridge 143:86740a56073b 152 NRF_PPI_TASK_CHG5_DIS = offsetof(NRF_PPI_Type, TASKS_CHG[5].DIS) /**< Task for disabling channel group 5 */
AnnaBridge 143:86740a56073b 153 #endif
AnnaBridge 143:86740a56073b 154 /*lint -restore*/
AnnaBridge 143:86740a56073b 155 } nrf_ppi_task_t;
AnnaBridge 143:86740a56073b 156
AnnaBridge 143:86740a56073b 157 /**
AnnaBridge 143:86740a56073b 158 * @brief Function for enabling a given PPI channel.
AnnaBridge 143:86740a56073b 159 *
AnnaBridge 143:86740a56073b 160 * @details This function enables only one channel.
AnnaBridge 143:86740a56073b 161 *
AnnaBridge 143:86740a56073b 162 * @param[in] channel Channel to enable.
AnnaBridge 143:86740a56073b 163 *
AnnaBridge 143:86740a56073b 164 * */
AnnaBridge 143:86740a56073b 165 __STATIC_INLINE void nrf_ppi_channel_enable(nrf_ppi_channel_t channel)
AnnaBridge 143:86740a56073b 166 {
AnnaBridge 143:86740a56073b 167 NRF_PPI->CHENSET = PPI_CHENSET_CH0_Set << ((uint32_t) channel);
AnnaBridge 143:86740a56073b 168 }
AnnaBridge 143:86740a56073b 169
AnnaBridge 143:86740a56073b 170
AnnaBridge 143:86740a56073b 171 /**
AnnaBridge 143:86740a56073b 172 * @brief Function for disabling a given PPI channel.
AnnaBridge 143:86740a56073b 173 *
AnnaBridge 143:86740a56073b 174 * @details This function disables only one channel.
AnnaBridge 143:86740a56073b 175 *
AnnaBridge 143:86740a56073b 176 * @param[in] channel Channel to disable.
AnnaBridge 143:86740a56073b 177 */
AnnaBridge 143:86740a56073b 178 __STATIC_INLINE void nrf_ppi_channel_disable(nrf_ppi_channel_t channel)
AnnaBridge 143:86740a56073b 179 {
AnnaBridge 143:86740a56073b 180 NRF_PPI->CHENCLR = PPI_CHENCLR_CH0_Clear << ((uint32_t) channel);
AnnaBridge 143:86740a56073b 181 }
AnnaBridge 143:86740a56073b 182
AnnaBridge 143:86740a56073b 183
AnnaBridge 143:86740a56073b 184 /**
AnnaBridge 143:86740a56073b 185 * @brief Function for checking if a given PPI channel is enabled.
AnnaBridge 143:86740a56073b 186 *
AnnaBridge 143:86740a56073b 187 * @details This function checks only one channel.
AnnaBridge 143:86740a56073b 188 *
AnnaBridge 143:86740a56073b 189 * @param[in] channel Channel to check.
AnnaBridge 143:86740a56073b 190 *
AnnaBridge 143:86740a56073b 191 * @retval NRF_PPI_CHANNEL_ENABLED If the channel is enabled.
AnnaBridge 143:86740a56073b 192 * @retval NRF_PPI_CHANNEL_DISABLED If the channel is not enabled.
AnnaBridge 143:86740a56073b 193 *
AnnaBridge 143:86740a56073b 194 */
AnnaBridge 143:86740a56073b 195 __STATIC_INLINE nrf_ppi_channel_enable_t nrf_ppi_channel_enable_get(nrf_ppi_channel_t channel)
AnnaBridge 143:86740a56073b 196 {
AnnaBridge 143:86740a56073b 197 if (NRF_PPI->CHEN & (PPI_CHEN_CH0_Msk << ((uint32_t) channel)))
AnnaBridge 143:86740a56073b 198 {
AnnaBridge 143:86740a56073b 199 return NRF_PPI_CHANNEL_ENABLED;
AnnaBridge 143:86740a56073b 200 }
AnnaBridge 143:86740a56073b 201 else
AnnaBridge 143:86740a56073b 202 {
AnnaBridge 143:86740a56073b 203 return NRF_PPI_CHANNEL_DISABLED;
AnnaBridge 143:86740a56073b 204 }
AnnaBridge 143:86740a56073b 205 }
AnnaBridge 143:86740a56073b 206
AnnaBridge 143:86740a56073b 207
AnnaBridge 143:86740a56073b 208 /**
AnnaBridge 143:86740a56073b 209 * @brief Function for disabling all PPI channels.
AnnaBridge 143:86740a56073b 210 */
AnnaBridge 143:86740a56073b 211 __STATIC_INLINE void nrf_ppi_channel_disable_all(void)
AnnaBridge 143:86740a56073b 212 {
AnnaBridge 143:86740a56073b 213 NRF_PPI->CHENCLR = ((uint32_t)0xFFFFFFFFuL);
AnnaBridge 143:86740a56073b 214 }
AnnaBridge 143:86740a56073b 215
AnnaBridge 143:86740a56073b 216 /**
AnnaBridge 143:86740a56073b 217 * @brief Function for disabling multiple PPI channels.
AnnaBridge 143:86740a56073b 218 *
AnnaBridge 143:86740a56073b 219 * @param[in] mask Channel mask.
AnnaBridge 143:86740a56073b 220 */
AnnaBridge 143:86740a56073b 221 __STATIC_INLINE void nrf_ppi_channels_disable(uint32_t mask)
AnnaBridge 143:86740a56073b 222 {
AnnaBridge 143:86740a56073b 223 NRF_PPI->CHENCLR = mask;
AnnaBridge 143:86740a56073b 224 }
AnnaBridge 143:86740a56073b 225
AnnaBridge 143:86740a56073b 226 /**
AnnaBridge 143:86740a56073b 227 * @brief Function for setting up event and task endpoints for a given PPI channel.
AnnaBridge 143:86740a56073b 228 *
AnnaBridge 143:86740a56073b 229 * @param[in] eep Event register address.
AnnaBridge 143:86740a56073b 230 *
AnnaBridge 143:86740a56073b 231 * @param[in] tep Task register address.
AnnaBridge 143:86740a56073b 232 *
AnnaBridge 143:86740a56073b 233 * @param[in] channel Channel to which the given endpoints are assigned.
AnnaBridge 143:86740a56073b 234 */
AnnaBridge 143:86740a56073b 235 __STATIC_INLINE void nrf_ppi_channel_endpoint_setup(nrf_ppi_channel_t channel,
AnnaBridge 143:86740a56073b 236 uint32_t eep,
AnnaBridge 143:86740a56073b 237 uint32_t tep)
AnnaBridge 143:86740a56073b 238 {
AnnaBridge 143:86740a56073b 239 NRF_PPI->CH[(uint32_t) channel].EEP = eep;
AnnaBridge 143:86740a56073b 240 NRF_PPI->CH[(uint32_t) channel].TEP = tep;
AnnaBridge 143:86740a56073b 241 }
AnnaBridge 143:86740a56073b 242
AnnaBridge 143:86740a56073b 243 #ifdef NRF52
AnnaBridge 143:86740a56073b 244 /**
AnnaBridge 143:86740a56073b 245 * @brief Function for setting up task endpoint for a given PPI fork.
AnnaBridge 143:86740a56073b 246 *
AnnaBridge 143:86740a56073b 247 * @param[in] fork_tep Task register address.
AnnaBridge 143:86740a56073b 248 *
AnnaBridge 143:86740a56073b 249 * @param[in] channel Channel to which the given fork endpoint is assigned.
AnnaBridge 143:86740a56073b 250 */
AnnaBridge 143:86740a56073b 251 __STATIC_INLINE void nrf_ppi_fork_endpoint_setup(nrf_ppi_channel_t channel,
AnnaBridge 143:86740a56073b 252 uint32_t fork_tep)
AnnaBridge 143:86740a56073b 253 {
AnnaBridge 143:86740a56073b 254 NRF_PPI->FORK[(uint32_t) channel].TEP = fork_tep;
AnnaBridge 143:86740a56073b 255 }
AnnaBridge 143:86740a56073b 256
AnnaBridge 143:86740a56073b 257 /**
AnnaBridge 143:86740a56073b 258 * @brief Function for setting up event and task endpoints for a given PPI channel and fork.
AnnaBridge 143:86740a56073b 259 *
AnnaBridge 143:86740a56073b 260 * @param[in] eep Event register address.
AnnaBridge 143:86740a56073b 261 *
AnnaBridge 143:86740a56073b 262 * @param[in] tep Task register address.
AnnaBridge 143:86740a56073b 263 *
AnnaBridge 143:86740a56073b 264 * @param[in] fork_tep Fork task register address (register value).
AnnaBridge 143:86740a56073b 265 *
AnnaBridge 143:86740a56073b 266 * @param[in] channel Channel to which the given endpoints are assigned.
AnnaBridge 143:86740a56073b 267 */
AnnaBridge 143:86740a56073b 268 __STATIC_INLINE void nrf_ppi_channel_and_fork_endpoint_setup(nrf_ppi_channel_t channel,
AnnaBridge 143:86740a56073b 269 uint32_t eep,
AnnaBridge 143:86740a56073b 270 uint32_t tep,
AnnaBridge 143:86740a56073b 271 uint32_t fork_tep)
AnnaBridge 143:86740a56073b 272 {
AnnaBridge 143:86740a56073b 273 nrf_ppi_channel_endpoint_setup(channel, eep, tep);
AnnaBridge 143:86740a56073b 274 nrf_ppi_fork_endpoint_setup(channel, fork_tep);
AnnaBridge 143:86740a56073b 275 }
AnnaBridge 143:86740a56073b 276 #endif
AnnaBridge 143:86740a56073b 277
AnnaBridge 143:86740a56073b 278 /**
AnnaBridge 143:86740a56073b 279 * @brief Function for including a PPI channel in a channel group.
AnnaBridge 143:86740a56073b 280 *
AnnaBridge 143:86740a56073b 281 * @details This function adds only one channel to the group.
AnnaBridge 143:86740a56073b 282 *
AnnaBridge 143:86740a56073b 283 * @param[in] channel Channel to be included in the group.
AnnaBridge 143:86740a56073b 284 *
AnnaBridge 143:86740a56073b 285 * @param[in] channel_group Channel group.
AnnaBridge 143:86740a56073b 286 *
AnnaBridge 143:86740a56073b 287 */
AnnaBridge 143:86740a56073b 288 __STATIC_INLINE void nrf_ppi_channel_include_in_group(nrf_ppi_channel_t channel,
AnnaBridge 143:86740a56073b 289 nrf_ppi_channel_group_t channel_group)
AnnaBridge 143:86740a56073b 290 {
AnnaBridge 143:86740a56073b 291 NRF_PPI->CHG[(uint32_t) channel_group] =
AnnaBridge 143:86740a56073b 292 NRF_PPI->CHG[(uint32_t) channel_group] | (PPI_CHG_CH0_Included << ((uint32_t) channel));
AnnaBridge 143:86740a56073b 293 }
AnnaBridge 143:86740a56073b 294
AnnaBridge 143:86740a56073b 295 /**
AnnaBridge 143:86740a56073b 296 * @brief Function for including multiple PPI channels in a channel group.
AnnaBridge 143:86740a56073b 297 *
AnnaBridge 143:86740a56073b 298 * @details This function adds all specified channels to the group.
AnnaBridge 143:86740a56073b 299 *
AnnaBridge 143:86740a56073b 300 * @param[in] channel_mask Channels to be included in the group.
AnnaBridge 143:86740a56073b 301 *
AnnaBridge 143:86740a56073b 302 * @param[in] channel_group Channel group.
AnnaBridge 143:86740a56073b 303 *
AnnaBridge 143:86740a56073b 304 */
AnnaBridge 143:86740a56073b 305 __STATIC_INLINE void nrf_ppi_channels_include_in_group(uint32_t channel_mask,
AnnaBridge 143:86740a56073b 306 nrf_ppi_channel_group_t channel_group)
AnnaBridge 143:86740a56073b 307 {
AnnaBridge 143:86740a56073b 308 NRF_PPI->CHG[(uint32_t) channel_group] =
AnnaBridge 143:86740a56073b 309 NRF_PPI->CHG[(uint32_t) channel_group] | (channel_mask);
AnnaBridge 143:86740a56073b 310 }
AnnaBridge 143:86740a56073b 311
AnnaBridge 143:86740a56073b 312
AnnaBridge 143:86740a56073b 313 /**
AnnaBridge 143:86740a56073b 314 * @brief Function for removing a PPI channel from a channel group.
AnnaBridge 143:86740a56073b 315 *
AnnaBridge 143:86740a56073b 316 * @details This function removes only one channel from the group.
AnnaBridge 143:86740a56073b 317 *
AnnaBridge 143:86740a56073b 318 * @param[in] channel Channel to be removed from the group.
AnnaBridge 143:86740a56073b 319 *
AnnaBridge 143:86740a56073b 320 * @param[in] channel_group Channel group.
AnnaBridge 143:86740a56073b 321 */
AnnaBridge 143:86740a56073b 322 __STATIC_INLINE void nrf_ppi_channel_remove_from_group(nrf_ppi_channel_t channel,
AnnaBridge 143:86740a56073b 323 nrf_ppi_channel_group_t channel_group)
AnnaBridge 143:86740a56073b 324 {
AnnaBridge 143:86740a56073b 325 NRF_PPI->CHG[(uint32_t) channel_group] =
AnnaBridge 143:86740a56073b 326 NRF_PPI->CHG[(uint32_t) channel_group] & ~(PPI_CHG_CH0_Included << ((uint32_t) channel));
AnnaBridge 143:86740a56073b 327 }
AnnaBridge 143:86740a56073b 328
AnnaBridge 143:86740a56073b 329 /**
AnnaBridge 143:86740a56073b 330 * @brief Function for removing multiple PPI channels from a channel group.
AnnaBridge 143:86740a56073b 331 *
AnnaBridge 143:86740a56073b 332 * @details This function removes all specified channels from the group.
AnnaBridge 143:86740a56073b 333 *
AnnaBridge 143:86740a56073b 334 * @param[in] channel_mask Channels to be removed from the group.
AnnaBridge 143:86740a56073b 335 *
AnnaBridge 143:86740a56073b 336 * @param[in] channel_group Channel group.
AnnaBridge 143:86740a56073b 337 */
AnnaBridge 143:86740a56073b 338 __STATIC_INLINE void nrf_ppi_channels_remove_from_group(uint32_t channel_mask,
AnnaBridge 143:86740a56073b 339 nrf_ppi_channel_group_t channel_group)
AnnaBridge 143:86740a56073b 340 {
AnnaBridge 143:86740a56073b 341 NRF_PPI->CHG[(uint32_t) channel_group] =
AnnaBridge 143:86740a56073b 342 NRF_PPI->CHG[(uint32_t) channel_group] & ~(channel_mask);
AnnaBridge 143:86740a56073b 343 }
AnnaBridge 143:86740a56073b 344
AnnaBridge 143:86740a56073b 345
AnnaBridge 143:86740a56073b 346 /**
AnnaBridge 143:86740a56073b 347 * @brief Function for removing all PPI channels from a channel group.
AnnaBridge 143:86740a56073b 348 *
AnnaBridge 143:86740a56073b 349 * @param[in] group Channel group.
AnnaBridge 143:86740a56073b 350 *
AnnaBridge 143:86740a56073b 351 */
AnnaBridge 143:86740a56073b 352 __STATIC_INLINE void nrf_ppi_channel_group_clear(nrf_ppi_channel_group_t group)
AnnaBridge 143:86740a56073b 353 {
AnnaBridge 143:86740a56073b 354 NRF_PPI->CHG[(uint32_t) group] = 0;
AnnaBridge 143:86740a56073b 355 }
AnnaBridge 143:86740a56073b 356
AnnaBridge 143:86740a56073b 357
AnnaBridge 143:86740a56073b 358 /**
AnnaBridge 143:86740a56073b 359 * @brief Function for enabling a channel group.
AnnaBridge 143:86740a56073b 360 *
AnnaBridge 143:86740a56073b 361 * @param[in] group Channel group.
AnnaBridge 143:86740a56073b 362 *
AnnaBridge 143:86740a56073b 363 */
AnnaBridge 143:86740a56073b 364 __STATIC_INLINE void nrf_ppi_group_enable(nrf_ppi_channel_group_t group)
AnnaBridge 143:86740a56073b 365 {
AnnaBridge 143:86740a56073b 366 NRF_PPI->TASKS_CHG[(uint32_t) group].EN = NRF_PPI_TASK_SET;
AnnaBridge 143:86740a56073b 367 }
AnnaBridge 143:86740a56073b 368
AnnaBridge 143:86740a56073b 369
AnnaBridge 143:86740a56073b 370 /**
AnnaBridge 143:86740a56073b 371 * @brief Function for disabling a channel group.
AnnaBridge 143:86740a56073b 372 *
AnnaBridge 143:86740a56073b 373 * @param[in] group Channel group.
AnnaBridge 143:86740a56073b 374 *
AnnaBridge 143:86740a56073b 375 */
AnnaBridge 143:86740a56073b 376 __STATIC_INLINE void nrf_ppi_group_disable(nrf_ppi_channel_group_t group)
AnnaBridge 143:86740a56073b 377 {
AnnaBridge 143:86740a56073b 378 NRF_PPI->TASKS_CHG[(uint32_t) group].DIS = NRF_PPI_TASK_SET;
AnnaBridge 143:86740a56073b 379 }
AnnaBridge 143:86740a56073b 380
AnnaBridge 143:86740a56073b 381
AnnaBridge 143:86740a56073b 382 /**
AnnaBridge 143:86740a56073b 383 * @brief Function for setting a PPI task.
AnnaBridge 143:86740a56073b 384 *
AnnaBridge 143:86740a56073b 385 * @param[in] ppi_task PPI task to set.
AnnaBridge 143:86740a56073b 386 */
AnnaBridge 143:86740a56073b 387 __STATIC_INLINE void nrf_ppi_task_trigger(nrf_ppi_task_t ppi_task)
AnnaBridge 143:86740a56073b 388 {
AnnaBridge 143:86740a56073b 389 *((volatile uint32_t *) ((uint8_t *) NRF_PPI_BASE + (uint32_t) ppi_task)) = NRF_PPI_TASK_SET;
AnnaBridge 143:86740a56073b 390 }
AnnaBridge 143:86740a56073b 391
AnnaBridge 143:86740a56073b 392
AnnaBridge 143:86740a56073b 393 /**
AnnaBridge 143:86740a56073b 394 * @brief Function for returning the address of a specific PPI task register.
AnnaBridge 143:86740a56073b 395 *
AnnaBridge 143:86740a56073b 396 * @param[in] ppi_task PPI task.
AnnaBridge 143:86740a56073b 397 */
AnnaBridge 143:86740a56073b 398 __STATIC_INLINE uint32_t * nrf_ppi_task_address_get(nrf_ppi_task_t ppi_task)
AnnaBridge 143:86740a56073b 399 {
AnnaBridge 143:86740a56073b 400 return (uint32_t *) ((uint8_t *) NRF_PPI_BASE + (uint32_t) ppi_task);
AnnaBridge 143:86740a56073b 401 }
AnnaBridge 143:86740a56073b 402
AnnaBridge 143:86740a56073b 403 /**
AnnaBridge 143:86740a56073b 404 * @brief Function for returning the PPI enable task address of a specific group.
AnnaBridge 143:86740a56073b 405 *
AnnaBridge 143:86740a56073b 406 * @param[in] group PPI group.
AnnaBridge 143:86740a56073b 407 */
AnnaBridge 143:86740a56073b 408 __STATIC_INLINE uint32_t * nrf_ppi_task_group_enable_address_get(nrf_ppi_channel_group_t group)
AnnaBridge 143:86740a56073b 409 {
AnnaBridge 143:86740a56073b 410 return (uint32_t *) &NRF_PPI->TASKS_CHG[(uint32_t) group].EN;
AnnaBridge 143:86740a56073b 411 }
AnnaBridge 143:86740a56073b 412
AnnaBridge 143:86740a56073b 413 /**
AnnaBridge 143:86740a56073b 414 * @brief Function for returning the PPI disable task address of a specific group.
AnnaBridge 143:86740a56073b 415 *
AnnaBridge 143:86740a56073b 416 * @param[in] group PPI group.
AnnaBridge 143:86740a56073b 417 */
AnnaBridge 143:86740a56073b 418 __STATIC_INLINE uint32_t * nrf_ppi_task_group_disable_address_get(nrf_ppi_channel_group_t group)
AnnaBridge 143:86740a56073b 419 {
AnnaBridge 143:86740a56073b 420 return (uint32_t *) &NRF_PPI->TASKS_CHG[(uint32_t) group].DIS;
AnnaBridge 143:86740a56073b 421 }
AnnaBridge 143:86740a56073b 422
AnnaBridge 143:86740a56073b 423
AnnaBridge 143:86740a56073b 424 /**
AnnaBridge 143:86740a56073b 425 *@}
AnnaBridge 143:86740a56073b 426 **/
AnnaBridge 143:86740a56073b 427
AnnaBridge 143:86740a56073b 428 /*lint --flb "Leave library region" */
AnnaBridge 143:86740a56073b 429 #endif // NRF_PPI_H__