Skip to content

Commit 9586145

Browse files
committed
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 <[email protected]>
1 parent a9d210c commit 9586145

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

esp_hosted_fg/esp/esp_driver/network_adapter/main/spi_slave_api.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ static const char TAG[] = "SPI_DRIVER";
134134
#define GPIO_DR CONFIG_ESP_SPI_GPIO_DATA_READY
135135

136136

137-
#define GPIO_MASK_DATA_READY (1 << GPIO_DR)
138-
#define GPIO_MASK_HANDSHAKE (1 << GPIO_HS)
137+
#define GPIO_MASK_DATA_READY (1ull << GPIO_DR)
138+
#define GPIO_MASK_HANDSHAKE (1ull << GPIO_HS)
139139

140140

141141
/* SPI internal configs */
@@ -227,22 +227,22 @@ static inline void spi_trans_free(spi_slave_transaction_t *trans)
227227

228228
static inline void set_handshake_gpio(void)
229229
{
230-
WRITE_PERI_REG(GPIO_OUT_W1TS_REG, GPIO_MASK_HANDSHAKE);
230+
gpio_set_level(CONFIG_ESP_SPI_GPIO_HANDSHAKE, 1);
231231
}
232232

233233
static inline void reset_handshake_gpio(void)
234234
{
235-
WRITE_PERI_REG(GPIO_OUT_W1TC_REG, GPIO_MASK_HANDSHAKE);
235+
gpio_set_level(CONFIG_ESP_SPI_GPIO_HANDSHAKE, 0);
236236
}
237237

238238
static inline void set_dataready_gpio(void)
239239
{
240-
WRITE_PERI_REG(GPIO_OUT_W1TS_REG, GPIO_MASK_DATA_READY);
240+
gpio_set_level(CONFIG_ESP_SPI_GPIO_DATA_READY, 1);
241241
}
242242

243243
static inline void reset_dataready_gpio(void)
244244
{
245-
WRITE_PERI_REG(GPIO_OUT_W1TC_REG, GPIO_MASK_DATA_READY);
245+
gpio_set_level(CONFIG_ESP_SPI_GPIO_DATA_READY, 0);
246246
}
247247

248248
interface_context_t *interface_insert_driver(int (*event_handler)(uint8_t val))

0 commit comments

Comments
 (0)