VL53L8CX SPI communication
Hi all,
I'm trying to setup the SPI communication with a VL53L8CX which is connected to a STM32F401RE-Nucleo. I took some code snippets from the STSW-IMG040 package and I wonder why the bytes to be send in VL53L8CX_WrMulti and VL53L8CX_RdMulti are treated with a special mask instead of just separating the bytes like shown below:
#define SPI_WRITE_MASK(x) (uint16_t)(x | 0x8000) // 1
#define SPI_READ_MASK(x) (uint16_t)(x & ~0x8000)
data_write[0] = SPI_WRITE_MASK(temp) >> 8;
data_write[1] = SPI_WRITE_MASK(temp) & 0xFF;
respectively
data_write[0] = SPI_READ_MASK(temp) >> 8;
data_write[1] = SPI_READ_MASK(temp) & 0xFF;
instead of just
data_write[0] = (temp >> 8) & 0xFF;
data_write[1] = temp & 0xFF;
Is there a special reason for doing this?
Regards
Bastian
