summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-07-11 13:50:56 -0700
committerKeith Packard <keithp@keithp.com>2012-07-11 13:50:56 -0700
commitfe70611c3c7d4b8cce3b5292f0ec549f3191bf86 (patch)
tree34c7b7c73fc3a2528757fece149e7a5d26edc4d6 /src/core
parent18431c88c8a6cb267922b97192e8b7ddb88d0e7e (diff)
altos: Create macros to convert from/to radio RSSI representation
AO_RSSI_FROM_RADIO and AO_RADIO_FROM_RSSI. Removes a bunch of open-coded versions of the same function. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ao.h6
-rw-r--r--src/core/ao_monitor.c5
2 files changed, 8 insertions, 3 deletions
diff --git a/src/core/ao.h b/src/core/ao.h
index 06daf48f..eb2d47cf 100644
--- a/src/core/ao.h
+++ b/src/core/ao.h
@@ -487,6 +487,12 @@ struct ao_telemetry_tiny_recv {
uint8_t status;
};
+/* Unfortunately, we've exposed the CC1111 rssi units as the 'usual' method
+ * for reporting RSSI. So, now we use these values everywhere
+ */
+#define AO_RSSI_FROM_RADIO(radio) ((int16_t) ((int8_t) (radio) >> 1) - 74)
+#define AO_RADIO_FROM_RSSI(rssi) (((int8_t) (rssi) + 74) << 1)
+
/*
* ao_radio_recv tacks on rssi and status bytes
*/
diff --git a/src/core/ao_monitor.c b/src/core/ao_monitor.c
index 51d61425..d492e32a 100644
--- a/src/core/ao_monitor.c
+++ b/src/core/ao_monitor.c
@@ -141,8 +141,7 @@ ao_monitor_put(void)
case AO_MONITORING_ORIG:
state = recv_orig.telemetry_orig.flight_state;
- /* Typical RSSI offset for 38.4kBaud at 433 MHz is 74 */
- rssi = (int16_t) (recv_orig.rssi >> 1) - 74;
+ rssi = (int16_t) AO_RSSI_FROM_RADIO(recv_orig.rssi);
ao_xmemcpy(callsign, recv_orig.telemetry_orig.callsign, AO_MAX_CALLSIGN);
if (state > ao_flight_invalid)
state = ao_flight_invalid;
@@ -240,7 +239,7 @@ ao_monitor_put(void)
putchar ('\n');
#if HAS_RSSI
if (recv_raw.packet[ao_monitoring + 1] & PKT_APPEND_STATUS_1_CRC_OK) {
- rssi = ((int16_t) recv_raw.packet[ao_monitoring] >> 1) - 74;
+ rssi = AO_RSSI_FROM_RADIO(recv_raw.packet[ao_monitoring]);
ao_rssi_set(rssi);
}
#endif