Skip to content

Commit a46d32d

Browse files
pillo79soburi
authored andcommitted
loader: remove unnecessary PINCTRL_DYNAMIC
PINCTRL_DYNAMIC is not used and increases memory footprint unnecessarily. Remove it and the related gates in the code. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
1 parent 1013c08 commit a46d32d

5 files changed

Lines changed: 1 addition & 19 deletions

File tree

cores/arduino/zephyrCommon.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <zephyr/spinlock.h>
1111

12-
#ifdef CONFIG_PINCTRL_DYNAMIC
1312
// create an array of arduino_pins with functions to reinitialize pins if needed
1413
static const struct device *pinmux_array[DT_PROP_LEN(DT_PATH(zephyr_user), digital_pin_gpios)] = {
1514
nullptr};
@@ -22,7 +21,6 @@ void _reinit_peripheral_if_needed(pin_size_t pin, const struct device *dev) {
2221
}
2322
}
2423
}
25-
#endif
2624

2725
static const struct gpio_dt_spec arduino_pins[] = {
2826
DT_FOREACH_PROP_ELEM_SEP(
@@ -241,9 +239,7 @@ void yield(void) {
241239
void pinMode(pin_size_t pinNumber, PinMode pinMode) {
242240
RETURN_ON_INVALID_PIN(pinNumber);
243241

244-
#ifdef CONFIG_PINCTRL_DYNAMIC
245242
_reinit_peripheral_if_needed(pinNumber, NULL);
246-
#endif
247243
if (pinMode == INPUT) { // input mode
248244
gpio_pin_configure_dt(&arduino_pins[pinNumber], GPIO_INPUT | GPIO_ACTIVE_HIGH);
249245
} else if (pinMode == INPUT_PULLUP) { // input with internal pull-up
@@ -480,11 +476,8 @@ void analogWrite(pin_size_t pinNumber, int value) {
480476
return;
481477
}
482478

483-
#ifdef CONFIG_PINCTRL_DYNAMIC
484479
_reinit_peripheral_if_needed(pinNumber, arduino_pwm[idx].dev);
485-
#endif
486480
value = CLAMP(value, 0, maxInput);
487-
value = map(value, 0, 1 << _analog_write_resolution, 0, arduino_pwm[idx].period);
488481

489482
const uint32_t pulse = map64(value, 0, maxInput, 0, arduino_pwm[idx].period);
490483

@@ -514,9 +507,7 @@ void analogWrite(enum dacPins dacName, int value) {
514507

515508
// TODO: add reverse map to find pin name from DAC* define
516509
// In the meantime, consider A0 == DAC0
517-
#ifdef CONFIG_PINCTRL_DYNAMIC
518510
_reinit_peripheral_if_needed((pin_size_t)(dacName + A0), dac_dev);
519-
#endif
520511
ret = dac_channel_setup(dac_dev, &dac_ch_cfg[dacName]);
521512
if (ret != 0) {
522513
return;
@@ -579,9 +570,8 @@ int analogRead(pin_size_t pinNumber) {
579570
return -ENOTSUP;
580571
}
581572

582-
#ifdef CONFIG_PINCTRL_DYNAMIC
583573
_reinit_peripheral_if_needed(pinNumber, arduino_adc[idx].dev);
584-
#endif
574+
585575
err = adc_channel_setup(arduino_adc[idx].dev, &arduino_adc[idx].channel_cfg);
586576
if (err < 0) {
587577
return err;

cores/arduino/zephyrInternal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ extern "C" {
1414

1515
void enableInterrupt(pin_size_t);
1616
void disableInterrupt(pin_size_t);
17-
#ifdef CONFIG_PINCTRL_DYNAMIC
1817
void _reinit_peripheral_if_needed(pin_size_t pin, const struct device *dev);
19-
#endif
2018

2119
#ifdef __cplusplus
2220
} // extern "C"

cores/arduino/zephyrSerial.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ void arduino::ZephyrSerial::begin(unsigned long baud, uint16_t conf) {
5858
.flow_ctrl = UART_CFG_FLOW_CTRL_NONE,
5959
};
6060

61-
#ifdef CONFIG_PINCTRL_DYNAMIC
6261
uart->ops.init(uart);
63-
#endif
6462

6563
uart_configure(uart, &config);
6664
uart_irq_callback_user_data_set(uart, arduino::ZephyrSerial::IrqDispatch, this);

libraries/SPI/SPI.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ void arduino::ZephyrSPI::detachInterrupt() {
118118
}
119119

120120
void arduino::ZephyrSPI::begin() {
121-
#ifdef CONFIG_PINCTRL_DYNAMIC
122121
spi_dev->ops.init(spi_dev);
123-
#endif
124122
}
125123

126124
void arduino::ZephyrSPI::end() {

libraries/Wire/Wire.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ arduino::ZephyrI2C::ZephyrI2C(const struct device *i2c) : i2c_dev(i2c) {
1515

1616
void arduino::ZephyrI2C::begin() {
1717
ring_buf_init(&rxRingBuffer.rb, sizeof(rxRingBuffer.buffer), rxRingBuffer.buffer);
18-
#ifdef CONFIG_PINCTRL_DYNAMIC
1918
i2c_dev->ops.init(i2c_dev);
20-
#endif
2119
}
2220

2321
void arduino::ZephyrI2C::begin(uint8_t slaveAddr) {

0 commit comments

Comments
 (0)