Skip to content

Commit

Permalink
Adding better declarations for ESP32 peripherals (at minimum allows u…
Browse files Browse the repository at this point in the history
…s to make nicer docs pages, maybe good for #2589)

fix default pin for ESP32 SPI2
  • Loading branch information
gfwilliams committed Jan 6, 2025
1 parent e30de2a commit 3c11580
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 20 deletions.
17 changes: 13 additions & 4 deletions boards/ESP32.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,19 @@ def get_pins():

pinutils.findpin(pins, "PD0", True)["functions"]["NEGATED"]=0; # BTN1 negate

pinutils.findpin(pins, "PD10", True)["functions"]["USART0_TX"]=0;
pinutils.findpin(pins, "PD16", True)["functions"]["USART2_RX"]=0;
pinutils.findpin(pins, "PD17", True)["functions"]["USART2_TX"]=0;
pinutils.findpin(pins, "PD32", True)["functions"]["USART0_RX"]=0;
pinutils.findpin(pins, "PD10", True)["functions"]["USART1_TX"]=0; # doesn't match jshardwareUart?
pinutils.findpin(pins, "PD32", True)["functions"]["USART1_RX"]=0; # doesn't match jshardwareUart?
pinutils.findpin(pins, "PD16", True)["functions"]["USART3_RX"]=0;
pinutils.findpin(pins, "PD17", True)["functions"]["USART3_TX"]=0;

pinutils.findpin(pins, "PD21", True)["functions"]["I2C1_SCL"]=0;
pinutils.findpin(pins, "PD22", True)["functions"]["I2C1_SDA"]=0;
pinutils.findpin(pins, "PD14", True)["functions"]["SPI1_SCLK"]=0;
pinutils.findpin(pins, "PD12", True)["functions"]["SPI1_MISO"]=0;
pinutils.findpin(pins, "PD13", True)["functions"]["SPI1_MOSI"]=0;
pinutils.findpin(pins, "PD18", True)["functions"]["SPI2_SCLK"]=0;
pinutils.findpin(pins, "PD19", True)["functions"]["SPI2_MISO"]=0;
pinutils.findpin(pins, "PD23", True)["functions"]["SPI2_MOSI"]=0;

# everything is non-5v tolerant
#for pin in pins:
Expand Down
11 changes: 8 additions & 3 deletions boards/ESP32C3_IDF4.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,14 @@ def get_pins():
# On supermini D9 is (inverted) Button
# D12-D17 are SPI (internal SPI) - not sure they should even be exposed??

#18/19 are USB
pinutils.findpin(pins, "PD20", True)["functions"]["USART0_RX"]=0;
pinutils.findpin(pins, "PD21", True)["functions"]["USART0_TX"]=0;
pinutils.findpin(pins, "PD18", True)["functions"]["USB"]=0; # D-
pinutils.findpin(pins, "PD19", True)["functions"]["USB"]=0; # D+
pinutils.findpin(pins, "PD20", True)["functions"]["USART1_RX"]=0;
pinutils.findpin(pins, "PD21", True)["functions"]["USART1_TX"]=0;
pinutils.findpin(pins, "PD9", True)["functions"]["I2C1_SCL"]=0;
pinutils.findpin(pins, "PD8", True)["functions"]["I2C1_SDA"]=0;
# SPI1_SCLK/etc?


# everything is non-5v tolerant
for pin in pins:
Expand Down
5 changes: 5 additions & 0 deletions boards/ESP32S3_IDF4.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@
def get_pins():
pins = pinutils.generate_pins(0,39) # 40 General Purpose I/O Pins.


pinutils.findpin(pins, "PD11", True)["functions"]["I2C1_SCL"]=0;
pinutils.findpin(pins, "PD10", True)["functions"]["I2C1_SDA"]=0;
# SPI1_SCLK/etc?

# everything is non-5v tolerant
#for pin in pins:
# pin["functions"]["3.3"]=0;
Expand Down
18 changes: 10 additions & 8 deletions boards/ESP32_CYD.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,19 @@ def get_pins():
pinutils.findpin(pins, "PD17", True)["functions"]["NEGATED"]=0;
pinutils.findpin(pins, "PD0", True)["functions"]["NEGATED"]=0; # BTN1

pinutils.findpin(pins, "PD10", True)["functions"]["USART0_TX"]=0;
pinutils.findpin(pins, "PD16", True)["functions"]["USART2_RX"]=0;
pinutils.findpin(pins, "PD17", True)["functions"]["USART2_TX"]=0;
pinutils.findpin(pins, "PD32", True)["functions"]["USART0_RX"]=0;
pinutils.findpin(pins, "PD10", True)["functions"]["USART1_TX"]=0; # doesn't match jshardwareUart?
pinutils.findpin(pins, "PD32", True)["functions"]["USART1_RX"]=0; # doesn't match jshardwareUart?
pinutils.findpin(pins, "PD16", True)["functions"]["USART3_RX"]=0;
pinutils.findpin(pins, "PD17", True)["functions"]["USART3_TX"]=0;

pinutils.findpin(pins, "PD13", True)["functions"]["SPI1_MOSI"]=0;
pinutils.findpin(pins, "PD12", True)["functions"]["SPI1_MISO"]=0;
pinutils.findpin(pins, "PD21", True)["functions"]["I2C1_SCL"]=0;
pinutils.findpin(pins, "PD22", True)["functions"]["I2C1_SDA"]=0;
pinutils.findpin(pins, "PD14", True)["functions"]["SPI1_SCLK"]=0;
pinutils.findpin(pins, "PD23", True)["functions"]["SPI2_MOSI"]=0;
pinutils.findpin(pins, "PD19", True)["functions"]["SPI2_MISO"]=0;
pinutils.findpin(pins, "PD12", True)["functions"]["SPI1_MISO"]=0;
pinutils.findpin(pins, "PD13", True)["functions"]["SPI1_MOSI"]=0;
pinutils.findpin(pins, "PD18", True)["functions"]["SPI2_SCLK"]=0;
pinutils.findpin(pins, "PD19", True)["functions"]["SPI2_MISO"]=0;
pinutils.findpin(pins, "PD23", True)["functions"]["SPI2_MOSI"]=0;


# everything is non-5v tolerant
Expand Down
17 changes: 13 additions & 4 deletions boards/ESP32_IDF4.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,19 @@ def get_pins():

pinutils.findpin(pins, "PD0", True)["functions"]["LED_1"]=0;

pinutils.findpin(pins, "PD10", True)["functions"]["USART0_TX"]=0;
pinutils.findpin(pins, "PD16", True)["functions"]["USART2_RX"]=0;
pinutils.findpin(pins, "PD17", True)["functions"]["USART2_TX"]=0;
pinutils.findpin(pins, "PD32", True)["functions"]["USART0_RX"]=0;
pinutils.findpin(pins, "PD10", True)["functions"]["USART1_TX"]=0; # doesn't match jshardwareUart?
pinutils.findpin(pins, "PD32", True)["functions"]["USART1_RX"]=0; # doesn't match jshardwareUart?
pinutils.findpin(pins, "PD16", True)["functions"]["USART3_RX"]=0;
pinutils.findpin(pins, "PD17", True)["functions"]["USART3_TX"]=0;

pinutils.findpin(pins, "PD21", True)["functions"]["I2C1_SCL"]=0;
pinutils.findpin(pins, "PD22", True)["functions"]["I2C1_SDA"]=0;
pinutils.findpin(pins, "PD14", True)["functions"]["SPI1_SCLK"]=0;
pinutils.findpin(pins, "PD12", True)["functions"]["SPI1_MISO"]=0;
pinutils.findpin(pins, "PD13", True)["functions"]["SPI1_MOSI"]=0;
pinutils.findpin(pins, "PD18", True)["functions"]["SPI2_SCLK"]=0;
pinutils.findpin(pins, "PD19", True)["functions"]["SPI2_MISO"]=0;
pinutils.findpin(pins, "PD23", True)["functions"]["SPI2_MOSI"]=0;

# everything is non-5v tolerant
#for pin in pins:
Expand Down
2 changes: 1 addition & 1 deletion targets/esp32/jshardwareSpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void jshSPISetup(
}
else {
dma_chan = 2;
sck = inf->pinSCK != PIN_UNDEFINED ? inf->pinSCK : 5;
sck = inf->pinSCK != PIN_UNDEFINED ? inf->pinSCK : 18;
miso = inf->pinMISO != PIN_UNDEFINED ? inf->pinMISO : 19;
mosi = inf->pinMOSI != PIN_UNDEFINED ? inf->pinMOSI : 23;
}
Expand Down

0 comments on commit 3c11580

Please sign in to comment.