japaric / stm32f103xx-hal

HAL for the STM32F103xx family of microcontrollers
Apache License 2.0
115 stars 40 forks source link

SPI: Support configuring LSB first transfers #96

Open johkra opened 5 years ago

johkra commented 5 years ago

Currently the SPI code hard configures MSB first transfers.

stm32f103xx-hal/src/spi.rs@83574bc starting at line 135:

                    // mstr: master configuration
                    // lsbfirst: MSB first
[…]
                    spi.cr1.write(|w| {
                        w.cpha()
[…]
                            .lsbfirst()
                            .clear_bit()

I'm interacting with a device which expects data LSB first and I have to reverse the bits in a byte before sending data with the SPI code. Could you please make MSB/LSB first configurable?

If you briefly describe how you'd like to see this implemented, I'll prepare a patch.