IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Git Source Tree
Root/
Source at commit 1f003f1c2100f7f3670106fd13df0eaec7a0e4e1 created 7 years 6 months ago. By Werner Almesberger, atusb/atusb.kicad_pcb: grow RF feed trace to 1.9 mm, for 1.0 mm PCB | |
---|---|
1 | /* |
2 | * atrf-reset/atrf-reset.c - Reset the transceiver or the whole board |
3 | * |
4 | * Written 2010-2011 by Werner Almesberger |
5 | * Copyright 2010-2011 Werner Almesberger |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | */ |
12 | |
13 | |
14 | #include <stdlib.h> |
15 | #include <stdio.h> |
16 | #include <unistd.h> |
17 | #include <string.h> |
18 | |
19 | #include "atrf.h" |
20 | |
21 | |
22 | static void usage(const char *name) |
23 | { |
24 | fprintf(stderr, |
25 | "usage: %s [-a|-t] [-d driver[:arg]]\n\n" |
26 | " -a reset MCU and transceiver\n" |
27 | " -d driver[:arg] use the specified driver (default: %s)\n" |
28 | " -t reset transceiver (default)\n" |
29 | , name, atrf_default_driver_name()); |
30 | exit(1); |
31 | } |
32 | |
33 | |
34 | int main(int argc, char *const *argv) |
35 | { |
36 | const char *driver = NULL; |
37 | struct atrf_dsc *dsc; |
38 | int txrx = 1; |
39 | int c; |
40 | |
41 | while ((c = getopt(argc, argv, "ad:t")) != EOF) |
42 | switch (c) { |
43 | case 'a': |
44 | txrx = 0; |
45 | break; |
46 | case 'd': |
47 | driver = optarg; |
48 | break; |
49 | case 't': |
50 | txrx = 1; |
51 | break; |
52 | default: |
53 | usage(*argv); |
54 | } |
55 | if (argc != optind) |
56 | usage(*argv); |
57 | |
58 | dsc = atrf_open(driver); |
59 | if (!dsc) |
60 | return 1; |
61 | |
62 | if (txrx) |
63 | atrf_reset_rf(dsc); |
64 | else |
65 | atrf_reset(dsc); |
66 | return 0; |
67 | } |
68 | |
69 |