1 /*
2  * Copyright (c) 2014 - 2024, Nordic Semiconductor ASA
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  *    list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  *    contributors may be used to endorse or promote products derived from this
19  *    software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef NRF_RTC_H
35 #define NRF_RTC_H
36 
37 #include <nrfx.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #if !defined(NRF_RTC0) && defined(NRF_RTC)
44 #define NRF_RTC0    NRF_RTC
45 #define RTC0_CC_NUM RTC_CC_NUM
46 #endif
47 
48 /**
49  * @defgroup nrf_rtc_hal RTC HAL
50  * @{
51  * @ingroup nrf_rtc
52  * @brief   Hardware access layer for managing the Real Time Counter (RTC) peripheral.
53  */
54 
55 /**
56  * @brief Macro getting pointer to the structure of registers of the RTC peripheral.
57  *
58  * @param[in] idx RTC instance index.
59  *
60  * @return Pointer to the structure of registers of the RTC peripheral.
61  */
62 #define NRF_RTC_INST_GET(idx) NRFX_CONCAT(NRF_, RTC, idx)
63 
64 /** @brief Macro for getting the number of compare channels available in a given RTC instance. */
65 #define NRF_RTC_CC_CHANNEL_COUNT(id)  NRFX_CONCAT_3(RTC, id, _CC_NUM)
66 
67 /** @brief Symbol specifying maximum number of available compare channels. */
68 #define NRF_RTC_CC_COUNT_MAX NRFX_ARRAY_SIZE(((NRF_RTC_Type*)0)->EVENTS_COMPARE)
69 
70 /** @brief Maximum value of the RTC counter. */
71 #define NRF_RTC_COUNTER_MAX RTC_COUNTER_COUNTER_Msk
72 
73 /** @brief Input frequency of the RTC instance. */
74 #define NRF_RTC_INPUT_FREQ 32768
75 
76 /** @brief Macro for converting expected frequency to prescaler setting. */
77 #define NRF_RTC_FREQ_TO_PRESCALER(FREQ) (uint16_t)(((NRF_RTC_INPUT_FREQ) / (FREQ)) - 1)
78 
79 /** @brief Macro for trimming values to the RTC bit width. */
80 #define NRF_RTC_WRAP(val) ((val) & RTC_COUNTER_COUNTER_Msk)
81 
82 /** @brief Macro for creating the interrupt bitmask for the specified compare channel. */
83 #define NRF_RTC_CHANNEL_INT_MASK(ch)    ((uint32_t)(NRF_RTC_INT_COMPARE0_MASK) << (ch))
84 
85 /** @brief Macro for creating the interrupt bitmask for all compare channels */
86 #define NRF_RTC_ALL_CHANNELS_INT_MASK \
87     ((uint32_t)(((1 << NRF_RTC_CC_COUNT_MAX) - 1) << RTC_INTENSET_COMPARE0_Pos))
88 
89 /** @brief Macro for obtaining the compare event for the specified channel. */
90 #define NRF_RTC_CHANNEL_EVENT_ADDR(ch) \
91     (nrf_rtc_event_t)((NRF_RTC_EVENT_COMPARE_0) + (ch) * sizeof(uint32_t))
92 
93 /** @brief RTC tasks. */
94 typedef enum
95 {
96     NRF_RTC_TASK_START            = offsetof(NRF_RTC_Type,TASKS_START),      /**< Start. */
97     NRF_RTC_TASK_STOP             = offsetof(NRF_RTC_Type,TASKS_STOP),       /**< Stop. */
98     NRF_RTC_TASK_CLEAR            = offsetof(NRF_RTC_Type,TASKS_CLEAR),      /**< Clear. */
99     NRF_RTC_TASK_TRIGGER_OVERFLOW = offsetof(NRF_RTC_Type,TASKS_TRIGOVRFLW), /**< Trigger overflow. */
100 #if defined(RTC_TASKS_CAPTURE_TASKS_CAPTURE_Msk) || defined(__NRFX_DOXYGEN__)
101     NRF_RTC_TASK_CAPTURE_0        = offsetof(NRF_RTC_Type,TASKS_CAPTURE[0]), /**< Capture the counter value on channel 0. */
102     NRF_RTC_TASK_CAPTURE_1        = offsetof(NRF_RTC_Type,TASKS_CAPTURE[1]), /**< Capture the counter value on channel 1. */
103     NRF_RTC_TASK_CAPTURE_2        = offsetof(NRF_RTC_Type,TASKS_CAPTURE[2]), /**< Capture the counter value on channel 2. */
104     NRF_RTC_TASK_CAPTURE_3        = offsetof(NRF_RTC_Type,TASKS_CAPTURE[3]), /**< Capture the counter value on channel 3. */
105 #endif
106 } nrf_rtc_task_t;
107 
108 /** @brief RTC events. */
109 typedef enum
110 {
111     NRF_RTC_EVENT_TICK        = offsetof(NRF_RTC_Type,EVENTS_TICK),       /**< Tick event. */
112     NRF_RTC_EVENT_OVERFLOW    = offsetof(NRF_RTC_Type,EVENTS_OVRFLW),     /**< Overflow event. */
113     NRF_RTC_EVENT_COMPARE_0   = offsetof(NRF_RTC_Type,EVENTS_COMPARE[0]), /**< Compare 0 event. */
114     NRF_RTC_EVENT_COMPARE_1   = offsetof(NRF_RTC_Type,EVENTS_COMPARE[1]), /**< Compare 1 event. */
115     NRF_RTC_EVENT_COMPARE_2   = offsetof(NRF_RTC_Type,EVENTS_COMPARE[2]), /**< Compare 2 event. */
116     NRF_RTC_EVENT_COMPARE_3   = offsetof(NRF_RTC_Type,EVENTS_COMPARE[3])  /**< Compare 3 event. */
117 } nrf_rtc_event_t;
118 
119 /** @brief RTC interrupts. */
120 typedef enum
121 {
122     NRF_RTC_INT_TICK_MASK     = RTC_INTENSET_TICK_Msk,     /**< RTC interrupt from tick event. */
123     NRF_RTC_INT_OVERFLOW_MASK = RTC_INTENSET_OVRFLW_Msk,   /**< RTC interrupt from overflow event. */
124     NRF_RTC_INT_COMPARE0_MASK = RTC_INTENSET_COMPARE0_Msk, /**< RTC interrupt from compare event on channel 0. */
125     NRF_RTC_INT_COMPARE1_MASK = RTC_INTENSET_COMPARE1_Msk, /**< RTC interrupt from compare event on channel 1. */
126     NRF_RTC_INT_COMPARE2_MASK = RTC_INTENSET_COMPARE2_Msk, /**< RTC interrupt from compare event on channel 2. */
127     NRF_RTC_INT_COMPARE3_MASK = RTC_INTENSET_COMPARE3_Msk  /**< RTC interrupt from compare event on channel 3. */
128 } nrf_rtc_int_t;
129 
130 /**
131  * @brief Function for setting a compare value for a channel.
132  *
133  * @param[in] p_reg  Pointer to the structure of registers of the peripheral.
134  * @param[in] ch     Channel.
135  * @param[in] cc_val Compare value to be set.
136  */
137 NRF_STATIC_INLINE void nrf_rtc_cc_set(NRF_RTC_Type * p_reg, uint32_t ch, uint32_t cc_val);
138 
139 /**
140  * @brief Function for returning the compare value for a channel.
141  *
142  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
143  * @param[in] ch    Channel.
144  *
145  * @return COMPARE[ch] value.
146  */
147 NRF_STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type const * p_reg, uint32_t ch);
148 
149 /**
150  * @brief Function for enabling interrupts.
151  *
152  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
153  * @param[in] mask  Mask of interrupts to be enabled.
154  *                  Use @ref nrf_rtc_int_t values for bit masking.
155  */
156 NRF_STATIC_INLINE void nrf_rtc_int_enable(NRF_RTC_Type * p_reg, uint32_t mask);
157 
158 /**
159  * @brief Function for disabling interrupts.
160  *
161  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
162  * @param[in] mask  Mask of interrupts to be disabled.
163  *                  Use @ref nrf_rtc_int_t values for bit masking.
164  */
165 NRF_STATIC_INLINE void nrf_rtc_int_disable(NRF_RTC_Type * p_reg, uint32_t mask);
166 
167 /**
168  * @brief Function for checking if the specified interrupts are enabled.
169  *
170  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
171  * @param[in] mask  Mask of interrupts to be checked.
172  *                  Use @ref nrf_rtc_int_t values for bit masking.
173  *
174  * @return Mask of enabled interrupts.
175  */
176 NRF_STATIC_INLINE uint32_t nrf_rtc_int_enable_check(NRF_RTC_Type const * p_reg, uint32_t mask);
177 
178 #if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
179 /**
180  * @brief Function for setting the subscribe configuration for a given
181  *        RTC task.
182  *
183  * @param[in] p_reg   Pointer to the structure of registers of the peripheral.
184  * @param[in] task    Task for which to set the configuration.
185  * @param[in] channel Channel through which to subscribe events.
186  */
187 NRF_STATIC_INLINE void nrf_rtc_subscribe_set(NRF_RTC_Type * p_reg,
188                                              nrf_rtc_task_t task,
189                                              uint8_t        channel);
190 
191 /**
192  * @brief Function for clearing the subscribe configuration for a given
193  *        RTC task.
194  *
195  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
196  * @param[in] task  Task for which to clear the configuration.
197  */
198 NRF_STATIC_INLINE void nrf_rtc_subscribe_clear(NRF_RTC_Type * p_reg,
199                                                nrf_rtc_task_t task);
200 
201 /**
202  * @brief Function for setting the publish configuration for a given
203  *        RTC event.
204  *
205  * @param[in] p_reg   Pointer to the structure of registers of the peripheral.
206  * @param[in] event   Event for which to set the configuration.
207  * @param[in] channel Channel through which to publish the event.
208  */
209 NRF_STATIC_INLINE void nrf_rtc_publish_set(NRF_RTC_Type *  p_reg,
210                                            nrf_rtc_event_t event,
211                                            uint8_t         channel);
212 
213 /**
214  * @brief Function for clearing the publish configuration for a given
215  *        RTC event.
216  *
217  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
218  * @param[in] event Event for which to clear the configuration.
219  */
220 NRF_STATIC_INLINE void nrf_rtc_publish_clear(NRF_RTC_Type *  p_reg,
221                                              nrf_rtc_event_t event);
222 #endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
223 
224 /**
225  * @brief Function for retrieving the state of the RTC event.
226  *
227  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
228  * @param[in] event Event to be checked.
229  *
230  * @retval true  The event has been generated.
231  * @retval false The event has not been generated.
232  */
233 NRF_STATIC_INLINE bool nrf_rtc_event_check(NRF_RTC_Type const * p_reg, nrf_rtc_event_t event);
234 
235 /**
236  * @brief Function for clearing an event.
237  *
238  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
239  * @param[in] event Event to be cleared.
240  */
241 NRF_STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t event);
242 
243 /**
244  * @brief Function for returning a counter value.
245  *
246  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
247  *
248  * @return Counter value.
249  */
250 NRF_STATIC_INLINE uint32_t nrf_rtc_counter_get(NRF_RTC_Type const * p_reg);
251 
252 /**
253  * @brief Function for setting a prescaler value.
254  *
255  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
256  * @param[in] val   Value to set the prescaler to.
257  */
258 NRF_STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val);
259 
260 /**
261  * @brief Function for getting a prescaler value.
262  *
263  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
264  *
265  * @return Prescaler value.
266  */
267 NRF_STATIC_INLINE uint32_t nrf_rtc_prescaler_get(NRF_RTC_Type const * p_reg);
268 
269 /**
270  * @brief Function for returning the address of an event.
271  *
272  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
273  * @param[in] event Requested event.
274  *
275  * @return Address of the requested event register.
276  */
277 NRF_STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type const * p_reg,
278                                                      nrf_rtc_event_t      event);
279 
280 /**
281  * @brief Function for returning the address of a task.
282  *
283  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
284  * @param[in] task  Requested task.
285  *
286  * @return Address of the requested task register.
287  */
288 NRF_STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type const * p_reg,
289                                                     nrf_rtc_task_t       task);
290 
291 #if defined(RTC_TASKS_CAPTURE_TASKS_CAPTURE_Msk) || defined(__NRFX_DOXYGEN__)
292 /**
293  * @brief Function for getting the CAPTURE task associated with the specified capture channel.
294  *
295  * @param[in] index Capture channel index.
296  *
297  * @return Requested CAPTURE task.
298  */
299 NRF_STATIC_INLINE nrf_rtc_task_t nrf_rtc_capture_task_get(uint8_t index);
300 #endif
301 
302 /**
303  * @brief Function for starting a task.
304  *
305  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
306  * @param[in] task  Requested task.
307  */
308 NRF_STATIC_INLINE void nrf_rtc_task_trigger(NRF_RTC_Type * p_reg, nrf_rtc_task_t task);
309 
310 /**
311  * @brief Function for enabling events.
312  *
313  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
314  * @param[in] mask  Mask of event flags to be enabled.
315  */
316 NRF_STATIC_INLINE void nrf_rtc_event_enable(NRF_RTC_Type * p_reg, uint32_t mask);
317 
318 /**
319  * @brief Function for disabling an event.
320  *
321  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
322  * @param[in] mask  Mask of event flags to be disabled.
323  */
324 NRF_STATIC_INLINE void nrf_rtc_event_disable(NRF_RTC_Type * p_reg, uint32_t mask);
325 
326 /**
327  * @brief Function for getting the COMPARE event associated with the specified compare channel.
328  *
329  * @param[in] index Compare channel index.
330  *
331  * @return Requested COMPARE event.
332  */
333 NRF_STATIC_INLINE nrf_rtc_event_t nrf_rtc_compare_event_get(uint8_t index);
334 
335 #ifndef NRF_DECLARE_ONLY
336 
nrf_rtc_cc_set(NRF_RTC_Type * p_reg,uint32_t ch,uint32_t cc_val)337 NRF_STATIC_INLINE  void nrf_rtc_cc_set(NRF_RTC_Type * p_reg, uint32_t ch, uint32_t cc_val)
338 {
339     p_reg->CC[ch] = cc_val;
340 }
341 
nrf_rtc_cc_get(NRF_RTC_Type const * p_reg,uint32_t ch)342 NRF_STATIC_INLINE  uint32_t nrf_rtc_cc_get(NRF_RTC_Type const * p_reg, uint32_t ch)
343 {
344     return p_reg->CC[ch];
345 }
346 
nrf_rtc_int_enable(NRF_RTC_Type * p_reg,uint32_t mask)347 NRF_STATIC_INLINE void nrf_rtc_int_enable(NRF_RTC_Type * p_reg, uint32_t mask)
348 {
349     p_reg->INTENSET = mask;
350 }
351 
nrf_rtc_int_disable(NRF_RTC_Type * p_reg,uint32_t mask)352 NRF_STATIC_INLINE void nrf_rtc_int_disable(NRF_RTC_Type * p_reg, uint32_t mask)
353 {
354     p_reg->INTENCLR = mask;
355 }
356 
nrf_rtc_int_enable_check(NRF_RTC_Type const * p_reg,uint32_t mask)357 NRF_STATIC_INLINE uint32_t nrf_rtc_int_enable_check(NRF_RTC_Type const * p_reg, uint32_t mask)
358 {
359     return p_reg->INTENSET & mask;
360 }
361 
362 #if defined(DPPI_PRESENT)
nrf_rtc_subscribe_set(NRF_RTC_Type * p_reg,nrf_rtc_task_t task,uint8_t channel)363 NRF_STATIC_INLINE void nrf_rtc_subscribe_set(NRF_RTC_Type * p_reg,
364                                              nrf_rtc_task_t task,
365                                              uint8_t        channel)
366 {
367     *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
368             ((uint32_t)channel | NRF_SUBSCRIBE_PUBLISH_ENABLE);
369 }
370 
nrf_rtc_subscribe_clear(NRF_RTC_Type * p_reg,nrf_rtc_task_t task)371 NRF_STATIC_INLINE void nrf_rtc_subscribe_clear(NRF_RTC_Type * p_reg,
372                                                nrf_rtc_task_t task)
373 {
374     *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
375 }
376 
nrf_rtc_publish_set(NRF_RTC_Type * p_reg,nrf_rtc_event_t event,uint8_t channel)377 NRF_STATIC_INLINE void nrf_rtc_publish_set(NRF_RTC_Type *  p_reg,
378                                            nrf_rtc_event_t event,
379                                            uint8_t         channel)
380 {
381     *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
382             ((uint32_t)channel | NRF_SUBSCRIBE_PUBLISH_ENABLE);
383 }
384 
nrf_rtc_publish_clear(NRF_RTC_Type * p_reg,nrf_rtc_event_t event)385 NRF_STATIC_INLINE void nrf_rtc_publish_clear(NRF_RTC_Type *  p_reg,
386                                              nrf_rtc_event_t event)
387 {
388     *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
389 }
390 #endif // defined(DPPI_PRESENT)
391 
nrf_rtc_event_check(NRF_RTC_Type const * p_reg,nrf_rtc_event_t event)392 NRF_STATIC_INLINE bool nrf_rtc_event_check(NRF_RTC_Type const * p_reg, nrf_rtc_event_t event)
393 {
394     return nrf_event_check(p_reg, event);
395 }
396 
nrf_rtc_event_clear(NRF_RTC_Type * p_reg,nrf_rtc_event_t event)397 NRF_STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type * p_reg, nrf_rtc_event_t event)
398 {
399     *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0;
400     nrf_event_readback((uint8_t *)p_reg + (uint32_t)event);
401 }
402 
nrf_rtc_counter_get(NRF_RTC_Type const * p_reg)403 NRF_STATIC_INLINE uint32_t nrf_rtc_counter_get(NRF_RTC_Type const * p_reg)
404 {
405      return p_reg->COUNTER;
406 }
407 
nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg,uint32_t val)408 NRF_STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type * p_reg, uint32_t val)
409 {
410     NRFX_ASSERT(val <= (RTC_PRESCALER_PRESCALER_Msk >> RTC_PRESCALER_PRESCALER_Pos));
411     p_reg->PRESCALER = val;
412 }
413 
nrf_rtc_prescaler_get(NRF_RTC_Type const * p_reg)414 NRF_STATIC_INLINE uint32_t nrf_rtc_prescaler_get(NRF_RTC_Type const * p_reg)
415 {
416     return p_reg->PRESCALER;
417 }
418 
nrf_rtc_event_address_get(NRF_RTC_Type const * p_reg,nrf_rtc_event_t event)419 NRF_STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type const * p_reg,
420                                                      nrf_rtc_event_t      event)
421 {
422     return (uint32_t)p_reg + event;
423 }
424 
nrf_rtc_task_address_get(NRF_RTC_Type const * p_reg,nrf_rtc_task_t task)425 NRF_STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type const * p_reg,
426                                                     nrf_rtc_task_t       task)
427 {
428     return (uint32_t)p_reg + task;
429 }
430 
431 #if defined(RTC_TASKS_CAPTURE_TASKS_CAPTURE_Msk)
nrf_rtc_capture_task_get(uint8_t index)432 NRF_STATIC_INLINE nrf_rtc_task_t nrf_rtc_capture_task_get(uint8_t index)
433 {
434     return (nrf_rtc_task_t)NRFX_OFFSETOF(NRF_RTC_Type, TASKS_CAPTURE[index]);
435 }
436 #endif
437 
nrf_rtc_task_trigger(NRF_RTC_Type * p_reg,nrf_rtc_task_t task)438 NRF_STATIC_INLINE void nrf_rtc_task_trigger(NRF_RTC_Type * p_reg, nrf_rtc_task_t task)
439 {
440     *(__IO uint32_t *)((uint32_t)p_reg + task) = 1;
441 }
442 
nrf_rtc_event_enable(NRF_RTC_Type * p_reg,uint32_t mask)443 NRF_STATIC_INLINE void nrf_rtc_event_enable(NRF_RTC_Type * p_reg, uint32_t mask)
444 {
445     p_reg->EVTENSET = mask;
446 }
447 
nrf_rtc_event_disable(NRF_RTC_Type * p_reg,uint32_t mask)448 NRF_STATIC_INLINE void nrf_rtc_event_disable(NRF_RTC_Type * p_reg, uint32_t mask)
449 {
450     p_reg->EVTENCLR = mask;
451 }
452 
nrf_rtc_compare_event_get(uint8_t index)453 NRF_STATIC_INLINE nrf_rtc_event_t nrf_rtc_compare_event_get(uint8_t index)
454 {
455     return (nrf_rtc_event_t)NRFX_OFFSETOF(NRF_RTC_Type, EVENTS_COMPARE[index]);
456 }
457 
458 #endif // NRF_DECLARE_ONLY
459 
460 /** @} */
461 
462 #ifdef __cplusplus
463 }
464 #endif
465 
466 #endif  /* NRF_RTC_H */
467