From 63cde3ed1533e20d5cec569198337502cf2531b0 Mon Sep 17 00:00:00 2001 From: Luca Burelli Date: Wed, 29 Nov 2023 14:53:10 +0100 Subject: [PATCH] fix: pin_remap: make periman APIs private and non-remapped Turns out that disabling the periman APIs from remap has a negligible effect on the source: the core is already excluded from remapping, as are most of the libraries. It's also expected to be a private API not exposed by default. This patch removes it from both esp32-hal.h and io_pin_remap.h, adjusting the relevant libraries. --- cores/esp32/esp32-hal.h | 1 - cores/esp32/io_pin_remap.h | 10 ---------- libraries/SD/src/sd_diskio.cpp | 6 +++++- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index c2e10dd172a..2f53bb2ff66 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -86,7 +86,6 @@ void yield(void); #include "esp32-hal-psram.h" #include "esp32-hal-rgb-led.h" #include "esp32-hal-cpu.h" -#include "esp32-hal-periman.h" void analogWrite(uint8_t pin, int value); void analogWriteFrequency(uint8_t pin, uint32_t freq); diff --git a/cores/esp32/io_pin_remap.h b/cores/esp32/io_pin_remap.h index 92e98604445..63fb16cefd0 100644 --- a/cores/esp32/io_pin_remap.h +++ b/cores/esp32/io_pin_remap.h @@ -71,16 +71,6 @@ int8_t gpioNumberToDigitalPin(int8_t gpioNumber); #define pinMatrixOutAttach(pin, function, invertOut, invertEnable) pinMatrixOutAttach(digitalPinToGPIONumber(pin), function, invertOut, invertEnable) #define pinMatrixOutDetach(pin, invertOut, invertEnable) pinMatrixOutDetach(digitalPinToGPIONumber(pin), invertOut, invertEnable) -// cores/esp32/esp32-hal-periman.h -#define perimanSetPinBus(pin, type, bus, bus_num, bus_channel) perimanSetPinBus(digitalPinToGPIONumber(pin), type, bus, bus_num, bus_channel) -#define perimanGetPinBus(pin, type) perimanGetPinBus(digitalPinToGPIONumber(pin), type) -#define perimanGetPinBusType(pin) perimanGetPinBusType(digitalPinToGPIONumber(pin)) -#define perimanGetPinBusNum(pin) perimanGetPinBusNum(digitalPinToGPIONumber(pin)) -#define perimanGetPinBusChannel(pin) perimanGetPinBusChannel(digitalPinToGPIONumber(pin)) -#define perimanPinIsValid(pin) perimanPinIsValid(digitalPinToGPIONumber(pin)) -#define perimanSetPinBusExtraType(pin, extra_type) perimanSetPinBusExtraType(digitalPinToGPIONumber(pin), extra_type) -#define perimanGetPinBusExtraType(pin) perimanGetPinBusExtraType(digitalPinToGPIONumber(pin)) - // cores/esp32/esp32-hal-rgb-led.h #define neopixelWrite(pin, red_val, green_val, blue_val) neopixelWrite(digitalPinToGPIONumber(pin), red_val, green_val, blue_val) diff --git a/libraries/SD/src/sd_diskio.cpp b/libraries/SD/src/sd_diskio.cpp index 4282bc18eac..f6a8df5e42b 100644 --- a/libraries/SD/src/sd_diskio.cpp +++ b/libraries/SD/src/sd_diskio.cpp @@ -11,6 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + +// Disable the automatic pin remapping of the API calls in this file +#define ARDUINO_CORE_BUILD + #include "sd_diskio.h" #include "esp_system.h" #include "esp32-hal-periman.h" @@ -742,7 +746,7 @@ uint8_t sdcard_init(uint8_t cs, SPIClass * spi, int hz) card->base_path = NULL; card->frequency = hz; card->spi = spi; - card->ssPin = cs; + card->ssPin = digitalPinToGPIONumber(cs); card->supports_crc = true; card->type = CARD_NONE;