Date:2010-08-24 02:49:20 (9 years 27 days ago)
Author:Werner Almesberger
Commit:b7700518d9a2276137e51c7ed8de8373a43007f9
Message:atspi-trim: utility to set the crystal trimming capacitors.

- atrf/tools/Makefile: added atspi-trim
- atrf/tools/atspi-trim/Makefile, atrf/tools/atspi-trim/atspi-trim.c: show
and adjust the capacitors to trim the crystal oscillator
- atrf/tools/atspi-rssi/atspi-rssi.c: removed left-over FROM_DEV and TO_DEV
Files: atrf/tools/Makefile (1 diff)
atrf/tools/atspi-rssi/atspi-rssi.c (1 diff)
atrf/tools/atspi-trim/Makefile (1 diff)
atrf/tools/atspi-trim/atspi-trim.c (1 diff)

Change Details

atrf/tools/Makefile
1111#
1212
1313
14DIRS=atspi-id atspi-reset atspi-rssi
14DIRS=atspi-id atspi-reset atspi-rssi atspi-trim
1515
1616include ../../Makefile.recurse
atrf/tools/atspi-rssi/atspi-rssi.c
2121#include "atspi.h"
2222
2323
24#define FROM_DEV ATSPI_FROM_DEV(0)
25#define TO_DEV ATSPI_TO_DEV(0)
26
27
2824static struct timeval t0;
2925
3026
atrf/tools/atspi-trim/Makefile
1#
2# atspi-trim/Makefile - Build the oscillator trim utility
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-trim
17
18include $(F32XBASE)/lib/Makefile.common
19
20CFLAGS += -I../../fw/include -I../include
21LDLIBS += -L../lib -latspi
atrf/tools/atspi-trim/atspi-trim.c
1/*
2 * atspi-trim/atspi-trim.c - AF86RF230 oscillator trim utility
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 <usb.h>
17#include <sys/time.h>
18
19#include "at86rf230.h"
20#include "atspi/ep0.h"
21#include "atspi.h"
22
23
24static void usage(const char *name)
25{
26    fprintf(stderr, "%s [trim_value]\n", name);
27    exit(1);
28}
29
30
31int main(int argc, const char **argv)
32{
33    usb_dev_handle *dev;
34    int trim = -1;
35    char *end;
36
37    switch (argc) {
38    case 1:
39        break;
40    case 2:
41        trim = strtoul(argv[1], &end, 0);
42        if (*end || trim > 15)
43            usage(*argv);
44        break;
45    default:
46        usage(*argv);
47    }
48
49    dev = atspi_open();
50    if (!dev)
51        return 1;
52
53    if (trim == -1) {
54        trim = atspi_reg_read(dev, REG_XOSC_CTRL) & XTAL_TRIM_MASK;
55        printf("%d (%d.%d pF)\n", trim, trim*3/10, trim*3 % 10);
56    } else {
57        atspi_reg_write(dev, REG_XOSC_CTRL,
58            (XTAL_MODE_INT << XTAL_MODE_SHIFT) | trim);
59    }
60
61    return 0;
62}

Archive Download the corresponding diff file



interactive