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.
TARGET_TY51822R3/TOOLCHAIN_IAR/nrf_rtc.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_NRF51_DONGLE/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_11/drivers_nrf/hal/nrf_rtc.h@169:a7c7b631e539
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 143:86740a56073b | 1 | /* |
AnnaBridge | 143:86740a56073b | 2 | * Copyright (c) 2014 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 | /** |
AnnaBridge | 143:86740a56073b | 41 | * @file |
AnnaBridge | 143:86740a56073b | 42 | * @brief RTC HAL API. |
AnnaBridge | 143:86740a56073b | 43 | */ |
AnnaBridge | 143:86740a56073b | 44 | |
AnnaBridge | 143:86740a56073b | 45 | #ifndef NRF_RTC_H |
AnnaBridge | 143:86740a56073b | 46 | #define NRF_RTC_H |
AnnaBridge | 143:86740a56073b | 47 | |
AnnaBridge | 143:86740a56073b | 48 | /** |
AnnaBridge | 143:86740a56073b | 49 | * @defgroup nrf_rtc_hal RTC HAL |
AnnaBridge | 143:86740a56073b | 50 | * @{ |
AnnaBridge | 143:86740a56073b | 51 | * @ingroup nrf_rtc |
AnnaBridge | 143:86740a56073b | 52 | * @brief Hardware access layer for managing the real time counter (RTC). |
AnnaBridge | 143:86740a56073b | 53 | */ |
AnnaBridge | 143:86740a56073b | 54 | |
AnnaBridge | 143:86740a56073b | 55 | #include <stdint.h> |
AnnaBridge | 143:86740a56073b | 56 | #include <stddef.h> |
AnnaBridge | 143:86740a56073b | 57 | #include <stdbool.h> |
AnnaBridge | 143:86740a56073b | 58 | #include "nrf.h" |
AnnaBridge | 143:86740a56073b | 59 | #include "nrf_assert.h" |
AnnaBridge | 143:86740a56073b | 60 | |
AnnaBridge | 143:86740a56073b | 61 | /** |
AnnaBridge | 143:86740a56073b | 62 | * @brief Macro for getting the number of compare channels available |
AnnaBridge | 143:86740a56073b | 63 | * in a given RTC instance. |
AnnaBridge | 143:86740a56073b | 64 | */ |
AnnaBridge | 143:86740a56073b | 65 | #ifdef NRF51 |
AnnaBridge | 143:86740a56073b | 66 | #define NRF_RTC_CC_CHANNEL_COUNT(id) 4 |
AnnaBridge | 143:86740a56073b | 67 | #else |
AnnaBridge | 143:86740a56073b | 68 | #define NRF_RTC_CC_CHANNEL_COUNT(id) ((id) == 0 ? 3 : 4) |
AnnaBridge | 143:86740a56073b | 69 | #endif |
AnnaBridge | 143:86740a56073b | 70 | |
AnnaBridge | 143:86740a56073b | 71 | #define RTC_INPUT_FREQ 32768 /**< Input frequency of the RTC instance. */ |
AnnaBridge | 143:86740a56073b | 72 | |
AnnaBridge | 143:86740a56073b | 73 | /**< Macro for wrapping values to RTC capacity. */ |
AnnaBridge | 143:86740a56073b | 74 | #define RTC_WRAP(val) (val & RTC_COUNTER_COUNTER_Msk) |
AnnaBridge | 143:86740a56073b | 75 | |
AnnaBridge | 143:86740a56073b | 76 | #define RTC_CHANNEL_INT_MASK(ch) ((uint32_t)NRF_RTC_INT_COMPARE0_MASK << ch) |
AnnaBridge | 143:86740a56073b | 77 | #define RTC_CHANNEL_EVENT_ADDR(ch) (nrf_rtc_event_t)(NRF_RTC_EVENT_COMPARE_0 + ch*sizeof(uint32_t)) |
AnnaBridge | 143:86740a56073b | 78 | /** |
AnnaBridge | 143:86740a56073b | 79 | * @enum nrf_rtc_task_t |
AnnaBridge | 143:86740a56073b | 80 | * @brief RTC tasks. |
AnnaBridge | 143:86740a56073b | 81 | */ |
AnnaBridge | 143:86740a56073b | 82 | typedef enum |
AnnaBridge | 143:86740a56073b | 83 | { |
AnnaBridge | 143:86740a56073b | 84 | /*lint -save -e30*/ |
AnnaBridge | 143:86740a56073b | 85 | NRF_RTC_TASK_START = offsetof(NRF_RTC_Type,TASKS_START), /**< Start. */ |
AnnaBridge | 143:86740a56073b | 86 | NRF_RTC_TASK_STOP = offsetof(NRF_RTC_Type,TASKS_STOP), /**< Stop. */ |
AnnaBridge | 143:86740a56073b | 87 | NRF_RTC_TASK_CLEAR = offsetof(NRF_RTC_Type,TASKS_CLEAR), /**< Clear. */ |
AnnaBridge | 143:86740a56073b | 88 | NRF_RTC_TASK_TRIGGER_OVERFLOW = offsetof(NRF_RTC_Type,TASKS_TRIGOVRFLW),/**< Trigger overflow. */ |
AnnaBridge | 143:86740a56073b | 89 | /*lint -restore*/ |
AnnaBridge | 143:86740a56073b | 90 | } nrf_rtc_task_t; |
AnnaBridge | 143:86740a56073b | 91 | |
AnnaBridge | 143:86740a56073b | 92 | /** |
AnnaBridge | 143:86740a56073b | 93 | * @enum nrf_rtc_event_t |
AnnaBridge | 143:86740a56073b | 94 | * @brief RTC events. |
AnnaBridge | 143:86740a56073b | 95 | */ |
AnnaBridge | 143:86740a56073b | 96 | typedef enum |
AnnaBridge | 143:86740a56073b | 97 | { |
AnnaBridge | 143:86740a56073b | 98 | /*lint -save -e30*/ |
AnnaBridge | 143:86740a56073b | 99 | NRF_RTC_EVENT_TICK = offsetof(NRF_RTC_Type,EVENTS_TICK), /**< Tick event. */ |
AnnaBridge | 143:86740a56073b | 100 | NRF_RTC_EVENT_OVERFLOW = offsetof(NRF_RTC_Type,EVENTS_OVRFLW), /**< Overflow event. */ |
AnnaBridge | 143:86740a56073b | 101 | NRF_RTC_EVENT_COMPARE_0 = offsetof(NRF_RTC_Type,EVENTS_COMPARE[0]), /**< Compare 0 event. */ |
AnnaBridge | 143:86740a56073b | 102 | NRF_RTC_EVENT_COMPARE_1 = offsetof(NRF_RTC_Type,EVENTS_COMPARE[1]), /**< Compare 1 event. */ |
AnnaBridge | 143:86740a56073b | 103 | NRF_RTC_EVENT_COMPARE_2 = offsetof(NRF_RTC_Type,EVENTS_COMPARE[2]), /**< Compare 2 event. */ |
AnnaBridge | 143:86740a56073b | 104 | NRF_RTC_EVENT_COMPARE_3 = offsetof(NRF_RTC_Type,EVENTS_COMPARE[3]) /**< Compare 3 event. */ |
AnnaBridge | 143:86740a56073b | 105 | /*lint -restore*/ |
AnnaBridge | 143:86740a56073b | 106 | } nrf_rtc_event_t; |
AnnaBridge | 143:86740a56073b | 107 | |
AnnaBridge | 143:86740a56073b | 108 | /** |
AnnaBridge | 143:86740a56073b | 109 | * @enum nrf_rtc_int_t |
AnnaBridge | 143:86740a56073b | 110 | * @brief RTC interrupts. |
AnnaBridge | 143:86740a56073b | 111 | */ |
AnnaBridge | 143:86740a56073b | 112 | typedef enum |
AnnaBridge | 143:86740a56073b | 113 | { |
AnnaBridge | 143:86740a56073b | 114 | NRF_RTC_INT_TICK_MASK = RTC_INTENSET_TICK_Msk, /**< RTC interrupt from tick event. */ |
AnnaBridge | 143:86740a56073b | 115 | NRF_RTC_INT_OVERFLOW_MASK = RTC_INTENSET_OVRFLW_Msk, /**< RTC interrupt from overflow event. */ |
AnnaBridge | 143:86740a56073b | 116 | NRF_RTC_INT_COMPARE0_MASK = RTC_INTENSET_COMPARE0_Msk, /**< RTC interrupt from compare event on channel 0. */ |
AnnaBridge | 143:86740a56073b | 117 | NRF_RTC_INT_COMPARE1_MASK = RTC_INTENSET_COMPARE1_Msk, /**< RTC interrupt from compare event on channel 1. */ |
AnnaBridge | 143:86740a56073b | 118 | NRF_RTC_INT_COMPARE2_MASK = RTC_INTENSET_COMPARE2_Msk, /**< RTC interrupt from compare event on channel 2. */ |
AnnaBridge | 143:86740a56073b | 119 | NRF_RTC_INT_COMPARE3_MASK = RTC_INTENSET_COMPARE3_Msk /**< RTC interrupt from compare event on channel 3. */ |
AnnaBridge | 143:86740a56073b | 120 | } nrf_rtc_int_t; |
AnnaBridge | 143:86740a56073b | 121 | |
AnnaBridge | 143:86740a56073b | 122 | /**@brief Function for setting a compare value for a channel. |
AnnaBridge | 143:86740a56073b | 123 | * |
AnnaBridge | 143:86740a56073b | 124 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 125 | * @param[in] ch Channel. |
AnnaBridge | 143:86740a56073b | 126 | * @param[in] cc_val Compare value to set. |
AnnaBridge | 143:86740a56073b | 127 | */ |
AnnaBridge | 143:86740a56073b | 128 | __STATIC_INLINE void nrf_rtc_cc_set(NRF_RTC_Type * p_rtc, uint32_t ch, uint32_t cc_val); |
AnnaBridge | 143:86740a56073b | 129 | |
AnnaBridge | 143:86740a56073b | 130 | /**@brief Function for returning the compare value for a channel. |
AnnaBridge | 143:86740a56073b | 131 | * |
AnnaBridge | 143:86740a56073b | 132 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 133 | * @param[in] ch Channel. |
AnnaBridge | 143:86740a56073b | 134 | * |
AnnaBridge | 143:86740a56073b | 135 | * @return COMPARE[ch] value. |
AnnaBridge | 143:86740a56073b | 136 | */ |
AnnaBridge | 143:86740a56073b | 137 | __STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type * p_rtc, uint32_t ch); |
AnnaBridge | 143:86740a56073b | 138 | |
AnnaBridge | 143:86740a56073b | 139 | /**@brief Function for enabling interrupts. |
AnnaBridge | 143:86740a56073b | 140 | * |
AnnaBridge | 143:86740a56073b | 141 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 142 | * @param[in] mask Interrupt mask to be enabled. |
AnnaBridge | 143:86740a56073b | 143 | */ |
AnnaBridge | 143:86740a56073b | 144 | __STATIC_INLINE void nrf_rtc_int_enable(NRF_RTC_Type * p_rtc, uint32_t mask); |
AnnaBridge | 143:86740a56073b | 145 | |
AnnaBridge | 143:86740a56073b | 146 | /**@brief Function for disabling interrupts. |
AnnaBridge | 143:86740a56073b | 147 | * |
AnnaBridge | 143:86740a56073b | 148 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 149 | * @param[in] mask Interrupt mask to be disabled. |
AnnaBridge | 143:86740a56073b | 150 | */ |
AnnaBridge | 143:86740a56073b | 151 | __STATIC_INLINE void nrf_rtc_int_disable(NRF_RTC_Type * p_rtc, uint32_t mask); |
AnnaBridge | 143:86740a56073b | 152 | |
AnnaBridge | 143:86740a56073b | 153 | /**@brief Function for checking if interrupts are enabled. |
AnnaBridge | 143:86740a56073b | 154 | * |
AnnaBridge | 143:86740a56073b | 155 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 156 | * @param[in] mask Mask of interrupt flags to check. |
AnnaBridge | 143:86740a56073b | 157 | * |
AnnaBridge | 143:86740a56073b | 158 | * @return Mask with enabled interrupts. |
AnnaBridge | 143:86740a56073b | 159 | */ |
AnnaBridge | 143:86740a56073b | 160 | __STATIC_INLINE uint32_t nrf_rtc_int_is_enabled(NRF_RTC_Type * p_rtc, uint32_t mask); |
AnnaBridge | 143:86740a56073b | 161 | |
AnnaBridge | 143:86740a56073b | 162 | /**@brief Function for returning the status of currently enabled interrupts. |
AnnaBridge | 143:86740a56073b | 163 | * |
AnnaBridge | 143:86740a56073b | 164 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 165 | * |
AnnaBridge | 143:86740a56073b | 166 | * @return Value in INTEN register. |
AnnaBridge | 143:86740a56073b | 167 | */ |
AnnaBridge | 143:86740a56073b | 168 | __STATIC_INLINE uint32_t nrf_rtc_int_get(NRF_RTC_Type * p_rtc); |
AnnaBridge | 143:86740a56073b | 169 | |
AnnaBridge | 143:86740a56073b | 170 | /**@brief Function for checking if an event is pending. |
AnnaBridge | 143:86740a56073b | 171 | * |
AnnaBridge | 143:86740a56073b | 172 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 173 | * @param[in] event Address of the event. |
AnnaBridge | 143:86740a56073b | 174 | * |
AnnaBridge | 143:86740a56073b | 175 | * @return Mask of pending events. |
AnnaBridge | 143:86740a56073b | 176 | */ |
AnnaBridge | 143:86740a56073b | 177 | __STATIC_INLINE uint32_t nrf_rtc_event_pending(NRF_RTC_Type * p_rtc, nrf_rtc_event_t event); |
AnnaBridge | 143:86740a56073b | 178 | |
AnnaBridge | 143:86740a56073b | 179 | /**@brief Function for clearing an event. |
AnnaBridge | 143:86740a56073b | 180 | * |
AnnaBridge | 143:86740a56073b | 181 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 182 | * @param[in] event Event to clear. |
AnnaBridge | 143:86740a56073b | 183 | */ |
AnnaBridge | 143:86740a56073b | 184 | __STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_rtc, nrf_rtc_event_t event); |
AnnaBridge | 143:86740a56073b | 185 | |
AnnaBridge | 143:86740a56073b | 186 | /**@brief Function for returning a counter value. |
AnnaBridge | 143:86740a56073b | 187 | * |
AnnaBridge | 143:86740a56073b | 188 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 189 | * |
AnnaBridge | 143:86740a56073b | 190 | * @return Counter value. |
AnnaBridge | 143:86740a56073b | 191 | */ |
AnnaBridge | 143:86740a56073b | 192 | __STATIC_INLINE uint32_t nrf_rtc_counter_get(NRF_RTC_Type * p_rtc); |
AnnaBridge | 143:86740a56073b | 193 | |
AnnaBridge | 143:86740a56073b | 194 | /**@brief Function for setting a prescaler value. |
AnnaBridge | 143:86740a56073b | 195 | * |
AnnaBridge | 143:86740a56073b | 196 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 197 | * @param[in] val Value to set the prescaler to. |
AnnaBridge | 143:86740a56073b | 198 | */ |
AnnaBridge | 143:86740a56073b | 199 | __STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_rtc, uint32_t val); |
AnnaBridge | 143:86740a56073b | 200 | |
AnnaBridge | 143:86740a56073b | 201 | /**@brief Function for returning the address of an event. |
AnnaBridge | 143:86740a56073b | 202 | * |
AnnaBridge | 143:86740a56073b | 203 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 204 | * @param[in] event Requested event. |
AnnaBridge | 143:86740a56073b | 205 | * |
AnnaBridge | 143:86740a56073b | 206 | * @return Address of the requested event register. |
AnnaBridge | 143:86740a56073b | 207 | */ |
AnnaBridge | 143:86740a56073b | 208 | __STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type * p_rtc, nrf_rtc_event_t event); |
AnnaBridge | 143:86740a56073b | 209 | |
AnnaBridge | 143:86740a56073b | 210 | /**@brief Function for returning the address of a task. |
AnnaBridge | 143:86740a56073b | 211 | * |
AnnaBridge | 143:86740a56073b | 212 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 213 | * @param[in] task Requested task. |
AnnaBridge | 143:86740a56073b | 214 | * |
AnnaBridge | 143:86740a56073b | 215 | * @return Address of the requested task register. |
AnnaBridge | 143:86740a56073b | 216 | */ |
AnnaBridge | 143:86740a56073b | 217 | __STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type * p_rtc, nrf_rtc_task_t task); |
AnnaBridge | 143:86740a56073b | 218 | |
AnnaBridge | 143:86740a56073b | 219 | /**@brief Function for starting a task. |
AnnaBridge | 143:86740a56073b | 220 | * |
AnnaBridge | 143:86740a56073b | 221 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 222 | * @param[in] task Requested task. |
AnnaBridge | 143:86740a56073b | 223 | */ |
AnnaBridge | 143:86740a56073b | 224 | __STATIC_INLINE void nrf_rtc_task_trigger(NRF_RTC_Type * p_rtc, nrf_rtc_task_t task); |
AnnaBridge | 143:86740a56073b | 225 | |
AnnaBridge | 143:86740a56073b | 226 | /**@brief Function for enabling events. |
AnnaBridge | 143:86740a56073b | 227 | * |
AnnaBridge | 143:86740a56073b | 228 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 229 | * @param[in] mask Mask of event flags to enable. |
AnnaBridge | 143:86740a56073b | 230 | */ |
AnnaBridge | 143:86740a56073b | 231 | __STATIC_INLINE void nrf_rtc_event_enable(NRF_RTC_Type * p_rtc, uint32_t mask); |
AnnaBridge | 143:86740a56073b | 232 | |
AnnaBridge | 143:86740a56073b | 233 | /**@brief Function for disabling an event. |
AnnaBridge | 143:86740a56073b | 234 | * |
AnnaBridge | 143:86740a56073b | 235 | * @param[in] p_rtc Pointer to the instance register structure. |
AnnaBridge | 143:86740a56073b | 236 | * @param[in] event Requested event. |
AnnaBridge | 143:86740a56073b | 237 | */ |
AnnaBridge | 143:86740a56073b | 238 | __STATIC_INLINE void nrf_rtc_event_disable(NRF_RTC_Type * p_rtc, uint32_t event); |
AnnaBridge | 143:86740a56073b | 239 | |
AnnaBridge | 143:86740a56073b | 240 | /** |
AnnaBridge | 143:86740a56073b | 241 | *@} |
AnnaBridge | 143:86740a56073b | 242 | **/ |
AnnaBridge | 143:86740a56073b | 243 | |
AnnaBridge | 143:86740a56073b | 244 | |
AnnaBridge | 143:86740a56073b | 245 | #ifndef SUPPRESS_INLINE_IMPLEMENTATION |
AnnaBridge | 143:86740a56073b | 246 | |
AnnaBridge | 143:86740a56073b | 247 | __STATIC_INLINE void nrf_rtc_cc_set(NRF_RTC_Type * p_rtc, uint32_t ch, uint32_t cc_val) |
AnnaBridge | 143:86740a56073b | 248 | { |
AnnaBridge | 143:86740a56073b | 249 | p_rtc->CC[ch] = cc_val; |
AnnaBridge | 143:86740a56073b | 250 | } |
AnnaBridge | 143:86740a56073b | 251 | |
AnnaBridge | 143:86740a56073b | 252 | __STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type * p_rtc, uint32_t ch) |
AnnaBridge | 143:86740a56073b | 253 | { |
AnnaBridge | 143:86740a56073b | 254 | return p_rtc->CC[ch]; |
AnnaBridge | 143:86740a56073b | 255 | } |
AnnaBridge | 143:86740a56073b | 256 | |
AnnaBridge | 143:86740a56073b | 257 | __STATIC_INLINE void nrf_rtc_int_enable(NRF_RTC_Type * p_rtc, uint32_t mask) |
AnnaBridge | 143:86740a56073b | 258 | { |
AnnaBridge | 143:86740a56073b | 259 | p_rtc->INTENSET = mask; |
AnnaBridge | 143:86740a56073b | 260 | } |
AnnaBridge | 143:86740a56073b | 261 | |
AnnaBridge | 143:86740a56073b | 262 | __STATIC_INLINE void nrf_rtc_int_disable(NRF_RTC_Type * p_rtc, uint32_t mask) |
AnnaBridge | 143:86740a56073b | 263 | { |
AnnaBridge | 143:86740a56073b | 264 | p_rtc->INTENCLR = mask; |
AnnaBridge | 143:86740a56073b | 265 | } |
AnnaBridge | 143:86740a56073b | 266 | |
AnnaBridge | 143:86740a56073b | 267 | __STATIC_INLINE uint32_t nrf_rtc_int_is_enabled(NRF_RTC_Type * p_rtc, uint32_t mask) |
AnnaBridge | 143:86740a56073b | 268 | { |
AnnaBridge | 143:86740a56073b | 269 | return (p_rtc->INTENSET & mask); |
AnnaBridge | 143:86740a56073b | 270 | } |
AnnaBridge | 143:86740a56073b | 271 | |
AnnaBridge | 143:86740a56073b | 272 | __STATIC_INLINE uint32_t nrf_rtc_int_get(NRF_RTC_Type * p_rtc) |
AnnaBridge | 143:86740a56073b | 273 | { |
AnnaBridge | 143:86740a56073b | 274 | return p_rtc->INTENSET; |
AnnaBridge | 143:86740a56073b | 275 | } |
AnnaBridge | 143:86740a56073b | 276 | |
AnnaBridge | 143:86740a56073b | 277 | __STATIC_INLINE uint32_t nrf_rtc_event_pending(NRF_RTC_Type * p_rtc, nrf_rtc_event_t event) |
AnnaBridge | 143:86740a56073b | 278 | { |
AnnaBridge | 143:86740a56073b | 279 | return *(volatile uint32_t *)((uint8_t *)p_rtc + (uint32_t)event); |
AnnaBridge | 143:86740a56073b | 280 | } |
AnnaBridge | 143:86740a56073b | 281 | |
AnnaBridge | 143:86740a56073b | 282 | __STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_rtc, nrf_rtc_event_t event) |
AnnaBridge | 143:86740a56073b | 283 | { |
AnnaBridge | 143:86740a56073b | 284 | *((volatile uint32_t *)((uint8_t *)p_rtc + (uint32_t)event)) = 0; |
AnnaBridge | 143:86740a56073b | 285 | #if __CORTEX_M == 0x04 |
AnnaBridge | 143:86740a56073b | 286 | volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_rtc + (uint32_t)event)); |
AnnaBridge | 143:86740a56073b | 287 | (void)dummy; |
AnnaBridge | 143:86740a56073b | 288 | #endif |
AnnaBridge | 143:86740a56073b | 289 | } |
AnnaBridge | 143:86740a56073b | 290 | |
AnnaBridge | 143:86740a56073b | 291 | __STATIC_INLINE uint32_t nrf_rtc_counter_get(NRF_RTC_Type * p_rtc) |
AnnaBridge | 143:86740a56073b | 292 | { |
AnnaBridge | 143:86740a56073b | 293 | return p_rtc->COUNTER; |
AnnaBridge | 143:86740a56073b | 294 | } |
AnnaBridge | 143:86740a56073b | 295 | |
AnnaBridge | 143:86740a56073b | 296 | __STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_rtc, uint32_t val) |
AnnaBridge | 143:86740a56073b | 297 | { |
AnnaBridge | 143:86740a56073b | 298 | ASSERT(val <= (RTC_PRESCALER_PRESCALER_Msk >> RTC_PRESCALER_PRESCALER_Pos)); |
AnnaBridge | 143:86740a56073b | 299 | p_rtc->PRESCALER = val; |
AnnaBridge | 143:86740a56073b | 300 | } |
AnnaBridge | 143:86740a56073b | 301 | __STATIC_INLINE uint32_t rtc_prescaler_get(NRF_RTC_Type * p_rtc) |
AnnaBridge | 143:86740a56073b | 302 | { |
AnnaBridge | 143:86740a56073b | 303 | return p_rtc->PRESCALER; |
AnnaBridge | 143:86740a56073b | 304 | } |
AnnaBridge | 143:86740a56073b | 305 | |
AnnaBridge | 143:86740a56073b | 306 | __STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type * p_rtc, nrf_rtc_event_t event) |
AnnaBridge | 143:86740a56073b | 307 | { |
AnnaBridge | 143:86740a56073b | 308 | return (uint32_t)p_rtc + event; |
AnnaBridge | 143:86740a56073b | 309 | } |
AnnaBridge | 143:86740a56073b | 310 | |
AnnaBridge | 143:86740a56073b | 311 | __STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type * p_rtc, nrf_rtc_task_t task) |
AnnaBridge | 143:86740a56073b | 312 | { |
AnnaBridge | 143:86740a56073b | 313 | return (uint32_t)p_rtc + task; |
AnnaBridge | 143:86740a56073b | 314 | } |
AnnaBridge | 143:86740a56073b | 315 | |
AnnaBridge | 143:86740a56073b | 316 | __STATIC_INLINE void nrf_rtc_task_trigger(NRF_RTC_Type * p_rtc, nrf_rtc_task_t task) |
AnnaBridge | 143:86740a56073b | 317 | { |
AnnaBridge | 143:86740a56073b | 318 | *(__IO uint32_t *)((uint32_t)p_rtc + task) = 1; |
AnnaBridge | 143:86740a56073b | 319 | } |
AnnaBridge | 143:86740a56073b | 320 | |
AnnaBridge | 143:86740a56073b | 321 | __STATIC_INLINE void nrf_rtc_event_enable(NRF_RTC_Type * p_rtc, uint32_t mask) |
AnnaBridge | 143:86740a56073b | 322 | { |
AnnaBridge | 143:86740a56073b | 323 | p_rtc->EVTENSET = mask; |
AnnaBridge | 143:86740a56073b | 324 | } |
AnnaBridge | 143:86740a56073b | 325 | __STATIC_INLINE void nrf_rtc_event_disable(NRF_RTC_Type * p_rtc, uint32_t mask) |
AnnaBridge | 143:86740a56073b | 326 | { |
AnnaBridge | 143:86740a56073b | 327 | p_rtc->EVTENCLR = mask; |
AnnaBridge | 143:86740a56073b | 328 | } |
AnnaBridge | 143:86740a56073b | 329 | #endif |
AnnaBridge | 143:86740a56073b | 330 | |
AnnaBridge | 143:86740a56073b | 331 | #endif /* NRF_RTC_H */ |