mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-22 19:20:41 +02:00
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
This commit is contained in:
parent
8c00833542
commit
9ef447865b
@ -74,14 +74,11 @@ static void sample(const struct sweep *sweep, int cont_tx,
|
|||||||
int sum = 0, min = -1, max = -1;
|
int sum = 0, min = -1, max = -1;
|
||||||
double offset = tx_power_step2dBm(sweep->tx, sweep->power);
|
double offset = tx_power_step2dBm(sweep->tx, sweep->power);
|
||||||
|
|
||||||
/*
|
if (cw_test_needs_reset(sweep->tx)) {
|
||||||
* For the 230, we don't have reset-less exit from test mode (yet ?) and
|
init_tx(sweep->tx, sweep->trim_tx, sweep->power);
|
||||||
* need to set up things from scratch:
|
need_init = 1;
|
||||||
*
|
}
|
||||||
* init_tx(sweep->tx, sweep->trim_tx, sweep->power);
|
usleep(155); /* table 7-2, tTR19 */
|
||||||
* set_channel(sweep->tx, chan);
|
|
||||||
* usleep(155); / * table 7-2, tTR19 * /
|
|
||||||
*/
|
|
||||||
if (first || need_init) {
|
if (first || need_init) {
|
||||||
cw_test_begin(sweep->tx, cont_tx);
|
cw_test_begin(sweep->tx, cont_tx);
|
||||||
need_init = 0;
|
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++) {
|
for (i = 0; i != N_CHAN; i++) {
|
||||||
set_channel(sweep->rx, chan);
|
set_channel(sweep->rx, chan);
|
||||||
set_channel(sweep->tx, chan);
|
set_channel(sweep->tx, chan);
|
||||||
usleep(155); /* table 7-2, tTR19 */
|
|
||||||
|
|
||||||
sample(sweep, cont_tx, res, chan == 11 && !sweep->cont_tx);
|
sample(sweep, cont_tx, res, chan == 11 && !sweep->cont_tx);
|
||||||
if (res->avg > sweep->max[i])
|
if (res->avg > sweep->max[i])
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "atrf.h"
|
#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_begin(struct atrf_dsc *dsc, uint8_t cont_tx);
|
||||||
void cw_test_resume(struct atrf_dsc *dsc);
|
void cw_test_resume(struct atrf_dsc *dsc);
|
||||||
void cw_test_end(struct atrf_dsc *dsc);
|
void cw_test_end(struct atrf_dsc *dsc);
|
||||||
|
@ -26,6 +26,16 @@
|
|||||||
static int last_cont_tx; /* @@@ hack for resuming on the 230 */
|
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)
|
static void enter_test_mode_230(struct atrf_dsc *dsc, uint8_t cont_tx)
|
||||||
{
|
{
|
||||||
atrf_buf_write(dsc, "", 1);
|
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);
|
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);
|
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_PART_NUM, 0x46); /*14 */
|
||||||
|
|
||||||
atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_PLL_ON); /*15 */
|
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 */
|
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
|
* AT86RF231 also exits test mode if we send it to sleep for a
|
||||||
* moment.
|
* moment.
|
||||||
*/
|
*/
|
||||||
if (atrf_identify(dsc) == artf_at86rf230 || atrf_usb_handle(dsc))
|
if (cw_test_needs_reset(dsc))
|
||||||
atrf_reset_rf(dsc);
|
atrf_reset_rf(dsc);
|
||||||
else {
|
else {
|
||||||
usleep(2); /* table 7-1: tTR12(typ) = 1 us */
|
usleep(2); /* table 7-1: tTR12(typ) = 1 us */
|
||||||
|
Loading…
Reference in New Issue
Block a user