Is there an easy way to keep the CS active after having done an SPI operation?
There is the SPI_PIN_REG register and the corresponding SPI_CS_KEEP_ACTIVE bit, but I would prefer not to write directly into the registers to keep my code portable.
More context:
I'm working with the Si4x55 sensor (https://www.silabs.com/documents/public ... 4x55-C.pdf).
On page 23, it is explained that operations consist of pulling the nSEL low, and then polling the CTS Value until the sensor indicates that it is ready.
I would like to implement this, but don't see any high-level functions that allow me to keep the CS active for multiple operations.
My current approach would now be to add a boolean parameter to my transfer function that en/disables the bit.
Code: Select all
REG_SET_FIELD(SPI_PIN_REG(host_device + 1),
SPI_CS_KEEP_ACTIVE,
keep_cs_active ? 1 : 0);
Code: Select all
REG_CLR_BIT(SPI_PIN_REG(host_device + 1), SPI_CS_KEEP_ACTIVE);
// Deactivate any CS that is currently high.
REG_SET_BIT(SPI_PIN_REG(host_device + 1), SPI_CS2_DIS);
REG_SET_BIT(SPI_PIN_REG(host_device + 1), SPI_CS1_DIS);
REG_SET_BIT(SPI_PIN_REG(host_device + 1), SPI_CS0_DIS);
Also, is there a good way to map from spi_host_device_t to the ID that needs to be passed to SPI_PIN_REG? Currently I'm just adding 1, but that feels extremely brittle.
Finally, do I need to call spi_device_acquire_bus before I start using the SPI_CS_KEEP_ACTIVE bit?
Thanks