Date:2011-06-13 19:24:59 (8 years 5 months ago)
Author:Werner Almesberger
Commit:9ef447865bcf755dfe91b170a465034b4e8bcbaa
Message:tools/: rearranged cwtest/atrf-path to be more clear about reset and do re-init

- include/cwtest.h (cw_test_needs_reset), lib/cwtest.c
(cw_test_needs_reset): new function to indicate all cases where the
transceiver needs to be reset (instead of using SLP_TR)
- lib/cwtest.c (cw_test_end): use cw_test_needs_reset instead of
open-coding the decision
- lib/cwtest.c (enter_test_mode_230, start_test_mode_231): always wait
for the PLL to lock. Contrary to the assumption in the previous
commit, we should always see this interrupt.
- atrf-path/atrf-path.c (sample): initialize the transceiver if we had
to reset it
- atrf-path/atrf-path.c (sample), atrf-path/atrf-path.c (do_half_sweep):
moved the tTR19 delay to "sweep", so that all branches share it and it
is taken only once
Files: tools/atrf-path/atrf-path.c (2 diffs)
tools/include/cwtest.h (1 diff)
tools/lib/cwtest.c (4 diffs)

Change Details

tools/atrf-path/atrf-path.c
7474    int sum = 0, min = -1, max = -1;
7575    double offset = tx_power_step2dBm(sweep->tx, sweep->power);
7676
77/*
78 * For the 230, we don't have reset-less exit from test mode (yet ?) and
79 * need to set up things from scratch:
80 *
81 * init_tx(sweep->tx, sweep->trim_tx, sweep->power);
82 * set_channel(sweep->tx, chan);
83 * usleep(155); / * table 7-2, tTR19 * /
84 */
77    if (cw_test_needs_reset(sweep->tx)) {
78        init_tx(sweep->tx, sweep->trim_tx, sweep->power);
79        need_init = 1;
80    }
81    usleep(155); /* table 7-2, tTR19 */
8582    if (first || need_init) {
8683        cw_test_begin(sweep->tx, cont_tx);
8784        need_init = 0;
...... 
123120    for (i = 0; i != N_CHAN; i++) {
124121        set_channel(sweep->rx, chan);
125122        set_channel(sweep->tx, chan);
126        usleep(155); /* table 7-2, tTR19 */
127123
128124        sample(sweep, cont_tx, res, chan == 11 && !sweep->cont_tx);
129125        if (res->avg > sweep->max[i])
tools/include/cwtest.h
1919#include "atrf.h"
2020
2121
22int cw_test_needs_reset(struct atrf_dsc *dsc);
2223void cw_test_begin(struct atrf_dsc *dsc, uint8_t cont_tx);
2324void cw_test_resume(struct atrf_dsc *dsc);
2425void cw_test_end(struct atrf_dsc *dsc);
tools/lib/cwtest.c
2626static int last_cont_tx; /* @@@ hack for resuming on the 230 */
2727
2828
29int cw_test_needs_reset(struct atrf_dsc *dsc)
30{
31    if (atrf_usb_handle(dsc))
32        return 1;
33    if (atrf_identify(dsc) == artf_at86rf230)
34        return 1;
35    return 0;
36}
37
38
2939static void enter_test_mode_230(struct atrf_dsc *dsc, uint8_t cont_tx)
3040{
3141    atrf_buf_write(dsc, "", 1);
...... 
3949    }
4050
4151    atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_PLL_ON);
42    wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 20);
52    wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 0);
4353
4454    atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TX_START);
4555}
...... 
92102    atrf_reg_write(dsc, REG_PART_NUM, 0x46); /*14 */
93103
94104    atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_PLL_ON); /*15 */
95    wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 20); /*16 */
105    wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 0); /*16 */
96106
97107    atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TX_START); /*17 */
98108}
...... 
142152     * AT86RF231 also exits test mode if we send it to sleep for a
143153     * moment.
144154     */
145    if (atrf_identify(dsc) == artf_at86rf230 || atrf_usb_handle(dsc))
155    if (cw_test_needs_reset(dsc))
146156        atrf_reset_rf(dsc);
147157    else {
148158        usleep(2); /* table 7-1: tTR12(typ) = 1 us */

Archive Download the corresponding diff file



interactive