From eb0e1720be2aa4fb6729ceada09c18947bfee2bc Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 29 Apr 2013 23:20:25 -0700 Subject: altos: Compute "real" RSSI value in radio code as needed Instead of dragging around the weird CC1111 RSSI values, just compute a dBm value in a signed 8-bit integer, ao_radio_rssi. Use that everywhere we need RSSI internally. We leave the weird CC1111 value in the packet reply as that's what the host expects. Signed-off-by: Keith Packard --- src/core/ao.h | 2 ++ src/core/ao_packet.h | 2 +- src/core/ao_radio_cmac.c | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/ao.h b/src/core/ao.h index 2a8eb042..6bcb3664 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -511,6 +511,8 @@ ao_telemetry_tiny_init(void); extern __xdata uint8_t ao_radio_dma; +extern __xdata int8_t ao_radio_rssi; + #ifdef PKT_APPEND_STATUS_1_CRC_OK #define AO_RADIO_STATUS_CRC_OK PKT_APPEND_STATUS_1_CRC_OK #else diff --git a/src/core/ao_packet.h b/src/core/ao_packet.h index 6d121bb9..b8426cf9 100644 --- a/src/core/ao_packet.h +++ b/src/core/ao_packet.h @@ -68,7 +68,7 @@ _ao_packet_pollchar(void); #if PACKET_HAS_MASTER /* ao_packet_master.c */ -extern __xdata uint8_t ao_packet_last_rssi; +extern __xdata int8_t ao_packet_last_rssi; void ao_packet_master_init(void); diff --git a/src/core/ao_radio_cmac.c b/src/core/ao_radio_cmac.c index 4920b50c..3ca3c313 100644 --- a/src/core/ao_radio_cmac.c +++ b/src/core/ao_radio_cmac.c @@ -92,7 +92,7 @@ radio_cmac_recv(uint8_t len, uint16_t timeout) __reentrant return AO_RADIO_CMAC_TIMEOUT; } - ao_radio_cmac_rssi = (int8_t) (((int8_t) cmac_data[len + AO_CMAC_KEY_LEN]) >> 1) - 74; + ao_radio_cmac_rssi = ao_radio_rssi; if (!(cmac_data[len + AO_CMAC_KEY_LEN +1] & AO_RADIO_STATUS_CRC_OK)) return AO_RADIO_CMAC_CRC_ERROR; @@ -146,7 +146,7 @@ ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant int8_t ao_radio_cmac_recv(__xdata void *packet, uint8_t len, uint16_t timeout) __reentrant { - uint8_t i; + int8_t i; if (len > AO_CMAC_MAX_LEN) return AO_RADIO_CMAC_LEN_ERROR; ao_mutex_get(&ao_radio_cmac_mutex); -- cgit v1.2.3