Search code examples
ciar

What is this increment and decrement assignment trying to do?


*pSpiTxBuf++ = CC2520_INS_SFLUSHRX; // get rid of this packet
*pSpiTxBuf-- = CC2520_INS_SFLUSHRX; // double flush [CC2520 Bug#1]

Can anyone explain to me what the above two lines are attempting to do? pSpiTxBuf is a uint8_t *


Solution

  • This is equivalent to:

    pSpiTxBuf[0] = CC2520_INS_SFLUSHRX; // get rid of this packet
    pSpiTxBuf[1] = CC2520_INS_SFLUSHRX; // double flush [CC2520 Bug#1]
    

    (which would probably have been a clearer way to write the code in the first place).

    i.e. it just sets two adjacent register values to CC2520_INS_SFLUSHRX.