请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:CC1201 在初始化无线电时、我将 CCA_MODE 设置为011、这"表示当 RSSI 低于阈值并且当前未接收到数据包时清除通道"。
然后我使用以下代码:
- 将无线电切换到 RX
- 确认无线电处于 RX 状态
- 将无线电切换到 TX
- 检查 CCA_STATUS 是否生效
for (i = 0; i < MRFI_CCA_RETRIES; i++) {
/* Radio must be in RX mode for CCA to happen.
* Otherwise it will transmit without CCA happening.
*/
/* Can not use the Mrfi_RxModeOn() function here since it turns on the
* Rx interrupt, which we don't want in this case.
*/
mrfiSpiCmdStrobe( SRX );
uint8_t marc_state = 0;
do {
marc_state = mrfiSpiReadExtendedReg(CC120X_MARCSTATE);
} while (marc_state != 0x6D);
// /* wait for the rssi to be valid. */
// MRFI_RSSI_VALID_WAIT();
/* send strobe to initiate transmit */
mrfiSpiCmdStrobe( STX );
if (MRFI_CCA_STATUS_PIN_IS_HIGH()) {
/* ------------------------------------------------------------------
* Clear Channel Assessment passed.
* ----------------------------------
*/
/* Wait for transmit to complete */
while(!MRFI_SYNC_PIN_INT_FLAG_IS_SET());
ESP_LOGI(TAG, "Transmit done");
/* Clear the interrupt flag */
MRFI_CLEAR_SYNC_PIN_INT_FLAG();
cca_passed = true;
break;
}
/* ------------------------------------------------------------------
* Clear Channel Assessment failed.
* ----------------------------------
*/
/* Turn off radio and save some power during backoff */
/* NOTE: Can't use Mrfi_RxModeOff() - since it tries to update the
* sync signal status which we are not using during the TX operation.
*/
MRFI_STROBE_IDLE_AND_WAIT();
/* flush the receive FIFO of any residual data */
mrfiSpiCmdStrobe( SFRX );
/* otherwise, backoff and perform CCA again */
Mrfi_RandomBackoffDelay();
ESP_LOGI(TAG, "CCA failed, retrying");
}
不过、使用逻辑分析仪、我可以看到 TX 的选通命令、但 CCA_STATUS 始终为低电平。 我是否需要等到收到 TXONCCA_DONE 事件后才能检查 CCA_STATUS?