diff --git a/tools/atrf-path/atrf-path.c b/tools/atrf-path/atrf-path.c index ee2f5e1..456c262 100644 --- a/tools/atrf-path/atrf-path.c +++ b/tools/atrf-path/atrf-path.c @@ -74,14 +74,11 @@ static void sample(const struct sweep *sweep, int cont_tx, int sum = 0, min = -1, max = -1; double offset = tx_power_step2dBm(sweep->tx, sweep->power); -/* - * For the 230, we don't have reset-less exit from test mode (yet ?) and - * need to set up things from scratch: - * - * init_tx(sweep->tx, sweep->trim_tx, sweep->power); - * set_channel(sweep->tx, chan); - * usleep(155); / * table 7-2, tTR19 * / - */ + if (cw_test_needs_reset(sweep->tx)) { + init_tx(sweep->tx, sweep->trim_tx, sweep->power); + need_init = 1; + } + usleep(155); /* table 7-2, tTR19 */ if (first || need_init) { cw_test_begin(sweep->tx, cont_tx); need_init = 0; @@ -123,7 +120,6 @@ static int do_half_sweep(const struct sweep *sweep, int cont_tx, for (i = 0; i != N_CHAN; i++) { set_channel(sweep->rx, chan); set_channel(sweep->tx, chan); - usleep(155); /* table 7-2, tTR19 */ sample(sweep, cont_tx, res, chan == 11 && !sweep->cont_tx); if (res->avg > sweep->max[i]) diff --git a/tools/include/cwtest.h b/tools/include/cwtest.h index c460807..6749716 100644 --- a/tools/include/cwtest.h +++ b/tools/include/cwtest.h @@ -19,6 +19,7 @@ #include "atrf.h" +int cw_test_needs_reset(struct atrf_dsc *dsc); void cw_test_begin(struct atrf_dsc *dsc, uint8_t cont_tx); void cw_test_resume(struct atrf_dsc *dsc); void cw_test_end(struct atrf_dsc *dsc); diff --git a/tools/lib/cwtest.c b/tools/lib/cwtest.c index f9a832c..ec8dc1e 100644 --- a/tools/lib/cwtest.c +++ b/tools/lib/cwtest.c @@ -26,6 +26,16 @@ static int last_cont_tx; /* @@@ hack for resuming on the 230 */ +int cw_test_needs_reset(struct atrf_dsc *dsc) +{ + if (atrf_usb_handle(dsc)) + return 1; + if (atrf_identify(dsc) == artf_at86rf230) + return 1; + return 0; +} + + static void enter_test_mode_230(struct atrf_dsc *dsc, uint8_t cont_tx) { atrf_buf_write(dsc, "", 1); @@ -39,7 +49,7 @@ static void enter_test_mode_230(struct atrf_dsc *dsc, uint8_t cont_tx) } atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_PLL_ON); - wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 20); + wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 0); atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TX_START); } @@ -92,7 +102,7 @@ static void start_test_mode_231(struct atrf_dsc *dsc) atrf_reg_write(dsc, REG_PART_NUM, 0x46); /*14 */ atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_PLL_ON); /*15 */ - wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 20); /*16 */ + wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 0); /*16 */ atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TX_START); /*17 */ } @@ -142,7 +152,7 @@ void cw_test_end(struct atrf_dsc *dsc) * AT86RF231 also exits test mode if we send it to sleep for a * moment. */ - if (atrf_identify(dsc) == artf_at86rf230 || atrf_usb_handle(dsc)) + if (cw_test_needs_reset(dsc)) atrf_reset_rf(dsc); else { usleep(2); /* table 7-1: tTR12(typ) = 1 us */