drivers: counter: Adapt to use device tree

Modifying counter drivers (rtc and timer) to rely completely on
device tree and not on Kconfig of MDK flags.

Adapting dtsi for all SoCs and adapting test configuration.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2023-03-16 13:48:40 +01:00 committed by Carles Cufí
parent a7a051801b
commit 656b0e6426
49 changed files with 347 additions and 412 deletions

View file

@ -2,109 +2,25 @@
# SPDX-License-Identifier: Apache-2.0
config COUNTER_NRF_TIMER
bool
def_bool y
depends on DT_HAS_NORDIC_NRF_TIMER_ENABLED
config COUNTER_NRF_RTC
bool
config COUNTER_TIMER0
bool "Counter on TIMER0"
depends on HAS_HW_NRF_TIMER0
depends on !NRF_HW_TIMER0_RESERVED
select COUNTER_NRF_TIMER
config COUNTER_TIMER0_ZLI
bool "Event in ZLI interrupt context"
depends on COUNTER_TIMER0
depends on ZERO_LATENCY_IRQS
config COUNTER_TIMER1
bool "Counter on TIMER1"
depends on HAS_HW_NRF_TIMER1
depends on !NRF_HW_TIMER1_RESERVED
select COUNTER_NRF_TIMER
config COUNTER_TIMER1_ZLI
bool "Event in ZLI interrupt context"
depends on COUNTER_TIMER1
depends on ZERO_LATENCY_IRQS
config COUNTER_TIMER2
bool "Counter on TIMER2"
depends on HAS_HW_NRF_TIMER2
depends on !NRF_HW_TIMER2_RESERVED
select COUNTER_NRF_TIMER
config COUNTER_TIMER2_ZLI
bool "Event in ZLI interrupt context"
depends on COUNTER_TIMER2
depends on ZERO_LATENCY_IRQS
config COUNTER_TIMER3
bool "Counter on TIMER3"
depends on HAS_HW_NRF_TIMER3
depends on !NRF_HW_TIMER3_RESERVED
select COUNTER_NRF_TIMER
config COUNTER_TIMER3_ZLI
bool "Event in ZLI interrupt context"
depends on COUNTER_TIMER3
depends on ZERO_LATENCY_IRQS
config COUNTER_TIMER4
bool "Counter on TIMER4"
depends on HAS_HW_NRF_TIMER4
depends on !NRF_HW_TIMER4_RESERVED
select COUNTER_NRF_TIMER
config COUNTER_TIMER4_ZLI
bool "Event in ZLI interrupt context"
depends on COUNTER_TIMER4
depends on ZERO_LATENCY_IRQS
config COUNTER_RTC0
bool "Counter on RTC0"
depends on HAS_HW_NRF_RTC0
depends on !NRF_HW_RTC0_RESERVED
select COUNTER_NRF_RTC
config COUNTER_RTC0_ZLI
bool "Event in ZLI interrupt context"
depends on COUNTER_RTC0
depends on ZERO_LATENCY_IRQS
config COUNTER_RTC1
bool "Counter on RTC1"
depends on HAS_HW_NRF_RTC1
depends on !NRF_HW_RTC1_RESERVED
select COUNTER_NRF_RTC
config COUNTER_RTC1_ZLI
bool "Event in ZLI interrupt context"
depends on COUNTER_RTC1
depends on ZERO_LATENCY_IRQS
config COUNTER_RTC2
bool "Counter on RTC2"
depends on HAS_HW_NRF_RTC2
depends on !NRF_HW_RTC2_RESERVED
select COUNTER_NRF_RTC
config COUNTER_RTC2_ZLI
bool "Event in ZLI interrupt context"
depends on COUNTER_RTC2
depends on ZERO_LATENCY_IRQS
def_bool y
depends on DT_HAS_NORDIC_NRF_RTC_ENABLED
# Internal flag which detects if PPI wrap feature is enabled for any instance
config COUNTER_RTC_WITH_PPI_WRAP
def_bool ($(dt_nodelabel_bool_prop,rtc0,ppi-wrap) && COUNTER_RTC0) || \
($(dt_nodelabel_bool_prop,rtc1,ppi-wrap) && COUNTER_RTC1) || \
($(dt_nodelabel_bool_prop,rtc2,ppi-wrap) && COUNTER_RTC2)
def_bool $(dt_nodelabel_bool_prop,rtc0,ppi-wrap) || \
$(dt_nodelabel_bool_prop,rtc1,ppi-wrap) || \
$(dt_nodelabel_bool_prop,rtc2,ppi-wrap)
depends on COUNTER_NRF_RTC
select NRFX_PPI if HAS_HW_NRF_PPI
select NRFX_DPPI if HAS_HW_NRF_DPPIC
# Internal flag which detects if fixed top feature is enabled for any instance
config COUNTER_RTC_CUSTOM_TOP_SUPPORT
def_bool (!$(dt_nodelabel_bool_prop,rtc0,fixed-top) && COUNTER_RTC0) || \
(!$(dt_nodelabel_bool_prop,rtc1,fixed-top) && COUNTER_RTC1) || \
(!$(dt_nodelabel_bool_prop,rtc2,fixed-top) && COUNTER_RTC2)
def_bool !$(dt_nodelabel_bool_prop,rtc0,fixed-top) || \
!$(dt_nodelabel_bool_prop,rtc1,fixed-top) || \
!$(dt_nodelabel_bool_prop,rtc2,fixed-top)
depends on COUNTER_NRF_RTC

View file

