Merge pull request #1787 from g-oikonomou/contrib/cc26xx/improve-cca-monitoring

Use `ccaInfo.ccaState` to decide whether CCA is complete
This commit is contained in:
George Oikonomou 2017-04-24 16:02:47 +01:00 committed by GitHub
commit 3cc5505b69

View file

@ -359,13 +359,12 @@ transmitting(void)
* It is the caller's responsibility to make sure the RF is on. This function * It is the caller's responsibility to make sure the RF is on. This function
* will return RF_GET_CCA_INFO_ERROR if the RF is off * will return RF_GET_CCA_INFO_ERROR if the RF is off
* *
* This function will in fact wait for a valid RSSI signal * This function will in fact wait for a valid CCA state
*/ */
static uint8_t static uint8_t
get_cca_info(void) get_cca_info(void)
{ {
uint32_t cmd_status; uint32_t cmd_status;
int8_t rssi;
rfc_CMD_IEEE_CCA_REQ_t cmd; rfc_CMD_IEEE_CCA_REQ_t cmd;
if(!rf_is_on()) { if(!rf_is_on()) {
@ -373,9 +372,10 @@ get_cca_info(void)
return RF_GET_CCA_INFO_ERROR; return RF_GET_CCA_INFO_ERROR;
} }
rssi = RF_CMD_CCA_REQ_RSSI_UNKNOWN; memset(&cmd, 0x00, sizeof(cmd));
cmd.ccaInfo.ccaState = RF_CMD_CCA_REQ_CCA_STATE_INVALID;
while(rssi == RF_CMD_CCA_REQ_RSSI_UNKNOWN || rssi == 0) { while(cmd.ccaInfo.ccaState == RF_CMD_CCA_REQ_CCA_STATE_INVALID) {
memset(&cmd, 0x00, sizeof(cmd)); memset(&cmd, 0x00, sizeof(cmd));
cmd.commandNo = CMD_IEEE_CCA_REQ; cmd.commandNo = CMD_IEEE_CCA_REQ;
@ -384,11 +384,9 @@ get_cca_info(void)
return RF_GET_CCA_INFO_ERROR; return RF_GET_CCA_INFO_ERROR;
} }
rssi = cmd.currentRssi;
} }
/* We have a valid RSSI signal. Return the CCA Info */ /* We have a valid CCA state. Return the CCA Info */
return *((uint8_t *)&cmd.ccaInfo); return *((uint8_t *)&cmd.ccaInfo);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/