rfid: harden SPI3 bus init failure path (no abort), add reader-bus diagnostic log
This commit is contained in:
@@ -76,12 +76,17 @@ esp_err_t rfid_manager_init(void)
|
||||
{
|
||||
/* Dedicated SPI3_HOST (HSPI) bus for the reader - independent controller
|
||||
* so the display (SPI2_HOST) and the RFID never share bus timing. The
|
||||
* rc522 driver will call spi_bus_initialize() itself on this host. */
|
||||
* rc522 driver will call spi_bus_initialize() itself on this host with
|
||||
* this bus config (MISO=13 is a real pin and is used for reads). */
|
||||
static spi_bus_config_t rfid_bus_cfg = {
|
||||
.sclk_io_num = HW_RFID_SCK_GPIO,
|
||||
.mosi_io_num = HW_RFID_MOSI_GPIO,
|
||||
.miso_io_num = HW_RFID_MISO_GPIO,
|
||||
.quadwp_io_num = -1,
|
||||
.quadhd_io_num = -1,
|
||||
};
|
||||
ESP_LOGI(TAG, "initializing MFRC522 on SPI3_HOST (SCK=%d MOSI=%d MISO=%d CS=%d)",
|
||||
HW_RFID_SCK_GPIO, HW_RFID_MOSI_GPIO, HW_RFID_MISO_GPIO, HW_RC522_CS_GPIO);
|
||||
|
||||
rc522_spi_config_t driver_config = {
|
||||
.host_id = HW_RFID_SPI_HOST,
|
||||
@@ -102,7 +107,12 @@ esp_err_t rfid_manager_init(void)
|
||||
ESP_LOGE(TAG, "rc522_spi_create failed: %s", esp_err_to_name(ret));
|
||||
return ret;
|
||||
}
|
||||
ESP_ERROR_CHECK(rc522_driver_install(s_driver));
|
||||
ret = rc522_driver_install(s_driver);
|
||||
if (ret != ESP_OK) {
|
||||
/* Includes the SPI3 bus initialization; never abort boot here. */
|
||||
ESP_LOGE(TAG, "rc522 driver install (incl. SPI3 bus init) failed: %s", esp_err_to_name(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
rc522_config_t scanner_config = {
|
||||
.driver = s_driver,
|
||||
|
||||
Reference in New Issue
Block a user