IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Commit Details
Date: | 2011-04-13 16:49:33 (9 years 9 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 | ||
---|---|---|
29 | 29 | #define DEFAULT_POWER 15 |
30 | 30 | |
31 | 31 | |
32 | static void init_common(struct atrf_dsc *dsc, int trim, int chan) | |
32 | static 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 | ||
38 | static void init_common(struct atrf_dsc *dsc, int trim) | |
33 | 39 | { |
34 | 40 | atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TRX_OFF); |
35 | 41 | atrf_reg_write(dsc, REG_XOSC_CTRL, |
36 | 42 | (XTAL_MODE_INT << XTAL_MODE_SHIFT) | trim); |
37 | 43 | atrf_set_clkm(dsc, 0); |
38 | atrf_reg_write(dsc, REG_PHY_CC_CCA, (1 << CCA_MODE_SHIFT) | chan); | |
39 | 44 | } |
40 | 45 | |
41 | 46 | |
42 | static void init_tx(struct atrf_dsc *dsc, int trim, int power, int chan) | |
47 | static void init_tx(struct atrf_dsc *dsc, int trim, int power) | |
43 | 48 | { |
44 | init_common(dsc, trim, chan); | |
49 | init_common(dsc, trim); | |
45 | 50 | set_power_step(dsc, power, 0); |
46 | 51 | } |
47 | 52 | |
48 | 53 | |
49 | static void init_rx(struct atrf_dsc *dsc, int trim, int chan) | |
54 | static void init_rx(struct atrf_dsc *dsc, int trim) | |
50 | 55 | { |
51 | init_common(dsc, trim, chan); | |
56 | init_common(dsc, trim); | |
52 | 57 | atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_RX_ON); |
53 | 58 | } |
54 | 59 | |
... | ... | |
66 | 71 | int sum = 0, min = -1, max = -1; |
67 | 72 | double offset = tx_power_step2dBm(sweep->tx, sweep->power); |
68 | 73 | |
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); | |
70 | 76 | usleep(155); /* table 7-2, tTR19 */ |
71 | 77 | |
72 | 78 | cw_test_begin(sweep->tx, cont_tx); |
... | ... | |
90 | 96 | res->avg = rssi_to_dBm((double) sum/sweep->samples)-offset; |
91 | 97 | res->min = rssi_to_dBm(min)-offset; |
92 | 98 | res->max = rssi_to_dBm(max)-offset; |
93 | ||
94 | 99 | } |
95 | 100 | |
96 | 101 | |
... | ... | |
99 | 104 | int chan; |
100 | 105 | |
101 | 106 | for (chan = 11; chan <= 26; chan++) { |
102 | init_rx(sweep->rx, sweep->trim_rx, chan); | |
107 | set_channel(sweep->rx, chan); | |
103 | 108 | sample(sweep, chan, CONT_TX_M500K, res++); |
104 | 109 | sample(sweep, chan, CONT_TX_P500K, res++); |
105 | 110 | } |
... | ... | |
237 | 242 | return 1; |
238 | 243 | |
239 | 244 | sweep.power = 15-power; |
245 | init_rx(sweep.rx, sweep.trim_rx); | |
240 | 246 | if (graphical) |
241 | 247 | gui(&sweep, sweeps); |
242 | 248 | else |