77#include < Arduino.h>
88#include " zephyrInternal.h"
99
10- #ifdef CONFIG_PINCTRL_DYNAMIC
1110// create an array of arduino_pins with functions to reinitialize pins if needed
1211static const struct device *pinmux_array[DT_PROP_LEN(DT_PATH(zephyr_user), digital_pin_gpios)] = {
1312 nullptr };
@@ -20,7 +19,6 @@ void _reinit_peripheral_if_needed(pin_size_t pin, const struct device *dev) {
2019 }
2120 }
2221}
23- #endif
2422
2523static const struct gpio_dt_spec arduino_pins[] = {
2624 DT_FOREACH_PROP_ELEM_SEP (
@@ -224,9 +222,7 @@ void yield(void) {
224222 * A high physical level will be interpreted as value 1
225223 */
226224void pinMode (pin_size_t pinNumber, PinMode pinMode) {
227- #ifdef CONFIG_PINCTRL_DYNAMIC
228225 _reinit_peripheral_if_needed (pinNumber, NULL );
229- #endif
230226 if (pinMode == INPUT) { // input mode
231227 gpio_pin_configure_dt (&arduino_pins[pinNumber], GPIO_INPUT | GPIO_ACTIVE_HIGH);
232228 } else if (pinMode == INPUT_PULLUP) { // input with internal pull-up
@@ -330,9 +326,7 @@ void analogWrite(pin_size_t pinNumber, int value) {
330326 return ;
331327 }
332328
333- #ifdef CONFIG_PINCTRL_DYNAMIC
334329 _reinit_peripheral_if_needed (pinNumber, arduino_pwm[idx].dev );
335- #endif
336330 value = map (value, 0 , 1 << _analog_write_resolution, 0 , arduino_pwm[idx].period );
337331
338332 if (((uint32_t )value) > arduino_pwm[idx].period ) {
@@ -358,9 +352,7 @@ void analogWrite(enum dacPins dacName, int value) {
358352
359353 // TODO: add reverse map to find pin name from DAC* define
360354 // In the meantime, consider A0 == DAC0
361- #ifdef CONFIG_PINCTRL_DYNAMIC
362355 _reinit_peripheral_if_needed ((pin_size_t )(dacName + A0), dac_dev);
363- #endif
364356 dac_channel_setup (dac_dev, &dac_ch_cfg[dacName]);
365357
366358 const int max_dac_value = 1U << dac_ch_cfg[dacName].resolution ;
@@ -411,9 +403,8 @@ int analogRead(pin_size_t pinNumber) {
411403 return -ENOTSUP;
412404 }
413405
414- #ifdef CONFIG_PINCTRL_DYNAMIC
415406 _reinit_peripheral_if_needed (pinNumber, arduino_adc[idx].dev );
416- # endif
407+
417408 err = adc_channel_setup (arduino_adc[idx].dev , &arduino_adc[idx].channel_cfg );
418409 if (err < 0 ) {
419410 return err;
0 commit comments