Merge pull request #1348 from g-oikonomou/bugfix/cc26xx/wait-for-rssi-valid
Wait for a valid RSSI reading in CC13xx/CC26xx RF drivers
This commit is contained in:
commit
b91448dfa4
|
@ -385,9 +385,8 @@ static radio_value_t
|
||||||
get_rssi(void)
|
get_rssi(void)
|
||||||
{
|
{
|
||||||
uint32_t cmd_status;
|
uint32_t cmd_status;
|
||||||
int8_t rssi;
|
|
||||||
uint8_t was_off = 0;
|
uint8_t was_off = 0;
|
||||||
rfc_CMD_GET_RSSI_t cmd;
|
rfc_CMD_IEEE_CCA_REQ_t cmd;
|
||||||
|
|
||||||
/* If we are off, turn on first */
|
/* If we are off, turn on first */
|
||||||
if(!rf_is_on()) {
|
if(!rf_is_on()) {
|
||||||
|
@ -399,13 +398,19 @@ get_rssi(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&cmd, 0x00, sizeof(cmd));
|
memset(&cmd, 0x00, sizeof(cmd));
|
||||||
cmd.commandNo = CMD_GET_RSSI;
|
cmd.ccaInfo.ccaEnergy = RF_CMD_CCA_REQ_CCA_STATE_INVALID;
|
||||||
|
|
||||||
rssi = RF_CMD_CCA_REQ_RSSI_UNKNOWN;
|
while(cmd.ccaInfo.ccaEnergy == RF_CMD_CCA_REQ_CCA_STATE_INVALID) {
|
||||||
|
memset(&cmd, 0x00, sizeof(cmd));
|
||||||
|
cmd.commandNo = CMD_IEEE_CCA_REQ;
|
||||||
|
|
||||||
if(rf_core_send_cmd((uint32_t)&cmd, &cmd_status) == RF_CORE_CMD_OK) {
|
if(rf_core_send_cmd((uint32_t)&cmd, &cmd_status) == RF_CORE_CMD_ERROR) {
|
||||||
/* Current RSSI in bits 23:16 of cmd_status */
|
PRINTF("get_rssi: CMDSTA=0x%08lx\n", cmd_status);
|
||||||
rssi = (cmd_status >> 16) & 0xFF;
|
|
||||||
|
/* Make sure to return RSSI unknown */
|
||||||
|
cmd.currentRssi = RF_CMD_CCA_REQ_RSSI_UNKNOWN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we were off, turn back off */
|
/* If we were off, turn back off */
|
||||||
|
@ -413,7 +418,7 @@ get_rssi(void)
|
||||||
off();
|
off();
|
||||||
}
|
}
|
||||||
|
|
||||||
return rssi;
|
return cmd.currentRssi;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Returns the current TX power in dBm */
|
/* Returns the current TX power in dBm */
|
||||||
|
|
|
@ -270,6 +270,7 @@ get_rssi(void)
|
||||||
{
|
{
|
||||||
uint32_t cmd_status;
|
uint32_t cmd_status;
|
||||||
int8_t rssi;
|
int8_t rssi;
|
||||||
|
uint8_t attempts = 0;
|
||||||
uint8_t was_off = 0;
|
uint8_t was_off = 0;
|
||||||
rfc_CMD_GET_RSSI_t cmd;
|
rfc_CMD_GET_RSSI_t cmd;
|
||||||
|
|
||||||
|
@ -282,14 +283,19 @@ get_rssi(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&cmd, 0x00, sizeof(cmd));
|
|
||||||
cmd.commandNo = CMD_GET_RSSI;
|
|
||||||
|
|
||||||
rssi = RF_CMD_CCA_REQ_RSSI_UNKNOWN;
|
rssi = RF_CMD_CCA_REQ_RSSI_UNKNOWN;
|
||||||
|
|
||||||
if(rf_core_send_cmd((uint32_t)&cmd, &cmd_status) == RF_CORE_CMD_OK) {
|
while((rssi == RF_CMD_CCA_REQ_RSSI_UNKNOWN || rssi == 0) && ++attempts < 10) {
|
||||||
/* Current RSSI in bits 23:16 of cmd_status */
|
memset(&cmd, 0x00, sizeof(cmd));
|
||||||
rssi = (cmd_status >> 16) & 0xFF;
|
cmd.commandNo = CMD_GET_RSSI;
|
||||||
|
|
||||||
|
if(rf_core_send_cmd((uint32_t)&cmd, &cmd_status) == RF_CORE_CMD_ERROR) {
|
||||||
|
PRINTF("get_rssi: CMDSTA=0x%08lx\n", cmd_status);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
/* Current RSSI in bits 23:16 of cmd_status */
|
||||||
|
rssi = (cmd_status >> 16) & 0xFF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we were off, turn back off */
|
/* If we were off, turn back off */
|
||||||
|
|
Loading…
Reference in a new issue