Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify w5500 chip properly (IDFGH-9158) #10554

Merged
merged 1 commit into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/esp_eth/src/esp_eth_mac_w5500.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ static esp_err_t w5500_verify_id(emac_w5500_t *emac)
esp_err_t ret = ESP_OK;
uint8_t version = 0;
ESP_GOTO_ON_ERROR(w5500_read(emac, W5500_REG_VERSIONR, &version, sizeof(version)), err, TAG, "read VERSIONR failed");
// W5500 doesn't have chip ID, we just print the version number instead
ESP_LOGI(TAG, "version=%x", version);
// W5500 doesn't have chip ID, we check the version number instead
ESP_GOTO_ON_FALSE(version == W5500_CHIP_VERSION, ESP_ERR_INVALID_VERSION, err, TAG, "invalid chip version, expected 0x%x, actual 0x%x", W5500_CHIP_VERSION, version);

err:
return ret;
Expand Down
2 changes: 2 additions & 0 deletions components/esp_eth/src/w5500.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#define W5500_BSB_OFFSET (3) // Block Select Bits offset
#define W5500_RWB_OFFSET (2) // Read Write Bits offset

#define W5500_CHIP_VERSION (0x4) // Chip version that VERSIONR returns

#define W5500_BSB_COM_REG (0x00) // Common Register
#define W5500_BSB_SOCK_REG(s) ((s)*4+1) // Socket Register
#define W5500_BSB_SOCK_TX_BUF(s) ((s)*4+2) // Socket TX Buffer
Expand Down