@@ -133,38 +133,36 @@ void handleGpioCallback(const struct device *port, struct gpio_callback *cb, uin
133
133
134
134
#ifdef CONFIG_PWM
135
135
136
- #define PWM_DT_SPEC (n,p,i ) PWM_DT_SPEC_GET_BY_IDX(n, i),
137
- #define PWM_PINS (n, p, i ) \
138
- DIGITAL_PIN_GPIOS_FIND_PIN ( \
139
- DT_REG_ADDR (DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), p, i)), \
140
- DT_PHA_BY_IDX(DT_PATH(zephyr_user), p, i, pin)),
136
+ #define PWM_DT_SPEC (n, p, i ) PWM_DT_SPEC_GET_BY_IDX(n, i),
137
+ #define PWM_PINS (n, p, i ) \
138
+ DIGITAL_PIN_GPIOS_FIND_PIN (DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), p, i)), \
139
+ DT_PHA_BY_IDX(DT_PATH(zephyr_user), p, i, pin)),
141
140
142
- const struct pwm_dt_spec arduino_pwm[] =
143
- { DT_FOREACH_PROP_ELEM (DT_PATH (zephyr_user), pwms, PWM_DT_SPEC) };
141
+ const struct pwm_dt_spec arduino_pwm[] = {
142
+ DT_FOREACH_PROP_ELEM (DT_PATH (zephyr_user), pwms, PWM_DT_SPEC)};
144
143
145
144
/* pwm-pins node provides a mapping digital pin numbers to pwm channels */
146
- const pin_size_t arduino_pwm_pins[] =
147
- { DT_FOREACH_PROP_ELEM (DT_PATH (zephyr_user), pwm_pin_gpios, PWM_PINS) };
145
+ const pin_size_t arduino_pwm_pins[] = {
146
+ DT_FOREACH_PROP_ELEM (DT_PATH (zephyr_user), pwm_pin_gpios, PWM_PINS)};
148
147
149
148
size_t pwm_pin_index (pin_size_t pinNumber) {
150
- for (size_t i= 0 ; i< ARRAY_SIZE (arduino_pwm_pins); i++) {
149
+ for (size_t i = 0 ; i < ARRAY_SIZE (arduino_pwm_pins); i++) {
151
150
if (arduino_pwm_pins[i] == pinNumber) {
152
151
return i;
153
152
}
154
153
}
155
154
return (size_t )-1 ;
156
155
}
157
156
158
- #endif // CONFIG_PWM
157
+ #endif // CONFIG_PWM
159
158
160
159
#ifdef CONFIG_ADC
161
160
162
- #define ADC_DT_SPEC (n,p,i ) ADC_DT_SPEC_GET_BY_IDX(n, i),
163
- #define ADC_PINS (n, p, i ) \
164
- DIGITAL_PIN_GPIOS_FIND_PIN ( \
165
- DT_REG_ADDR (DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), p, i)), \
166
- DT_PHA_BY_IDX(DT_PATH(zephyr_user), p, i, pin)),
167
- #define ADC_CH_CFG (n,p,i ) arduino_adc[i].channel_cfg,
161
+ #define ADC_DT_SPEC (n, p, i ) ADC_DT_SPEC_GET_BY_IDX(n, i),
162
+ #define ADC_PINS (n, p, i ) \
163
+ DIGITAL_PIN_GPIOS_FIND_PIN (DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), p, i)), \
164
+ DT_PHA_BY_IDX(DT_PATH(zephyr_user), p, i, pin)),
165
+ #define ADC_CH_CFG (n, p, i ) arduino_adc[i].channel_cfg,
168
166
169
167
const struct adc_dt_spec arduino_adc[] =
170
168
{ DT_FOREACH_PROP_ELEM (DT_PATH (zephyr_user), io_channels, ADC_DT_SPEC) };
@@ -177,15 +175,15 @@ struct adc_channel_cfg channel_cfg[ARRAY_SIZE(arduino_analog_pins)] =
177
175
{ DT_FOREACH_PROP_ELEM (DT_PATH (zephyr_user), io_channels, ADC_CH_CFG) };
178
176
179
177
size_t analog_pin_index (pin_size_t pinNumber) {
180
- for (size_t i= 0 ; i< ARRAY_SIZE (arduino_analog_pins); i++) {
178
+ for (size_t i = 0 ; i < ARRAY_SIZE (arduino_analog_pins); i++) {
181
179
if (arduino_analog_pins[i] == pinNumber) {
182
180
return i;
183
181
}
184
182
}
185
183
return (size_t )-1 ;
186
184
}
187
185
188
- #endif // CONFIG_ADC
186
+ #endif // CONFIG_ADC
189
187
190
188
static unsigned int irq_key;
191
189
static bool interrupts_disabled = false ;
@@ -300,7 +298,7 @@ void analogWrite(pin_size_t pinNumber, int value)
300
298
return ;
301
299
}
302
300
303
- if (idx >= ARRAY_SIZE (arduino_pwm) ) {
301
+ if (idx >= ARRAY_SIZE (arduino_pwm)) {
304
302
return ;
305
303
}
306
304
@@ -328,7 +326,7 @@ void analogReference(uint8_t mode)
328
326
* the mode argument of analogReference().
329
327
* Treat the value as equivalent to zephyr's adc_reference.
330
328
*/
331
- for (size_t i= 0 ; i< ARRAY_SIZE (channel_cfg); i++) {
329
+ for (size_t i = 0 ; i < ARRAY_SIZE (channel_cfg); i++) {
332
330
channel_cfg[i].reference = static_cast <adc_reference>(mode);
333
331
}
334
332
}
@@ -337,10 +335,10 @@ int analogRead(pin_size_t pinNumber)
337
335
{
338
336
int err;
339
337
int16_t buf;
340
- struct adc_sequence seq = { .buffer = &buf, .buffer_size = sizeof (buf) };
338
+ struct adc_sequence seq = {.buffer = &buf, .buffer_size = sizeof (buf)};
341
339
size_t idx = analog_pin_index (pinNumber);
342
340
343
- if (idx >= ARRAY_SIZE (arduino_adc) ) {
341
+ if (idx >= ARRAY_SIZE (arduino_adc)) {
344
342
return -EINVAL;
345
343
}
346
344
@@ -504,8 +502,7 @@ void noInterrupts(void) {
504
502
}
505
503
506
504
int digitalPinToInterrupt (pin_size_t pin) {
507
- struct gpio_port_callback *pcb =
508
- find_gpio_port_callback (local_gpio_port (pin));
505
+ struct gpio_port_callback *pcb = find_gpio_port_callback (local_gpio_port (pin));
509
506
510
507
return (pcb) ? pin : -1 ;
511
508
}
0 commit comments