2010-09-09 23:42:47 +03:00
|
|
|
/*
|
|
|
|
* lib/misctxrx.c - Miscellaenous transceiver helper functions
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
2010-09-14 23:12:03 +03:00
|
|
|
#include <signal.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"
|
2010-09-09 23:42:47 +03:00
|
|
|
#include "misctxrx.h"
|
|
|
|
|
|
|
|
|
2010-09-14 23:12:03 +03:00
|
|
|
static volatile int run = 1;
|
|
|
|
|
|
|
|
|
|
|
|
static void die(int sig)
|
|
|
|
{
|
|
|
|
run = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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,
|
2010-09-09 23:42:47 +03:00
|
|
|
uint8_t ignore, int sleep_us, int timeout)
|
|
|
|
{
|
2010-09-14 23:12:03 +03:00
|
|
|
uint8_t irq = 0, show;
|
|
|
|
void (*old_sig)(int);
|
2010-09-09 23:42:47 +03:00
|
|
|
|
2010-09-14 23:12:03 +03:00
|
|
|
run = 1;
|
|
|
|
old_sig = signal(SIGINT, die);
|
|
|
|
while (run) {
|
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
|
|
|
while (run && !atrf_interrupt(dsc)) {
|
2010-09-09 23:42:47 +03:00
|
|
|
usleep(sleep_us);
|
|
|
|
if (timeout && !--timeout)
|
|
|
|
return 0;
|
|
|
|
}
|
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
|
|
|
irq = atrf_reg_read(dsc, REG_IRQ_STATUS);
|
|
|
|
if (atrf_error(dsc))
|
2010-09-09 23:42:47 +03:00
|
|
|
exit(1);
|
|
|
|
if (!irq)
|
|
|
|
continue;
|
|
|
|
show = irq & ~ignore;
|
|
|
|
if ((irq & wait_for) && !show)
|
|
|
|
break;
|
|
|
|
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_TRX_UR)
|
|
|
|
fprintf(stderr, " TRX_UR");
|
|
|
|
if (irq & IRQ_BAT_LOW)
|
|
|
|
fprintf(stderr, " BAT_LOW");
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
if (irq & wait_for)
|
|
|
|
break;
|
|
|
|
}
|
2010-09-14 23:12:03 +03:00
|
|
|
signal(SIGINT, old_sig);
|
|
|
|
if (!run)
|
|
|
|
raise(SIGINT);
|
2010-09-09 23:42:47 +03:00
|
|
|
return irq;
|
|
|
|
}
|