How to use QSPI mode on VSPI peripheral
Posted: Mon May 07, 2018 2:44 pm
Hi all,
I tried to use QSPI mode on VSPI module.
Here is my code to initialize VSPI module:
However, when I check with Logic Analyser on all QSPI signals, there are 16 SCK pulses which means it is still single SPI (I expect to have 4 SCK pulses to transfer 2 bytes in QSPI mode).
Have anyone be able to use QSPI mode with VSPI module? Please share information.
Thanks,
Huy
I tried to use QSPI mode on VSPI module.
Here is my code to initialize VSPI module:
Code: Select all
void app_main()
{
esp_err_t ret;
spi_device_handle_t spi;
spi_bus_config_t buscfg={
.miso_io_num=19,
.mosi_io_num=23,
.sclk_io_num=18,
.quadwp_io_num=22,
.quadhd_io_num=21,
.flags = SPICOMMON_BUSFLAG_SCLK | SPICOMMON_BUSFLAG_MOSI | SPICOMMON_BUSFLAG_MISO | SPICOMMON_BUSFLAG_NATIVE_PINS | SPICOMMON_BUSFLAG_QUAD,
.max_transfer_sz=PARALLEL_LINES*320*2+8
};
spi_device_interface_config_t devcfg={
.clock_speed_hz=1*1000*1000, //Clock out at 1 MHz
.mode=0, //SPI mode 0
.spics_io_num=5,
.queue_size=7, //We want to be able to queue 7 transactions at a time
.pre_cb=lcd_spi_pre_transfer_callback, //Specify pre-transfer callback to handle D/C line
};
//Initialize the SPI bus
ret=spi_bus_initialize(VSPI_HOST, &buscfg, 1);
ESP_ERROR_CHECK(ret);
//Attach the LCD to the SPI bus
ret=spi_bus_add_device(VSPI_HOST, &devcfg, &spi);
ESP_ERROR_CHECK(ret);
uint8_t data[2] = {255, 128};
spi_transaction_t trans;
trans.tx_buffer = data; //point to user buffer for Tx data
trans.rxlength = 0;
trans.length = 2*8; //translate to length in bits
trans.flags = 0;
trans.rx_buffer = NULL;
while(1)
{
spi_device_transmit(spi, &trans);
vTaskDelay(150 / portTICK_RATE_MS);
}
}
Have anyone be able to use QSPI mode with VSPI module? Please share information.
Thanks,
Huy