From d42b1b50e58cbc9f71da3efd2f387742c6ef94de Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 24 Jan 2016 13:39:02 +0000 Subject: [PATCH] Allow the caller to access the entire content of CMDSTA When sending a command to the CC13xx/CC25xx RF core, we wait for command completion by checking the LSB of CMDSTA (correctly so). However, in doing so we also zero out the 3 CMDSTA return bytes. For some commands, those bytes contain useful information (e.g. an RSSI value) and are required by the caller. This problem manifests itself e.g. in PROP mode `channel_clear()`, whereby the caller will always see an RSSI value of 0. This pull therefore fixes the logic in `rf_core_send_cmd()` to check for command completion by blocking on the CMDSTA result byte without zeroing out the 3 return bytes. Fixes #1465 --- cpu/cc26xx-cc13xx/rf-core/rf-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/rf-core.c b/cpu/cc26xx-cc13xx/rf-core/rf-core.c index 932297b91..8efe41dac 100644 --- a/cpu/cc26xx-cc13xx/rf-core/rf-core.c +++ b/cpu/cc26xx-cc13xx/rf-core/rf-core.c @@ -160,7 +160,7 @@ rf_core_send_cmd(uint32_t cmd, uint32_t *status) HWREG(RFC_DBELL_BASE + RFC_DBELL_O_CMDR) = cmd; do { - *status = HWREG(RFC_DBELL_BASE + RFC_DBELL_O_CMDSTA) & 0xFF; + *status = HWREG(RFC_DBELL_BASE + RFC_DBELL_O_CMDSTA); if(++timeout_count > 50000) { PRINTF("rf_core_send_cmd: 0x%08lx Timeout\n", cmd); if(!interrupts_disabled) { @@ -168,7 +168,7 @@ rf_core_send_cmd(uint32_t cmd, uint32_t *status) } return RF_CORE_CMD_ERROR; } - } while(*status == RF_CORE_CMDSTA_PENDING); + } while((*status & RF_CORE_CMDSTA_RESULT_MASK) == RF_CORE_CMDSTA_PENDING); if(!interrupts_disabled) { ti_lib_int_master_enable();