Skip to content

Commit f1c2a89

Browse files
committed
treewide: Replace clock api with clock api v2
Replaced old clock_control.h api with nrf_clock_control.h api. Old api is still available when CONFIG_CLOCK_CONTROL_NRF is set. Replaced nrfx_clock.h api calls with nrfx_clock_... calls. Signed-off-by: Michal Frankiewicz <[email protected]>
1 parent 4911a49 commit f1c2a89

File tree

39 files changed

+298
-146
lines changed

39 files changed

+298
-146
lines changed

applications/nrf5340_audio/src/audio/audio_datapath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <zephyr/zbus/zbus.h>
1313
#include <zephyr/kernel.h>
1414
#include <zephyr/shell/shell.h>
15-
#include <nrfx_clock.h>
15+
#include <nrfx_clock_hfclkaudio.h>
1616
#include <contin_array.h>
1717
#include <tone.h>
1818
#include <pcm_mix.h>

applications/nrf5340_audio/src/audio/le_audio_rx.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include <stdlib.h>
1010
#include <zephyr/kernel.h>
11-
#include <nrfx_clock.h>
1211

1312
#include "streamctrl.h"
1413
#include "audio_datapath.h"

applications/nrf5340_audio/src/modules/audio_i2s.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <zephyr/device.h>
1111
#include <zephyr/drivers/pinctrl.h>
1212
#include <nrfx_i2s.h>
13-
#include <nrfx_clock.h>
13+
#include <nrfx_clock_hfclkaudio.h>
1414

1515
#include "audio_sync_timer.h"
1616

applications/nrf5340_audio/src/utils/peripherals.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
#include "peripherals.h"
77

8-
#include <nrfx_clock.h>
8+
#include <nrfx_clock_hfclk.h>
99

1010
#include "led_assignments.h"
1111
#include "led.h"
@@ -148,10 +148,7 @@ int peripherals_init(void)
148148
}
149149

150150
/* Use this to turn on 128 MHz clock for cpu_app */
151-
ret = nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);
152-
if (ret) {
153-
return ret;
154-
}
151+
nrfx_clock_hfclk_divider_set(NRF_CLOCK_HFCLK_DIV_1);
155152

156153
return 0;
157154
}

applications/nrf_desktop/configuration/nrf52dmouse_nrf52832/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ CONFIG_QDEC_NRFX=y
8989
CONFIG_SPI=y
9090
CONFIG_SPI_NRFX=y
9191

92-
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
92+
CONFIG_CLOCK_CONTROL_NRF=n
9393

9494
CONFIG_BT_MAX_PAIRED=2
9595
CONFIG_BT_ID_MAX=3

applications/nrf_desktop/configuration/nrf52dmouse_nrf52832/prj_release.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ CONFIG_QDEC_NRFX=y
8484
CONFIG_SPI=y
8585
CONFIG_SPI_NRFX=y
8686

87-
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
87+
CONFIG_CLOCK_CONTROL_NRF=n
8888

8989
CONFIG_BT_MAX_PAIRED=2
9090
CONFIG_BT_ID_MAX=3

applications/nrf_desktop/configuration/nrf52kbd_nrf52832/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ CONFIG_LED_PWM=y
102102
# Disable unused LED driver to reduce memory footprint.
103103
CONFIG_LED_GPIO=n
104104

105-
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
105+
CONFIG_CLOCK_CONTROL_NRF=n
106106

107107
CONFIG_BT_MAX_PAIRED=4
108108
CONFIG_BT_ID_MAX=5

applications/nrf_desktop/configuration/nrf52kbd_nrf52832/prj_release.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ CONFIG_LED_PWM=y
9999
# Disable unused LED driver to reduce memory footprint.
100100
CONFIG_LED_GPIO=n
101101

102-
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
102+
CONFIG_CLOCK_CONTROL_NRF=n
103103

104104
CONFIG_BT_MAX_PAIRED=4
105105
CONFIG_BT_ID_MAX=5

applications/nrf_desktop/configuration/nrf52kbd_nrf52832/prj_release_fast_pair.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ CONFIG_LED_PWM=y
116116
# Disable unused LED driver to reduce memory footprint.
117117
CONFIG_LED_GPIO=n
118118

119-
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
119+
CONFIG_CLOCK_CONTROL_NRF=n
120120

121121
# Enable MCUmgr Bluetooth transport and increase Bluetooth buffers to speed up DFU image transfer.
122122
CONFIG_MCUMGR_TRANSPORT_BT=y

applications/nrf_desktop/src/modules/hfclk_lock.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@
1717
#include <zephyr/logging/log.h>
1818
LOG_MODULE_REGISTER(MODULE);
1919

20+
#if defined(CONFIG_CLOCK_CONTROL_NRF)
2021
static struct onoff_manager *mgr;
22+
#else
23+
static struct device *dev;
24+
#endif
2125
static struct onoff_client cli;
2226

2327
static void hfclk_lock(void)
2428
{
29+
#if defined(CONFIG_CLOCK_CONTROL_NRF)
2530
if (mgr) {
2631
return;
2732
}
@@ -41,19 +46,52 @@ static void hfclk_lock(void)
4146
module_set_state(MODULE_STATE_READY);
4247
}
4348
}
49+
#else
50+
if (dev) {
51+
return;
52+
}
53+
54+
dev = DEVICE_DT_GET_ONE(COND_CODE_1((NRF_CLOCK_HAS_HFCLK),
55+
(nordic_nrf_clock_hfclk),
56+
(nordic_nrf_clock_xo)));
57+
if (!dev) {
58+
module_set_state(MODULE_STATE_ERROR);
59+
} else {
60+
int err;
61+
62+
sys_notify_init_spinwait(&cli.notify);
63+
err = nrf_clock_control_request(dev, NULL, &cli);
64+
if (err < 0) {
65+
dev = NULL;
66+
module_set_state(MODULE_STATE_ERROR);
67+
} else {
68+
module_set_state(MODULE_STATE_READY);
69+
}
70+
}
71+
#endif
4472
}
4573

4674
static void hfclk_unlock(void)
4775
{
4876
int err;
4977

78+
#if defined(CONFIG_CLOCK_CONTROL_NRF)
5079
if (!mgr) {
5180
return;
5281
}
5382

5483
err = onoff_cancel_or_release(mgr, &cli);
5584
module_set_state((err < 0) ? MODULE_STATE_ERROR : MODULE_STATE_OFF);
5685
mgr = NULL;
86+
#else
87+
if (!dev) {
88+
return;
89+
}
90+
91+
err = nrf_clock_control_cancel_or_release(dev, NULL, &cli);
92+
module_set_state((err < 0) ? MODULE_STATE_ERROR : MODULE_STATE_OFF);
93+
dev = NULL;
94+
#endif
5795
}
5896

5997

0 commit comments

Comments
 (0)