I am using the nRF52840 DK to read data from an IMU sensor (STm LSM9DS1 9DOF). Like most sensors, you transmit the register number first (on MOSI), then continue clocking and the sensor returns the value.
I have based my code on the SDK v15.3.0 example "SPI Master". The sensor-specific code is from STm's "STMems Standard C Drivers" library. It works fine, but needed some tweaking.
The sensor's MISO line remains high impedance until the register has been sent. However, the SPI Master Driver functions returns data starting with that very first write, which is undefined data. I can do an initial write (to set the register) and discard the returned byte, and then further reads to get the register value(s), but this seems clumsy -- there is a noticeable delay between the initial register write, and the subsequent data read.
The STm library assumes all reads are just the selected register data, and doesn't account for that initial undefined data byte.
Is it possible to configure the SPI Master functions to always discard the initial returned byte, rather than having to do the two separate writes? Am I missing something in the SPI Master Library?