硬件:ESP32C3芯片
IDF:V4.3.2
问题现象:
初始化SPI2_HOST后,进行SPI2读写操作时,会造成GPIO0引脚的电平异常变化(接近2us的下降沿)。(注意,初始化SPI2后,不要对GPIO0进行任何配置)
SPI2使用引脚如下:
#define NRF_PIN_NUM_MISO 2
#define NRF_PIN_NUM_MOSI 7
#define NRF_PIN_NUM_CLK 6
#define NRF_PIN_NUM_CS 10
SPI2初始化代码如下:
sta
tic void NrfSpiInit(void) {
esp_err_t ret;
gpio_reset_pin(NRF_PIN_NUM_CS);
gpio_set_direction(NRF_PIN_NUM_CS, GPIO_MODE_OUTPUT);
gpio_set_level(NRF_PIN_NUM_CS, 1);
spi_bus_config_t spi_bus_config = {.sclk_io_num = NRF_PIN_NUM_CLK,
.mosi_io_num = NRF_PIN_NUM_MOSI,
.miso_io_num = NRF_PIN_NUM_MISO,
.quadwp_io_num = -1,
.quadhd_io_num = -1};
ret = spi_bus_initialize(NRF_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO);
// ESP_LOGI(TAG, "spi_bus_initialize=%d",ret);
assert(ret == ESP_OK);
spi_device_interface_config_t devcfg;
memset(&devcfg, 0, sizeof(spi_device_interface_config_t));
devcfg.clock_speed_hz = SPI_Frequency;
devcfg.queue_size = 7;
devcfg.mode = 0;
devcfg.flags = SPI_DEVICE_NO_DUMMY;
spi_device_handle_t handle;
ret = spi_bus_add_device(NRF_SPI_HOST, &devcfg, &handle);
// ESP_LOGI(TAG, "spi_bus_add_device=%d",ret);
assert(ret == ESP_OK);
anoNrf_SPIHandle = handle;
}