@@ -127,8 +127,8 @@ static void start_clock(uint32_t clock_sel)
127
127
}
128
128
129
129
static int ambiq_ctimer_pwm_set_cycles (const struct device * dev , uint32_t channel ,
130
- uint32_t period_cycles , uint32_t pulse_cycles ,
131
- pwm_flags_t flags )
130
+ uint32_t period_cycles , uint32_t pulse_cycles ,
131
+ pwm_flags_t flags )
132
132
{
133
133
const struct pwm_ambiq_ctimer_config * config = dev -> config ;
134
134
@@ -172,7 +172,7 @@ static int ambiq_ctimer_pwm_set_cycles(const struct device *dev, uint32_t channe
172
172
}
173
173
174
174
static int ambiq_ctimer_pwm_get_cycles_per_sec (const struct device * dev , uint32_t channel ,
175
- uint64_t * cycles )
175
+ uint64_t * cycles )
176
176
{
177
177
struct pwm_ambiq_ctimer_data * data = dev -> data ;
178
178
int err = 0 ;
@@ -230,21 +230,23 @@ static DEVICE_API(pwm, pwm_ambiq_ctimer_driver_api) = {
230
230
231
231
#define TEST_CHILDREN DT_PATH(test, test_children)
232
232
233
- #define PWM_AMBIQ_CTIMER_DEVICE_INIT (n ) \
233
+ #define PWM_AMBIQ_CTIMER_DEVICE_INIT (n ) \
234
+ BUILD_ASSERT(DT_CHILD_NUM_STATUS_OKAY(DT_INST_PARENT(n)) == 1, \
235
+ "Too many children for Timer!"); \
234
236
PINCTRL_DT_INST_DEFINE(n); \
235
- static struct pwm_ambiq_ctimer_data pwm_ambiq_ctimer_data_##n = { \
237
+ static struct pwm_ambiq_ctimer_data pwm_ambiq_ctimer_data_##n = { \
236
238
.cycles = 0, \
237
239
}; \
238
- static const struct pwm_ambiq_ctimer_config pwm_ambiq_ctimer_config_##n = { \
240
+ static const struct pwm_ambiq_ctimer_config pwm_ambiq_ctimer_config_##n = { \
239
241
.timer_num = (DT_REG_ADDR(DT_INST_PARENT(n)) - CTIMER_BASE) / \
240
242
DT_REG_SIZE(DT_INST_PARENT(n)), \
241
243
.timer_seg = DT_INST_ENUM_IDX(n, timer_segment), \
242
- .clock_sel = DT_ENUM_IDX(DT_INST_PARENT(n), clk_source), \
244
+ .clock_sel = DT_ENUM_IDX(DT_INST_PARENT(n), clk_source), \
243
245
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
244
246
.pwm_type = DT_INST_ENUM_IDX(n, pwm_type)}; \
245
247
\
246
- DEVICE_DT_INST_DEFINE(n, ambiq_ctimer_pwm_init, NULL, &pwm_ambiq_ctimer_data_##n, \
247
- &pwm_ambiq_ctimer_config_##n, POST_KERNEL, CONFIG_PWM_INIT_PRIORITY, \
248
+ DEVICE_DT_INST_DEFINE(n, ambiq_ctimer_pwm_init, NULL, &pwm_ambiq_ctimer_data_##n, \
249
+ &pwm_ambiq_ctimer_config_##n, POST_KERNEL, CONFIG_PWM_INIT_PRIORITY, \
248
250
&pwm_ambiq_ctimer_driver_api);
249
251
250
252
DT_INST_FOREACH_STATUS_OKAY (PWM_AMBIQ_CTIMER_DEVICE_INIT )
0 commit comments