esp_eth: Improve GPIO interrupt processing in w5500 driver

Increase the interrupt reassert level timing so the chances of missing
two consecutive events are minimal.
Enable only SIR_RECV interrupt event, so the SEND events are not used
for GPIO signal.
This commit is contained in:
David Cermak 2021-04-09 21:25:20 +02:00 committed by bot
parent 0cd021adb1
commit 45846f06cf
2 changed files with 6 additions and 2 deletions

View File

@ -259,9 +259,12 @@ static esp_err_t w5500_setup_default(emac_w5500_t *emac)
/* Enable MAC RAW mode for SOCK0, enable MAC filter, no blocking broadcast and multicast */
reg_value = W5500_SMR_MAC_RAW | W5500_SMR_MAC_FILTER;
ESP_GOTO_ON_ERROR(w5500_write(emac, W5500_REG_SOCK_MR(0), &reg_value, sizeof(reg_value)), err, TAG, "write SMR failed");
/* Enable receive and send event for SOCK0 */
reg_value = W5500_SIR_RECV | W5500_SIR_SEND;
/* Enable receive event for SOCK0 */
reg_value = W5500_SIR_RECV;
ESP_GOTO_ON_ERROR(w5500_write(emac, W5500_REG_SOCK_IMR(0), &reg_value, sizeof(reg_value)), err, TAG, "write SOCK0 IMR failed");
/* Set the interrupt re-assert level to maximum (~1.5ms) to lower the chances of missing it */
uint16_t int_level = __builtin_bswap16(0xFFFF);
ESP_GOTO_ON_ERROR(w5500_write(emac, W5500_REG_INTLEVEL, &int_level, sizeof(int_level)), err, TAG, "write INTLEVEL failed");
err:
return ret;

View File

@ -33,6 +33,7 @@
#define W5500_REG_MR W5500_MAKE_MAP(0x0000, W5500_BSB_COM_REG) // Mode
#define W5500_REG_MAC W5500_MAKE_MAP(0x0009, W5500_BSB_COM_REG) // MAC Address
#define W5500_REG_INTLEVEL W5500_MAKE_MAP(0x0013, W5500_BSB_COM_REG) // Interrupt Level Timeout
#define W5500_REG_IR W5500_MAKE_MAP(0x0015, W5500_BSB_COM_REG) // Interrupt
#define W5500_REG_IMR W5500_MAKE_MAP(0x0016, W5500_BSB_COM_REG) // Interrupt Mask
#define W5500_REG_SIR W5500_MAKE_MAP(0x0017, W5500_BSB_COM_REG) // Socket Interrupt