Date:2010-08-22 11:24:52 (10 years 27 days ago)
Author:Werner Almesberger
Commit:419b596c5db7092cdd66b6d5a120774e177b44d9
Message:atspi-reset: utility to reset transceiver or entire board.

- tools/include/atspi.h, tools/lib/atspi.c (atspi_reset): new function to
send the ATSPI_RESET command (MCU reset)
- tools/include/atspi.h, tools/lib/atspi.c (atspi_reset_rf): new function
to send the ATSPI_RESET_RF command (transceiver reset)
- tools/atspi-reset/Makefile, tools/atspi-reset/atspi-reset.c: reset utility
Files: tools/atspi-reset/Makefile (1 diff)
tools/atspi-reset/atspi-reset.c (1 diff)
tools/include/atspi.h (1 diff)
tools/lib/atspi.c (1 diff)

Change Details

tools/atspi-reset/Makefile
1#
2# atspi-reset/Makefile - Reset the transceiver or the whole board
3#
4# Written 2010 by Werner Almesberger
5# Copyright 2010 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
14F32XBASE = ../../../f32xbase
15
16MAIN = atspi-reset
17
18include $(F32XBASE)/lib/Makefile.common
19
20CFLAGS += -I../../fw/include -I../include
21LDLIBS += -L../lib -latspi
tools/atspi-reset/atspi-reset.c
1/*
2 * atspi-rssi/atspi-rssi.c - ben-wpan AF86RF230 spectrum scan
3 *
4 * Written 2010 by Werner Almesberger
5 * Copyright 2010 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 <string.h>
17#include <usb.h>
18
19#include "atspi.h"
20
21
22static void usage(const char *name)
23{
24    fprintf(stderr,
25"usage: %s [-a|-t]\n\n"
26" -a reset the MCU and transceiver\n"
27" -t reset transceiver (default)\n"
28    , name);
29    exit(1);
30}
31
32
33int main(int argc, const char **argv)
34{
35    usb_dev_handle *dev;
36    int txrx = 1;
37
38    switch (argc) {
39    case 1:
40        break;
41    case 2:
42        if (!strcmp(argv[1], "-t"))
43            break;
44        txrx = 0;
45        if (!strcmp(argv[1], "-a"))
46            break;
47        /* fall through */
48    default:
49        usage(*argv);
50    }
51
52    dev = atspi_open();
53    if (!dev)
54        return 1;
55
56        if (txrx)
57                atspi_reset_rf(dev);
58        else
59                atspi_reset(dev);
60        return 0;
61}
62
tools/include/atspi.h
1212usb_dev_handle *atspi_open(void);
1313void atspi_close(usb_dev_handle *dev);
1414
15void atspi_reset(usb_dev_handle *dev);
16void atspi_reset_rf(usb_dev_handle *dev);
17
1518void atspi_reg_write(usb_dev_handle *dev, uint8_t reg, uint8_t value);
1619uint8_t atspi_reg_read(usb_dev_handle *dev, uint8_t reg);
1720
tools/lib/atspi.c
7171}
7272
7373
74/* ----- device mode ------------------------------------------------------- */
75
76
77void atspi_reset(usb_dev_handle *dev)
78{
79    int res;
80
81    if (error)
82        return;
83
84    res =
85        usb_control_msg(dev, TO_DEV, ATSPI_RESET, 0, 0, NULL, 0, 1000);
86    if (res < 0) {
87        fprintf(stderr, "ATSPI_RESET: %d\n", res);
88        error = 1;
89    }
90}
91
92
93void atspi_reset_rf(usb_dev_handle *dev)
94{
95    int res;
96
97    if (error)
98        return;
99
100    res =
101        usb_control_msg(dev, TO_DEV, ATSPI_RF_RESET, 0, 0, NULL, 0, 1000);
102    if (res < 0) {
103        fprintf(stderr, "ATSPI_RF_RESET: %d\n", res);
104        error = 1;
105    }
106}
107
108
74109/* ----- register access --------------------------------------------------- */
75110
76111

Archive Download the corresponding diff file



interactive