Date:2010-11-11 06:32:09 (9 years 8 days ago)
Author:Werner Almesberger
Commit:d4fe0277c28563f870334b68dde373751ace8197
Message:atspi-txrx: option -T <delta_MHz> to emit a constant wave

- atspi-txrx/atspi-txrx.c (set_power): make enabling the CRC optional
(this is necessary for test mode, which doesn't seem to work if the CRC
is selected)
- atspi-txrx/atspi-txrx.c (test_mode): emit a constant wave in test mode
- atspi-txrx/atspi-txrx.c (usage, main): new option -T <delta> to emit a
constant wave -2 MHz, -0.5 MHz, or +0.5 MHz from the nominal carrier
frequency
Files: tools/atspi-txrx/atspi-txrx.c (8 diffs)

Change Details

tools/atspi-txrx/atspi-txrx.c
8181}
8282
8383
84static void set_power(struct atspi_dsc *dsc, double power)
84static void set_power(struct atspi_dsc *dsc, double power, int crc)
8585{
8686    int n;
8787
...... 
9090            break;
9191    if (fabs(tx_pwr[n]-power) > 0.01)
9292        fprintf(stderr, "TX power %.1f dBm\n", tx_pwr[n]);
93    atspi_reg_write(dsc, REG_PHY_TX_PWR, TX_AUTO_CRC_ON | n);
93    atspi_reg_write(dsc, REG_PHY_TX_PWR, (crc ? TX_AUTO_CRC_ON : 0) | n);
9494}
9595
9696
...... 
159159}
160160
161161
162static void test_mode(struct atspi_dsc *dsc, uint8_t cont_tx)
163{
164    atspi_buf_write(dsc, "", 1);
165    atspi_reg_write(dsc, REG_CONT_TX_0, CONT_TX_MAGIC);
166    atspi_reg_write(dsc, REG_CONT_TX_1, cont_tx);
167
168    if (!atspi_test_mode(dsc)) {
169        atspi_reset_rf(dsc);
170        fprintf(stderr, "device does not support test mode\n");
171        exit(1);
172    }
173
174    atspi_reg_write(dsc, REG_TRX_STATE, TRX_CMD_PLL_ON);
175    wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 20);
176
177    atspi_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TX_START);
178
179    while (run)
180        sleep(1);
181    atspi_reset_rf(dsc);
182}
183
184
162185static void die(int sig)
163186{
164187    run = 0;
...... 
169192{
170193    fprintf(stderr,
171194"usage: %s [-c channel] [-p power] [-t trim] [message [repetitions]]\n"
172" -c channel channel number, 11 to 26 (default %d)\n"
173" -p power transmit power, -17.2 to 3.0 dBm (default %.1f)\n"
174" -t trim trim capacitor, 0 to 15 (default 0)\n"
175        , name , DEFAULT_CHANNEL, DEFAULT_POWER);
195" %s [-c channel] [-p power] [-t trim] -T delta\n"
196" -c channel channel number, 11 to 26 (default %d)\n"
197" -p power transmit power, -17.2 to 3.0 dBm (default %.1f)\n"
198" -t trim trim capacitor, 0 to 15 (default 0)\n"
199" -t trim trim capacitor, 0 to 15 (default 0)\n"
200" -T delta_MHz test mode. delta_MHz is -2, -0.5, or +0.5\n"
201        , name, name, DEFAULT_CHANNEL, DEFAULT_POWER);
176202    exit(1);
177203}
178204
...... 
182208    int channel = DEFAULT_CHANNEL;
183209    double power = DEFAULT_POWER;
184210    int trim = 0, times = 1;
211    uint8_t cont_tx = 0;
185212    char *end;
186213    int c;
187214    struct atspi_dsc *dsc;
188215
189    while ((c = getopt(argc, argv, "c:p:t:")) != EOF)
216    while ((c = getopt(argc, argv, "c:p:t:T:")) != EOF)
190217        switch (c) {
191218        case 'c':
192219            channel = strtoul(optarg, &end, 0);
...... 
207234            if (trim > 15)
208235                usage(*argv);
209236            break;
237        case 'T':
238            if (!strcmp(optarg, "-2"))
239                cont_tx = CONT_TX_M2M;
240            else if (!strcmp(optarg, "-0.5"))
241                cont_tx = CONT_TX_M500K;
242            else if (!strcmp(optarg, "+0.5"))
243                cont_tx = CONT_TX_P500K;
244            else
245                usage(*argv);
246            break;
210247        default:
211248            usage(*argv);
212249        }
...... 
217254    case 0:
218255        dsc = init_txrx(trim);
219256        set_channel(dsc, channel);
220        receive(dsc);
257        if (!cont_tx)
258            receive(dsc);
259        else {
260            set_power(dsc, power, 0);
261            test_mode(dsc, cont_tx);
262        }
221263        break;
222264    case 2:
223265        times = strtoul(argv[optind+1], &end, 0);
...... 
225267            usage(*argv);
226268        /* fall through */
227269    case 1:
270        if (cont_tx)
271            usage(*argv);
228272        dsc = init_txrx(trim);
229273        set_channel(dsc, channel);
230        set_power(dsc, power);
274        set_power(dsc, power, 1);
231275        transmit(dsc, argv[optind], times);
232276        break;
233277    default:

Archive Download the corresponding diff file



interactive