Skip to content

Commit

Permalink
spi_slave_api.c: Allow to use GPIO 32 and 33 for interface signals.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
robert-hh committed Jul 7, 2024
1 parent a9d210c commit 9586145
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 9586145

Please sign in to comment.