Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions drivers/timer/nrf_rtc_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@

#if (CONFIG_NRF_RTC_COUNTER_BIT_WIDTH < RTC_BIT_WIDTH)
#define CUSTOM_COUNTER_BIT_WIDTH 1
#define WRAP_CH 1
#define WRAP_CH 0
#define SYS_CLOCK_CH 1
#include "nrfx_ppi.h"
#else
#define CUSTOM_COUNTER_BIT_WIDTH 0
#define SYS_CLOCK_CH 0
#endif

Check notice on line 30 in drivers/timer/nrf_rtc_timer.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/timer/nrf_rtc_timer.c:30 -#define WRAP_CH 0 -#define SYS_CLOCK_CH 1 +#define WRAP_CH 0 +#define SYS_CLOCK_CH 1 #include "nrfx_ppi.h" #else #define CUSTOM_COUNTER_BIT_WIDTH 0 -#define SYS_CLOCK_CH 0 +#define SYS_CLOCK_CH 0

#define RTC_PRETICK (IS_ENABLED(CONFIG_SOC_NRF53_RTC_PRETICK) && \
IS_ENABLED(CONFIG_SOC_NRF5340_CPUNET))
Expand All @@ -37,7 +39,6 @@
#define RTC_IRQn NRFX_IRQ_NUMBER_GET(RTC)
#define RTC_LABEL rtc1
#define CHAN_COUNT_MAX (RTC1_CC_NUM - (RTC_PRETICK ? 1 : 0))
#define SYS_CLOCK_CH 0

BUILD_ASSERT(CHAN_COUNT <= CHAN_COUNT_MAX, "Not enough compare channels");
/* Ensure that counter driver for RTC1 is not enabled. */
Expand Down Expand Up @@ -275,15 +276,6 @@
*/
enum { MIN_CYCLES_FROM_NOW = 3 };
uint32_t cc_val = req_cc;

#if CUSTOM_COUNTER_BIT_WIDTH
/* If a CC value is 0 when a CLEAR task is set, this will not
* trigger a COMAPRE event. Need to use 1 instead.
*/
if (cc_val % COUNTER_MAX == 0) {
cc_val = 1;
}
#endif
uint32_t cc_inc = MIN_CYCLES_FROM_NOW;

/* Disable event routing for the channel to avoid getting a COMPARE
Expand All @@ -299,6 +291,14 @@
for (;;) {
uint32_t now;

#if CUSTOM_COUNTER_BIT_WIDTH
/* If a CC value is 0 when a CLEAR task is set, this will not
* trigger a COMAPRE event. Need to use 1 instead.
*/
if ((cc_val & COUNTER_MAX) == 0) {
cc_val = 1;
}
#endif
set_comparator(chan, cc_val);
/* Enable event routing after the required CC value was set.
* Even though the above operation may get repeated (see below),
Expand Down Expand Up @@ -597,16 +597,16 @@
}

#if CUSTOM_COUNTER_BIT_WIDTH
if (nrfy_rtc_int_enable_check(RTC, NRF_RTC_INT_COMPARE1_MASK) &&
nrfy_rtc_events_process(RTC, NRF_RTC_INT_COMPARE1_MASK)) {
if (nrfy_rtc_int_enable_check(RTC, NRF_RTC_CHANNEL_INT_MASK(WRAP_CH)) &&
nrfy_rtc_events_process(RTC, NRF_RTC_CHANNEL_INT_MASK(WRAP_CH))) {
#else
if (nrfy_rtc_int_enable_check(RTC, NRF_RTC_INT_OVERFLOW_MASK) &&
nrfy_rtc_events_process(RTC, NRF_RTC_INT_OVERFLOW_MASK)) {
#endif
overflow_cnt++;
}

for (int32_t chan = 0; chan < CHAN_COUNT; chan++) {
for (int32_t chan = SYS_CLOCK_CH; chan < CHAN_COUNT; chan++) {
process_channel(chan);
}
}
Expand Down
Loading