diff options
author | Tomas Vanek <vanekt@fbl.cz> | 2021-12-01 18:34:39 +0100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-12-15 15:49:23 +1100 |
commit | 3305ec44a2f45f9afbae029d157d49d1270cf21d (patch) | |
tree | 9eb9b834db3db8a705599987d60664e8515baec6 | |
parent | f9733705a907a9e9c3b3e6ab613cc1d7f63b51a6 (diff) |
esp32/machine_hw_spi: Fix SPI default pins reordering on ESP32-S2/S3.
The index of machine_hw_spi_obj and machine_hw_spi_default_pins arrays is
assigned to 0 for ARG_id==HSPI_HOST and 1 for another SPI. On ESP32S2 and
S3 HSPI_HOST=2 so the first set (idx=0) of default pins is used for
SPI(id=2) aka HSPI/SPI3 and the second set (idx=1) for SPI(id=1) aka
FSPI/SPI2. This makes a misleading mess in MICROPY_HW_SPIxxxx definitions
and it is also in contradiction to the comments around the definitions.
Change the test of ARG_id to fix the order of machine_hw_spi_default_pins.
This change might require adjusting MICROPY_HW_SPIxxxx definitions in
mpconfigboard.h of S2/S3 based boards.
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
-rw-r--r-- | ports/esp32/machine_hw_spi.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ports/esp32/machine_hw_spi.c b/ports/esp32/machine_hw_spi.c index 467bff7cc..27afa60af 100644 --- a/ports/esp32/machine_hw_spi.c +++ b/ports/esp32/machine_hw_spi.c @@ -458,7 +458,7 @@ mp_obj_t machine_hw_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_ machine_hw_spi_obj_t *self; const machine_hw_spi_default_pins_t *default_pins; - if (args[ARG_id].u_int == HSPI_HOST) { + if (args[ARG_id].u_int == 1) { // SPI2_HOST which is FSPI_HOST on ESP32Sx, HSPI_HOST on others self = &machine_hw_spi_obj[0]; default_pins = &machine_hw_spi_default_pins[0]; } else { |