diff options
author | Keith Packard <keithp@keithp.com> | 2013-04-29 23:20:25 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-05-07 20:07:54 -0700 |
commit | eb0e1720be2aa4fb6729ceada09c18947bfee2bc (patch) | |
tree | 77bfbad77fa2d2f653c9bf6814b7d63607672a77 /src/cc1111 | |
parent | 949700f276b80b4eb28f15b5559714f430f227f1 (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.c | 19 |
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; } |