From 958614557d5203b5632bc3aee30ea351ef4cc72b Mon Sep 17 00:00:00 2001 From: robert-hh Date: Thu, 20 Jul 2023 21:04:06 +0200 Subject: [PATCH] spi_slave_api.c: Allow to use GPIO 32 and 33 for interface signals. Using consistently the IDF API instead of direct port access. There is a small performace drop compared to direct port access for setting the pin, but that can be accepted in favoer of consistence. GPIO33 for instance is used by Adafruit and NINA modules for the handshake signal, and these modules cannot be rewired. Signed-off-by: robert-hh --- .../esp_driver/network_adapter/main/spi_slave_api.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/esp_hosted_fg/esp/esp_driver/network_adapter/main/spi_slave_api.c b/esp_hosted_fg/esp/esp_driver/network_adapter/main/spi_slave_api.c index 745a675f4a..7e12a4e8e8 100644 --- a/esp_hosted_fg/esp/esp_driver/network_adapter/main/spi_slave_api.c +++ b/esp_hosted_fg/esp/esp_driver/network_adapter/main/spi_slave_api.c @@ -134,8 +134,8 @@ static const char TAG[] = "SPI_DRIVER"; #define GPIO_DR CONFIG_ESP_SPI_GPIO_DATA_READY -#define GPIO_MASK_DATA_READY (1 << GPIO_DR) -#define GPIO_MASK_HANDSHAKE (1 << GPIO_HS) +#define GPIO_MASK_DATA_READY (1ull << GPIO_DR) +#define GPIO_MASK_HANDSHAKE (1ull << GPIO_HS) /* SPI internal configs */ @@ -227,22 +227,22 @@ static inline void spi_trans_free(spi_slave_transaction_t *trans) static inline void set_handshake_gpio(void) { - WRITE_PERI_REG(GPIO_OUT_W1TS_REG, GPIO_MASK_HANDSHAKE); + gpio_set_level(CONFIG_ESP_SPI_GPIO_HANDSHAKE, 1); } static inline void reset_handshake_gpio(void) { - WRITE_PERI_REG(GPIO_OUT_W1TC_REG, GPIO_MASK_HANDSHAKE); + gpio_set_level(CONFIG_ESP_SPI_GPIO_HANDSHAKE, 0); } static inline void set_dataready_gpio(void) { - WRITE_PERI_REG(GPIO_OUT_W1TS_REG, GPIO_MASK_DATA_READY); + gpio_set_level(CONFIG_ESP_SPI_GPIO_DATA_READY, 1); } static inline void reset_dataready_gpio(void) { - WRITE_PERI_REG(GPIO_OUT_W1TC_REG, GPIO_MASK_DATA_READY); + gpio_set_level(CONFIG_ESP_SPI_GPIO_DATA_READY, 0); } interface_context_t *interface_insert_driver(int (*event_handler)(uint8_t val))