SPI Endianess managment

Hello to all.
The format method for SPI lack the endianess managment.
There are 3 parameters to manage in SPI :

  • The size of data packet
  • The phase (polarity and edge)
  • The Endianess (LSB or MSB first)

Mbed lacks endianess managment, that is, by the way, ALWAYS present in all microcontrolers registers with for exemple in STM32 in CR1 a bit called LSBFIRST, or in NXP LPC the bit LSBF in SPICR register.

You can check that it’s ALWAYS present in every SPI controler.

Because master must adapt itself to slave, and Mbed SPI write method are mostly base on multiple bytes transmission (ie transfert or write), there are only 2 solutions : one must manualy (or by software) swap bit order before calling write method, copying both transmit (to send right values to the slave) and received (to gain access to slave response in the right order) buffers, or one must write target specific code…

Thanks you all for all for the good job you’ve done.
And Merry Christmas

1 Like