Date:2011-04-13 16:49:33 (9 years 3 months ago)
Author:Werner Almesberger
Commit:5f153ca4b8fb15713c1967073e04c8b6be0aefe8
Message:atrf-path/atrf-path.c: initialize the receiver only once, not for each sweep

atrf-path -g ... 10 10 time:

before 2.08 s
after 1.92-1.93 s (92-93%)

- atrf-path.c (set_channel, init_common): moved setting of the channel
to separate function, for better granularity
- atrf-path.c (init_common, init_tx, init_rx, sample, do_sweep): the
init_* functions no longer set the channel; use set_channel
- atrf-path.c (main): initialize the receiver only once
Files: tools/atrf-path/atrf-path.c (5 diffs)

Change Details

tools/atrf-path/atrf-path.c
2929#define DEFAULT_POWER 15
3030
3131
32static void init_common(struct atrf_dsc *dsc, int trim, int chan)
32static void set_channel(struct atrf_dsc *dsc, int chan)
33{
34    atrf_reg_write(dsc, REG_PHY_CC_CCA, (1 << CCA_MODE_SHIFT) | chan);
35}
36
37
38static void init_common(struct atrf_dsc *dsc, int trim)
3339{
3440    atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TRX_OFF);
3541    atrf_reg_write(dsc, REG_XOSC_CTRL,
3642        (XTAL_MODE_INT << XTAL_MODE_SHIFT) | trim);
3743    atrf_set_clkm(dsc, 0);
38    atrf_reg_write(dsc, REG_PHY_CC_CCA, (1 << CCA_MODE_SHIFT) | chan);
3944}
4045
4146
42static void init_tx(struct atrf_dsc *dsc, int trim, int power, int chan)
47static void init_tx(struct atrf_dsc *dsc, int trim, int power)
4348{
44    init_common(dsc, trim, chan);
49    init_common(dsc, trim);
4550    set_power_step(dsc, power, 0);
4651}
4752
4853
49static void init_rx(struct atrf_dsc *dsc, int trim, int chan)
54static void init_rx(struct atrf_dsc *dsc, int trim)
5055{
51    init_common(dsc, trim, chan);
56    init_common(dsc, trim);
5257    atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_RX_ON);
5358}
5459
...... 
6671    int sum = 0, min = -1, max = -1;
6772    double offset = tx_power_step2dBm(sweep->tx, sweep->power);
6873
69    init_tx(sweep->tx, sweep->trim_tx, sweep->power, chan);
74    init_tx(sweep->tx, sweep->trim_tx, sweep->power);
75    set_channel(sweep->tx, chan);
7076    usleep(155); /* table 7-2, tTR19 */
7177
7278    cw_test_begin(sweep->tx, cont_tx);
...... 
9096    res->avg = rssi_to_dBm((double) sum/sweep->samples)-offset;
9197    res->min = rssi_to_dBm(min)-offset;
9298    res->max = rssi_to_dBm(max)-offset;
93
9499}
95100
96101
...... 
99104    int chan;
100105
101106    for (chan = 11; chan <= 26; chan++) {
102        init_rx(sweep->rx, sweep->trim_rx, chan);
107        set_channel(sweep->rx, chan);
103108        sample(sweep, chan, CONT_TX_M500K, res++);
104109        sample(sweep, chan, CONT_TX_P500K, res++);
105110    }
...... 
237242        return 1;
238243
239244    sweep.power = 15-power;
245    init_rx(sweep.rx, sweep.trim_rx);
240246    if (graphical)
241247        gui(&sweep, sweeps);
242248    else

Archive Download the corresponding diff file



interactive