Loading...
Searching...
No Matches
nrf_clock.h
1/*
2 * Copyright (C) 2022 Gunar Schorcht
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
23#ifndef NRF52_NRF_CLOCK_H
24#define NRF52_NRF_CLOCK_H
25
26#include <stdbool.h>
27
28#include "nrf.h"
29#include_next "nrf_clock.h"
30
31#if !DOXYGEN
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#define NRF_CLOCK_HFCLK_HIGH_ACCURACY (1UL)
38#define NRF_CLOCK_EVENT_HFCLKSTARTED offsetof(NRF_CLOCK_Type, EVENTS_HFCLKSTARTED)
39
40typedef enum {
41 NRF_CLOCK_TASK_HFCLKSTART,
42 NRF_CLOCK_TASK_HFCLKSTOP,
43} nrf_clock_task_t;
44
56static bool _nrf_clock_hf_running = false;
57
61static inline bool nrf_clock_hf_is_running(NRF_CLOCK_Type const *reg,
62 uint32_t clk_src)
63{
64
65 return _nrf_clock_hf_running;
66}
67
74static inline bool nrf_clock_event_clear(NRF_CLOCK_Type *reg, uint32_t event)
75{
76 (void)reg;
77 (void)event;
78 return true;
79}
80
86static inline void nrf_clock_task_trigger(NRF_CLOCK_Type *reg,
87 nrf_clock_task_t task)
88{
89 switch (task) {
90 case NRF_CLOCK_TASK_HFCLKSTART:
92 _nrf_clock_hf_running = true;
93 break;
94 case NRF_CLOCK_TASK_HFCLKSTOP:
96 _nrf_clock_hf_running = false;
97 break;
98 default:
99 break;
100 }
101}
102
103#ifdef __cplusplus
104}
105#endif
106
107#endif /* !DOXYGEN */
108#endif /* NRF52_NRF_CLOCK_H */
void clock_hfxo_request(void)
Request the external high frequency crystal (HFXO) as HF clock source.
void clock_hfxo_release(void)
Release the use of the HFXO.
event structure
Definition event.h:148