esp32s3 esp-idf v5.1.1 lvgl驱动夏普memory lcd

如何使用lvgl驱动夏普memory lcd 分辨率400x240
官方有对应的驱动,但是具体关于esp-idf spi的初始化和数据发送并没有明确定义
我尝试写了spi初始化和数据发送,屏幕只能显示乱码

static void disp_init(void)
{
    // Initialize SPI
    esp_err_t ret;
    // MISO not used, only Master to Slave
    spi_bus_config_t buscfg = {
        .mosi_io_num = _mosi,
        .miso_io_num = -1,
        .sclk_io_num = _clk,
        .quadwp_io_num = -1,
        .quadhd_io_num = -1,
        .max_transfer_sz = 4094};
    // max_transfer_sz   4Kb is the defaut SPI transfer size if 0
    // debug: 50000  0.5 Mhz so we can sniff the SPI commands with a Slave
    uint16_t multiplier = 1000;

    // Config Frequency and SS GPIO

    // SPI_DEVICE_TXBIT_LSBFIRST
    spi_device_interface_config_t devcfg = {
        .mode = 0,                               // SPI mode 0
        .clock_speed_hz = 4 * multiplier * 1000, // Can be up to 4 Mhz
        .spics_io_num = -1,                      // -1 == Do not control CS automatically!
        .flags = SPI_DEVICE_TXBIT_LSBFIRST,
        .queue_size = 5};
    // DISABLED Callbacks pre_cb/post_cb. SPI does not seem to behave the same
    // CS / DC GPIO states the usual way

    // Initialize the SPI bus
    ret = spi_bus_initialize(EPD_HOST, &buscfg, DMA_CHAN);
    ESP_ERROR_CHECK(ret);

    // Attach the EPD to the SPI bus
    ret = spi_bus_add_device(EPD_HOST, &devcfg, &spi);
    ESP_ERROR_CHECK(ret);
    printf("SPI initialized. MOSI:%d CLK:%d CS:%d\n", _mosi, _clk, _cs);

    // This display is weird in that _cs is active HIGH not LOW like every other SPI device
    gpio_set_level((gpio_num_t)_cs, 0);
}
static void disp_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
{
    /*Return if the area is out the screen*/
    if (area->y2 < 0)
        return;
    if (area->y1 > SHARP_MIP_VER_RES - 1)
        return;

    /*Truncate the area to the screen*/
    uint16_t act_y1 = area->y1 < 0 ? 0 : area->y1;
    uint16_t act_y2 = area->y2 > SHARP_MIP_VER_RES - 1 ? SHARP_MIP_VER_RES - 1 : area->y2;

    uint8_t *buf = (uint8_t *)color_p;                           /*Get the buffer address*/
    uint16_t buf_h = (act_y2 - act_y1 + 1);                      /*Number of buffer lines*/
    uint16_t buf_size = buf_h * (2 + SHARP_MIP_HOR_RES / 8) + 2; /*Buffer size in bytes  */

    /* Set lines to flush dummy byte & gate address in draw_buf*/
    for (uint16_t act_y = 0; act_y < buf_h; act_y++)
    {
        buf[BUFIDX(0, act_y) - 1] = ((act_y1 + act_y + 1));
        buf[BUFIDX(0, act_y) - 2] = 0;
    }

    /* Set last dummy two bytes in draw_buf */
    buf[BUFIDX(0, buf_h) - 1] = 0;
    buf[BUFIDX(0, buf_h) - 2] = 0;

    /* Set frame header in draw_buf */
    buf[0] = SHARP_MIP_HEADER |
             SHARP_MIP_UPDATE_RAM_FLAG;

    /* Write the frame on display memory */
    gpio_set_level(GPIO_NUM_10, 1);
    esp_err_t ret;
    spi_transaction_t t;
    memset(&t, 0, sizeof(t));                   // Zero out the transaction
    t.length = buf_size * 8;                         // Len is in bytes, transaction length is in bits.
    t.tx_buffer = buf;                         // Data
    ret = spi_device_transmit(spi, &t); // Transmit!
    assert(ret == ESP_OK);                      // Should have had no issues.
    gpio_set_level(GPIO_NUM_10, 0);

    lv_disp_flush_ready(disp_drv);
}