2010-09-09 23:42:47 +03:00
|
|
|
/*
|
|
|
|
* lib/misctxrx.c - Miscellaenous transceiver helper functions
|
|
|
|
*
|
2011-01-10 00:38:33 +02:00
|
|
|
* Written 2010-2011 by Werner Almesberger
|
|
|
|
* Copyright 2010-2011 Werner Almesberger
|
2010-09-09 23:42:47 +03:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
2010-09-14 23:12:03 +03:00
|
|
|
#include <signal.h>
|
2011-04-12 22:37:05 +03:00
|
|
|
#include <math.h>
|
2010-09-09 23:42:47 +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"
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
#include "timeout.h"
|
2010-09-09 23:42:47 +03:00
|
|
|
#include "misctxrx.h"
|
|
|
|
|
|
|
|
|
2011-06-23 19:17:31 +03:00
|
|
|
#define MIN_TIMEOUT_MS 10
|
|
|
|
|
|
|
|
|
2011-04-12 22:37:05 +03:00
|
|
|
/* ----- Interrupts -------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
static volatile int sigint;
|
2010-09-14 23:12:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
static void die(int sig)
|
|
|
|
{
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
sigint = 1;
|
2010-09-14 23:12:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-20 23:21:40 +03:00
|
|
|
void flush_interrupts(struct atrf_dsc *dsc)
|
|
|
|
{
|
2011-06-21 02:48:15 +03:00
|
|
|
int res;
|
|
|
|
|
|
|
|
res = atrf_interrupt_wait(dsc, 1);
|
|
|
|
if (res < 0) {
|
|
|
|
fprintf(stderr, "atrf_interrupt_wait returns %d\n", res);
|
|
|
|
exit(1);
|
|
|
|
}
|
2011-06-20 23:21:40 +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
|
|
|
uint8_t wait_for_interrupt(struct atrf_dsc *dsc, uint8_t wait_for,
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
uint8_t ignore, int timeout_ms)
|
2010-09-09 23:42:47 +03:00
|
|
|
{
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
struct timeout to;
|
2010-09-14 23:12:03 +03:00
|
|
|
uint8_t irq = 0, show;
|
|
|
|
void (*old_sig)(int);
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
int ms;
|
|
|
|
int timedout = 0;
|
2010-09-09 23:42:47 +03:00
|
|
|
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
sigint = 0;
|
2010-09-14 23:12:03 +03:00
|
|
|
old_sig = signal(SIGINT, die);
|
2011-06-23 19:17:31 +03:00
|
|
|
if (timeout_ms) {
|
|
|
|
if (timeout_ms < MIN_TIMEOUT_MS)
|
|
|
|
timeout_ms = MIN_TIMEOUT_MS;
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
timeout_start(&to, timeout_ms);
|
2011-06-23 19:17:31 +03:00
|
|
|
}
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
while (!sigint && !timedout) {
|
|
|
|
while (!sigint && !timedout) {
|
|
|
|
if (timeout_ms) {
|
|
|
|
ms = timeout_left_ms(&to);
|
2011-06-21 04:56:59 +03:00
|
|
|
if (ms <= 0) {
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
timedout = 1;
|
|
|
|
ms = 1;
|
|
|
|
}
|
|
|
|
} else {
|
2011-06-21 04:56:59 +03:00
|
|
|
ms = 0;
|
2011-01-10 18:52:57 +02:00
|
|
|
}
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
irq = atrf_interrupt_wait(dsc, ms);
|
|
|
|
if (irq)
|
|
|
|
break;
|
2010-09-09 23:42:47 +03:00
|
|
|
}
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +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
|
|
|
if (atrf_error(dsc))
|
2010-09-09 23:42:47 +03:00
|
|
|
exit(1);
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
|
2010-09-09 23:42:47 +03:00
|
|
|
show = irq & ~ignore;
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
if (show) {
|
|
|
|
fprintf(stderr, "IRQ (0x%02x):", irq);
|
|
|
|
if (irq & IRQ_PLL_LOCK)
|
|
|
|
fprintf(stderr, " PLL_LOCK");
|
|
|
|
if (irq & IRQ_PLL_UNLOCK)
|
|
|
|
fprintf(stderr, " PLL_UNLOCK");
|
|
|
|
if (irq & IRQ_RX_START)
|
|
|
|
fprintf(stderr, " RX_START");
|
|
|
|
if (irq & IRQ_TRX_END)
|
|
|
|
fprintf(stderr, " TRX_END");
|
|
|
|
if (irq & IRQ_CCA_ED_DONE)
|
|
|
|
fprintf(stderr, " CCA_ED_DONE");
|
|
|
|
if (irq & IRQ_AMI)
|
|
|
|
fprintf(stderr, " AMI");
|
|
|
|
if (irq & IRQ_TRX_UR)
|
|
|
|
fprintf(stderr, " TRX_UR");
|
|
|
|
if (irq & IRQ_BAT_LOW)
|
|
|
|
fprintf(stderr, " BAT_LOW");
|
|
|
|
fprintf(stderr, "\n");
|
2011-01-19 22:43:01 +02:00
|
|
|
}
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
|
2010-09-09 23:42:47 +03:00
|
|
|
if (irq & wait_for)
|
|
|
|
break;
|
|
|
|
}
|
2011-01-10 18:52:57 +02:00
|
|
|
out:
|
2010-09-14 23:12:03 +03:00
|
|
|
signal(SIGINT, old_sig);
|
tools/: major overhaul of wait_for_interrupt; uses atrf_interrupt_wait now
- include/misctxrx.h (wait_for_interrupt), lib/misctxrx.c
(wait_for_interrupt): replaced sleep_us*timeout limiting mechanism
with a single timeout value in milliseconds
- lib/misctxrx.c (wait_for_interrupt): use atrf_interrupt_wait instead
of polling
- lib/misctxrx.c (wait_for_interrupt): cleaned up control flow
- lib/misctxrx.c (run, die, wait_for_interrupt): renamed variable "run"
to more specific "sigint"
- atrf-txrx/atrf-txrx.c (ping_rx, ping): pass timeout in milliseconds,
not deciseconds
- atrf-rssi/atrf-rssi.c (sweep), atrf-rssi/gui.c (sweep),
atrf-txrx/atrf-txrx.c (init_txrx, receive_message, receive_pcap,
receive, transmit, transmit_pattern, ping_tx, ping_rx),
atrf-xmit/atrf-xmit.c (init_tx, init_rx, xfer_one),
lib/cwtest.c (enter_test_mode_230, start_test_mode_231):
updated use of wait_for_interrupt
2011-06-21 01:58:31 +03:00
|
|
|
if (sigint)
|
2010-09-14 23:12:03 +03:00
|
|
|
raise(SIGINT);
|
2010-09-09 23:42:47 +03:00
|
|
|
return irq;
|
|
|
|
}
|
2011-04-12 22:37:05 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* ----- Transmit power ---------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2011-04-13 00:41:03 +03:00
|
|
|
static const double tx_pwr_230[] = {
|
2011-04-12 22:37:05 +03:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-04-13 00:41:03 +03:00
|
|
|
static const double tx_pwr_231[] = {
|
2011-04-12 22:37:05 +03:00
|
|
|
3.0, 2.8, 2.3, 1.8,
|
|
|
|
1.3, 0.7, 0.0, -1,
|
|
|
|
-2, -3, -4, -5,
|
|
|
|
-7, -9, -12, -17
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-04-13 00:41:03 +03:00
|
|
|
#define POWER_TABLE_SIZE (sizeof(tx_pwr_230)/sizeof(*tx_pwr_230))
|
|
|
|
|
|
|
|
|
2011-04-12 22:37:05 +03:00
|
|
|
void set_power_step(struct atrf_dsc *dsc, int power, int crc)
|
|
|
|
{
|
|
|
|
uint8_t tmp;
|
|
|
|
|
|
|
|
switch (atrf_identify(dsc)) {
|
|
|
|
case artf_at86rf230:
|
|
|
|
atrf_reg_write(dsc, REG_PHY_TX_PWR,
|
|
|
|
(crc ? TX_AUTO_CRC_ON_230 : 0) | power);
|
|
|
|
break;
|
|
|
|
case artf_at86rf231:
|
|
|
|
tmp = atrf_reg_read(dsc, REG_PHY_TX_PWR);
|
|
|
|
tmp = (tmp & ~TX_PWR_MASK) | power;
|
|
|
|
atrf_reg_write(dsc, REG_PHY_TX_PWR, tmp);
|
|
|
|
atrf_reg_write(dsc, REG_TRX_CTRL_1,
|
|
|
|
crc ? TX_AUTO_CRC_ON : 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-13 00:41:03 +03:00
|
|
|
static const double *tx_power_table(struct atrf_dsc *dsc)
|
2011-04-12 22:37:05 +03:00
|
|
|
{
|
|
|
|
switch (atrf_identify(dsc)) {
|
|
|
|
case artf_at86rf230:
|
2011-04-13 00:41:03 +03:00
|
|
|
return tx_pwr_230;
|
2011-04-12 22:37:05 +03:00
|
|
|
case artf_at86rf231:
|
2011-04-13 00:41:03 +03:00
|
|
|
return tx_pwr_231;
|
2011-04-12 22:37:05 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2011-04-13 00:41:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int tx_power_dBm2step(struct atrf_dsc *dsc, double power)
|
|
|
|
{
|
|
|
|
const double *tx_pwr = tx_power_table(dsc);
|
|
|
|
int n;
|
2011-04-12 22:37:05 +03:00
|
|
|
|
2011-04-13 00:41:03 +03:00
|
|
|
for (n = 0; n != POWER_TABLE_SIZE-1; n++)
|
2011-04-12 22:37:05 +03:00
|
|
|
if (tx_pwr[n] <= power)
|
|
|
|
break;
|
2011-04-13 00:41:03 +03:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double tx_power_step2dBm(struct atrf_dsc *dsc, int step)
|
|
|
|
{
|
|
|
|
const double *tx_pwr = tx_power_table(dsc);
|
|
|
|
|
2011-04-13 01:17:43 +03:00
|
|
|
if (step < 0 || step >= POWER_TABLE_SIZE)
|
2011-04-13 00:41:03 +03:00
|
|
|
abort();
|
|
|
|
return tx_pwr[step];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void set_power_dBm(struct atrf_dsc *dsc, double power, int crc)
|
|
|
|
{
|
|
|
|
int step;
|
|
|
|
double got;
|
|
|
|
|
|
|
|
step = tx_power_dBm2step(dsc, power);
|
|
|
|
got = tx_power_step2dBm(dsc, step);
|
|
|
|
|
|
|
|
if (fabs(got-power) > 0.01)
|
|
|
|
fprintf(stderr, "TX power %.1f dBm\n", got);
|
2011-04-12 22:37:05 +03:00
|
|
|
|
2011-04-13 00:41:03 +03:00
|
|
|
set_power_step(dsc, step, crc);
|
2011-04-12 22:37:05 +03:00
|
|
|
}
|