|
|
|
@ -292,6 +292,8 @@ static int _send(netdev2_t *netdev, const struct iovec *vector, int count)
|
|
|
|
|
static int _recv(netdev2_t *netdev, char *buf, int len, void *info)
|
|
|
|
|
{
|
|
|
|
|
cc2538_rf_t *dev = (cc2538_rf_t *) netdev;
|
|
|
|
|
uint8_t corr_val;
|
|
|
|
|
int8_t rssi_val;
|
|
|
|
|
size_t pkt_len;
|
|
|
|
|
|
|
|
|
|
mutex_lock(&dev->mutex);
|
|
|
|
@ -323,17 +325,29 @@ static int _recv(netdev2_t *netdev, char *buf, int len, void *info)
|
|
|
|
|
|
|
|
|
|
rfcore_read_fifo(buf, pkt_len);
|
|
|
|
|
|
|
|
|
|
if (info != NULL) {
|
|
|
|
|
if (info != NULL && RFCORE->XREG_RSSISTATbits.RSSI_VALID) {
|
|
|
|
|
netdev2_ieee802154_rx_info_t *radio_info = info;
|
|
|
|
|
radio_info->rssi = rfcore_read_byte();
|
|
|
|
|
|
|
|
|
|
/* This is not strictly 802.15.4 compliant, since according to
|
|
|
|
|
the CC2538 documentation, this value will tend between ~50
|
|
|
|
|
for the lowest quality link detectable by the receiver, and
|
|
|
|
|
~110 for the highest. The IEEE 802.15.4 spec mandates that
|
|
|
|
|
this value be between 0-255, with 0 as lowest quality and
|
|
|
|
|
255 as the highest. FIXME. */
|
|
|
|
|
radio_info->lqi = rfcore_read_byte() & 0x7F;
|
|
|
|
|
rssi_val = rfcore_read_byte() + CC2538_RSSI_OFFSET;
|
|
|
|
|
|
|
|
|
|
RFCORE_ASSERT(rssi_val > CC2538_RF_SENSITIVITY);
|
|
|
|
|
|
|
|
|
|
/* The number of dB above maximum sensitivity detected for the
|
|
|
|
|
* received packet */
|
|
|
|
|
radio_info->rssi = -CC2538_RF_SENSITIVITY + rssi_val;
|
|
|
|
|
|
|
|
|
|
corr_val = rfcore_read_byte() & CC2538_CORR_VAL_MASK;
|
|
|
|
|
|
|
|
|
|
if (corr_val < CC2538_CORR_VAL_MIN) {
|
|
|
|
|
corr_val = CC2538_CORR_VAL_MIN;
|
|
|
|
|
}
|
|
|
|
|
else if (corr_val > CC2538_CORR_VAL_MAX) {
|
|
|
|
|
corr_val = CC2538_CORR_VAL_MAX;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Interpolate the correlation value between 0 - 255
|
|
|
|
|
* to provide an LQI value */
|
|
|
|
|
radio_info->lqi = 255 * (corr_val - CC2538_CORR_VAL_MIN) /
|
|
|
|
|
(CC2538_CORR_VAL_MAX - CC2538_CORR_VAL_MIN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RFCORE_SFR_RFST = ISFLUSHRX;
|
|
|
|
|