summaryrefslogtreecommitdiff
path: root/src/cc1111
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-04-29 23:20:25 -0700
committerKeith Packard <keithp@keithp.com>2013-04-29 23:20:25 -0700
commit491771214bd1853aa18afa5d7848309b5f413e49 (patch)
treee4ba0c48537a5d8269e89c014830547a3083ed28 /src/cc1111
parent18cc254bcda7707740d6dd723f3a2963780441de (diff)
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 <keithp@keithp.com>
Diffstat (limited to 'src/cc1111')
-rw-r--r--src/cc1111/ao_radio.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cc1111/ao_radio.c b/src/cc1111/ao_radio.c
index 07b0d1b5..4842486b 100644
--- a/src/cc1111/ao_radio.c
+++ b/src/cc1111/ao_radio.c
@@ -249,6 +249,18 @@ __xdata uint8_t ao_radio_done;
__xdata uint8_t ao_radio_abort;
__xdata uint8_t ao_radio_mutex;
+#if PACKET_HAS_MASTER || HAS_AES
+#define NEED_RADIO_RSSI 1
+#endif
+
+#ifndef NEED_RADIO_RSSI
+#define NEED_RADIO_RSSI 0
+#endif
+
+#if NEED_RADIO_RSSI
+__xdata int8_t ao_radio_rssi;
+#endif
+
void
ao_radio_general_isr(void) __interrupt 16
{
@@ -356,7 +368,14 @@ ao_radio_recv(__xdata void *packet, uint8_t size, uint8_t timeout) __reentrant
if (!ao_radio_dma_done) {
ao_dma_abort(ao_radio_dma);
ao_radio_idle();
+#if NEED_RADIO_RSSI
+ ao_radio_rssi = 0;
+#endif
}
+#if NEED_RADIO_RSSI
+ else
+ ao_radio_rssi = AO_RSSI_FROM_RADIO(((uint8_t *)packet)[size - 1]);
+#endif
ao_radio_put();
return ao_radio_dma_done;
}