Does pyboard support 3-wire mode SPI bus?
Standard SPI is 4-wire, MOSI, MISO, SCK and CS. But in some case, we use 3-wire mode SPI, does micropython support it?
Does pyboard support 3-wire mode SPI bus?
-
- Posts: 363
- Joined: Sun Apr 17, 2016 1:55 pm
Re: Does pyboard support 3-wire mode SPI bus?
MicroPython doesn't directly support this, but the reference Manual for the STM32F405 says that it is supported.
So I think that you can make it work by using the stm module to read/write the registers directly to tweak the SPI mode.
Here's an example of using the stm module to set the HDSEL bit in a UART:
https://github.com/dhylands/bioloid3/bl ... ort.py#L27
You should be able to do something similar to play with the SPI registers. The stm module has the following SPI constants:SPI1, SPI2, and SPI3 are the SPI base register addresses and SPI_xxx are the offsets of the various registers.
So I think that you can make it work by using the stm module to read/write the registers directly to tweak the SPI mode.
Here's an example of using the stm module to set the HDSEL bit in a UART:
https://github.com/dhylands/bioloid3/bl ... ort.py#L27
You should be able to do something similar to play with the SPI registers. The stm module has the following SPI constants:
Code: Select all
>>> import stm
>>> [x for x in dir(stm) if x.startswith('SPI')]
['SPI2', 'SPI3', 'SPI1', 'SPI_CR1', 'SPI_CR2', 'SPI_SR', 'SPI_DR', 'SPI_CRCPR', 'SPI_RXCRCR', 'SPI_TXCRCR', 'SPI_I2SCFGR', 'SPI_I2SPR']
-
- Posts: 363
- Joined: Sun Apr 17, 2016 1:55 pm
Re: Does pyboard support 3-wire mode SPI bus?
Thank you !dhylands wrote:MicroPython doesn't directly support this, but the reference Manual for the STM32F405 says that it is supported.
So I think that you can make it work by using the stm module to read/write the registers directly to tweak the SPI mode.
Here's an example of using the stm module to set the HDSEL bit in a UART:
https://github.com/dhylands/bioloid3/bl ... ort.py#L27
You should be able to do something similar to play with the SPI registers. The stm module has the following SPI constants:SPI1, SPI2, and SPI3 are the SPI base register addresses and SPI_xxx are the offsets of the various registers.Code: Select all
>>> import stm >>> [x for x in dir(stm) if x.startswith('SPI')] ['SPI2', 'SPI3', 'SPI1', 'SPI_CR1', 'SPI_CR2', 'SPI_SR', 'SPI_DR', 'SPI_CRCPR', 'SPI_RXCRCR', 'SPI_TXCRCR', 'SPI_I2SCFGR', 'SPI_I2SPR']