这样写GPIO0操作无效
Code: Select all
gpio_reset_pin(GPIO_NUM_0);
gpio_set_direction(GPIO_NUM_0, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_NUM_0, 1);
spi_device_handle_t spi;
spi_bus_config_t bus_cfg = {
.mosi_io_num = GPIO_NUM_37,
.miso_io_num = GPIO_NUM_46,
.sclk_io_num = GPIO_NUM_45,
.max_transfer_sz = 100,
};
spi_bus_initialize(SPI2_HOST, &bus_cfg, SPI_DMA_CH_AUTO);
spi_device_interface_config_t dev_cfg = {
.clock_speed_hz = 1 * 1000 * 1000,
.command_bits = 0,
.address_bits = 0,
.dummy_bits = 0,
.mode = 2,
.spics_io_num = -1,
.queue_size = 1,
};
spi_bus_add_device(SPI2_HOST, &dev_cfg, &spi);
while(1)
{
gpio_set_level(GPIO_NUM_0, 0);
gpio_set_level(GPIO_NUM_0, 1);
vTaskDelay(pdMS_TO_TICKS(100));
}
Code: Select all
gpio_reset_pin(GPIO_NUM_0);
gpio_set_direction(GPIO_NUM_0, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_NUM_0, 1);
spi_device_handle_t spi;
spi_bus_config_t bus_cfg = {
.mosi_io_num = GPIO_NUM_37,
.miso_io_num = GPIO_NUM_46,
.sclk_io_num = GPIO_NUM_45,
.max_transfer_sz = 100,
};
spi_bus_initialize(SPI2_HOST, &bus_cfg, SPI_DMA_CH_AUTO);
spi_device_interface_config_t dev_cfg = {
.clock_speed_hz = 1 * 1000 * 1000,
.command_bits = 0,
.address_bits = 0,
.dummy_bits = 0,
.mode = 2,
.spics_io_num = -1,
.queue_size = 1,
};
spi_bus_add_device(SPI2_HOST, &dev_cfg, &spi);
while(1)
{
gpio_set_level(GPIO_NUM_0, 0);
gpio_set_level(GPIO_NUM_0, 1);
vTaskDelay(pdMS_TO_TICKS(100));
}