mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cc2420: Add RSSI dBm conversion
This commit is contained in:
parent
11e147736d
commit
047b8172ae
@ -197,8 +197,8 @@ int cc2420_rx(cc2420_t *dev, uint8_t *buf, size_t max_len, void *info)
|
||||
DEBUG("cc2420: recv: reading %i byte of the packet\n", (int)len);
|
||||
cc2420_fifo_read(dev, buf, len);
|
||||
|
||||
uint8_t rssi;
|
||||
cc2420_fifo_read(dev, &rssi, 1);
|
||||
int8_t rssi;
|
||||
cc2420_fifo_read(dev, (uint8_t*)&rssi, 1);
|
||||
DEBUG("cc2420: recv: RSSI is %i\n", (int)rssi);
|
||||
|
||||
/* fetch and check if CRC_OK bit (MSB) is set */
|
||||
@ -208,6 +208,11 @@ int cc2420_rx(cc2420_t *dev, uint8_t *buf, size_t max_len, void *info)
|
||||
/* drop the corrupted frame from the RXFIFO */
|
||||
len = 0;
|
||||
}
|
||||
if (info != NULL) {
|
||||
netdev_ieee802154_rx_info_t *radio_info = info;
|
||||
radio_info->rssi = CC2420_RSSI_OFFSET + rssi;
|
||||
radio_info->lqi = crc_corr & CC2420_CRCCOR_COR_MASK;
|
||||
}
|
||||
|
||||
/* finally flush the FIFO */
|
||||
cc2420_strobe(dev, CC2420_STROBE_FLUSHRX);
|
||||
|
@ -190,6 +190,14 @@ enum {
|
||||
#define CC2420_MDMCTRL0_PREAMBLE_3B (0x0002)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief CRC/Correlation bit masks
|
||||
* @{
|
||||
*/
|
||||
#define CC2420_CRCCOR_CRC_MASK (0x80)
|
||||
#define CC2420_CRCCOR_COR_MASK (0x7F)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Transmit control register bitfields
|
||||
* @{
|
||||
|
@ -61,6 +61,11 @@ extern "C" {
|
||||
#define CC2420_TXPOWER_DEFAULT (IEEE802154_DEFAULT_TXPOWER)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief RSSI offset
|
||||
*/
|
||||
#define CC2420_RSSI_OFFSET (-45)
|
||||
|
||||
/**
|
||||
* @brief A couple of return values used in this driver
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user