2010-08-21 07:42:58 +03:00
|
|
|
/*
|
2010-11-11 15:24:22 +02:00
|
|
|
* atrf-txrx/atrf-txrx.c - ben-wpan AT86RF230 TX/RX
|
2010-08-21 07:42:58 +03:00
|
|
|
*
|
|
|
|
* Written 2010 by Werner Almesberger
|
|
|
|
* Copyright 2010 Werner Almesberger
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-09-09 23:42:47 +03:00
|
|
|
#include <stdint.h>
|
2010-08-21 07:42:58 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
Merged uSD driver into unified tool build, completed conversion of tools.
- atusd/tools/lib/atusd.c: moved to tools/lib/
- atusd/tools/lib/atusd.h: removed, we can now use tools/include/atspi.h
- tools/lib/atusd.c: added copyright header
- tools/lib/atusd.c: updated for driver API
- tools/lib/Makefile: added atusd.o
- tools/Makefile.common: moved common elements from all other makefiles in
tools/*/ here
- tools/Makefile.common: added target-specific compiler and flags
- tools/atspi-id/Makefile, tools/atspi-reset/Makefile,
tools/atspi-rssi/Makefile, tools/atspi-trim/Makefile,
tools/atspi-txrx/Makefile, tools/lib/Makefile: used Makefile.common
- tools/lib/Makefile: differentiate USB and uSD build
- tools/atspi-id/atspi-id.c, tools/atspi-reset/atspi-reset.c,
tools/atspi-rssi/atspi-rssi.c, tools/atspi-trim/atspi-trim.c,
tools/atspi-txr/atspi-txr.c: updated for driver-agnostic API
- tools/atspi-id/atspi-id.c, tools/atspi-reset/atspi-reset.c,
tools/atspi-rssi/atspi-rssi.c, tools/atspi-trim/atspi-trim.c,
tools/atspi-txr/atspi-txr.c: corrected AF86RF230 typo in title
- tools/include/atspi.h, tools/lib/atspi.c, tools/lib/driver.c,
tools/lib/atusb.c: brought back support for atspi_error and
atspi_clear_error
- tools/atspi-id/atspi-id.c (atspi_get_protocol): renamed to get_protocol,
to make it clear that it's not from libatspi
- tools/atspi-id/atspi-id.c (atspi_get_build): renamed to get_build, to
make it clear that it's not from libatspi
- tools/include/atspi.h, tools/lib/atspi.c (atspi_usb_handle): new function
to obtain a driver's USB device handle (or NULL if the driver doesn't use
USB)
2010-09-06 02:32:58 +03:00
|
|
|
#include <unistd.h>
|
2010-08-24 12:16:48 +03:00
|
|
|
#include <string.h>
|
2010-09-14 23:12:03 +03:00
|
|
|
#include <math.h>
|
|
|
|
#include <signal.h>
|
2010-08-21 07:42:58 +03:00
|
|
|
|
|
|
|
#include "at86rf230.h"
|
The Great ATSPI Renaming, part 4: rename include/atspi.h to include/atrf.h
- include/atspi.h: renamed to include/atrf.h
- include/misctxrx.h, lib/atrf.c, lib/misctxrx.c, atspi-id/atspi-id.c,
atspi-reset/atspi-reset.c, atspi-rssi/atspi-rssi.c, atspi-rssi/gui.c,
atspi-rssi/gui.h, atspi-trim/atspi-trim.c, atspi-txrx/atspi-txrx.c:
change #include "atspi.h" to #include "atrf.h"
2010-11-11 13:58:47 +02:00
|
|
|
#include "atrf.h"
|
2010-09-09 23:42:47 +03:00
|
|
|
#include "misctxrx.h"
|
2010-08-21 07:42:58 +03:00
|
|
|
|
|
|
|
|
2010-08-24 12:16:48 +03:00
|
|
|
/*
|
|
|
|
* According to IEEE 802.15.4-2003 section E.2.6, channel 15 is the only
|
|
|
|
* channel that falls into the 802.11 guard bands in North America an Europe.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEFAULT_CHANNEL 15 /* channel 15, 2425 MHz */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Transmit power, dBm. IEEE 802.15.4-2003 section E.3.1.3 specifies a transmit
|
|
|
|
* power of 0 dBm for IEEE 802.15.4. We assume an antenna gain of 3 dB or
|
|
|
|
* better.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEFAULT_POWER -3.2 /* transmit power, dBm */
|
|
|
|
|
|
|
|
|
|
|
|
static double tx_pwr[] = {
|
|
|
|
3.0, 2.6, 2.1, 1.6,
|
|
|
|
1.1, 0.5, -0.2, -1.2,
|
|
|
|
-2.2, -3.2, -4.2, -5.2,
|
|
|
|
-7.2, -9.2, -12.2, -17.2
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-09-14 23:12:03 +03:00
|
|
|
static volatile int run = 1;
|
|
|
|
|
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
static struct atrf_dsc *init_txrx(int trim)
|
2010-08-24 12:16:48 +03:00
|
|
|
{
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
struct atrf_dsc *dsc;
|
2010-08-24 12:16:48 +03:00
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
dsc = atrf_open();
|
Merged uSD driver into unified tool build, completed conversion of tools.
- atusd/tools/lib/atusd.c: moved to tools/lib/
- atusd/tools/lib/atusd.h: removed, we can now use tools/include/atspi.h
- tools/lib/atusd.c: added copyright header
- tools/lib/atusd.c: updated for driver API
- tools/lib/Makefile: added atusd.o
- tools/Makefile.common: moved common elements from all other makefiles in
tools/*/ here
- tools/Makefile.common: added target-specific compiler and flags
- tools/atspi-id/Makefile, tools/atspi-reset/Makefile,
tools/atspi-rssi/Makefile, tools/atspi-trim/Makefile,
tools/atspi-txrx/Makefile, tools/lib/Makefile: used Makefile.common
- tools/lib/Makefile: differentiate USB and uSD build
- tools/atspi-id/atspi-id.c, tools/atspi-reset/atspi-reset.c,
tools/atspi-rssi/atspi-rssi.c, tools/atspi-trim/atspi-trim.c,
tools/atspi-txr/atspi-txr.c: updated for driver-agnostic API
- tools/atspi-id/atspi-id.c, tools/atspi-reset/atspi-reset.c,
tools/atspi-rssi/atspi-rssi.c, tools/atspi-trim/atspi-trim.c,
tools/atspi-txr/atspi-txr.c: corrected AF86RF230 typo in title
- tools/include/atspi.h, tools/lib/atspi.c, tools/lib/driver.c,
tools/lib/atusb.c: brought back support for atspi_error and
atspi_clear_error
- tools/atspi-id/atspi-id.c (atspi_get_protocol): renamed to get_protocol,
to make it clear that it's not from libatspi
- tools/atspi-id/atspi-id.c (atspi_get_build): renamed to get_build, to
make it clear that it's not from libatspi
- tools/include/atspi.h, tools/lib/atspi.c (atspi_usb_handle): new function
to obtain a driver's USB device handle (or NULL if the driver doesn't use
USB)
2010-09-06 02:32:58 +03:00
|
|
|
if (!dsc)
|
2010-08-24 12:16:48 +03:00
|
|
|
exit(1);
|
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_reset_rf(dsc);
|
|
|
|
atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TRX_OFF);
|
Updated atusd driver for new hardware. Make use of the interrupt line.
- tools/lib/atusd.c (spi_send_partial, spi_send): removed the old spi_send
and renamed spi_send_partial to spi_send
- tools/lib/atusd.c (atusd_cycle, spi_send, spi_recv, atusd_open): updated
for removal of SLP_TR and split of MxSx into MOSI and MISO
- tools/lib/atusd.c (atusd_reset_rf, atusd_open): added delays to precharge
the capacitors
- tools/lib/atusd.c (atusd_reset, spi_data_in, spi_data_out, spi_finish):
removed functions for obsolete hardware features
- tools/lib/atusd.c (atusd_reg_read): removed calls to removed functions
- tools/lib/atusd.c (atusd_buf_write, atusd_buf_read, atusd_driver): new
buffer read/write functions
- tools/atspi-txrx/atspi-txrx.c (init_txrx): set the internal osciallator
trim only in the USB version. Switch to the external oscillator in the
uSD version.
- tools/atspi-rssi/atspi-rssi.c (sweep), tools/atspi-txrx/atspi-txrx.c
(set_channel): wait for the PLL to settle after setting the channel
- tools/include/atspi.h, tools/lib/atspi.c (atspi_interrupt),
tools/lib/driver.h (struct atspi_driver), tools/lib/atusd.c
(atusd_interrupt): new function to poll the interrupt line
- tools/atspi-txrx/atspi-txrx.c (receive): only read REG_IRQ_STATUS if
there is a pending interrupt
- tools/atspi-id/atspi-id.c (usage): print "usage:" as well
- tools/Makefile (upload): upload the atspi tools to the Ben
2010-09-09 15:19:06 +03:00
|
|
|
#ifdef HAVE_USB /* @@@ yeah, ugly */
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_reg_write(dsc, REG_XOSC_CTRL,
|
2010-08-24 12:16:48 +03:00
|
|
|
(XTAL_MODE_INT << XTAL_MODE_SHIFT) | trim);
|
Updated atusd driver for new hardware. Make use of the interrupt line.
- tools/lib/atusd.c (spi_send_partial, spi_send): removed the old spi_send
and renamed spi_send_partial to spi_send
- tools/lib/atusd.c (atusd_cycle, spi_send, spi_recv, atusd_open): updated
for removal of SLP_TR and split of MxSx into MOSI and MISO
- tools/lib/atusd.c (atusd_reset_rf, atusd_open): added delays to precharge
the capacitors
- tools/lib/atusd.c (atusd_reset, spi_data_in, spi_data_out, spi_finish):
removed functions for obsolete hardware features
- tools/lib/atusd.c (atusd_reg_read): removed calls to removed functions
- tools/lib/atusd.c (atusd_buf_write, atusd_buf_read, atusd_driver): new
buffer read/write functions
- tools/atspi-txrx/atspi-txrx.c (init_txrx): set the internal osciallator
trim only in the USB version. Switch to the external oscillator in the
uSD version.
- tools/atspi-rssi/atspi-rssi.c (sweep), tools/atspi-txrx/atspi-txrx.c
(set_channel): wait for the PLL to settle after setting the channel
- tools/include/atspi.h, tools/lib/atspi.c (atspi_interrupt),
tools/lib/driver.h (struct atspi_driver), tools/lib/atusd.c
(atusd_interrupt): new function to poll the interrupt line
- tools/atspi-txrx/atspi-txrx.c (receive): only read REG_IRQ_STATUS if
there is a pending interrupt
- tools/atspi-id/atspi-id.c (usage): print "usage:" as well
- tools/Makefile (upload): upload the atspi tools to the Ben
2010-09-09 15:19:06 +03:00
|
|
|
#else
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_reg_write(dsc, REG_XOSC_CTRL, XTAL_MODE_EXT << XTAL_MODE_SHIFT);
|
Updated atusd driver for new hardware. Make use of the interrupt line.
- tools/lib/atusd.c (spi_send_partial, spi_send): removed the old spi_send
and renamed spi_send_partial to spi_send
- tools/lib/atusd.c (atusd_cycle, spi_send, spi_recv, atusd_open): updated
for removal of SLP_TR and split of MxSx into MOSI and MISO
- tools/lib/atusd.c (atusd_reset_rf, atusd_open): added delays to precharge
the capacitors
- tools/lib/atusd.c (atusd_reset, spi_data_in, spi_data_out, spi_finish):
removed functions for obsolete hardware features
- tools/lib/atusd.c (atusd_reg_read): removed calls to removed functions
- tools/lib/atusd.c (atusd_buf_write, atusd_buf_read, atusd_driver): new
buffer read/write functions
- tools/atspi-txrx/atspi-txrx.c (init_txrx): set the internal osciallator
trim only in the USB version. Switch to the external oscillator in the
uSD version.
- tools/atspi-rssi/atspi-rssi.c (sweep), tools/atspi-txrx/atspi-txrx.c
(set_channel): wait for the PLL to settle after setting the channel
- tools/include/atspi.h, tools/lib/atspi.c (atspi_interrupt),
tools/lib/driver.h (struct atspi_driver), tools/lib/atusd.c
(atusd_interrupt): new function to poll the interrupt line
- tools/atspi-txrx/atspi-txrx.c (receive): only read REG_IRQ_STATUS if
there is a pending interrupt
- tools/atspi-id/atspi-id.c (usage): print "usage:" as well
- tools/Makefile (upload): upload the atspi tools to the Ben
2010-09-09 15:19:06 +03:00
|
|
|
#endif
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_reg_write(dsc, REG_TRX_CTRL_0, 0); /* disable CLKM */
|
2010-08-24 12:16:48 +03:00
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
(void) atrf_reg_read(dsc, REG_IRQ_STATUS);
|
2010-09-09 23:23:47 +03:00
|
|
|
|
Merged uSD driver into unified tool build, completed conversion of tools.
- atusd/tools/lib/atusd.c: moved to tools/lib/
- atusd/tools/lib/atusd.h: removed, we can now use tools/include/atspi.h
- tools/lib/atusd.c: added copyright header
- tools/lib/atusd.c: updated for driver API
- tools/lib/Makefile: added atusd.o
- tools/Makefile.common: moved common elements from all other makefiles in
tools/*/ here
- tools/Makefile.common: added target-specific compiler and flags
- tools/atspi-id/Makefile, tools/atspi-reset/Makefile,
tools/atspi-rssi/Makefile, tools/atspi-trim/Makefile,
tools/atspi-txrx/Makefile, tools/lib/Makefile: used Makefile.common
- tools/lib/Makefile: differentiate USB and uSD build
- tools/atspi-id/atspi-id.c, tools/atspi-reset/atspi-reset.c,
tools/atspi-rssi/atspi-rssi.c, tools/atspi-trim/atspi-trim.c,
tools/atspi-txr/atspi-txr.c: updated for driver-agnostic API
- tools/atspi-id/atspi-id.c, tools/atspi-reset/atspi-reset.c,
tools/atspi-rssi/atspi-rssi.c, tools/atspi-trim/atspi-trim.c,
tools/atspi-txr/atspi-txr.c: corrected AF86RF230 typo in title
- tools/include/atspi.h, tools/lib/atspi.c, tools/lib/driver.c,
tools/lib/atusb.c: brought back support for atspi_error and
atspi_clear_error
- tools/atspi-id/atspi-id.c (atspi_get_protocol): renamed to get_protocol,
to make it clear that it's not from libatspi
- tools/atspi-id/atspi-id.c (atspi_get_build): renamed to get_build, to
make it clear that it's not from libatspi
- tools/include/atspi.h, tools/lib/atspi.c (atspi_usb_handle): new function
to obtain a driver's USB device handle (or NULL if the driver doesn't use
USB)
2010-09-06 02:32:58 +03:00
|
|
|
return dsc;
|
2010-08-24 12:16:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
static void set_channel(struct atrf_dsc *dsc, int channel)
|
2010-08-24 12:16:48 +03:00
|
|
|
{
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_reg_write(dsc, REG_PHY_CC_CCA, (1 << CCA_MODE_SHIFT) | channel);
|
2010-08-24 12:16:48 +03:00
|
|
|
}
|
2010-08-21 07:42:58 +03:00
|
|
|
|
2010-08-24 12:16:48 +03:00
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
static void set_power(struct atrf_dsc *dsc, double power, int crc)
|
2010-08-24 12:16:48 +03:00
|
|
|
{
|
|
|
|
int n;
|
|
|
|
|
2010-08-24 13:17:42 +03:00
|
|
|
for (n = 0; n != sizeof(tx_pwr)/sizeof(*tx_pwr)-1; n++)
|
2010-08-24 12:16:48 +03:00
|
|
|
if (tx_pwr[n] <= power)
|
|
|
|
break;
|
2010-09-14 23:12:03 +03:00
|
|
|
if (fabs(tx_pwr[n]-power) > 0.01)
|
|
|
|
fprintf(stderr, "TX power %.1f dBm\n", tx_pwr[n]);
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_reg_write(dsc, REG_PHY_TX_PWR, (crc ? TX_AUTO_CRC_ON : 0) | n);
|
2010-08-24 12:16:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
static void receive(struct atrf_dsc *dsc)
|
2010-08-24 12:16:48 +03:00
|
|
|
{
|
2010-08-25 03:03:39 +03:00
|
|
|
uint8_t buf[MAX_PSDU+1]; /* PSDU+LQI */
|
2010-08-24 12:16:48 +03:00
|
|
|
int n, ok, i;
|
2010-09-09 23:23:47 +03:00
|
|
|
uint8_t ed, lqi;
|
2010-08-24 12:16:48 +03:00
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_RX_ON);
|
2010-09-09 23:23:47 +03:00
|
|
|
/*
|
|
|
|
* 180 us, according to AVR2001 section 4.2. We time out after
|
|
|
|
* nominally 200 us.
|
|
|
|
*/
|
|
|
|
wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 20);
|
2010-08-24 12:16:48 +03:00
|
|
|
|
|
|
|
fprintf(stderr, "Ready.\n");
|
2010-09-09 23:23:47 +03:00
|
|
|
wait_for_interrupt(dsc, IRQ_TRX_END, IRQ_TRX_END | IRQ_RX_START,
|
|
|
|
10, 0);
|
2010-09-14 23:12:03 +03:00
|
|
|
if (!run)
|
|
|
|
return;
|
2010-08-24 12:16:48 +03:00
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
n = atrf_buf_read(dsc, buf, sizeof(buf));
|
2010-08-24 12:16:48 +03:00
|
|
|
if (n < 0)
|
|
|
|
exit(1);
|
|
|
|
if (n < 3) {
|
|
|
|
fprintf(stderr, "%d bytes received\n", n);
|
|
|
|
exit(1);
|
|
|
|
}
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
ed = atrf_reg_read(dsc, REG_PHY_ED_LEVEL);
|
|
|
|
ok = !!(atrf_reg_read(dsc, REG_PHY_RSSI) & RX_CRC_VALID);
|
2010-09-09 23:23:47 +03:00
|
|
|
lqi = buf[n-1];
|
|
|
|
fprintf(stderr, "%d bytes payload, CRC %s, LQI %u, ED %d dBm\n",
|
|
|
|
n-3, ok ? "OK" : "BAD", lqi, -91+ed);
|
2010-08-24 12:16:48 +03:00
|
|
|
for (i = 0; i != n-3; i++)
|
|
|
|
putchar(buf[i] < ' ' || buf[i] > '~' ? '?' : buf[i]);
|
|
|
|
putchar('\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
static void transmit(struct atrf_dsc *dsc, const char *msg, int times)
|
2010-08-24 12:16:48 +03:00
|
|
|
{
|
|
|
|
uint8_t buf[MAX_PSDU];
|
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_PLL_ON);
|
2010-09-09 23:23:47 +03:00
|
|
|
/*
|
|
|
|
* 180 us, according to AVR2001 section 4.3. We time out after
|
|
|
|
* nominally 200 us.
|
|
|
|
*/
|
|
|
|
wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 20);
|
2010-08-24 12:16:48 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We need to copy the message to append the CRC placeholders.
|
|
|
|
*/
|
|
|
|
strcpy((void *) buf, msg);
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_buf_write(dsc, buf, strlen(msg)+2);
|
2010-08-24 12:16:48 +03:00
|
|
|
|
2010-09-14 23:12:03 +03:00
|
|
|
while (run && times--) {
|
|
|
|
/* @@@ should wait for clear channel */
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TX_START);
|
2010-09-09 23:23:47 +03:00
|
|
|
|
2010-09-14 23:12:03 +03:00
|
|
|
/* wait up to 10 ms (nominally) */
|
|
|
|
wait_for_interrupt(dsc, IRQ_TRX_END,
|
|
|
|
IRQ_TRX_END | IRQ_PLL_LOCK, 10, 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
static void test_mode(struct atrf_dsc *dsc, uint8_t cont_tx)
|
2010-11-11 07:32:09 +02:00
|
|
|
{
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_buf_write(dsc, "", 1);
|
|
|
|
atrf_reg_write(dsc, REG_CONT_TX_0, CONT_TX_MAGIC);
|
|
|
|
atrf_reg_write(dsc, REG_CONT_TX_1, cont_tx);
|
2010-11-11 07:32:09 +02:00
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
if (!atrf_test_mode(dsc)) {
|
|
|
|
atrf_reset_rf(dsc);
|
2010-11-11 07:32:09 +02:00
|
|
|
fprintf(stderr, "device does not support test mode\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_PLL_ON);
|
2010-11-11 07:32:09 +02:00
|
|
|
wait_for_interrupt(dsc, IRQ_PLL_LOCK, IRQ_PLL_LOCK, 10, 20);
|
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_reg_write(dsc, REG_TRX_STATE, TRX_CMD_TX_START);
|
2010-11-11 07:32:09 +02:00
|
|
|
|
|
|
|
while (run)
|
|
|
|
sleep(1);
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_reset_rf(dsc);
|
2010-11-11 07:32:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-14 23:12:03 +03:00
|
|
|
static void die(int sig)
|
|
|
|
{
|
|
|
|
run = 0;
|
2010-08-24 12:16:48 +03:00
|
|
|
}
|
2010-08-21 07:42:58 +03:00
|
|
|
|
|
|
|
|
|
|
|
static void usage(const char *name)
|
|
|
|
{
|
2010-08-24 12:16:48 +03:00
|
|
|
fprintf(stderr,
|
2010-11-11 07:44:33 +02:00
|
|
|
"usage: %s [-c channel|-f freq] [-p power] [-t trim] [message [repetitions]]\n"
|
|
|
|
" %s [-c channel|-f freq] [-p power] [-t trim] -T delta\n"
|
2010-11-11 07:32:09 +02:00
|
|
|
" -c channel channel number, 11 to 26 (default %d)\n"
|
2010-11-11 07:44:33 +02:00
|
|
|
" -f freq frequency in MHz, 2405 to 2480 (default %d)\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"
|
|
|
|
" -T delta test mode. delta is the frequency offset of the constant wave\n"
|
|
|
|
" in MHz: -2, -0.5, or +0.5\n"
|
|
|
|
, name, name, DEFAULT_CHANNEL, 2405+5*(DEFAULT_CHANNEL-11),
|
|
|
|
DEFAULT_POWER);
|
2010-08-21 07:42:58 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-24 12:16:48 +03:00
|
|
|
int main(int argc, char *const *argv)
|
2010-08-21 07:42:58 +03:00
|
|
|
{
|
2010-08-24 12:16:48 +03:00
|
|
|
int channel = DEFAULT_CHANNEL;
|
|
|
|
double power = DEFAULT_POWER;
|
2010-09-14 23:12:03 +03:00
|
|
|
int trim = 0, times = 1;
|
2010-11-11 07:32:09 +02:00
|
|
|
uint8_t cont_tx = 0;
|
2010-08-24 12:16:48 +03:00
|
|
|
char *end;
|
2010-11-11 07:44:33 +02:00
|
|
|
int c, freq;
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
struct atrf_dsc *dsc;
|
2010-08-21 07:42:58 +03:00
|
|
|
|
2010-11-11 07:44:33 +02:00
|
|
|
while ((c = getopt(argc, argv, "c:f:p:t:T:")) != EOF)
|
2010-08-24 12:16:48 +03:00
|
|
|
switch (c) {
|
|
|
|
case 'c':
|
|
|
|
channel = strtoul(optarg, &end, 0);
|
|
|
|
if (*end)
|
|
|
|
usage(*argv);
|
|
|
|
if (channel < 11 || channel > 26)
|
|
|
|
usage(*argv);
|
|
|
|
break;
|
2010-11-11 07:44:33 +02:00
|
|
|
case 'f':
|
|
|
|
freq = strtoul(optarg, &end, 0);
|
|
|
|
if (*end)
|
|
|
|
usage(*argv);
|
|
|
|
if (freq % 5)
|
|
|
|
usage(*argv);
|
|
|
|
channel = (freq-2405)/5+11;
|
|
|
|
if (channel < 11 || channel > 26)
|
|
|
|
usage(*argv);
|
|
|
|
break;
|
2010-08-24 12:16:48 +03:00
|
|
|
case 'p':
|
|
|
|
power = strtod(optarg, &end);
|
|
|
|
if (*end)
|
|
|
|
usage(*argv);
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
trim = strtoul(optarg, &end, 0);
|
|
|
|
if (*end)
|
|
|
|
usage(*argv);
|
|
|
|
if (trim > 15)
|
|
|
|
usage(*argv);
|
|
|
|
break;
|
2010-11-11 07:32:09 +02:00
|
|
|
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;
|
2010-08-24 12:16:48 +03:00
|
|
|
default:
|
|
|
|
usage(*argv);
|
|
|
|
}
|
2010-08-21 07:42:58 +03:00
|
|
|
|
2010-09-14 23:12:03 +03:00
|
|
|
signal(SIGINT, die);
|
|
|
|
|
2010-08-24 12:16:48 +03:00
|
|
|
switch (argc-optind) {
|
|
|
|
case 0:
|
Merged uSD driver into unified tool build, completed conversion of tools.
- atusd/tools/lib/atusd.c: moved to tools/lib/
- atusd/tools/lib/atusd.h: removed, we can now use tools/include/atspi.h
- tools/lib/atusd.c: added copyright header
- tools/lib/atusd.c: updated for driver API
- tools/lib/Makefile: added atusd.o
- tools/Makefile.common: moved common elements from all other makefiles in
tools/*/ here
- tools/Makefile.common: added target-specific compiler and flags
- tools/atspi-id/Makefile, tools/atspi-reset/Makefile,
tools/atspi-rssi/Makefile, tools/atspi-trim/Makefile,
tools/atspi-txrx/Makefile, tools/lib/Makefile: used Makefile.common
- tools/lib/Makefile: differentiate USB and uSD build
- tools/atspi-id/atspi-id.c, tools/atspi-reset/atspi-reset.c,
tools/atspi-rssi/atspi-rssi.c, tools/atspi-trim/atspi-trim.c,
tools/atspi-txr/atspi-txr.c: updated for driver-agnostic API
- tools/atspi-id/atspi-id.c, tools/atspi-reset/atspi-reset.c,
tools/atspi-rssi/atspi-rssi.c, tools/atspi-trim/atspi-trim.c,
tools/atspi-txr/atspi-txr.c: corrected AF86RF230 typo in title
- tools/include/atspi.h, tools/lib/atspi.c, tools/lib/driver.c,
tools/lib/atusb.c: brought back support for atspi_error and
atspi_clear_error
- tools/atspi-id/atspi-id.c (atspi_get_protocol): renamed to get_protocol,
to make it clear that it's not from libatspi
- tools/atspi-id/atspi-id.c (atspi_get_build): renamed to get_build, to
make it clear that it's not from libatspi
- tools/include/atspi.h, tools/lib/atspi.c (atspi_usb_handle): new function
to obtain a driver's USB device handle (or NULL if the driver doesn't use
USB)
2010-09-06 02:32:58 +03:00
|
|
|
dsc = init_txrx(trim);
|
|
|
|
set_channel(dsc, channel);
|
2010-11-11 07:32:09 +02:00
|
|
|
if (!cont_tx)
|
|
|
|
receive(dsc);
|
|
|
|
else {
|
|
|
|
set_power(dsc, power, 0);
|
|
|
|
test_mode(dsc, cont_tx);
|
|
|
|
}
|
2010-08-24 12:16:48 +03:00
|
|
|
break;
|
2010-09-14 23:12:03 +03:00
|
|
|
case 2:
|
|
|
|
times = strtoul(argv[optind+1], &end, 0);
|
|
|
|
if (*end)
|
|
|
|
usage(*argv);
|
|
|
|
/* fall through */
|
2010-08-24 12:16:48 +03:00
|
|
|
case 1:
|
2010-11-11 07:32:09 +02:00
|
|
|
if (cont_tx)
|
|
|
|
usage(*argv);
|
Merged uSD driver into unified tool build, completed conversion of tools.
- atusd/tools/lib/atusd.c: moved to tools/lib/
- atusd/tools/lib/atusd.h: removed, we can now use tools/include/atspi.h
- tools/lib/atusd.c: added copyright header
- tools/lib/atusd.c: updated for driver API
- tools/lib/Makefile: added atusd.o
- tools/Makefile.common: moved common elements from all other makefiles in
tools/*/ here
- tools/Makefile.common: added target-specific compiler and flags
- tools/atspi-id/Makefile, tools/atspi-reset/Makefile,
tools/atspi-rssi/Makefile, tools/atspi-trim/Makefile,
tools/atspi-txrx/Makefile, tools/lib/Makefile: used Makefile.common
- tools/lib/Makefile: differentiate USB and uSD build
- tools/atspi-id/atspi-id.c, tools/atspi-reset/atspi-reset.c,
tools/atspi-rssi/atspi-rssi.c, tools/atspi-trim/atspi-trim.c,
tools/atspi-txr/atspi-txr.c: updated for driver-agnostic API
- tools/atspi-id/atspi-id.c, tools/atspi-reset/atspi-reset.c,
tools/atspi-rssi/atspi-rssi.c, tools/atspi-trim/atspi-trim.c,
tools/atspi-txr/atspi-txr.c: corrected AF86RF230 typo in title
- tools/include/atspi.h, tools/lib/atspi.c, tools/lib/driver.c,
tools/lib/atusb.c: brought back support for atspi_error and
atspi_clear_error
- tools/atspi-id/atspi-id.c (atspi_get_protocol): renamed to get_protocol,
to make it clear that it's not from libatspi
- tools/atspi-id/atspi-id.c (atspi_get_build): renamed to get_build, to
make it clear that it's not from libatspi
- tools/include/atspi.h, tools/lib/atspi.c (atspi_usb_handle): new function
to obtain a driver's USB device handle (or NULL if the driver doesn't use
USB)
2010-09-06 02:32:58 +03:00
|
|
|
dsc = init_txrx(trim);
|
|
|
|
set_channel(dsc, channel);
|
2010-11-11 07:32:09 +02:00
|
|
|
set_power(dsc, power, 1);
|
2010-09-14 23:12:03 +03:00
|
|
|
transmit(dsc, argv[optind], times);
|
2010-08-24 12:16:48 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage(*argv);
|
|
|
|
}
|
2010-08-21 07:42:58 +03:00
|
|
|
|
The Great ATSPI Renaming, part 6: change atrf API from atspi_* to atrf_*
- include/atrf.h, lib/atrf.c (struct atspi_dsc): renamed to "struct
atrf_dsc"
- include/atrf.h, lib/atrf.c (atspi_*): renamed all functions to atrf_*
- include/misctxrx.h, lib/misctxrx.c (wait_for_interrupt): updated for API
name change
- atspi-id/atspi-id.c (show_usb_info, show_info, main),
atspi-reset/atspi-reset.c (main), atspi-rssi/atspi-rssi.c (sweep, main),
atspi-rssi/gui.h (gui), atspi-rssi/gui.c (sweep, gui),
atspi-trim/atspi-trim.c (main), atspi-txrx/atspi-txrx.c (init_txrx,
set_channel, set_power, receive, transmit, test_mode, main):
updated for API name change
2010-11-11 15:10:13 +02:00
|
|
|
atrf_close(dsc);
|
2010-09-09 23:23:47 +03:00
|
|
|
|
2010-08-21 07:42:58 +03:00
|
|
|
return 0;
|
|
|
|
}
|