Datasheet of sensor: https://www.murata.com/~/media/webrenew ... x?la=en-us
This portion of code is used to read responses for different requests:
Code: Select all
uint32_t SendRequest(uint32_t Request)
{
uint32_t Response;
LPC_GPIO->CLR[PORT0] = PIN_CSB; // digitalWrite(PIN_CSB, LOW);
Response = LPC_SSP0->DR; // Read RX buffer just to clear interrupt flag
// Move on only if NOT busy and TX FIFO not full
while ((LPC_SSP0->SR & (SSPSR_TNF|SSPSR_BSY)) != SSPSR_TNF);
LPC_SSP0->DR = Request >> 16; // Write Request high word to TX buffer
while (LPC_SSP0->SR & SSPSR_BSY); // Wait until the Busy bit is cleared
Response = LPC_SSP0->DR; // Read RX buffer (Response high word)
Response <<= 16;
LPC_SSP0->DR = Request & 0x0000FFFF; // Write Request low word to TX buffer
while (LPC_SSP0->SR & SSPSR_BSY); // Wait until the Busy bit is cleared
Response |= LPC_SSP0->DR; // Read RX buffer (Response low word)
LPC_GPIO->SET[PORT0] = PIN_CSB; // digitalWrite(PIN_CSB, HIGH);
return Response;
}
Could you please help me understand how works in steps?