Hi,
Description
I am trying to write a driver for the esp32 i2s module a while already.
I want to use i2s module in lcd parallel mode (8bits) with dma and two alterneted buffers.
The espressif team replied to me that it is not possible to pass a buffer of uint8_t directly to the i2s module using dma.
link: “https://www.esp32.com/viewtopic.php?f=13&t=12905&start=30”.
"Hi, Baldhead
Thank you for your suggestion. Due to hardware limitations, the DMA transfer data size is at least one word long. Can you provide an LCD data sheet, maybe we can use 16-bit mode to drive it.
thanks !!"
I started the studies by the two links below a long time ago:
“https://blog.littlevgl.com/2019-02-02/use-ipod-nano6-lcd-for-littlevgl”
“https://github.com/espressif/esp-iot-solution/tree/master/components/i2s_devices/lcd_common”
The problem is that i need to copy a “lv_color_t” buffer (in my case uint16_t each pixel), to a uint32_t buffer byte by byte.
This way there is a big waste of memory and time to copy the buffer ( unfortunately it’s the only way ).
I studied the link “https://github.com/espressif/esp-iot-solution/tree/master/components/i2s_devices/lcd_common”, of espressif and that’s how it’s done using dynamically allocated memory. My driver is using statically allocated memory.
example:
#define buffer_size 30720 // in bytes
DMA_ATTR lv_color_t buffer_a[buffer_size/2]; // littlevgl buffer. // buffer_size/2 = 15360 uint16_t.
DMA_ATTR lv_color_t buffer_b[buffer_size/2]; // littlevgl buffer.
static DMA_ATTR uint32_t buf_a[buffer_size/4]; // dma buffer. // buffer_size/4 = 7680 uint32_t.
static DMA_ATTR uint32_t buf_b[buffer_size/4]; // dma buffer.
I need to copy the littlevgl buffer(buffer_a) to dma buffer(buf_a) byte by byte using a single position in uint32_t buffer to store only one single byte like:
ptr = (uint8_t *) &buffer_a; // buffer_a are uint16_t.
for ( i = 0 ; i < length ; i = i + 2 ) // length <= 7680 bytes. loop max 7680/2 = 3840 times.
{
buf_a[ i ] = ptr[ i ]; // low pixel byte.
buf_a[ i + 1 ] = ptr[ i + 1 ]; // high pixel byte.
// the buf_a address inc in 4 bytes while the buffer_a(ptr) address inc in 1 byte.
}
What MCU/Processor/Board and compiler are you using?
MCU: ESP32.
Framework: esp32-idf.
What do you want to achieve?
I would like to pass the littlevgl buffer directly to i2s module using dma.
I would like that littlevgl write directly in buffer uint32_t like so (if possible obviously):
uint16_t pixel0, pixel1, pixel2, pixel3, …, pixel N.
uint32_t buf_a[ ];
buf_a[0] = pixel0 low byte.
buf_a[1] = pixel0 high byte.
buf_a[2] = pixel1 low byte.
buf_a[3] = pixel1 high byte.
buf_a[4] = pixel2 low byte.
buf_a[5] = pixel2 high byte.
and so on.
This way i only declares 2 buffers uint32_t and the littlevgl write directly in that buffers.
This saves a little memory (2 buffers instead of 4 buffers) and also saves time to copy one buffer to another.
What have you tried so far?
Copy the buffer directly in my i2s driver.
Thank’s.