Merge branch 'buttonbox'
[fw/altos] / src / ao_radio.c
index f4a9d3b265edb1a82ea37ee95cac9568022da9c6..67d5f6bad7e7272190cb2b967c311c69efeb7af4 100644 (file)
@@ -432,8 +432,11 @@ ao_radio_rdf(int ms)
 void
 ao_radio_abort(void)
 {
-       ao_dma_abort(ao_radio_dma);
-       ao_radio_idle();
+       /* Only abort if a task is waiting to receive data */
+       if (RFST == RFST_SRX) {
+               ao_dma_abort(ao_radio_dma);
+               ao_radio_idle();
+       }
 }
 
 void
@@ -448,19 +451,35 @@ ao_radio_rdf_abort(void)
 void
 ao_radio_test(void)
 {
-       ao_set_monitor(0);
-       ao_packet_slave_stop();
-       ao_radio_get();
-       printf ("Hit a character to stop..."); flush();
-       RFST = RFST_STX;
-       getchar();
-       ao_radio_idle();
-       ao_radio_put();
-       putchar('\n');
+       uint8_t mode = 2;
+       static __xdata radio_on;
+       ao_cmd_white();
+       if (ao_cmd_lex_c != '\n') {
+               ao_cmd_decimal();
+               mode = (uint8_t) ao_cmd_lex_u32;
+       }
+       mode++;
+       if ((mode & 2) && !radio_on) {
+               ao_set_monitor(0);
+               ao_packet_slave_stop();
+               ao_radio_get();
+               RFST = RFST_STX;
+               radio_on = 1;
+       }
+       if (mode == 3) {
+               printf ("Hit a character to stop..."); flush();
+               getchar();
+               putchar('\n');
+       }
+       if ((mode & 1) && radio_on) {
+               ao_radio_idle();
+               ao_radio_put();
+               radio_on = 0;
+       }
 }
 
 __code struct ao_cmds ao_radio_cmds[] = {
-       { 'C',  ao_radio_test,  "C                                  Radio carrier test" },
+       { 'C',  ao_radio_test,  "C <1 start, 0 stop, none both>     Radio carrier test" },
        { 0,    ao_radio_test,  NULL },
 };