altos: Make profiling Viterbi decoder more useful
authorKeith Packard <keithp@keithp.com>
Thu, 28 Jun 2012 02:47:52 +0000 (19:47 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 28 Jun 2012 02:47:52 +0000 (19:47 -0700)
This blocks starting the decoder until all of the data have arrived so
that the time spent in the decoder is easily computed.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_cc1120.c
src/drivers/ao_packet.c
src/megametrum-v0.1/Makefile
src/megametrum-v0.1/ao_megametrum.c

index 30663042677668e17bcb35cf3170341268e9d738..1d28148ba2b4a74366a87c345cad72e6f9ebb02d 100644 (file)
@@ -605,8 +605,10 @@ ao_radio_rx_isr(void)
                        rx_data[rx_data_cur++] = d;
                if (rx_waiting && rx_data_cur - rx_data_consumed >= AO_FEC_DECODE_BLOCK) {
 #if AO_PROFILE
-                       if (rx_data_consumed == 0)
+                       if (!rx_packet_tick)
                                rx_packet_tick = ao_profile_tick();
+                       if (rx_data_cur < rx_data_count)
+                               return;
 #endif
                        rx_waiting = 0;
                        ao_wakeup(&ao_radio_wake);
@@ -630,6 +632,9 @@ ao_radio_rx_wait(void)
        if (ao_radio_abort)
                return 0;
        rx_data_consumed += AO_FEC_DECODE_BLOCK;
+#if AO_PROFILE
+       return rx_data_cur - rx_data_consumed;
+#endif
        return AO_FEC_DECODE_BLOCK;
 }
 
@@ -649,6 +654,7 @@ ao_radio_recv(__xdata void *d, uint8_t size)
        }
 #if AO_PROFILE
        rx_start_tick = ao_profile_tick();
+       rx_packet_tick = 0;
 #endif
        len = size + 2;                 /* CRC bytes */
        len += 1 + ~(len & 1);          /* 1 or two pad bytes */
index 28a0c4155803dc450e81fa4ba938c6489149fef3..e020c0030ce0dffd6e8ef4da383a40397f50ed77 100644 (file)
@@ -61,6 +61,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)
index 07a339b9702ed66fbcf938dbc9a496c4db608f9c..06b5e2ae37aea6fec0c86718898a2dbea3487f9d 100644 (file)
@@ -27,8 +27,7 @@ INC = \
 # Common AltOS sources
 #
 
-#      ao_packet.c \
-#      ao_packet_slave.c \
+#PROFILE=ao_profile.c
 
 ALTOS_SRC = \
        ao_interrupt.c \
@@ -72,8 +71,8 @@ ALTOS_SRC = \
        ao_telemetry.c \
        ao_packet_slave.c \
        ao_packet.c \
-       ao_companion.c
-
+       ao_companion.c \
+       $(PROFILE)
 
 PRODUCT=MegaMetrum-v0.1
 PRODUCT_DEF=-DMEGAMETRUM
index ed35efa4028c929c30d898386c30ef7056da200b..749f251d913571028384ae42e759d2c51214ea1e 100644 (file)
@@ -63,6 +63,9 @@ main(void)
        ao_companion_init();
 
        ao_config_init();
+#if AO_PROFILE
+       ao_profile_init();
+#endif
        
        ao_start_scheduler();
        return 0;