Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5381

SDK • Re: Byte (re-)ordering when using 8-bit DMA towards SPI display?

$
0
0
The CPU writes in little. The RAM does not care. DMA needs to be told to read in little. 8-bit reads are neither little or big. 16-bit writes are little.

This comes with a performance consequence and possibly a memory cost.

First option: (C++ allows hiding the endian. (C type system sucks.) Saves memory but not time.)

Code:

struct RGB565 {public:void write_red(uint8_t val);void write_green(uint8_t val);void write_blue(uint8_t val);uint8_t get_red();uint8_t get_green();uint8_t get_blue();private:uint16_t  data;}
Second option: (Expensive in time and memory)
Multibuffering with ntohs applied after drawing. Complete redrawing required.

Third option: (Expensive in time and memory)
Multibuffering with memcpy and ntohs applied after drawing. Does not require redrawing.

Statistics: Posted by dthacher — Sun Nov 17, 2024 12:18 pm



Viewing all articles
Browse latest Browse all 5381

Trending Articles