This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

reading register from cma300d accelerometer (CC2540 mini DK)

Other Parts Discussed in Thread: CC2540

Hi everyone ,

sorry for my bad english

I am a student who need to understand how cc2540 reads accelerometer register on
CC2540DK-MINI. For example in this piece of code ( keyfobdemo cma3000d.c ),when I want to read
the X value of the accelerometer I didn't understand how spiReadByte works

reg --> DOUTX

*pVal --> *pXVal

void accReadReg(uint8 reg, uint8 *pVal)
{
CS = CS_ENABLED;
WAIT_1_3US(2);
spiWriteByte(reg);
spiReadByte(pVal, 0xFF);
CS = CS_DISABLED;
}

Why has passed 0xFF in input ?

spiReadByte(pVal,OxFF)
{
U0CSR &= ~0x02; // Clear TX_BYTE
U0DBUF = OXFF; --> ??
while (!(U0CSR & 0x02)); // Wait for TX_BYTE to be set
*pVal= U0DBUF;

}

thanks in advance