@felmue Thank you for the pointer! Looks like perhaps it's fixed for the Arduino implementation? It does not seem fixed for the ESP-IDF version quite yet. Your workaround combined with the pre_cb and post_cb callbacks worked! Here's a snippet/summary of what I did:
#ifdef CONFIG_M5CORES3_SPI_CONFLICT_FIX
#define M5CORES3_SPI_CONFIG_FIX_MISO_PIN 35
void sx127x_spi_pre_transfer_m5cores3_fix_callback(spi_transaction_t* t) {
// before a SPI transaction is started, we need to change the driving direction
// of the DC pin in the CoreS3 (the CoreS3 uses the MISO pin as the DC pin and
// configures it as an output ping which conflicts with other SPI devices on the bus)
// set gpio direction for MISO pin to input
gpio_set_direction(M5CORES3_SPI_CONFIG_FIX_MISO_PIN, GPIO_MODE_INPUT);
}
void sx127x_spi_post_transfer_m5cores3_fix_callback(spi_transaction_t* t) {
// undo pin direction change after SPI transaction is done
// set gpio direction for MISO pin back to output
gpio_set_direction(M5CORES3_SPI_CONFIG_FIX_MISO_PIN, GPIO_MODE_OUTPUT);
}
#endif
sx127x_handle_t sx127x_init(const sx127x_modem_config_t* modem_config)
{
// ...
// Configure SPI device
spi_device_interface_config_t spi_dev_cfg = {
.clock_speed_hz = 9000000, // 9MHz
.mode = 0,
.spics_io_num = modem_config->cs_gpio,
.queue_size = 7,
.flags = 0,
#ifdef CONFIG_M5CORES3_SPI_CONFLICT_FIX
.pre_cb = sx127x_spi_pre_transfer_m5cores3_fix_callback,
.post_cb = sx127x_spi_post_transfer_m5cores3_fix_callback
#endif
};
ret = spi_bus_add_device(spi_host, &spi_dev_cfg, &device->spi);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to add SPI device");
vSemaphoreDelete(device->spi_mutex);
free(device);
return NULL;
}
// ...
}
I can now use both the display and the sx1276 at the same time on the M5Stack CoreS3.
Thanks again for your assistance!