SPI_USER_REG byte order flags: what do they exactly do?

powerbroker
Posts: 21
Joined: Sun May 19, 2024 12:58 pm

SPI_USER_REG byte order flags: what do they exactly do?

Postby powerbroker » Mon Jun 17, 2024 4:07 am

There are SPI_USER_REG (0x1C) flags SPI_WR_BYTE_ORDER and SPI_RD_BYTE_ORDER, switching endianess of Tx and Rx data.

When SPI MISO stream is following:
00 49 4A F0 80 00.png
00 49 4A F0 80 00.png (13.5 KiB) Viewed 1048 times
from left to right: 00 49 4A F0 80 00, with default settings SPI transaction field rx_buffer gets MISO data exactly in the order from left to right.

Which effect will cause SPI_RD_BYTE_ORDER when enabled?
Does it depend on DMA or not?
How to enable these options in spi master driver?

User avatar
ok-home
Posts: 78
Joined: Sun May 02, 2021 7:23 pm
Location: Russia Novosibirsk
Contact:

Re: SPI_USER_REG byte order flags: what do they exactly do?

Postby ok-home » Mon Jun 17, 2024 4:35 am

hi
https://github.com/espressif/esp-idf/bl ... i_master.h

Code: Select all

#define SPI_DEVICE_TXBIT_LSBFIRST          (1<<0)  ///< Transmit command/address/data LSB first instead of the default MSB first
#define SPI_DEVICE_RXBIT_LSBFIRST          (1<<1)  ///< Receive data LSB first instead of the default MSB first
#define SPI_DEVICE_BIT_LSBFIRST            (SPI_DEVICE_TXBIT_LSBFIRST|SPI_DEVICE_RXBIT_LSBFIRST) ///< Transmit and receive LSB first
spi_device_interface_config.flags

powerbroker
Posts: 21
Joined: Sun May 19, 2024 12:58 pm

Re: SPI_USER_REG byte order flags: what do they exactly do?

Postby powerbroker » Tue Jun 18, 2024 2:10 am

ok-home wrote:
Mon Jun 17, 2024 4:35 am
hi
https://github.com/espressif/esp-idf/bl ... i_master.h

Code: Select all

#define SPI_DEVICE_TXBIT_LSBFIRST          (1<<0)  ///< Transmit command/address/data LSB first instead of the default MSB first
#define SPI_DEVICE_RXBIT_LSBFIRST          (1<<1)  ///< Receive data LSB first instead of the default MSB first
#define SPI_DEVICE_BIT_LSBFIRST            (SPI_DEVICE_TXBIT_LSBFIRST|SPI_DEVICE_RXBIT_LSBFIRST) ///< Transmit and receive LSB first
spi_device_interface_config.flags
so, byte order remains the same, and bits within bytes get reversed
thanks

Who is online

Users browsing this forum: No registered users and 21 guests