Skip to content

Commit a280fbf

Browse files
adamkondraciukkartben
authored andcommitted
drivers: timer: nrf_grtc_timer: Add frequency parameter for K32SRC
Add frequency value for LFCLK sources to be used when `lfxo` node is not present. Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
1 parent cc86ce7 commit a280fbf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/timer/nrf_grtc_timer.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@
5454

5555
#define MAX_CYCLES (MAX_TICKS * CYC_PER_TICK)
5656

57+
#if DT_NODE_HAS_STATUS_OKAY(LFCLK_NODE)
5758
#define LFCLK_FREQUENCY_HZ DT_PROP(LFCLK_NODE, clock_frequency)
59+
#else
60+
#define LFCLK_FREQUENCY_HZ CONFIG_CLOCK_CONTROL_NRF_K32SRC_FREQUENCY
61+
#endif
5862

5963
#if defined(CONFIG_TEST)
6064
const int32_t z_sys_timer_irq_for_test = DT_IRQN(GRTC_NODE);
@@ -414,8 +418,8 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
414418

415419
/* This mechanism ensures that stored CC value is latched. */
416420
uint32_t wait_time =
417-
nrfy_grtc_timeout_get(NRF_GRTC) * CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / 32768 +
418-
MAX_CC_LATCH_WAIT_TIME_US;
421+
nrfy_grtc_timeout_get(NRF_GRTC) * CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC /
422+
LFCLK_FREQUENCY_HZ + MAX_CC_LATCH_WAIT_TIME_US;
419423
k_busy_wait(wait_time);
420424
k_spin_unlock(&lock, key);
421425
return 0;

0 commit comments

Comments
 (0)