Hey,
my controller supports up to 16bit words for SPI, but the transfer functions only accept byte arrays.
Is there a way to send larger words?
Thanks,
-ExXec
[TM4C123] SPI word length
Re: [TM4C123] SPI word length
Just to make sure I understand your question, can you give an example of what you'd like this to look like in Python? i.e. it sounds like you want more things like bytearray, i.e. `uint16array` etc?
The way it works currently on ports that allow configuring the SPI transfer width to 16 bits (via the `bits` param to the constructor/init, e.g. on stm32) is that the bytearray you pass it will be interpreted as pairs of bytes making up the 16-bit transfer size.
i.e. this is from the stm32 HAL in the non-DMA path, pData is essentially the contents of the buffer passed to spi.write(), DR is a 16-bit register but whether the top byte is used is configured in CR1.
So if you want to transmit 16-bit words from Python, then you just need a way to stash them into a bytearray. (e.g. struct.pack, manually shifting, etc).
The way it works currently on ports that allow configuring the SPI transfer width to 16 bits (via the `bits` param to the constructor/init, e.g. on stm32) is that the bytearray you pass it will be interpreted as pairs of bytes making up the 16-bit transfer size.
i.e. this is from the stm32 HAL in the non-DMA path, pData is essentially the contents of the buffer passed to spi.write(), DR is a 16-bit register but whether the top byte is used is configured in CR1.
Code: Select all
hspi->Instance->DR = *((uint16_t *)pData);
pData += sizeof(uint16_t);
hspi->TxXferCount--;
Re: [TM4C123] SPI word length
I didn't know if bytestitching was the only way to achieve this, maybe there would have been a better solution.
Thanks for your reply!
Thanks for your reply!
My fork/port: https://github.com/rk-exxec/micropython ... ts/tm4c123