altosdroid: initial implementation of telemetry logging.
[fw/altos] / src / drivers / ao_packet.c
index 28a0c4155803dc450e81fa4ba938c6489149fef3..d813b25f27448c43c3707dc0f46d689b4024f94b 100644 (file)
@@ -27,7 +27,11 @@ static __pdata uint8_t rx_seq;
 
 __xdata struct ao_task ao_packet_task;
 __xdata uint8_t ao_packet_enable;
+
+#if PACKET_HAS_MASTER
 __xdata uint8_t ao_packet_master_sleeping;
+__xdata uint8_t ao_packet_last_rssi;
+#endif
 
 void
 ao_packet_send(void)
@@ -61,6 +65,18 @@ ao_packet_recv(void)
 #ifdef AO_LED_GREEN
        ao_led_off(AO_LED_GREEN);
 #endif
+#if AO_PROFILE
+               {
+                       extern uint32_t ao_rx_start_tick, ao_rx_packet_tick, ao_rx_done_tick, ao_rx_last_done_tick;
+                       extern uint32_t ao_fec_decode_start, ao_fec_decode_end;
+
+                       printf ("between packet: %d\n", ao_rx_start_tick - ao_rx_last_done_tick);
+                       printf ("receive start delay: %d\n", ao_rx_packet_tick - ao_rx_start_tick);
+                       printf ("decode time: %d\n", ao_fec_decode_end - ao_fec_decode_start);
+                       printf ("rx cleanup: %d\n\n", ao_rx_done_tick - ao_fec_decode_end);
+                       flush();
+               }
+#endif
 
        /* Check to see if we got a valid packet */
        if (!dma_done)
@@ -68,6 +84,9 @@ ao_packet_recv(void)
        if (!(ao_rx_packet.status & AO_RADIO_STATUS_CRC_OK))
                return 0;
 
+#if PACKET_HAS_MASTER
+       ao_packet_last_rssi = ao_rx_packet.rssi;
+#endif
        /* Accept packets with matching call signs, or any packet if
         * our callsign hasn't been configured
         */
@@ -118,10 +137,6 @@ ao_packet_recv(void)
        return 1;
 }
 
-#ifndef PACKET_HAS_MASTER
-#define PACKET_HAS_MASTER 1
-#endif
-
 #if PACKET_HAS_MASTER
 void
 ao_packet_flush(void)