-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
main.c
50 lines (40 loc) · 962 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#include <zephyr/sys/printk.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
static void clock_init(void)
{
int err;
int res;
struct onoff_manager *clk_mgr;
struct onoff_client clk_cli;
clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
if (!clk_mgr) {
printk("Unable to get the Clock manager\n");
return;
}
sys_notify_init_spinwait(&clk_cli.notify);
err = onoff_request(clk_mgr, &clk_cli);
if (err < 0) {
printk("Clock request failed: %d\n", err);
return;
}
do {
err = sys_notify_fetch_result(&clk_cli.notify, &res);
if (!err && res) {
printk("Clock could not be started: %d\n", res);
return;
}
} while (err);
printk("Clock has started\n");
}
int main(void)
{
printk("Starting Radio Test example\n");
clock_init();
return 0;
}