Skip to content

Commit a7f58fb

Browse files
committed
cosmetic
1 parent b5dedeb commit a7f58fb

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

cores/arduino/zephyrCommon.cpp

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -133,38 +133,36 @@ void handleGpioCallback(const struct device *port, struct gpio_callback *cb, uin
133133

134134
#ifdef CONFIG_PWM
135135

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)),
141140

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)};
144143

145144
/* 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)};
148147

149148
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++) {
151150
if (arduino_pwm_pins[i] == pinNumber) {
152151
return i;
153152
}
154153
}
155154
return (size_t)-1;
156155
}
157156

158-
#endif //CONFIG_PWM
157+
#endif // CONFIG_PWM
159158

160159
#ifdef CONFIG_ADC
161160

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,
168166

169167
const struct adc_dt_spec arduino_adc[] =
170168
{ 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)] =
177175
{ DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), io_channels, ADC_CH_CFG) };
178176

179177
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++) {
181179
if (arduino_analog_pins[i] == pinNumber) {
182180
return i;
183181
}
184182
}
185183
return (size_t)-1;
186184
}
187185

188-
#endif //CONFIG_ADC
186+
#endif // CONFIG_ADC
189187

190188
static unsigned int irq_key;
191189
static bool interrupts_disabled = false;
@@ -300,7 +298,7 @@ void analogWrite(pin_size_t pinNumber, int value)
300298
return;
301299
}
302300

303-
if (idx >= ARRAY_SIZE(arduino_pwm) ) {
301+
if (idx >= ARRAY_SIZE(arduino_pwm)) {
304302
return;
305303
}
306304

@@ -328,7 +326,7 @@ void analogReference(uint8_t mode)
328326
* the mode argument of analogReference().
329327
* Treat the value as equivalent to zephyr's adc_reference.
330328
*/
331-
for (size_t i=0; i<ARRAY_SIZE(channel_cfg); i++) {
329+
for (size_t i = 0; i < ARRAY_SIZE(channel_cfg); i++) {
332330
channel_cfg[i].reference = static_cast<adc_reference>(mode);
333331
}
334332
}
@@ -337,10 +335,10 @@ int analogRead(pin_size_t pinNumber)
337335
{
338336
int err;
339337
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)};
341339
size_t idx = analog_pin_index(pinNumber);
342340

343-
if (idx >= ARRAY_SIZE(arduino_adc) ) {
341+
if (idx >= ARRAY_SIZE(arduino_adc)) {
344342
return -EINVAL;
345343
}
346344

@@ -504,8 +502,7 @@ void noInterrupts(void) {
504502
}
505503

506504
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));
509506

510507
return (pcb) ? pin : -1;
511508
}

0 commit comments

Comments
 (0)