/*******************************************************************************
 * @fn          RFHAL_InitRfHal API
 *
 * @brief       This function is used initialize the RF HAL. Currently, this
 *              means issuing a Radio FW Information command, and updating
 *              the available RAT channels for software.
 *
 * input parameters
 *
 * @param       None.
 *
 * output parameters
 *
 * @param       None.
 *
 * @return      None.
 */
uint8 RFHAL_InitRfHal( void )
{
  uint8 i, j;
  fwInfoCmd.cmdNum = CMD_GET_FW_INFO;

  if ( MAP_MB_SendCommand( (uint32)&fwInfoCmd ) != CMDSTA_DONE )
  {
    return( RFHAL_ERROR_FW_INFO_FAILED );
  }

  // mark all RAT channels as invalid
  for (i=0; i<MAX_NUM_SW_RAT_CHANS; i++)
  {
    ratChanInfo[i].ratChanNum   = RAT_CHAN_INVALID;
    ratChanInfo[i].ratChanStat  = RAT_CHAN_INVALID;
    ratChanInfo[i].ratChanCBack = NULL;
  }

  // find available software RAT channels as indicated by the radio FW
  for (i=0, j=0; i<MAX_NUM_RAT_CHANS; i++)
  {
    // check if bit is set
    if ( fwInfoCmd.availRatChans & (1 << i) )
    {
      // it is, so this RAT channel belongs to software
      ratChanInfo[j].ratChanNum  = i;
      ratChanInfo[j].ratChanStat = RAT_CHAN_FREE;

      // check if we're done
      if ( ++j == MAX_NUM_SW_RAT_CHANS ) return( RFHAL_SUCCESS );
    }
  }

  return( RFHAL_SUCCESS );
}
예제 #2
0
/*******************************************************************************
 * @fn          RFHAL_QueueRFDataEntries API
 *
 * @brief       This function is used to add all Pending Tx data entries on the
 *              internal TX data queue to the radio FW's TX data entry queue.
 *
 *              Note: It is assumed the data entry queue is really based on a
 *                    data queue.
 *
 * input parameters
 *
 * @param       pDataEntryQ   - Pointer to data entry queue.
 *
 * output parameters
 *
 * @param       None.
 *
 * @return      RFHAL Status
 */
rfhalStat_t RFHAL_QueueRFDataEntries( dataEntryQ_t *pDataEntryQ )
{
  halIntState_t  cs;
  dataEntry_t   *pEntry;

  HAL_ENTER_CRITICAL_SECTION(cs);

  // get head of internal queue, or NULL
  pEntry = ((dataQ_t *)pDataEntryQ)->pNextDataEntry;

  while( pEntry != NULL )
  {
    // check if data entry is pending
    if ( pEntry->status == DATASTAT_PENDING )
    {
      rfOpImmedCmd_AddRemoveFlushQueue_t rfCmd;

      // setup a radio command to add to Tx RF queue
      rfCmd.cmdNum = CMD_ADD_DATA_ENTRY;
      rfCmd.pQueue = pDataEntryQ;
      rfCmd.pEntry = (uint8 *)pEntry;

      // issue immediate command to add the data entry to the Tx RF queue and
      // check if we were successful
      if ( MAP_MB_SendCommand( (uint32)&rfCmd ) != CMDSTA_DONE )
      {
        HAL_EXIT_CRITICAL_SECTION(cs);

        return( RFHAL_ERROR_ADD_TX_ENTRY_FAIL );
      }

      // move on to the next data entry
      pEntry = pEntry->pNextEntry;
    }
  }

  HAL_EXIT_CRITICAL_SECTION(cs);

  return( RFHAL_SUCCESS );
}
예제 #3
0
/*******************************************************************************
 * @fn          RFHAL_AddTxDataEntry API
 *
 * @brief       This function is used to add a Tx data entry to the internal
 *              Tx data entry queue, adjusting the internal number of entries.
 *              If Tx data is enabled, then the entry is also queued for Tx RF
 *              on the FW's data entry queue.
 *
 *              Note: It is assumed the number of allowed entries is managed by
 *                    the calling routine.
 *
 *              Note: It is assumed the data entry queue is really based on a
 *                    data queue.
 *
 * input parameters
 *
 * @param       pDataEntryQ   - Pointer to data entry queue.
 * @param       pDataEntry    - Pointer to data entry to add.
 * @param       rfCoreState   - RFCORE_STATE_IDLE or RFCORE_STATE_SLEEPING
 *                              placed on the radio FW's data entry queue.
 *
 * output parameters
 *
 * @param       None.
 *
 * @return      RFHAL Status
 */
rfhalStat_t RFHAL_AddTxDataEntry( dataEntryQ_t *pDataEntryQ,
                                  dataEntry_t  *pDataEntry,
                                  uint8         rfCoreState )
{
  halIntState_t                       cs;
  dataEntry_t                        *pEntry;
  rfOpImmedCmd_AddRemoveFlushQueue_t  rfCmd;

  HAL_ENTER_CRITICAL_SECTION(cs);

  // get head of internal queue, or NULL
  pEntry = ((dataQ_t *)pDataEntryQ)->pNextDataEntry;

  // check if internal queue is empty
  if ( pEntry == NULL )
  {
    // it is, so just add this entry
    ((dataQ_t *)pDataEntryQ)->pNextDataEntry = pDataEntry;
  }
  else // at least one entry on queue
  {
    // find last entry on internal queue
    while( pEntry->pNextEntry != NULL ) pEntry = pEntry->pNextEntry;

    // and add this packet
    pEntry->pNextEntry = pDataEntry;
  }

  // clear entries next pointer
  pDataEntry->pNextEntry = NULL;

  // check if the RF Core is sleeping
  if ( rfCoreState == RFCORE_STATE_SLEEPING )
  {
    // it is, so data entry has to be queued manually
    if ( pDataEntryQ->pCurEntry == NULL )
    {
      // queue is empty
      pDataEntryQ->pCurEntry = pDataEntry;
    }
    else // queue not empty
    {
      pDataEntryQ->pLastEntry->pNextEntry = pDataEntry;
    }

    pDataEntryQ->pLastEntry = pDataEntry;
  }
  else // radio interface is active
  {
    // setup a radio command to add to Tx RF queue
    rfCmd.cmdNum = CMD_ADD_DATA_ENTRY;
    rfCmd.pQueue = pDataEntryQ;
    rfCmd.pEntry = (uint8 *)pDataEntry;

    // issue immediate command to add the data entry to the Tx RF queue and
    // check if we were successful
    if ( MAP_MB_SendCommand( (uint32)&rfCmd ) != CMDSTA_DONE )
    {
      HAL_EXIT_CRITICAL_SECTION(cs);

      return( RFHAL_ERROR_ADD_TX_ENTRY_FAIL );
    }
  }

  HAL_EXIT_CRITICAL_SECTION(cs);

  return( RFHAL_SUCCESS );
}