diff --git a/src/hal/generic.h b/src/hal/generic.h index a8a5555d..6f1e4230 100644 --- a/src/hal/generic.h +++ b/src/hal/generic.h @@ -11,7 +11,7 @@ #define SPI_MOSI GPIO_NUM_23 #define SPI_MISO GPIO_NUM_19 #define SPI_SCLK GPIO_NUM_18 -#define SPI_CS GPIO_NUM_5 +#define SPI_CS GPIO_NUM_5 #define CFG_sx1276_radio 1 // select LoRa chip //#define CFG_sx1272_radio 1 // select LoRa chip diff --git a/src/hal/lopy4.h b/src/hal/lopy4.h index e98408b1..5e68c78c 100644 --- a/src/hal/lopy4.h +++ b/src/hal/lopy4.h @@ -9,10 +9,10 @@ #define HAS_SPI 1 // comment out if device shall not send data via SPI // pin definitions for local wired SPI slave interface -#define SPI_MOSI (22) -#define SPI_MISO (33) -#define SPI_SCLK (26) -#define SPI_CS (36) +#define SPI_MOSI GPIO_NUM_22 +#define SPI_MISO GPIO_NUM_33 +#define SPI_SCLK GPIO_NUM_26 +#define SPI_CS GPIO_NUM_36 #define CFG_sx1276_radio 1 //#define HAS_LED NOT_A_PIN // LoPy4 has no on board mono LED, we use on board RGB LED diff --git a/src/spislave.cpp b/src/spislave.cpp index 7657a924..67d544eb 100644 --- a/src/spislave.cpp +++ b/src/spislave.cpp @@ -128,11 +128,16 @@ esp_err_t spi_init() { gpio_set_pull_mode(SPI_SCLK, GPIO_PULLUP_ONLY); gpio_set_pull_mode(SPI_CS, GPIO_PULLUP_ONLY); - ESP_LOGI(TAG, "Starting SPIloop..."); - xTaskCreate(spi_slave_task, "spiloop", 4096, (void *)NULL, 2, &spiTask); - esp_err_t ret = spi_slave_initialize(HSPI_HOST, &spi_bus_cfg, &spi_slv_cfg, 1); + + if (ret == ESP_OK) { + ESP_LOGI(TAG, "Starting SPIloop..."); + xTaskCreate(spi_slave_task, "spiloop", 4096, (void *)NULL, 2, &spiTask); + } else { + ESP_LOGE(TAG, "SPI interface initialization failed"); + } + return ret; #endif