@ -30,6 +30,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_COUNTER_LOG_LEVEL);
#define DBG(...) LOG_INST_DBG( \
((const struct counter_nrfx_config *)dev->config)->log, __VA_ARGS__)
#define DT_DRV_COMPAT nordic_nrf_rtc
#define COUNTER_MAX_TOP_VALUE RTC_COUNTER_COUNTER_Msk
#define COUNTER_GET_TOP_CH(dev) counter_get_num_of_channels(dev)
@ -388,7 +390,7 @@ static int ppi_setup(const struct device *dev, uint8_t chan)
}
nrf_rtc_subscribe_set(rtc, NRF_RTC_TASK_CLEAR, data->ppi_ch);
nrf_rtc_publish_set(rtc->p_reg, evt, data->ppi_ch);
nrf_rtc_publish_set(rtc, evt, data->ppi_ch);
(void)nrfx_dppi_channel_enable(data->ppi_ch);
#else /* DPPI_PRESENT */
uint32_t evt_addr;
@ -422,7 +424,6 @@ static void ppi_free(const struct device *dev, uint8_t chan)
}
nrf_rtc_event_disable(rtc, RTC_CHANNEL_INT_MASK(chan));
#ifdef DPPI_PRESENT
NRF_RTC_Type *rtc = nrfx_config->rtc;
nrf_rtc_event_t evt = RTC_CHANNEL_EVENT_ADDR(chan);
(void)nrfx_dppi_channel_disable(ppi_ch);
@ -674,72 +675,60 @@ static const struct counter_driver_api counter_nrfx_driver_api = {
* are indexed by peripheral number, so DT_INST APIs won't work.
*/
#define RTC(idx) DT_NODELABEL(rtc##idx)
#define RTC_PROP(idx, prop) DT_PROP(RTC(idx), prop)
#define RTC_IRQ_CONNECT(idx) \
COND_CODE_1(CONFIG_COUNTER_RTC##idx##_ZLI, \
(IRQ_DIRECT_CONNECT(DT_IRQN(RTC(idx)), \
DT_IRQ(RTC(idx), priority), \
COND_CODE_1(DT_INST_PROP(idx, zli), \
(IRQ_DIRECT_CONNECT(DT_INST_IRQN(idx), \
DT_INST_IRQ(idx, priority), \
counter_rtc##idx##_isr_wrapper, \
IRQ_ZERO_LATENCY)), \
(IRQ_CONNECT(DT_IRQN(RTC(idx)), DT_IRQ(RTC(idx), priority), \
irq_handler, DEVICE_DT_GET(RTC(idx)), 0)) \
(IRQ_CONNECT(DT_INST_IRQN(idx), DT_INST_IRQ(idx, priority), \
irq_handler, DEVICE_DT_INST_GET(idx), 0)) \
)
#define COUNTER_NRF_RTC_DEVICE(idx) \
BUILD_ASSERT((RTC_PROP(idx, prescaler) - 1) <= \
BUILD_ASSERT((DT_INST_PROP(idx, prescaler) - 1) <= \
RTC_PRESCALER_PRESCALER_Msk, \
"RTC prescaler out of range"); \
COND_CODE_1(CONFIG_COUNTER_RTC##idx##_ZLI, ( \
COND_CODE_1(DT_INST_PROP(idx, zli), ( \
ISR_DIRECT_DECLARE(counter_rtc##idx##_isr_wrapper) \
{ \
irq_handler(DEVICE_DT_GET(RTC(idx))); \
irq_handler(DEVICE_DT_INST_GET(idx)); \
/* No rescheduling, it shall not access zephyr primitives. */ \
return 0; \
}), ()) \
static int counter_##idx##_init(const struct device *dev) \
{ \
RTC_IRQ_CONNECT(idx); \
return init_rtc(dev, RTC_PROP(idx, prescaler) - 1); \
return init_rtc(dev, DT_INST_PROP(idx, prescaler) - 1); \
} \
static struct counter_nrfx_data counter_##idx##_data; \
static struct counter_nrfx_ch_data \
counter##idx##_ch_data[RTC##idx##_CC_NUM]; \
counter##idx##_ch_data[DT_INST_PROP(idx, cc_num)]; \
LOG_INSTANCE_REGISTER(LOG_MODULE_NAME, idx, CONFIG_COUNTER_LOG_LEVEL); \
static const struct counter_nrfx_config nrfx_counter_##idx##_config = {\
.info = { \
.max_top_value = COUNTER_MAX_TOP_VALUE, \
.freq = RTC_PROP(idx, clock_frequency) / \
RTC_PROP(idx, prescaler), \
.freq = DT_INST_PROP(idx, clock_frequency) / \
DT_INST_PROP(idx, prescaler), \
.flags = COUNTER_CONFIG_INFO_COUNT_UP, \
.channels = RTC_PROP(idx, fixed_top) ? \
RTC##idx##_CC_NUM : RTC##idx##_CC_NUM - 1 \
.channels = DT_INST_PROP(idx, fixed_top) \
? DT_INST_PROP(idx, cc_num) \
: DT_INST_PROP(idx, cc_num) - 1 \
}, \
.ch_data = counter##idx##_ch_data, \
.rtc = (NRF_RTC_Type *)DT_REG_ADDR(RTC(idx)), \
.rtc = (NRF_RTC_Type *)DT_INST_REG_ADDR(idx), \
IF_ENABLED(CONFIG_COUNTER_RTC_WITH_PPI_WRAP, \
(.use_ppi = RTC_PROP(idx, ppi_wrap),)) \
(.use_ppi = DT_INST_PROP(idx, ppi_wrap),)) \
IF_ENABLED(CONFIG_COUNTER_RTC_CUSTOM_TOP_SUPPORT, \
(.fixed_top = RTC_PROP(idx, fixed_top),)) \
(.fixed_top = DT_INST_PROP(idx, fixed_top),)) \
LOG_INSTANCE_PTR_INIT(log, LOG_MODULE_NAME, idx) \
}; \
DEVICE_DT_DEFINE(RTC(idx), \
DEVICE_DT_INST_DEFINE(idx, \
counter_##idx##_init, \
NULL, \
&counter_##idx##_data, \
&nrfx_counter_##idx##_config.info, \
PRE_KERNEL_1, CONFIG_COUNTER_INIT_PRIORITY, \
&counter_nrfx_driver_api)
&counter_nrfx_driver_api);
#ifdef CONFIG_COUNTER_RTC0
COUNTER_NRF_RTC_DEVICE(0);
#endif
#ifdef CONFIG_COUNTER_RTC1
COUNTER_NRF_RTC_DEVICE(1);
#endif
#ifdef CONFIG_COUNTER_RTC2
COUNTER_NRF_RTC_DEVICE(2);
#endif
DT_INST_FOREACH_STATUS_OKAY(COUNTER_NRF_RTC_DEVICE)

View file

@ -13,6 +13,8 @@
#include <zephyr/irq.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME, LOG_LEVEL);
#define DT_DRV_COMPAT nordic_nrf_timer
#define TIMER_CLOCK(timer_instance) NRF_TIMER_BASE_FREQUENCY_GET(timer_instance)
#define CC_TO_ID(cc_num) (cc_num - 2)
@ -389,83 +391,60 @@ static const struct counter_driver_api counter_nrfx_driver_api = {
* are indexed by peripheral number, so DT_INST APIs won't work.
*/
#define TIMER(idx) DT_NODELABEL(timer##idx)
#define TIMER_PROP(idx, prop) DT_PROP(TIMER(idx), prop)
#define TIMER_IRQ_CONNECT(idx) \
COND_CODE_1(CONFIG_COUNTER_TIMER##idx##_ZLI, \
(IRQ_DIRECT_CONNECT(DT_IRQN(TIMER(idx)), \
DT_IRQ(TIMER(idx), priority), \
counter_timer##idx##_isr_wrapper, \
IRQ_ZERO_LATENCY)), \
(IRQ_CONNECT(DT_IRQN(TIMER(idx)), DT_IRQ(TIMER(idx), priority),\
irq_handler, DEVICE_DT_GET(TIMER(idx)), 0)) \
#define TIMER_IRQ_CONNECT(idx) \
COND_CODE_1(DT_INST_PROP(idx, zli), \
(IRQ_DIRECT_CONNECT(DT_INST_IRQN(idx), \
DT_INST_IRQ(idx, priority), \
counter_timer##idx##_isr_wrapper, \
IRQ_ZERO_LATENCY)), \
(IRQ_CONNECT(DT_INST_IRQN(idx), DT_INST_IRQ(idx, priority), \
irq_handler, DEVICE_DT_INST_GET(idx), 0)) \
)
#define COUNTER_NRFX_TIMER_DEVICE(idx) \
BUILD_ASSERT(TIMER_PROP(idx, prescaler) <= \
TIMER_PRESCALER_PRESCALER_Msk, \
"TIMER prescaler out of range"); \
COND_CODE_1(CONFIG_COUNTER_TIMER##idx##_ZLI, ( \
ISR_DIRECT_DECLARE(counter_timer##idx##_isr_wrapper) \
{ \
irq_handler(DEVICE_DT_GET(TIMER(idx))); \
/* No rescheduling, it shall not access zephyr primitives. */ \
return 0; \
}), ()) \
static int counter_##idx##_init(const struct device *dev) \
{ \
TIMER_IRQ_CONNECT(idx); \
static const struct counter_timer_config config = { \
.prescaler = TIMER_PROP(idx, prescaler), \
.mode = NRF_TIMER_MODE_TIMER, \
.bit_width = (TIMER##idx##_MAX_SIZE == 32) ? \
NRF_TIMER_BIT_WIDTH_32 : \
NRF_TIMER_BIT_WIDTH_16, \
}; \
return init_timer(dev, &config); \
} \
static struct counter_nrfx_data counter_##idx##_data; \
static struct counter_nrfx_ch_data \
counter##idx##_ch_data[CC_TO_ID(TIMER##idx##_CC_NUM)]; \
LOG_INSTANCE_REGISTER(LOG_MODULE_NAME, idx, CONFIG_COUNTER_LOG_LEVEL); \
static const struct counter_nrfx_config nrfx_counter_##idx##_config = {\
.info = { \
.max_top_value = (TIMER##idx##_MAX_SIZE == 32) ? \
0xffffffff : 0x0000ffff, \
.freq = TIMER_CLOCK(NRF_TIMER##idx) / \
(1 << TIMER_PROP(idx, prescaler)), \
.flags = COUNTER_CONFIG_INFO_COUNT_UP, \
.channels = CC_TO_ID(TIMER##idx##_CC_NUM), \
}, \
.ch_data = counter##idx##_ch_data, \
.timer = (NRF_TIMER_Type *)DT_REG_ADDR(TIMER(idx)), \
LOG_INSTANCE_PTR_INIT(log, LOG_MODULE_NAME, idx) \
}; \
DEVICE_DT_DEFINE(TIMER(idx), \
counter_##idx##_init, \
NULL, \
&counter_##idx##_data, \
&nrfx_counter_##idx##_config.info, \
PRE_KERNEL_1, CONFIG_COUNTER_INIT_PRIORITY, \
&counter_nrfx_driver_api)
#define COUNTER_NRFX_TIMER_DEVICE(idx) \
BUILD_ASSERT(DT_INST_PROP(idx, prescaler) <= \
TIMER_PRESCALER_PRESCALER_Msk, \
"TIMER prescaler out of range"); \
COND_CODE_1(DT_INST_PROP(idx, zli), ( \
ISR_DIRECT_DECLARE(counter_timer##idx##_isr_wrapper) \
{ \
irq_handler(DEVICE_DT_INST_GET(idx)); \
/* No rescheduling, it shall not access zephyr primitives. */ \
return 0; \
}), ()) \
static int counter_##idx##_init(const struct device *dev) \
{ \
TIMER_IRQ_CONNECT(idx); \
static const struct counter_timer_config config = { \
.prescaler = DT_INST_PROP(idx, prescaler), \
.mode = NRF_TIMER_MODE_TIMER, \
.bit_width = (DT_INST_PROP(idx, max_bit_width) == 32) ? \
NRF_TIMER_BIT_WIDTH_32 : NRF_TIMER_BIT_WIDTH_16, \
}; \
return init_timer(dev, &config); \
} \
static struct counter_nrfx_data counter_##idx##_data; \
static struct counter_nrfx_ch_data \
counter##idx##_ch_data[CC_TO_ID(DT_INST_PROP(idx, cc_num))]; \
LOG_INSTANCE_REGISTER(LOG_MODULE_NAME, idx, CONFIG_COUNTER_LOG_LEVEL); \
static const struct counter_nrfx_config nrfx_counter_##idx##_config = { \
.info = { \
.max_top_value = (uint32_t)BIT64_MASK(DT_INST_PROP(idx, max_bit_width)),\
.freq = TIMER_CLOCK((NRF_TIMER_Type *)DT_INST_REG_ADDR(idx)) / \
BIT(DT_INST_PROP(idx, prescaler)), \
.flags = COUNTER_CONFIG_INFO_COUNT_UP, \
.channels = CC_TO_ID(DT_INST_PROP(idx, cc_num)), \
}, \
.ch_data = counter##idx##_ch_data, \
.timer = (NRF_TIMER_Type *)DT_INST_REG_ADDR(idx), \
LOG_INSTANCE_PTR_INIT(log, LOG_MODULE_NAME, idx) \
}; \
DEVICE_DT_INST_DEFINE(idx, \
counter_##idx##_init, \
NULL, \
&counter_##idx##_data, \
&nrfx_counter_##idx##_config.info, \
PRE_KERNEL_1, CONFIG_COUNTER_INIT_PRIORITY, \
&counter_nrfx_driver_api);
#ifdef CONFIG_COUNTER_TIMER0
COUNTER_NRFX_TIMER_DEVICE(0);
#endif
#ifdef CONFIG_COUNTER_TIMER1
COUNTER_NRFX_TIMER_DEVICE(1);
#endif
#ifdef CONFIG_COUNTER_TIMER2
COUNTER_NRFX_TIMER_DEVICE(2);
#endif
#ifdef CONFIG_COUNTER_TIMER3
COUNTER_NRFX_TIMER_DEVICE(3);
#endif
#ifdef CONFIG_COUNTER_TIMER4
COUNTER_NRFX_TIMER_DEVICE(4);
#endif
DT_INST_FOREACH_STATUS_OKAY(COUNTER_NRFX_TIMER_DEVICE)

View file

@ -142,27 +142,30 @@
timer0: timer@40008000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40008000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <8 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer1: timer@40009000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40009000 0x1000>;
cc-num = <4>;
max-bit-width = <16>;
interrupts = <9 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer2: timer@4000a000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4000a000 0x1000>;
cc-num = <4>;
max-bit-width = <16>;
interrupts = <10 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -172,7 +175,7 @@
reg = <0x4000b000 0x1000>;
cc-num = <3>;
interrupts = <11 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -217,7 +220,7 @@
reg = <0x40011000 0x1000>;
cc-num = <4>;
interrupts = <17 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};

View file

@ -143,27 +143,30 @@
timer0: timer@40008000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40008000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <8 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer1: timer@40009000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40009000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <9 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer2: timer@4000a000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4000a000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <10 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -173,7 +176,7 @@
reg = <0x4000b000 0x1000>;
cc-num = <3>;
interrupts = <11 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -219,7 +222,7 @@
reg = <0x40011000 0x1000>;
cc-num = <4>;
interrupts = <17 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};

View file

@ -146,27 +146,30 @@
};
timer0: timer@40008000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40008000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <8 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer1: timer@40009000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40009000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <9 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer2: timer@4000a000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4000a000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <10 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -176,7 +179,7 @@
reg = <0x4000b000 0x1000>;
cc-num = <3>;
interrupts = <11 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -222,7 +225,7 @@
reg = <0x40011000 0x1000>;
cc-num = <4>;
interrupts = <17 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};

View file

@ -177,27 +177,30 @@
timer0: timer@40008000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40008000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <8 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer1: timer@40009000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40009000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <9 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer2: timer@4000a000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4000a000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <10 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -207,7 +210,7 @@
reg = <0x4000b000 0x1000>;
cc-num = <3>;
interrupts = <11 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -253,7 +256,7 @@
reg = <0x40011000 0x1000>;
cc-num = <4>;
interrupts = <17 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};

View file

@ -175,27 +175,30 @@
timer0: timer@40008000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40008000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <8 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer1: timer@40009000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40009000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <9 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer2: timer@4000a000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4000a000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <10 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -205,7 +208,7 @@
reg = <0x4000b000 0x1000>;
cc-num = <3>;
interrupts = <11 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -251,7 +254,7 @@
reg = <0x40011000 0x1000>;
cc-num = <4>;
interrupts = <17 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -315,9 +318,10 @@
timer3: timer@4001a000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4001a000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <26 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};

View file

@ -188,27 +188,30 @@
timer0: timer@40008000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40008000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <8 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer1: timer@40009000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40009000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <9 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer2: timer@4000a000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4000a000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <10 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -218,7 +221,7 @@
reg = <0x4000b000 0x1000>;
cc-num = <3>;
interrupts = <11 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -264,7 +267,7 @@
reg = <0x40011000 0x1000>;
cc-num = <4>;
interrupts = <17 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -334,18 +337,20 @@
timer3: timer@4001a000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4001a000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <26 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer4: timer@4001b000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4001b000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <27 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -430,7 +435,7 @@
reg = <0x40024000 0x1000>;
cc-num = <4>;
interrupts = <36 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};

View file

@ -195,27 +195,30 @@
timer0: timer@40008000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40008000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <8 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer1: timer@40009000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40009000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <9 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer2: timer@4000a000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4000a000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <10 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -225,7 +228,7 @@
reg = <0x4000b000 0x1000>;
cc-num = <3>;
interrupts = <11 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -271,7 +274,7 @@
reg = <0x40011000 0x1000>;
cc-num = <4>;
interrupts = <17 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -341,18 +344,20 @@
timer3: timer@4001a000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4001a000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <26 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer4: timer@4001b000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4001b000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <27 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -444,7 +449,7 @@
reg = <0x40024000 0x1000>;
cc-num = <4>;
interrupts = <36 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};

View file

@ -190,27 +190,30 @@
timer0: timer@40008000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40008000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <8 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer1: timer@40009000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x40009000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <9 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer2: timer@4000a000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4000a000 0x1000>;
cc-num = <4>;
max-bit-width = <32>;
interrupts = <10 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -220,7 +223,7 @@
reg = <0x4000b000 0x1000>;
cc-num = <3>;
interrupts = <11 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -266,7 +269,7 @@
reg = <0x40011000 0x1000>;
cc-num = <4>;
interrupts = <17 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -336,18 +339,20 @@
timer3: timer@4001a000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4001a000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <26 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
timer4: timer@4001b000 {
compatible = "nordic,nrf-timer";
status = "okay";
status = "disabled";
reg = <0x4001b000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <27 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -439,7 +444,7 @@
reg = <0x40024000 0x1000>;
cc-num = <4>;
interrupts = <36 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};

View file

@ -242,6 +242,7 @@ timer0: timer@f000 {
status = "disabled";
reg = <0xf000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <15 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -251,6 +252,7 @@ timer1: timer@10000 {
status = "disabled";
reg = <0x10000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <16 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -260,6 +262,7 @@ timer2: timer@11000 {
status = "disabled";
reg = <0x11000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <17 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -269,7 +272,7 @@ rtc0: rtc@14000 {
reg = <0x14000 0x1000>;
cc-num = <4>;
interrupts = <20 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -279,7 +282,7 @@ rtc1: rtc@15000 {
reg = <0x15000 0x1000>;
cc-num = <4>;
interrupts = <21 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};

View file

@ -123,6 +123,7 @@
status = "disabled";
reg = <0x4100c000 0x1000>;
cc-num = <8>;
max-bit-width = <32>;
interrupts = <12 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -160,7 +161,7 @@
reg = <0x41011000 0x1000>;
cc-num = <4>;
interrupts = <17 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
};
mbox: ipc: mbox@41012000 {
@ -224,7 +225,7 @@
reg = <0x41016000 0x1000>;
cc-num = <4>;
interrupts = <22 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
};
timer1: timer@41018000 {
@ -232,6 +233,7 @@
status = "disabled";
reg = <0x41018000 0x1000>;
cc-num = <8>;
max-bit-width = <32>;
interrupts = <24 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -241,6 +243,7 @@
status = "disabled";
reg = <0x41019000 0x1000>;
cc-num = <8>;
max-bit-width = <32>;
interrupts = <25 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};

View file

@ -312,7 +312,7 @@ rtc0: rtc@14000 {
reg = <0x14000 0x1000>;
cc-num = <4>;
interrupts = <20 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -322,7 +322,7 @@ rtc1: rtc@15000 {
reg = <0x15000 0x1000>;
cc-num = <4>;
interrupts = <21 NRF_DEFAULT_IRQ_PRIORITY>;
status = "okay";
status = "disabled";
clock-frequency = <32768>;
prescaler = <1>;
};
@ -367,6 +367,7 @@ timer0: timer@f000 {
status = "disabled";
reg = <0xf000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <15 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -376,6 +377,7 @@ timer1: timer@10000 {
status = "disabled";
reg = <0x10000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <16 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};
@ -385,6 +387,7 @@ timer2: timer@11000 {
status = "disabled";
reg = <0x11000 0x1000>;
cc-num = <6>;
max-bit-width = <32>;
interrupts = <17 NRF_DEFAULT_IRQ_PRIORITY>;
prescaler = <0>;
};

View file

@ -33,3 +33,7 @@ properties:
fixed-top:
type: boolean
description: Enable fixed top value
zli:
type: boolean
description: Enable event handler in the ZLI (Zero latency interrupt) context

View file

@ -16,6 +16,11 @@ properties:
required: true
description: Number of capture/compare (CC) registers available
max-bit-width:
type: int
required: true
description: Maximum bit width supported
interrupts:
required: true
@ -23,3 +28,7 @@ properties:
type: int
required: true
description: Prescaler value determines frequency (base_frequency/2^prescaler)
zli:
type: boolean
description: Enable event handler in the ZLI (Zero latency interrupt) context

View file

@ -0,0 +1,3 @@
&timer0 {
status = "okay";
};

View file

@ -1,5 +1,3 @@
#CONFIG_CLOCK_CONTROL=y
CONFIG_COUNTER=y
CONFIG_COUNTER_TIMER0=y
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y

View file

@ -1,4 +0,0 @@
CONFIG_COUNTER_TIMER0=y
CONFIG_COUNTER_TIMER1=y
CONFIG_COUNTER_TIMER2=y
CONFIG_COUNTER_RTC0=y

View file

@ -1,11 +1,19 @@
&timer0 {
status = "okay";
prescaler = <4>;
};
&timer1 {
status = "okay";
prescaler = <4>;
};
&timer2 {
status = "okay";
prescaler = <4>;
};
&rtc0 {
status = "okay";
ppi-wrap;
};

View file

@ -1,7 +0,0 @@
CONFIG_COUNTER_TIMER0=y
CONFIG_COUNTER_TIMER1=y
CONFIG_COUNTER_TIMER2=y
CONFIG_COUNTER_TIMER3=y
CONFIG_COUNTER_TIMER4=y
CONFIG_COUNTER_RTC0=y
CONFIG_COUNTER_RTC2=y

View file

@ -1,23 +1,33 @@
&timer0 {
status = "okay";
prescaler = <4>;
};
&timer1 {
status = "okay";
prescaler = <4>;
};
&timer2 {
status = "okay";
prescaler = <4>;
};
&timer3 {
status = "okay";
prescaler = <4>;
};
&timer4 {
status = "okay";
prescaler = <4>;
};
&rtc0 {
status = "okay";
};
&rtc2 {
status = "okay";
ppi-wrap;
};

View file

@ -1,4 +0,0 @@
CONFIG_COUNTER_TIMER0=y
CONFIG_COUNTER_TIMER1=y
CONFIG_COUNTER_TIMER2=y
CONFIG_COUNTER_RTC0=y

View file

@ -1,11 +1,19 @@
&timer0 {
status = "okay";
prescaler = <4>;
};
&timer1 {
status = "okay";
prescaler = <4>;
};
&timer2 {
status = "okay";
prescaler = <4>;
};
&rtc0 {
status = "okay";
ppi-wrap;
};

View file

@ -1,7 +0,0 @@
CONFIG_COUNTER_TIMER0=y
CONFIG_COUNTER_TIMER1=y
CONFIG_COUNTER_TIMER2=y
CONFIG_COUNTER_TIMER3=y
CONFIG_COUNTER_TIMER4=y
CONFIG_COUNTER_RTC0=y
CONFIG_COUNTER_RTC2=y

View file

@ -1,23 +1,33 @@
&timer0 {
status = "okay";
prescaler = <4>;
};
&timer1 {
status = "okay";
prescaler = <4>;
};
&timer2 {
status = "okay";
prescaler = <4>;
};
&timer3 {
status = "okay";
prescaler = <4>;
};
&timer4 {
status = "okay";
prescaler = <4>;
};
&rtc0 {
status = "okay";
ppi-wrap;
};
&rtc2 {
status = "okay";
};

View file

@ -1,14 +0,0 @@
CONFIG_COUNTER_TIMER0=y
CONFIG_COUNTER_TIMER0_ZLI=y
CONFIG_COUNTER_TIMER1=y
CONFIG_COUNTER_TIMER1_ZLI=y
CONFIG_COUNTER_TIMER2=y
CONFIG_COUNTER_TIMER2_ZLI=y
CONFIG_COUNTER_TIMER3=y
CONFIG_COUNTER_TIMER3_ZLI=y
CONFIG_COUNTER_TIMER4=y
CONFIG_COUNTER_TIMER4_ZLI=y
CONFIG_COUNTER_RTC0=y
CONFIG_COUNTER_RTC0_ZLI=y
CONFIG_COUNTER_RTC2=y
CONFIG_COUNTER_RTC2_ZLI=y

View file

@ -0,0 +1,23 @@
&timer0 {
zli;
};
&timer1 {
zli;
};
&timer2 {
zli;
};
&timer3 {
zli;
};
&timer4 {
zli;
};
&rtc0 {
zli;
};

View file

@ -1,4 +0,0 @@
CONFIG_COUNTER_TIMER0=y
CONFIG_COUNTER_TIMER1=y
CONFIG_COUNTER_TIMER2=y
CONFIG_COUNTER_RTC0=y

View file

@ -1,11 +1,19 @@
&timer0 {
status = "okay";
prescaler = <4>;
};
&timer1 {
status = "okay";
prescaler = <4>;
};
&timer2 {
status = "okay";
prescaler = <4>;
};
&rtc0 {
status = "okay";
ppi-wrap;
};

View file

@ -1,7 +0,0 @@
CONFIG_COUNTER_TIMER0=y
CONFIG_COUNTER_TIMER1=y
CONFIG_COUNTER_TIMER2=y
CONFIG_COUNTER_TIMER3=y
CONFIG_COUNTER_TIMER4=y
CONFIG_COUNTER_RTC0=y
CONFIG_COUNTER_RTC2=y

View file

@ -1,19 +1,34 @@
&timer0 {
status = "okay";
prescaler = <4>;
};
&timer1 {
status = "okay";
prescaler = <4>;
};
&timer2 {
status = "okay";
prescaler = <4>;
};
&timer3 {
status = "okay";
prescaler = <4>;
};
&timer4 {
status = "okay";
prescaler = <4>;
};
&rtc0 {
status = "okay";
ppi-wrap;
};
&rtc2 {
status = "okay";
ppi-wrap;
};

View file

@ -1,4 +0,0 @@
CONFIG_COUNTER_TIMER0=y
CONFIG_COUNTER_TIMER1=y
CONFIG_COUNTER_TIMER2=y
CONFIG_COUNTER_RTC0=y

View file

@ -1,11 +1,19 @@
&timer0 {
status = "okay";
prescaler = <4>;
};
&timer1 {
status = "okay";
prescaler = <4>;
};
&timer2 {
status = "okay";
prescaler = <4>;
};
&rtc0 {
status = "okay";
ppi-wrap;
};

View file

@ -28,29 +28,11 @@ struct counter_alarm_cfg alarm_cfg2;
DT_FOREACH_STATUS_OKAY(compat, DEVICE_DT_GET_AND_COMMA)
static const struct device *const devices[] = {
#ifdef CONFIG_COUNTER_TIMER0
/* Nordic TIMER0 may be reserved for Bluetooth */
DEVICE_DT_GET(DT_NODELABEL(timer0)),
#ifdef CONFIG_COUNTER_NRF_TIMER
DEVS_FOR_DT_COMPAT(nordic_nrf_timer)
#endif
#ifdef CONFIG_COUNTER_TIMER1
DEVICE_DT_GET(DT_NODELABEL(timer1)),
#endif
#ifdef CONFIG_COUNTER_TIMER2
DEVICE_DT_GET(DT_NODELABEL(timer2)),
#endif
#ifdef CONFIG_COUNTER_TIMER3
DEVICE_DT_GET(DT_NODELABEL(timer3)),
#endif
#ifdef CONFIG_COUNTER_TIMER4
DEVICE_DT_GET(DT_NODELABEL(timer4)),
#endif
#ifdef CONFIG_COUNTER_RTC0
/* Nordic RTC0 may be reserved for Bluetooth */
DEVICE_DT_GET(DT_NODELABEL(rtc0)),
#endif
/* Nordic RTC1 is used for the system clock */
#ifdef CONFIG_COUNTER_RTC2
DEVICE_DT_GET(DT_NODELABEL(rtc2)),
#ifdef CONFIG_COUNTER_NRF_RTC
DEVS_FOR_DT_COMPAT(nordic_nrf_rtc)
#endif
#ifdef CONFIG_COUNTER_TIMER_STM32
#define STM32_COUNTER_DEV(idx) \
@ -938,47 +920,8 @@ static bool reliable_cancel_capable(const struct device *dev)
{
/* Test performed only for NRF_RTC instances. Other probably will fail.
*/
#ifdef CONFIG_COUNTER_RTC0
/* Nordic RTC0 may be reserved for Bluetooth */
if (dev == DEVICE_DT_GET(DT_NODELABEL(rtc0))) {
return true;
}
#endif
#ifdef CONFIG_COUNTER_RTC2
if (dev == DEVICE_DT_GET(DT_NODELABEL(rtc2))) {
return true;
}
#endif
#ifdef CONFIG_COUNTER_TIMER0
if (dev == DEVICE_DT_GET(DT_NODELABEL(timer0))) {
return true;
}
#endif
#ifdef CONFIG_COUNTER_TIMER1
if (dev == DEVICE_DT_GET(DT_NODELABEL(timer1))) {
return true;
}
#endif
#ifdef CONFIG_COUNTER_TIMER2
if (dev == DEVICE_DT_GET(DT_NODELABEL(timer2))) {
return true;
}
#endif
#ifdef CONFIG_COUNTER_TIMER3
if (dev == DEVICE_DT_GET(DT_NODELABEL(timer3))) {
return true;
}
#endif
#ifdef CONFIG_COUNTER_TIMER4
if (dev == DEVICE_DT_GET(DT_NODELABEL(timer4))) {
return true;
}
#if defined(CONFIG_COUNTER_NRF_RTC) || defined(CONFIG_COUNTER_NRF_TIMER)
return true;
#endif
#ifdef CONFIG_COUNTER_TIMER_STM32
if (single_channel_alarm_capable(dev)) {

View file

@ -10,5 +10,7 @@ tests:
depends_on: counter
platform_allow: nrf52840dk_nrf52840
timeout: 400
extra_args: >
OVERLAY_CONFIG="zli.conf;boards/nrf52840dk_nrf52840_zli.conf"
extra_configs:
- CONFIG_ZERO_LATENCY_IRQS=y
extra_args:
DTC_OVERLAY_FILE="boards/nrf52840dk_nrf52840.overlay;boards/nrf52840dk_nrf52840_zli.overlay"

View file

@ -1,2 +0,0 @@
CONFIG_COUNTER_RTC0=y
CONFIG_COUNTER_RTC2=y

View file

@ -1,6 +1,8 @@
&rtc0 {
status = "okay";
fixed-top;
};
&rtc2 {
status = "okay";
fixed-top;
};

View file

@ -13,19 +13,31 @@ LOG_MODULE_REGISTER(test);
static volatile uint32_t top_cnt;
#define DEVICE_DT_GET_AND_COMMA(node_id) DEVICE_DT_GET(node_id),
/* Generate a list of devices for all instances of the "compat" */
#define DEVS_FOR_DT_COMPAT(compat) \
DT_FOREACH_STATUS_OKAY(compat, DEVICE_DT_GET_AND_COMMA)
#define DEVICE_DT_GET_REG_AND_COMMA(node_id) (NRF_RTC_Type *)DT_REG_ADDR(node_id),
/* Generate a list of devices for all instances of the "compat" */
#define REGS_FOR_DT_COMPAT(compat) \
DT_FOREACH_STATUS_OKAY(compat, DEVICE_DT_GET_REG_AND_COMMA)
static const struct device *const devices[] = {
#ifdef CONFIG_COUNTER_RTC0
/* Nordic RTC0 may be reserved for Bluetooth */
DEVICE_DT_GET(DT_NODELABEL(rtc0)),
#endif
/* Nordic RTC1 is used for the system clock */
#ifdef CONFIG_COUNTER_RTC2
DEVICE_DT_GET(DT_NODELABEL(rtc2)),
#ifdef CONFIG_COUNTER_NRF_RTC
DEVS_FOR_DT_COMPAT(nordic_nrf_rtc)
#endif
};
typedef void (*counter_test_func_t)(const struct device *dev);
static NRF_RTC_Type *const regs[] = {
#ifdef CONFIG_COUNTER_NRF_RTC
REGS_FOR_DT_COMPAT(nordic_nrf_rtc)
#endif
};
typedef void (*counter_test_func_t)(int idx);
static void counter_setup_instance(const struct device *dev)
{
@ -45,15 +57,16 @@ static void test_all_instances(counter_test_func_t func)
{
for (int i = 0; i < ARRAY_SIZE(devices); i++) {
counter_setup_instance(devices[i]);
func(devices[i]);
func(i);
counter_tear_down_instance(devices[i]);
/* Allow logs to be printed. */
k_sleep(K_MSEC(100));
}
}
static void test_set_custom_top_value_fails_on_instance(const struct device *dev)
static void test_set_custom_top_value_fails_on_instance(int idx)
{
const struct device *dev = devices[idx];
int err;
struct counter_top_cfg top_cfg = {
.callback = NULL,
@ -76,8 +89,10 @@ static void top_handler(const struct device *dev, void *user_data)
top_cnt++;
}
static void test_top_handler_on_instance(const struct device *dev)
static void test_top_handler_on_instance(int idx)
{
const struct device *dev = devices[idx];
NRF_RTC_Type *reg = regs[idx];
uint32_t tmp_top_cnt;
int err;
struct counter_top_cfg top_cfg = {
@ -90,12 +105,7 @@ static void test_top_handler_on_instance(const struct device *dev)
err = counter_set_top_value(dev, &top_cfg);
zassert_equal(0, err, "%s: Unexpected error code (%d)", dev->name, err);
#ifdef CONFIG_COUNTER_RTC0
nrf_rtc_task_trigger(NRF_RTC0, NRF_RTC_TASK_TRIGGER_OVERFLOW);
#endif
#ifdef CONFIG_COUNTER_RTC2
nrf_rtc_task_trigger(NRF_RTC2, NRF_RTC_TASK_TRIGGER_OVERFLOW);
#endif
nrf_rtc_task_trigger(reg, NRF_RTC_TASK_TRIGGER_OVERFLOW);
counter_start(dev);
k_busy_wait(10000);

View file

@ -1,2 +0,0 @@
CONFIG_COUNTER=y
CONFIG_COUNTER_TIMER0=y

View file

@ -63,3 +63,7 @@
&rtc1 {
interrupts = <17 2>;
};
&timer0 {
status = "okay";
};

View file

@ -1,2 +0,0 @@
CONFIG_COUNTER=y
CONFIG_COUNTER_TIMER0=y

View file

@ -34,3 +34,7 @@
&rtc1 {
interrupts = <21 2>;
};
&timer0 {
status = "okay";
};

View file

@ -1,2 +0,0 @@
CONFIG_COUNTER=y
CONFIG_COUNTER_TIMER0=y

View file

@ -34,3 +34,7 @@
&rtc1 {
interrupts = <21 2>;
};
&timer0 {
status = "okay";
};

View file

@ -6,6 +6,7 @@ CONFIG_ZTEST_THREAD_PRIORITY=5
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_ZTEST_STACK_SIZE=2048
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_COUNTER=y
# CONFIG_NO_OPTIMIZATIONS=y
# CONFIG_LOG_MODE_MINIMAL=n

View file

@ -1,8 +1,4 @@
# Disable hardware watchdog
CONFIG_WDT_NRFX=n
CONFIG_NRFX_WDT0=n
# Setup counter on TIMER0 with ZLI enabled
CONFIG_COUNTER_TIMER0=y
CONFIG_ZERO_LATENCY_IRQS=y
CONFIG_COUNTER_TIMER0_ZLI=y

View file

@ -7,6 +7,7 @@
&timer0 {
status = "okay";
interrupts = <8 0>;
zli;
};
&wdt0 {

View file

@ -1 +0,0 @@
CONFIG_COUNTER_TIMER0=y