应用于LCD显示,向LCD传输360x360个16bit数据。 每个16bit数据扩展成18bit(9+9)数据,通过3Wire SPI 传输。
按目前的理解,受限于数据编码(无法在连续的8bit中进行数据编码),只能每18bit或者27bit执行一次发送事务。
在一次发送事务中,Transaction interval大约占了94.5%(20MHz SCLK见下图)。
请问Transaction interval是否可以优化? 如何优化?
1、SPI配置
- void SPI_3Wire_Interface_Init( esp_err_t* ret, \
- spi_device_handle_t* spi, \
- spi_bus_config_t* buscfg, \
- spi_device_interface_config_t* devcfg)
- {
- buscfg->miso_io_num=-1;
- buscfg->mosi_io_num=PIN_NUM_SPI_3WIRE_SDA_IO;
- buscfg->sclk_io_num=PIN_NUM_SPI_3WIRE_SCLK_O;
- buscfg->quadwp_io_num=-1;
- buscfg->quadhd_io_num=-1;
- //buscfg.data4_io_num=-1;
- //buscfg.data5_io_num=-1;
- //buscfg.data6_io_num=-1;
- //buscfg.data7_io_num=-1;
- buscfg->max_transfer_sz=xSPI_Max_transfer_size;
- buscfg->flags=SPICOMMON_BUSFLAG_DUAL;
- //buscfg.intr_flags=;
- devcfg->command_bits=1;
- //devcfg.address_bits=24;
- //devcfg.dummy_bits=;
- devcfg->mode=xSPI_CPOL_CPHA_mode; //CPOL, CPHA
- //devcfg.duty_cycle_pos;
- //devcfg.cs_ena_pretrans;
- //devcfg.cs_ena_posttrans;
- devcfg->clock_speed_hz=xSPI_Clock_Speed_For_DM_Initial;
- //devcfg.input_delay_ns=;
- //devcfg->spics_io_num=PIN_NUM_SPI_4WIRE_2_CS_O;
- devcfg->flags=SPI_DEVICE_3WIRE | SPI_DEVICE_HALFDUPLEX;
- devcfg->queue_size=7;
- //*devcfg.pre_cb=RS_transfer_callback; //D/C(RS)处理
- //devcfg.post_cb=;
- //Initialize the SPI bus
- *ret=spi_bus_initialize(LCD_HOST, buscfg, SPI_DMA_CH_AUTO);
- ESP_ERROR_CHECK(*ret);
- //Attach the LCD to the SPI bus
- *ret=spi_bus_add_device(LCD_HOST, devcfg, spi);
- ESP_ERROR_CHECK(*ret);
- }
- void DM_Display_Color(uint16_t u16Color)
- {
- uint32_t i,j= 0;
- uint32_t u32TxBuffer = 0;
- uint32_t u32temp = 0;
- //uint16_t u16Color = 0xF800; //16bit 565 红色
- u32temp = (1 << 17) | (1 << 8) | ((u16Color & 0xFF00) << 1) | ((u16Color & 0x00FF) << 1); //增加D/Cx标识位
- u32TxBuffer = SPI_SWAP_DATA_TX(u32temp,18);
- ICNA3310_write_1R4D(0x2A, 0x00, 0x00, 0x01, 0x67); // paritial update
- ICNA3310_write_1R4D(0x2B, 0x00, 0x00, 0x01, 0x67); // partial update
- ICNA3310_write_1R0D(0x2C);
- devcfg.command_bits=0;
- ret=spi_bus_add_device(LCD_HOST, &devcfg, &spi);
- ESP_ERROR_CHECK(ret);
- DM_CS(0);
- for(i=0; i<360; i++)
- {
- for(j=0; j<360; j++)
- {
- //发送data
- memset(&sendcfg, 0, sizeof(sendcfg));
- sendcfg.length = 18;
- sendcfg.tx_buffer = &u32TxBuffer;
- ret=spi_device_polling_transmit(spi, &sendcfg);
- assert(ret==ESP_OK);
- }
- }
- DM_CS(1);
- }