[cc2538] fix RSSI calibration when CC2592 is in use (#3636)

* Define parameter for RSSI offset.

This defines the RSSI offset as an overridable parameter in the CC2538
configuration for users that have installed a CC2592 on their board but
have hard-wired the HGM pin either to `VDD` or `GND`.

* Calibrate RSSI according to HGM state.

I had actually misread the datasheet a little bit, having gotten
sensitivity and RSSI offset confused.  The values I needed for the
sensitivity were actually in the table *above* where I got the original
figures here from.

This puts the *correct* figures in place, and also defines a function
that returns the RSSI offset based on the state of the HGM pin (or
returns a static value if we omit CC2592 support or disable HGM
control).

* Expose RSSI offset setting in Makefile

* Document RSSI offset parameter
This commit is contained in:
Stuart Longland
2019-02-28 08:18:56 -08:00
committed by Jonathan Hui
parent db945a5278
commit 74ad300556
4 changed files with 50 additions and 7 deletions
+4
View File
@@ -113,6 +113,10 @@ ifneq ($(CC2538_RECEIVE_SENSITIVITY),)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2538_RECEIVE_SENSITIVITY=$(CC2538_RECEIVE_SENSITIVITY)
endif
ifneq ($(CC2538_RSSI_OFFSET),)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2538_RSSI_OFFSET=$(CC2538_RSSI_OFFSET)
endif
CPPFLAGS += \
$(COMMONCFLAGS) \
$(target_CPPFLAGS) \
+3
View File
@@ -72,6 +72,9 @@ Additional settings can be customised:
* `CC2538_RECEIVE_SENSITIVITY`: If you have tied the HGM pin to a power rail, this allows
you to calibrate the RSSI values according to the new receive sensitivity. This has no
effect if `CC2592_USE_HGM=1` (the default).
* `CC2538_RSSI_OFFSET`: If you have tied the HGM pin to a power rail, this allows
you to calibrate the RSSI values according to the new RSSI offset. This has no
effect if `CC2592_USE_HGM=1` (the default).
## Flash Binaries
@@ -184,6 +184,22 @@
#define OPENTHREAD_CONFIG_CC2538_RECEIVE_SENSITIVITY -88
#endif
/**
* @def OPENTHREAD_CONFIG_CC2538_RSSI_OFFSET
*
* Set the CC2538 RSSI offset. This calibrates the RSSI readings received from
* the CC2538 radio module to give a reading in dBm.
*
* For a standard CC2538 (no front-end), the RSSI offset is 73.
*
* For a CC2592 hard-wired in high-gain mode, an offset of 85 should be used;
* or for low-gain mode, 81. If `OPENTHREAD_CONFIG_CC2592_USE_HGM` is 0, then
* this calibrates the RSSI value accordingly.
*/
#ifndef OPENTHREAD_CONFIG_CC2538_RSSI_OFFSET
#define OPENTHREAD_CONFIG_CC2538_RSSI_OFFSET 73
#endif
/**
* @def OPENTHREAD_CONFIG_CC2592_HGM_PORT
*
+27 -7
View File
@@ -101,17 +101,21 @@ enum
enum
{
CC2538_RSSI_OFFSET = 73,
CC2538_CRC_BIT_MASK = 0x80,
CC2538_LQI_BIT_MASK = 0x7f,
CC2538_RSSI_OFFSET = OPENTHREAD_CONFIG_CC2538_RSSI_OFFSET,
// TI AN130 (SWRA447) Table 4 (bottom of page 3)
CC2592_RSSI_OFFSET_HGM = 85,
CC2592_RSSI_OFFSET_LGM = 81,
CC2538_CRC_BIT_MASK = 0x80,
CC2538_LQI_BIT_MASK = 0x7f,
};
// All values in dBm
enum
{
CC2538_RECEIVE_SENSITIVITY = OPENTHREAD_CONFIG_CC2538_RECEIVE_SENSITIVITY,
CC2592_RECEIVE_SENSITIVITY_LGM = -81,
CC2592_RECEIVE_SENSITIVITY_HGM = -85,
CC2538_RECEIVE_SENSITIVITY = OPENTHREAD_CONFIG_CC2538_RECEIVE_SENSITIVITY,
// TI AN130 (SWRA447) Table 3 (middle of page 3)
CC2592_RECEIVE_SENSITIVITY_LGM = -99,
CC2592_RECEIVE_SENSITIVITY_HGM = -101,
};
typedef struct TxPowerTable
@@ -613,6 +617,22 @@ bool otPlatRadioGetPromiscuous(otInstance *aInstance)
return (HWREG(RFCORE_XREG_FRMFILT0) & RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN) == 0;
}
static int8_t cc2538RadioGetRssiOffset(void)
{
#if OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
if (cc2538RadioGetHgm())
{
return CC2592_RSSI_OFFSET_HGM;
}
else
{
return CC2592_RSSI_OFFSET_LGM;
}
#else // OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
return CC2538_RSSI_OFFSET;
#endif // OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
}
void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
{
OT_UNUSED_VARIABLE(aInstance);
@@ -655,7 +675,7 @@ void readFrame(otInstance *aInstance)
sReceiveFrame.mPsdu[i] = HWREG(RFCORE_SFR_RFDATA);
}
sReceiveFrame.mInfo.mRxInfo.mRssi = (int8_t)HWREG(RFCORE_SFR_RFDATA) - CC2538_RSSI_OFFSET;
sReceiveFrame.mInfo.mRxInfo.mRssi = (int8_t)HWREG(RFCORE_SFR_RFDATA) - cc2538RadioGetRssiOffset();
crcCorr = HWREG(RFCORE_SFR_RFDATA);
if (crcCorr & CC2538_CRC_BIT_MASK)