Skip to content

Commit bc4d3b9

Browse files
RichardSWheatleyAlessandroLuo
authored andcommitted
drivers: add assert to check for max children in timer
check for max number of children in timer. Signed-off-by: Richard Wheatley <richard.wheatley@ambiq.com>
1 parent f6b8731 commit bc4d3b9

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

drivers/counter/counter_ambiq_timer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ static void counter_ambiq_isr(void *arg)
438438
#endif
439439

440440
#define AMBIQ_COUNTER_INIT(idx) \
441+
BUILD_ASSERT(DT_CHILD_NUM_STATUS_OKAY(DT_INST_PARENT(idx)) == 1, \
442+
"Too many children for Timer!"); \
441443
static void counter_irq_config_func_##idx(void); \
442444
static struct counter_ambiq_data counter_data_##idx; \
443445
static const struct counter_ambiq_config counter_config_##idx = { \

drivers/pwm/pwm_ambiq_ctimer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ static DEVICE_API(pwm, pwm_ambiq_timer_driver_api) = {
225225
};
226226

227227
#define PWM_AMBIQ_TIMER_DEVICE_INIT(n) \
228+
BUILD_ASSERT(DT_CHILD_NUM_STATUS_OKAY(DT_INST_PARENT(n)) == 1, \
229+
"Too many children for Timer!"); \
228230
PINCTRL_DT_INST_DEFINE(n); \
229231
static struct pwm_ambiq_timer_data pwm_ambiq_timer_data_##n = { \
230232
.cycles = 0, \

drivers/pwm/pwm_ambiq_timer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ static DEVICE_API(pwm, pwm_ambiq_timer_driver_api) = {
178178
};
179179

180180
#define PWM_AMBIQ_TIMER_DEVICE_INIT(n) \
181+
BUILD_ASSERT(DT_CHILD_NUM_STATUS_OKAY(DT_INST_PARENT(n)) == 1, \
182+
"Too many children for Timer!"); \
181183
PINCTRL_DT_INST_DEFINE(n); \
182184
static struct pwm_ambiq_timer_data pwm_ambiq_timer_data_##n = { \
183185
.cycles = 0, \

0 commit comments

Comments
 (0)