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