mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2025-04-21 12:27:27 +03:00
atrf-xtal: added atusb support (via ATUSB_TIMER)
- Makefile: removed limitation to Ben and added host build - atusb.c: atusb-specific acquisition and calculations - atrf-xtal.h (do_atusb): interface to atusb.c - atrf-xtal.c (atben, atusb, main): added switch to board-specific driver - atrf-xtal.c (usage, main): added support for atusb
This commit is contained in:
@@ -23,22 +23,52 @@
|
||||
|
||||
#define DEFAULT_SIZE 127
|
||||
#define DEFAULT_TRIM 8
|
||||
#define DEFAULT_SAMPLES 1000
|
||||
|
||||
|
||||
static void atben(struct atrf_dsc *dsc, int size, int trim, int rep,
|
||||
int dump_raw, double base, double ppm)
|
||||
{
|
||||
#ifdef HAVE_ATBEN
|
||||
do_atben(dsc, size, trim, rep, dump_raw, base, ppm);
|
||||
#else
|
||||
fprintf(stderr, "not compiled with ATBEN support\n");
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void atusb(struct atrf_dsc *dsc, int trim, int dump_raw, double ppm,
|
||||
int sequence)
|
||||
{
|
||||
#ifdef HAVE_ATUSB
|
||||
do_atusb(dsc, trim, dump_raw, ppm, sequence);
|
||||
#else
|
||||
fprintf(stderr, "not compiled with ATUSB support\n");
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [-b count [-p ppm]] [-d driver[:arg]] [-r] [-s size] [-t trim]\n"
|
||||
" %*s [repetitions]\n\n"
|
||||
" %*s [repetitions]\n"
|
||||
" %s [-d driver[:arg]] [-p ppm] [-r] [-t trim] [samples]\n\n"
|
||||
"atben arguments:\n"
|
||||
" -b count base count for relative result\n"
|
||||
" -s size payload size in bytes, 0-127 (default: %d bytes)\n"
|
||||
" repetitions number of measurements (default: 1)\n\n"
|
||||
"atusb arguments:\n"
|
||||
" samples number of samples (default: %d)\n\n"
|
||||
"common options\n"
|
||||
" -d driver[:arg] use the specified driver (default: %s)\n"
|
||||
" -p ppm maximum deviation from base count\n"
|
||||
" -r instead of printing a mean value, dump the raw samples\n"
|
||||
" -s size payload size in bytes, 0-127 (default: %d bytes)\n"
|
||||
" -t trim trim capacitor setting, 0-15 (default: %d)\n"
|
||||
" repetitions number of measurements (default: 1)\n"
|
||||
, name, (int) strlen(name), "",
|
||||
atrf_default_driver_name(), DEFAULT_SIZE, DEFAULT_TRIM);
|
||||
, name, (int) strlen(name), "", name,
|
||||
DEFAULT_SIZE, DEFAULT_SAMPLES, atrf_default_driver_name(), DEFAULT_TRIM);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -50,7 +80,7 @@ int main(int argc, char *const *argv)
|
||||
int size = DEFAULT_SIZE;
|
||||
int trim = DEFAULT_TRIM;
|
||||
double base = 0, ppm = 0;
|
||||
int rep = 1;
|
||||
int n = 0;
|
||||
int dump_raw = 0;
|
||||
char *end;
|
||||
int c;
|
||||
@@ -91,14 +121,16 @@ int main(int argc, char *const *argv)
|
||||
usage(*argv);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (ppm && !base)
|
||||
usage(*argv);
|
||||
#endif
|
||||
|
||||
switch (argc-optind) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
rep = strtoul(argv[optind], &end, 0);
|
||||
n = strtoul(argv[optind], &end, 0);
|
||||
if (*end)
|
||||
usage(*argv);
|
||||
break;
|
||||
@@ -110,7 +142,10 @@ int main(int argc, char *const *argv)
|
||||
if (!dsc)
|
||||
return 1;
|
||||
|
||||
do_atben(dsc, size, trim, rep, dump_raw, base, ppm);
|
||||
if (atrf_usb_handle(dsc))
|
||||
atusb(dsc, trim, dump_raw, ppm, n ? n : DEFAULT_SAMPLES);
|
||||
else
|
||||
atben(dsc, size, trim, n ? n : 1, dump_raw, base, ppm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user