mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-26 11:50:36 +02:00
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
This commit is contained in:
parent
5d63a009c8
commit
d4fe0277c2
@ -81,7 +81,7 @@ static void set_channel(struct atspi_dsc *dsc, int channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void set_power(struct atspi_dsc *dsc, double power)
|
static void set_power(struct atspi_dsc *dsc, double power, int crc)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ static void set_power(struct atspi_dsc *dsc, double power)
|
|||||||
break;
|
break;
|
||||||
if (fabs(tx_pwr[n]-power) > 0.01)
|
if (fabs(tx_pwr[n]-power) > 0.01)
|
||||||
fprintf(stderr, "TX power %.1f dBm\n", tx_pwr[n]);
|
fprintf(stderr, "TX power %.1f dBm\n", tx_pwr[n]);
|
||||||
atspi_reg_write(dsc, REG_PHY_TX_PWR, TX_AUTO_CRC_ON | n);
|
atspi_reg_write(dsc, REG_PHY_TX_PWR, (crc ? TX_AUTO_CRC_ON : 0) | n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -159,6 +159,29 @@ static void transmit(struct atspi_dsc *dsc, const char *msg, int times)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void test_mode(struct atspi_dsc *dsc, uint8_t cont_tx)
|
||||||
|
{
|
||||||
|
atspi_buf_write(dsc, "", 1);
|
||||||
|
atspi_reg_write(dsc, REG_CONT_TX_0, CONT_TX_MAGIC);
|
||||||
|
atspi_reg_write(dsc, REG_CONT_TX_1, cont_tx);
|
||||||
|
|
||||||
|
if (!atspi_test_mode(dsc)) {
|
||||||
|
atspi_reset_rf(dsc);
|
||||||
|
fprintf(stderr, "device does not support test mode\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
atspi_reg_write(dsc, REG_TRX_STATE, TRX_CMD_PLL_ON);
|
||||||
|
wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 20);
|
||||||
|
|
||||||
|
atspi_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TX_START);
|
||||||
|
|
||||||
|
while (run)
|
||||||
|
sleep(1);
|
||||||
|
atspi_reset_rf(dsc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void die(int sig)
|
static void die(int sig)
|
||||||
{
|
{
|
||||||
run = 0;
|
run = 0;
|
||||||
@ -169,10 +192,13 @@ static void usage(const char *name)
|
|||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s [-c channel] [-p power] [-t trim] [message [repetitions]]\n"
|
"usage: %s [-c channel] [-p power] [-t trim] [message [repetitions]]\n"
|
||||||
|
" %s [-c channel] [-p power] [-t trim] -T delta\n"
|
||||||
" -c channel channel number, 11 to 26 (default %d)\n"
|
" -c channel channel number, 11 to 26 (default %d)\n"
|
||||||
" -p power transmit power, -17.2 to 3.0 dBm (default %.1f)\n"
|
" -p power transmit power, -17.2 to 3.0 dBm (default %.1f)\n"
|
||||||
" -t trim trim capacitor, 0 to 15 (default 0)\n"
|
" -t trim trim capacitor, 0 to 15 (default 0)\n"
|
||||||
, name , DEFAULT_CHANNEL, DEFAULT_POWER);
|
" -t trim trim capacitor, 0 to 15 (default 0)\n"
|
||||||
|
" -T delta_MHz test mode. delta_MHz is -2, -0.5, or +0.5\n"
|
||||||
|
, name, name, DEFAULT_CHANNEL, DEFAULT_POWER);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,11 +208,12 @@ int main(int argc, char *const *argv)
|
|||||||
int channel = DEFAULT_CHANNEL;
|
int channel = DEFAULT_CHANNEL;
|
||||||
double power = DEFAULT_POWER;
|
double power = DEFAULT_POWER;
|
||||||
int trim = 0, times = 1;
|
int trim = 0, times = 1;
|
||||||
|
uint8_t cont_tx = 0;
|
||||||
char *end;
|
char *end;
|
||||||
int c;
|
int c;
|
||||||
struct atspi_dsc *dsc;
|
struct atspi_dsc *dsc;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "c:p:t:")) != EOF)
|
while ((c = getopt(argc, argv, "c:p:t:T:")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
channel = strtoul(optarg, &end, 0);
|
channel = strtoul(optarg, &end, 0);
|
||||||
@ -207,6 +234,16 @@ int main(int argc, char *const *argv)
|
|||||||
if (trim > 15)
|
if (trim > 15)
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
break;
|
break;
|
||||||
|
case 'T':
|
||||||
|
if (!strcmp(optarg, "-2"))
|
||||||
|
cont_tx = CONT_TX_M2M;
|
||||||
|
else if (!strcmp(optarg, "-0.5"))
|
||||||
|
cont_tx = CONT_TX_M500K;
|
||||||
|
else if (!strcmp(optarg, "+0.5"))
|
||||||
|
cont_tx = CONT_TX_P500K;
|
||||||
|
else
|
||||||
|
usage(*argv);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
}
|
}
|
||||||
@ -217,7 +254,12 @@ int main(int argc, char *const *argv)
|
|||||||
case 0:
|
case 0:
|
||||||
dsc = init_txrx(trim);
|
dsc = init_txrx(trim);
|
||||||
set_channel(dsc, channel);
|
set_channel(dsc, channel);
|
||||||
|
if (!cont_tx)
|
||||||
receive(dsc);
|
receive(dsc);
|
||||||
|
else {
|
||||||
|
set_power(dsc, power, 0);
|
||||||
|
test_mode(dsc, cont_tx);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
times = strtoul(argv[optind+1], &end, 0);
|
times = strtoul(argv[optind+1], &end, 0);
|
||||||
@ -225,9 +267,11 @@ int main(int argc, char *const *argv)
|
|||||||
usage(*argv);
|
usage(*argv);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 1:
|
case 1:
|
||||||
|
if (cont_tx)
|
||||||
|
usage(*argv);
|
||||||
dsc = init_txrx(trim);
|
dsc = init_txrx(trim);
|
||||||
set_channel(dsc, channel);
|
set_channel(dsc, channel);
|
||||||
set_power(dsc, power);
|
set_power(dsc, power, 1);
|
||||||
transmit(dsc, argv[optind], times);
|
transmit(dsc, argv[optind], times);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user