Nordic stack and drivers for the mbed BLE API
Dependents: BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate writable_gatt ... more
TARGET_MCU_NRF51822/sdk/source/drivers_nrf/hal/nrf_wdt.h@638:c90ae1400bf2, 2016-09-14 (annotated)
- Committer:
- Vincent Coubard
- Date:
- Wed Sep 14 14:39:43 2016 +0100
- Revision:
- 638:c90ae1400bf2
Sync with bdab10dc0f90748b6989c8b577771bb403ca6bd8 from ARMmbed/mbed-os.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Vincent Coubard |
638:c90ae1400bf2 | 1 | /* |
Vincent Coubard |
638:c90ae1400bf2 | 2 | * Copyright (c) Nordic Semiconductor ASA |
Vincent Coubard |
638:c90ae1400bf2 | 3 | * All rights reserved. |
Vincent Coubard |
638:c90ae1400bf2 | 4 | * |
Vincent Coubard |
638:c90ae1400bf2 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
Vincent Coubard |
638:c90ae1400bf2 | 6 | * are permitted provided that the following conditions are met: |
Vincent Coubard |
638:c90ae1400bf2 | 7 | * |
Vincent Coubard |
638:c90ae1400bf2 | 8 | * 1. Redistributions of source code must retain the above copyright notice, this |
Vincent Coubard |
638:c90ae1400bf2 | 9 | * list of conditions and the following disclaimer. |
Vincent Coubard |
638:c90ae1400bf2 | 10 | * |
Vincent Coubard |
638:c90ae1400bf2 | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, this |
Vincent Coubard |
638:c90ae1400bf2 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
Vincent Coubard |
638:c90ae1400bf2 | 13 | * other materials provided with the distribution. |
Vincent Coubard |
638:c90ae1400bf2 | 14 | * |
Vincent Coubard |
638:c90ae1400bf2 | 15 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of other |
Vincent Coubard |
638:c90ae1400bf2 | 16 | * contributors to this software may be used to endorse or promote products |
Vincent Coubard |
638:c90ae1400bf2 | 17 | * derived from this software without specific prior written permission. |
Vincent Coubard |
638:c90ae1400bf2 | 18 | * |
Vincent Coubard |
638:c90ae1400bf2 | 19 | * |
Vincent Coubard |
638:c90ae1400bf2 | 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
Vincent Coubard |
638:c90ae1400bf2 | 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Vincent Coubard |
638:c90ae1400bf2 | 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Vincent Coubard |
638:c90ae1400bf2 | 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
Vincent Coubard |
638:c90ae1400bf2 | 24 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
Vincent Coubard |
638:c90ae1400bf2 | 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Vincent Coubard |
638:c90ae1400bf2 | 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
Vincent Coubard |
638:c90ae1400bf2 | 27 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Vincent Coubard |
638:c90ae1400bf2 | 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Vincent Coubard |
638:c90ae1400bf2 | 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Vincent Coubard |
638:c90ae1400bf2 | 30 | * |
Vincent Coubard |
638:c90ae1400bf2 | 31 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 32 | |
Vincent Coubard |
638:c90ae1400bf2 | 33 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 34 | * @defgroup nrf_wdt_hal WDT HAL |
Vincent Coubard |
638:c90ae1400bf2 | 35 | * @{ |
Vincent Coubard |
638:c90ae1400bf2 | 36 | * @ingroup nrf_wdt |
Vincent Coubard |
638:c90ae1400bf2 | 37 | * |
Vincent Coubard |
638:c90ae1400bf2 | 38 | * @brief Hardware access layer for accessing the watchdog timer (WDT) peripheral. |
Vincent Coubard |
638:c90ae1400bf2 | 39 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 40 | |
Vincent Coubard |
638:c90ae1400bf2 | 41 | #ifndef NRF_WDT_H__ |
Vincent Coubard |
638:c90ae1400bf2 | 42 | #define NRF_WDT_H__ |
Vincent Coubard |
638:c90ae1400bf2 | 43 | |
Vincent Coubard |
638:c90ae1400bf2 | 44 | #include <stddef.h> |
Vincent Coubard |
638:c90ae1400bf2 | 45 | #include <stdbool.h> |
Vincent Coubard |
638:c90ae1400bf2 | 46 | #include <stdint.h> |
Vincent Coubard |
638:c90ae1400bf2 | 47 | |
Vincent Coubard |
638:c90ae1400bf2 | 48 | #include "nrf.h" |
Vincent Coubard |
638:c90ae1400bf2 | 49 | |
Vincent Coubard |
638:c90ae1400bf2 | 50 | #define NRF_WDT_CHANNEL_NUMBER 0x8UL |
Vincent Coubard |
638:c90ae1400bf2 | 51 | #define NRF_WDT_RR_VALUE 0x6E524635UL /* Fixed value, shouldn't be modified.*/ |
Vincent Coubard |
638:c90ae1400bf2 | 52 | |
Vincent Coubard |
638:c90ae1400bf2 | 53 | #define NRF_WDT_TASK_SET 1UL |
Vincent Coubard |
638:c90ae1400bf2 | 54 | #define NRF_WDT_EVENT_CLEAR 0UL |
Vincent Coubard |
638:c90ae1400bf2 | 55 | |
Vincent Coubard |
638:c90ae1400bf2 | 56 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 57 | * @enum nrf_wdt_task_t |
Vincent Coubard |
638:c90ae1400bf2 | 58 | * @brief WDT tasks. |
Vincent Coubard |
638:c90ae1400bf2 | 59 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 60 | typedef enum |
Vincent Coubard |
638:c90ae1400bf2 | 61 | { |
Vincent Coubard |
638:c90ae1400bf2 | 62 | /*lint -save -e30 -esym(628,__INTADDR__)*/ |
Vincent Coubard |
638:c90ae1400bf2 | 63 | NRF_WDT_TASK_START = offsetof(NRF_WDT_Type, TASKS_START), /**< Task for starting WDT. */ |
Vincent Coubard |
638:c90ae1400bf2 | 64 | /*lint -restore*/ |
Vincent Coubard |
638:c90ae1400bf2 | 65 | } nrf_wdt_task_t; |
Vincent Coubard |
638:c90ae1400bf2 | 66 | |
Vincent Coubard |
638:c90ae1400bf2 | 67 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 68 | * @enum nrf_wdt_event_t |
Vincent Coubard |
638:c90ae1400bf2 | 69 | * @brief WDT events. |
Vincent Coubard |
638:c90ae1400bf2 | 70 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 71 | typedef enum |
Vincent Coubard |
638:c90ae1400bf2 | 72 | { |
Vincent Coubard |
638:c90ae1400bf2 | 73 | /*lint -save -e30*/ |
Vincent Coubard |
638:c90ae1400bf2 | 74 | NRF_WDT_EVENT_TIMEOUT = offsetof(NRF_WDT_Type, EVENTS_TIMEOUT), /**< Event from WDT time-out. */ |
Vincent Coubard |
638:c90ae1400bf2 | 75 | /*lint -restore*/ |
Vincent Coubard |
638:c90ae1400bf2 | 76 | } nrf_wdt_event_t; |
Vincent Coubard |
638:c90ae1400bf2 | 77 | |
Vincent Coubard |
638:c90ae1400bf2 | 78 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 79 | * @enum nrf_wdt_behaviour_t |
Vincent Coubard |
638:c90ae1400bf2 | 80 | * @brief WDT behavior in CPU SLEEP or HALT mode. |
Vincent Coubard |
638:c90ae1400bf2 | 81 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 82 | typedef enum |
Vincent Coubard |
638:c90ae1400bf2 | 83 | { |
Vincent Coubard |
638:c90ae1400bf2 | 84 | NRF_WDT_BEHAVIOUR_RUN_SLEEP = WDT_CONFIG_SLEEP_Msk, /**< WDT will run when CPU is in SLEEP mode. */ |
Vincent Coubard |
638:c90ae1400bf2 | 85 | NRF_WDT_BEHAVIOUR_RUN_HALT = WDT_CONFIG_HALT_Msk, /**< WDT will run when CPU is in HALT mode. */ |
Vincent Coubard |
638:c90ae1400bf2 | 86 | NRF_WDT_BEHAVIOUR_RUN_SLEEP_HALT = WDT_CONFIG_SLEEP_Msk | WDT_CONFIG_HALT_Msk, /**< WDT will run when CPU is in SLEEP or HALT mode. */ |
Vincent Coubard |
638:c90ae1400bf2 | 87 | NRF_WDT_BEHAVIOUR_PAUSE_SLEEP_HALT = 0, /**< WDT will be paused when CPU is in SLEEP or HALT mode. */ |
Vincent Coubard |
638:c90ae1400bf2 | 88 | } nrf_wdt_behaviour_t; |
Vincent Coubard |
638:c90ae1400bf2 | 89 | |
Vincent Coubard |
638:c90ae1400bf2 | 90 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 91 | * @enum nrf_wdt_rr_register_t |
Vincent Coubard |
638:c90ae1400bf2 | 92 | * @brief WDT reload request registers. |
Vincent Coubard |
638:c90ae1400bf2 | 93 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 94 | typedef enum |
Vincent Coubard |
638:c90ae1400bf2 | 95 | { |
Vincent Coubard |
638:c90ae1400bf2 | 96 | NRF_WDT_RR0 = 0, /**< Reload request register 0. */ |
Vincent Coubard |
638:c90ae1400bf2 | 97 | NRF_WDT_RR1, /**< Reload request register 1. */ |
Vincent Coubard |
638:c90ae1400bf2 | 98 | NRF_WDT_RR2, /**< Reload request register 2. */ |
Vincent Coubard |
638:c90ae1400bf2 | 99 | NRF_WDT_RR3, /**< Reload request register 3. */ |
Vincent Coubard |
638:c90ae1400bf2 | 100 | NRF_WDT_RR4, /**< Reload request register 4. */ |
Vincent Coubard |
638:c90ae1400bf2 | 101 | NRF_WDT_RR5, /**< Reload request register 5. */ |
Vincent Coubard |
638:c90ae1400bf2 | 102 | NRF_WDT_RR6, /**< Reload request register 6. */ |
Vincent Coubard |
638:c90ae1400bf2 | 103 | NRF_WDT_RR7 /**< Reload request register 7. */ |
Vincent Coubard |
638:c90ae1400bf2 | 104 | } nrf_wdt_rr_register_t; |
Vincent Coubard |
638:c90ae1400bf2 | 105 | |
Vincent Coubard |
638:c90ae1400bf2 | 106 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 107 | * @enum nrf_wdt_int_mask_t |
Vincent Coubard |
638:c90ae1400bf2 | 108 | * @brief WDT interrupts. |
Vincent Coubard |
638:c90ae1400bf2 | 109 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 110 | typedef enum |
Vincent Coubard |
638:c90ae1400bf2 | 111 | { |
Vincent Coubard |
638:c90ae1400bf2 | 112 | NRF_WDT_INT_TIMEOUT_MASK = WDT_INTENSET_TIMEOUT_Msk, /**< WDT interrupt from time-out event. */ |
Vincent Coubard |
638:c90ae1400bf2 | 113 | } nrf_wdt_int_mask_t; |
Vincent Coubard |
638:c90ae1400bf2 | 114 | |
Vincent Coubard |
638:c90ae1400bf2 | 115 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 116 | * @brief Function for configuring the watchdog behavior when the CPU is sleeping or halted. |
Vincent Coubard |
638:c90ae1400bf2 | 117 | * |
Vincent Coubard |
638:c90ae1400bf2 | 118 | * @param behaviour Watchdog behavior when CPU is in SLEEP or HALT mode. |
Vincent Coubard |
638:c90ae1400bf2 | 119 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 120 | __STATIC_INLINE void nrf_wdt_behaviour_set(nrf_wdt_behaviour_t behaviour) |
Vincent Coubard |
638:c90ae1400bf2 | 121 | { |
Vincent Coubard |
638:c90ae1400bf2 | 122 | NRF_WDT->CONFIG = behaviour; |
Vincent Coubard |
638:c90ae1400bf2 | 123 | } |
Vincent Coubard |
638:c90ae1400bf2 | 124 | |
Vincent Coubard |
638:c90ae1400bf2 | 125 | |
Vincent Coubard |
638:c90ae1400bf2 | 126 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 127 | * @brief Function for starting the watchdog. |
Vincent Coubard |
638:c90ae1400bf2 | 128 | * |
Vincent Coubard |
638:c90ae1400bf2 | 129 | * @param[in] task Task. |
Vincent Coubard |
638:c90ae1400bf2 | 130 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 131 | __STATIC_INLINE void nrf_wdt_task_trigger(nrf_wdt_task_t task) |
Vincent Coubard |
638:c90ae1400bf2 | 132 | { |
Vincent Coubard |
638:c90ae1400bf2 | 133 | *((volatile uint32_t *)((uint8_t *)NRF_WDT + task)) = NRF_WDT_TASK_SET; |
Vincent Coubard |
638:c90ae1400bf2 | 134 | } |
Vincent Coubard |
638:c90ae1400bf2 | 135 | |
Vincent Coubard |
638:c90ae1400bf2 | 136 | |
Vincent Coubard |
638:c90ae1400bf2 | 137 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 138 | * @brief Function for clearing the WDT event. |
Vincent Coubard |
638:c90ae1400bf2 | 139 | * |
Vincent Coubard |
638:c90ae1400bf2 | 140 | * @param[in] event Event. |
Vincent Coubard |
638:c90ae1400bf2 | 141 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 142 | __STATIC_INLINE void nrf_wdt_event_clear(nrf_wdt_event_t event) |
Vincent Coubard |
638:c90ae1400bf2 | 143 | { |
Vincent Coubard |
638:c90ae1400bf2 | 144 | *((volatile uint32_t *)((uint8_t *)NRF_WDT + (uint32_t)event)) = NRF_WDT_EVENT_CLEAR; |
Vincent Coubard |
638:c90ae1400bf2 | 145 | } |
Vincent Coubard |
638:c90ae1400bf2 | 146 | |
Vincent Coubard |
638:c90ae1400bf2 | 147 | |
Vincent Coubard |
638:c90ae1400bf2 | 148 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 149 | * @brief Function for retrieving the state of the WDT event. |
Vincent Coubard |
638:c90ae1400bf2 | 150 | * |
Vincent Coubard |
638:c90ae1400bf2 | 151 | * @param[in] event Event. |
Vincent Coubard |
638:c90ae1400bf2 | 152 | * |
Vincent Coubard |
638:c90ae1400bf2 | 153 | * @retval true If the event is set. |
Vincent Coubard |
638:c90ae1400bf2 | 154 | * @retval false If the event is not set. |
Vincent Coubard |
638:c90ae1400bf2 | 155 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 156 | __STATIC_INLINE bool nrf_wdt_event_check(nrf_wdt_event_t event) |
Vincent Coubard |
638:c90ae1400bf2 | 157 | { |
Vincent Coubard |
638:c90ae1400bf2 | 158 | return (bool)*((volatile uint32_t *)((uint8_t *)NRF_WDT + event)); |
Vincent Coubard |
638:c90ae1400bf2 | 159 | } |
Vincent Coubard |
638:c90ae1400bf2 | 160 | |
Vincent Coubard |
638:c90ae1400bf2 | 161 | |
Vincent Coubard |
638:c90ae1400bf2 | 162 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 163 | * @brief Function for enabling a specific interrupt. |
Vincent Coubard |
638:c90ae1400bf2 | 164 | * |
Vincent Coubard |
638:c90ae1400bf2 | 165 | * @param[in] int_mask Interrupt. |
Vincent Coubard |
638:c90ae1400bf2 | 166 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 167 | __STATIC_INLINE void nrf_wdt_int_enable(uint32_t int_mask) |
Vincent Coubard |
638:c90ae1400bf2 | 168 | { |
Vincent Coubard |
638:c90ae1400bf2 | 169 | NRF_WDT->INTENSET = int_mask; |
Vincent Coubard |
638:c90ae1400bf2 | 170 | } |
Vincent Coubard |
638:c90ae1400bf2 | 171 | |
Vincent Coubard |
638:c90ae1400bf2 | 172 | |
Vincent Coubard |
638:c90ae1400bf2 | 173 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 174 | * @brief Function for retrieving the state of given interrupt. |
Vincent Coubard |
638:c90ae1400bf2 | 175 | * |
Vincent Coubard |
638:c90ae1400bf2 | 176 | * @param[in] int_mask Interrupt. |
Vincent Coubard |
638:c90ae1400bf2 | 177 | * |
Vincent Coubard |
638:c90ae1400bf2 | 178 | * @retval true Interrupt is enabled. |
Vincent Coubard |
638:c90ae1400bf2 | 179 | * @retval false Interrupt is not enabled. |
Vincent Coubard |
638:c90ae1400bf2 | 180 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 181 | __STATIC_INLINE bool nrf_wdt_int_enable_check(uint32_t int_mask) |
Vincent Coubard |
638:c90ae1400bf2 | 182 | { |
Vincent Coubard |
638:c90ae1400bf2 | 183 | return (bool)(NRF_WDT->INTENSET & int_mask); |
Vincent Coubard |
638:c90ae1400bf2 | 184 | } |
Vincent Coubard |
638:c90ae1400bf2 | 185 | |
Vincent Coubard |
638:c90ae1400bf2 | 186 | |
Vincent Coubard |
638:c90ae1400bf2 | 187 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 188 | * @brief Function for disabling a specific interrupt. |
Vincent Coubard |
638:c90ae1400bf2 | 189 | * |
Vincent Coubard |
638:c90ae1400bf2 | 190 | * @param[in] int_mask Interrupt. |
Vincent Coubard |
638:c90ae1400bf2 | 191 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 192 | __STATIC_INLINE void nrf_wdt_int_disable(uint32_t int_mask) |
Vincent Coubard |
638:c90ae1400bf2 | 193 | { |
Vincent Coubard |
638:c90ae1400bf2 | 194 | NRF_WDT->INTENCLR = int_mask; |
Vincent Coubard |
638:c90ae1400bf2 | 195 | } |
Vincent Coubard |
638:c90ae1400bf2 | 196 | |
Vincent Coubard |
638:c90ae1400bf2 | 197 | |
Vincent Coubard |
638:c90ae1400bf2 | 198 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 199 | * @brief Function for returning the address of a specific WDT task register. |
Vincent Coubard |
638:c90ae1400bf2 | 200 | * |
Vincent Coubard |
638:c90ae1400bf2 | 201 | * @param[in] task Task. |
Vincent Coubard |
638:c90ae1400bf2 | 202 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 203 | __STATIC_INLINE uint32_t nrf_wdt_task_address_get(nrf_wdt_task_t task) |
Vincent Coubard |
638:c90ae1400bf2 | 204 | { |
Vincent Coubard |
638:c90ae1400bf2 | 205 | return ((uint32_t)NRF_WDT + task); |
Vincent Coubard |
638:c90ae1400bf2 | 206 | } |
Vincent Coubard |
638:c90ae1400bf2 | 207 | |
Vincent Coubard |
638:c90ae1400bf2 | 208 | |
Vincent Coubard |
638:c90ae1400bf2 | 209 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 210 | * @brief Function for returning the address of a specific WDT event register. |
Vincent Coubard |
638:c90ae1400bf2 | 211 | * |
Vincent Coubard |
638:c90ae1400bf2 | 212 | * @param[in] event Event. |
Vincent Coubard |
638:c90ae1400bf2 | 213 | * |
Vincent Coubard |
638:c90ae1400bf2 | 214 | * @retval address of requested event register |
Vincent Coubard |
638:c90ae1400bf2 | 215 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 216 | __STATIC_INLINE uint32_t nrf_wdt_event_address_get(nrf_wdt_event_t event) |
Vincent Coubard |
638:c90ae1400bf2 | 217 | { |
Vincent Coubard |
638:c90ae1400bf2 | 218 | return ((uint32_t)NRF_WDT + event); |
Vincent Coubard |
638:c90ae1400bf2 | 219 | } |
Vincent Coubard |
638:c90ae1400bf2 | 220 | |
Vincent Coubard |
638:c90ae1400bf2 | 221 | |
Vincent Coubard |
638:c90ae1400bf2 | 222 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 223 | * @brief Function for retrieving the watchdog status. |
Vincent Coubard |
638:c90ae1400bf2 | 224 | * |
Vincent Coubard |
638:c90ae1400bf2 | 225 | * @retval true If the watchdog is started. |
Vincent Coubard |
638:c90ae1400bf2 | 226 | * @retval false If the watchdog is not started. |
Vincent Coubard |
638:c90ae1400bf2 | 227 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 228 | __STATIC_INLINE bool nrf_wdt_started(void) |
Vincent Coubard |
638:c90ae1400bf2 | 229 | { |
Vincent Coubard |
638:c90ae1400bf2 | 230 | return (bool)(NRF_WDT->RUNSTATUS); |
Vincent Coubard |
638:c90ae1400bf2 | 231 | } |
Vincent Coubard |
638:c90ae1400bf2 | 232 | |
Vincent Coubard |
638:c90ae1400bf2 | 233 | |
Vincent Coubard |
638:c90ae1400bf2 | 234 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 235 | * @brief Function for retrieving the watchdog reload request status. |
Vincent Coubard |
638:c90ae1400bf2 | 236 | * |
Vincent Coubard |
638:c90ae1400bf2 | 237 | * @param[in] rr_register Reload request register to check. |
Vincent Coubard |
638:c90ae1400bf2 | 238 | * |
Vincent Coubard |
638:c90ae1400bf2 | 239 | * @retval true If a reload request is running. |
Vincent Coubard |
638:c90ae1400bf2 | 240 | * @retval false If no reload request is running. |
Vincent Coubard |
638:c90ae1400bf2 | 241 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 242 | __STATIC_INLINE bool nrf_wdt_request_status(nrf_wdt_rr_register_t rr_register) |
Vincent Coubard |
638:c90ae1400bf2 | 243 | { |
Vincent Coubard |
638:c90ae1400bf2 | 244 | return (bool)(((NRF_WDT->REQSTATUS) >> rr_register) & 0x1UL); |
Vincent Coubard |
638:c90ae1400bf2 | 245 | } |
Vincent Coubard |
638:c90ae1400bf2 | 246 | |
Vincent Coubard |
638:c90ae1400bf2 | 247 | |
Vincent Coubard |
638:c90ae1400bf2 | 248 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 249 | * @brief Function for setting the watchdog reload value. |
Vincent Coubard |
638:c90ae1400bf2 | 250 | * |
Vincent Coubard |
638:c90ae1400bf2 | 251 | * @param[in] reload_value Watchdog counter initial value. |
Vincent Coubard |
638:c90ae1400bf2 | 252 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 253 | __STATIC_INLINE void nrf_wdt_reload_value_set(uint32_t reload_value) |
Vincent Coubard |
638:c90ae1400bf2 | 254 | { |
Vincent Coubard |
638:c90ae1400bf2 | 255 | NRF_WDT->CRV = reload_value; |
Vincent Coubard |
638:c90ae1400bf2 | 256 | } |
Vincent Coubard |
638:c90ae1400bf2 | 257 | |
Vincent Coubard |
638:c90ae1400bf2 | 258 | |
Vincent Coubard |
638:c90ae1400bf2 | 259 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 260 | * @brief Function for retrieving the watchdog reload value. |
Vincent Coubard |
638:c90ae1400bf2 | 261 | * |
Vincent Coubard |
638:c90ae1400bf2 | 262 | * @retval Reload value. |
Vincent Coubard |
638:c90ae1400bf2 | 263 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 264 | __STATIC_INLINE uint32_t nrf_wdt_reload_value_get(void) |
Vincent Coubard |
638:c90ae1400bf2 | 265 | { |
Vincent Coubard |
638:c90ae1400bf2 | 266 | return (uint32_t)NRF_WDT->CRV; |
Vincent Coubard |
638:c90ae1400bf2 | 267 | } |
Vincent Coubard |
638:c90ae1400bf2 | 268 | |
Vincent Coubard |
638:c90ae1400bf2 | 269 | |
Vincent Coubard |
638:c90ae1400bf2 | 270 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 271 | * @brief Function for enabling a specific reload request register. |
Vincent Coubard |
638:c90ae1400bf2 | 272 | * |
Vincent Coubard |
638:c90ae1400bf2 | 273 | * @param[in] rr_register Reload request register to enable. |
Vincent Coubard |
638:c90ae1400bf2 | 274 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 275 | __STATIC_INLINE void nrf_wdt_reload_request_enable(nrf_wdt_rr_register_t rr_register) |
Vincent Coubard |
638:c90ae1400bf2 | 276 | { |
Vincent Coubard |
638:c90ae1400bf2 | 277 | NRF_WDT->RREN |= 0x1UL << rr_register; |
Vincent Coubard |
638:c90ae1400bf2 | 278 | } |
Vincent Coubard |
638:c90ae1400bf2 | 279 | |
Vincent Coubard |
638:c90ae1400bf2 | 280 | |
Vincent Coubard |
638:c90ae1400bf2 | 281 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 282 | * @brief Function for disabling a specific reload request register. |
Vincent Coubard |
638:c90ae1400bf2 | 283 | * |
Vincent Coubard |
638:c90ae1400bf2 | 284 | * @param[in] rr_register Reload request register to disable. |
Vincent Coubard |
638:c90ae1400bf2 | 285 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 286 | __STATIC_INLINE void nrf_wdt_reload_request_disable(nrf_wdt_rr_register_t rr_register) |
Vincent Coubard |
638:c90ae1400bf2 | 287 | { |
Vincent Coubard |
638:c90ae1400bf2 | 288 | NRF_WDT->RREN &= ~(0x1UL << rr_register); |
Vincent Coubard |
638:c90ae1400bf2 | 289 | } |
Vincent Coubard |
638:c90ae1400bf2 | 290 | |
Vincent Coubard |
638:c90ae1400bf2 | 291 | |
Vincent Coubard |
638:c90ae1400bf2 | 292 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 293 | * @brief Function for retrieving the status of a specific reload request register. |
Vincent Coubard |
638:c90ae1400bf2 | 294 | * |
Vincent Coubard |
638:c90ae1400bf2 | 295 | * @param[in] rr_register Reload request register to check. |
Vincent Coubard |
638:c90ae1400bf2 | 296 | * |
Vincent Coubard |
638:c90ae1400bf2 | 297 | * @retval true If the reload request register is enabled. |
Vincent Coubard |
638:c90ae1400bf2 | 298 | * @retval false If the reload request register is not enabled. |
Vincent Coubard |
638:c90ae1400bf2 | 299 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 300 | __STATIC_INLINE bool nrf_wdt_reload_request_is_enabled(nrf_wdt_rr_register_t rr_register) |
Vincent Coubard |
638:c90ae1400bf2 | 301 | { |
Vincent Coubard |
638:c90ae1400bf2 | 302 | return (bool)(NRF_WDT->RREN & (0x1UL << rr_register)); |
Vincent Coubard |
638:c90ae1400bf2 | 303 | } |
Vincent Coubard |
638:c90ae1400bf2 | 304 | |
Vincent Coubard |
638:c90ae1400bf2 | 305 | |
Vincent Coubard |
638:c90ae1400bf2 | 306 | /** |
Vincent Coubard |
638:c90ae1400bf2 | 307 | * @brief Function for setting a specific reload request register. |
Vincent Coubard |
638:c90ae1400bf2 | 308 | * |
Vincent Coubard |
638:c90ae1400bf2 | 309 | * @param[in] rr_register Reload request register to set. |
Vincent Coubard |
638:c90ae1400bf2 | 310 | */ |
Vincent Coubard |
638:c90ae1400bf2 | 311 | __STATIC_INLINE void nrf_wdt_reload_request_set(nrf_wdt_rr_register_t rr_register) |
Vincent Coubard |
638:c90ae1400bf2 | 312 | { |
Vincent Coubard |
638:c90ae1400bf2 | 313 | NRF_WDT->RR[rr_register] = NRF_WDT_RR_VALUE; |
Vincent Coubard |
638:c90ae1400bf2 | 314 | } |
Vincent Coubard |
638:c90ae1400bf2 | 315 | |
Vincent Coubard |
638:c90ae1400bf2 | 316 | |
Vincent Coubard |
638:c90ae1400bf2 | 317 | #endif |
Vincent Coubard |
638:c90ae1400bf2 | 318 | |
Vincent Coubard |
638:c90ae1400bf2 | 319 | /** @} */ |