telefire: Make 'good' RSSI value configurable
authorKeith Packard <keithp@keithp.com>
Mon, 25 May 2015 00:25:25 +0000 (17:25 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 25 May 2015 00:27:25 +0000 (17:27 -0700)
Different radios will have different 'good' RSSI values, so let each
product configure it, leaving the default set to -90dBm, which is
a solid signal value for the CC1111.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_pad.c

index dc2c83fe0cf3c668668dfbf354cbae020d14533f..3ad239cced3e3c62f07545ba51277982668face2 100644 (file)
@@ -29,6 +29,10 @@ static __pdata uint8_t       ao_pad_box;
 static __xdata uint8_t ao_pad_disabled;
 static __pdata uint16_t        ao_pad_packet_time;
 
 static __xdata uint8_t ao_pad_disabled;
 static __pdata uint16_t        ao_pad_packet_time;
 
+#ifndef AO_PAD_RSSI_MINIMUM
+#define AO_PAD_RSSI_MINIMUM    -90
+#endif
+
 #define DEBUG  1
 
 #if DEBUG
 #define DEBUG  1
 
 #if DEBUG
@@ -36,8 +40,8 @@ static __pdata uint8_t        ao_pad_debug;
 #define PRINTD(...) (ao_pad_debug ? (printf(__VA_ARGS__), 0) : 0)
 #define FLUSHD()    (ao_pad_debug ? (flush(), 0) : 0)
 #else
 #define PRINTD(...) (ao_pad_debug ? (printf(__VA_ARGS__), 0) : 0)
 #define FLUSHD()    (ao_pad_debug ? (flush(), 0) : 0)
 #else
-#define PRINTD(...) 
-#define FLUSHD()    
+#define PRINTD(...)
+#define FLUSHD()
 #endif
 
 static void
 #endif
 
 static void
@@ -138,7 +142,7 @@ ao_pad_monitor(void)
                }
                if ((ao_time() - ao_pad_packet_time) > AO_SEC_TO_TICKS(2))
                        cur |= AO_LED_RED;
                }
                if ((ao_time() - ao_pad_packet_time) > AO_SEC_TO_TICKS(2))
                        cur |= AO_LED_RED;
-               else if (ao_radio_cmac_rssi < -90)
+               else if (ao_radio_cmac_rssi < AO_PAD_RSSI_MINIMUM)
                        cur |= AO_LED_AMBER;
                else
                        cur |= AO_LED_GREEN;
                        cur |= AO_LED_AMBER;
                else
                        cur |= AO_LED_GREEN;
@@ -255,7 +259,7 @@ ao_pad(void)
                if (ret != AO_RADIO_CMAC_OK)
                        continue;
                ao_pad_packet_time = ao_time();
                if (ret != AO_RADIO_CMAC_OK)
                        continue;
                ao_pad_packet_time = ao_time();
-               
+
                ao_pad_box = ao_pad_read_box();
 
                PRINTD ("tick %d box %d (me %d) cmd %d channels %02x\n",
                ao_pad_box = ao_pad_read_box();
 
                PRINTD ("tick %d box %d (me %d) cmd %d channels %02x\n",