9 years, 1 month ago.

why on Nucleo board, there is only write function, witch out read function, in SPI(SPI master) class

I want to make a SPI test on Nucleo-L053R8(as a spi master), access a spi slave device. after checked the SPI class, there is a problem, I can find the read function.

1 Answer

9 years, 1 month ago.

The write function also reads. It returns the read value. Due to how SPI works it is not possible to read without writing. So generally to read you need to write out dummy values, like:

char value = _spi.write(0xFF);

Accepted Answer