altos: Scale packet master receive delay by baud rate
authorKeith Packard <keithp@keithp.com>
Sun, 7 Sep 2014 03:44:30 +0000 (20:44 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 7 Sep 2014 03:44:30 +0000 (20:44 -0700)
Increase the time we wait for return packets based on the remote
protocol baud rate.

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

index d6c99cbd89defb62b07a2def1b7964f8be2f9df9..2354504981d6f09d3b51046d02fab1e300bc6b3a 100644 (file)
@@ -57,6 +57,12 @@ static __xdata uint16_t              ao_packet_master_time;
 #define AO_PACKET_MASTER_DELAY_LONG    AO_MS_TO_TICKS(1000)
 #define AO_PACKET_MASTER_DELAY_TIMEOUT AO_MS_TO_TICKS(2000)
 
+#if HAS_RADIO_RATE
+#define AO_PACKET_MASTER_RECV_DELAY    AO_MS_TO_TICKS(100) << (ao_config.radio_rate << 1)
+#else
+#define AO_PACKET_MASTER_RECV_DELAY    AO_MS_TO_TICKS(100)
+#endif
+
 static void
 ao_packet_master_busy(void)
 {
@@ -91,7 +97,7 @@ ao_packet_master(void)
                if (ao_tx_packet.len)
                        ao_packet_master_busy();
                ao_packet_master_check_busy();
-               ao_alarm(ao_packet_master_delay);
+               ao_alarm(AO_PACKET_MASTER_RECV_DELAY);
                r = ao_packet_recv();
                ao_clear_alarm();
                if (r) {