mrf24j40: Add RSSI dBm conversion
This commit is contained in:
parent
fa64e93313
commit
4bd5fd611c
@ -366,6 +366,14 @@ void mrf24j40_reset_state_machine(mrf24j40_t *dev);
|
|||||||
*/
|
*/
|
||||||
void mrf24j40_software_reset(mrf24j40_t *dev);
|
void mrf24j40_software_reset(mrf24j40_t *dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Convert scalar from mrf24j40 RSSI to dBm
|
||||||
|
*
|
||||||
|
* @param[in] value value to convert to dBm
|
||||||
|
* @return converted value in dBm
|
||||||
|
*/
|
||||||
|
int8_t mrf24j40_dbm_from_reg(uint8_t value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prepare for sending of data
|
* @brief Prepare for sending of data
|
||||||
*
|
*
|
||||||
|
|||||||
@ -74,38 +74,38 @@ static const uint8_t dbm_to_tx_pow[] = { 0x00, 0x10, 0x18, 0x20, 0x28, 0x30, 0x3
|
|||||||
0xc0, 0xd0, 0xd8, 0xe0, 0xe8, 0xf0, 0xf8 };
|
0xc0, 0xd0, 0xd8, 0xe0, 0xe8, 0xf0, 0xf8 };
|
||||||
|
|
||||||
/* take a look onto datasheet table 3-8 */
|
/* take a look onto datasheet table 3-8 */
|
||||||
static const int8_t dBm_value[] = { 95, 89, 88, 88, 87, 87, 87, 87, \
|
static const int8_t dBm_value[] = { -90, -89, -88, -88, -87, -87, -87, -87, \
|
||||||
86, 86, 86, 86, 85, 85, 85, 85, \
|
-86, -86, -86, -86, -85, -85, -85, -85, \
|
||||||
84, 84, 84, 84, 84, 84, 83, 83, \
|
-84, -84, -84, -84, -84, -84, -83, -83, \
|
||||||
83, 83, 82, 82, 82, 82, 81, 81, \
|
-83, -83, -82, -82, -82, -82, -81, -81, \
|
||||||
81, 81, 81, 80, 80, 80, 80, 80, \
|
-81, -81, -81, -80, -80, -80, -80, -80, \
|
||||||
80, 79, 79, 79, 79, 79, 78, 78, \
|
-80, -79, -79, -79, -79, -79, -78, -78, \
|
||||||
78, 78, 78, 77, 77, 77, 77, 77, \
|
-78, -78, -78, -77, -77, -77, -77, -77, \
|
||||||
76, 76, 76, 76, 76, 75, 75, 75, \
|
-76, -76, -76, -76, -76, -75, -75, -75, \
|
||||||
75, 75, 75, 74, 74, 74, 74, 73, \
|
-75, -75, -75, -74, -74, -74, -74, -73, \
|
||||||
73, 73, 73, 73, 72, 72, 72, 72, \
|
-73, -73, -73, -73, -72, -72, -72, -72, \
|
||||||
72, 71, 71, 71, 71, 71, 70, 70, \
|
-72, -71, -71, -71, -71, -71, -70, -70, \
|
||||||
70, 70, 70, 70, 70, 69, 69, 69, \
|
-70, -70, -70, -70, -70, -69, -69, -69, \
|
||||||
69, 69, 68, 68, 68, 68, 68, 68, \
|
-69, -69, -68, -68, -68, -68, -68, -68, \
|
||||||
68, 67, 67, 67, 67, 66, 66, 66, \
|
-68, -67, -67, -67, -67, -66, -66, -66, \
|
||||||
66, 66, 66, 65, 65, 65, 65, 65, \
|
-66, -66, -66, -65, -65, -65, -65, -65, \
|
||||||
64, 64, 64, 64, 63, 63, 63, 63, \
|
-64, -64, -64, -64, -63, -63, -63, -63, \
|
||||||
62, 62, 62, 62, 61, 61, 61, 61, \
|
-62, -62, -62, -62, -61, -61, -61, -61, \
|
||||||
60, 60, 60, 60, 60, 59, 59, 59, \
|
-60, -60, -60, -60, -60, -59, -59, -59, \
|
||||||
59, 59, 58, 58, 58, 58, 58, 57, \
|
-59, -59, -58, -58, -58, -58, -58, -57, \
|
||||||
57, 57, 57, 57, 57, 56, 56, 56, \
|
-57, -57, -57, -57, -57, -56, -56, -56, \
|
||||||
56, 56, 56, 56, 55, 55, 55, 55, \
|
-56, -56, -56, -56, -55, -55, -55, -55, \
|
||||||
54, 54, 54, 54, 54, 54, 53, 53, \
|
-54, -54, -54, -54, -54, -54, -53, -53, \
|
||||||
53, 53, 53, 53, 53, 52, 52, 52, \
|
-53, -53, -53, -53, -53, -52, -52, -52, \
|
||||||
52, 52, 52, 51, 51, 51, 51, 51, \
|
-52, -52, -52, -51, -51, -51, -51, -51, \
|
||||||
50, 50, 50, 50, 50, 49, 49, 49, \
|
-50, -50, -50, -50, -50, -49, -49, -49, \
|
||||||
49, 49, 48, 48, 48, 48, 47, 47, \
|
-49, -49, -48, -48, -48, -48, -47, -47, \
|
||||||
47, 47, 47, 46, 46, 46, 46, 45, \
|
-47, -47, -47, -46, -46, -46, -46, -45, \
|
||||||
45, 45, 45, 44, 44, 44, 44, 44, \
|
-45, -45, -45, -44, -44, -44, -44, -44, \
|
||||||
43, 43, 43, 42, 42, 42, 42, 41, \
|
-43, -43, -43, -42, -42, -42, -42, -41, \
|
||||||
41, 41, 41, 41, 41, 40, 40, 40, \
|
-41, -41, -41, -41, -41, -40, -40, -40, \
|
||||||
40, 40, 39, 39, 39, 39, 39, 38, \
|
-40, -40, -39, -39, -39, -39, -39, -38, \
|
||||||
38, 38, 38, 37, 37, 37, 36, 30 };
|
-38, -38, -38, -37, -37, -37, -36, -35 };
|
||||||
|
|
||||||
/* take a look onto datasheet table 3-8 */
|
/* take a look onto datasheet table 3-8 */
|
||||||
static const uint8_t RSSI_value[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
|
static const uint8_t RSSI_value[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
|
||||||
@ -488,3 +488,8 @@ void mrf24j40_software_reset(mrf24j40_t *dev)
|
|||||||
softrst = mrf24j40_reg_read_short(dev, MRF24J40_REG_SOFTRST);
|
softrst = mrf24j40_reg_read_short(dev, MRF24J40_REG_SOFTRST);
|
||||||
} while (softrst != 0); /* wait until soft-reset has finished */
|
} while (softrst != 0); /* wait until soft-reset has finished */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int8_t mrf24j40_dbm_from_reg(uint8_t value)
|
||||||
|
{
|
||||||
|
return dBm_value[value];
|
||||||
|
}
|
||||||
|
|||||||
@ -154,9 +154,11 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
|
|||||||
|
|
||||||
if (info != NULL) {
|
if (info != NULL) {
|
||||||
netdev_ieee802154_rx_info_t *radio_info = info;
|
netdev_ieee802154_rx_info_t *radio_info = info;
|
||||||
|
uint8_t rssi_scalar = 0;
|
||||||
/* Read LQI and RSSI values from the RX fifo */
|
/* Read LQI and RSSI values from the RX fifo */
|
||||||
mrf24j40_rx_fifo_read(dev, phr + 1, &(radio_info->lqi), 1);
|
mrf24j40_rx_fifo_read(dev, phr + 1, &(radio_info->lqi), 1);
|
||||||
mrf24j40_rx_fifo_read(dev, phr + 2, &(radio_info->rssi), 1);
|
mrf24j40_rx_fifo_read(dev, phr + 2, &(rssi_scalar), 1);
|
||||||
|
radio_info->rssi = mrf24j40_dbm_from_reg(rssi_scalar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Turn on reception of packets off the air */
|
/* Turn on reception of packets off the air */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user