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.

cc112xSpiReadReg

I find this function in the example cc112x_easy_link, and its specific location is in cc112x_spi.c. But I am puzzled with its  exactly meaning even though I have read through the annotation and the function body. Can anyone helps explain it to me? Here is the code body. THX. :)

 * @fn          cc112xSpiReadReg
 *
 * @brief       Read value(s) from config/status/extended radio register(s).
 *              If len  = 1: Reads a single register
 *              if len != 1: Reads len register values in burst mode 
 *
 * input parameters
 *
 * @param       addr   - address of first register to read
 * @param       *pData - pointer to data array where read bytes are saved
 * @param       len   - number of bytes to read
 *
 * output parameters
 *
 * @return      rfStatus_t
 */
rfStatus_t cc112xSpiReadReg(uint16 addr, uint8 *pData, uint8 len)
{
  uint8 tempExt  = (uint8)(addr>>8);
  uint8 tempAddr = (uint8)(addr & 0x00FF);
  uint8 rc;
  
  /* Checking if this is a FIFO access -> returns chip not ready  */
  if((CC112X_SINGLE_TXFIFO<=tempAddr)&&(tempExt==0)) return STATUS_CHIP_RDYn_BM;
  
  /* Decide what register space is accessed */
  if(!tempExt)
  {
    rc = trx8BitRegAccess((RADIO_BURST_ACCESS|RADIO_READ_ACCESS),tempAddr,pData,len);
  }
  else if (tempExt == 0x2F)
  {
    rc = trx16BitRegAccess((RADIO_BURST_ACCESS|RADIO_READ_ACCESS),tempExt,tempAddr,pData,len);
  }
  return (rc);
}

  • Here just a return of the status. Since I have read the register, where dose the data go?

  • Look at how the function is used. Taken from the Rx code as an example:

    uint8 marcState;

    cc112xSpiReadReg(CC112X_MARCSTATE, &marcState, 1);

    The function definition is as follows:

    rfStatus_t cc112xSpiReadReg(uint16 addr, uint8 *pData, uint8 len)

    The actual read of the register looks like:

    trx8BitRegAccess((RADIO_BURST_ACCESS|RADIO_READ_ACCESS),tempAddr,pData,len);

    The content of the register is stored in the local variable pData and in the example marcState is set equal to pData