Date:2010-11-11 06:25:54 (8 years 7 months ago)
Author:Werner Almesberger
Commit:2337557a8c8a68db49013b30759be9ac8ca8135b
Message:atusd firmware now supports setting the TST pin.

- common/io.h: TST is connected to P0_7
- include/at86rf230.h: added test mode registers REG_CONT_TX_0 (0x36) and
REG_CONT_TX_1 (0x3d), with their values
- atspi/atspi.c (set_test_mode): set or reset TST and the LED
- atspi/atspi.c (reset_rf): leave test mode
- atspi/atspi.c (test_mode): enter test mode
- atspi/atspi.c (main): flash the LED when in test mode
- include/atspi/ep0.h (enum atspi_requests), atspi/ep0.c (my_setup): new
command ATSPI_TEST to enter test mode
- include/atspi/ep0.h (EP0ATSPI_MINOR): bumped protocol to version 0.1
- include/at86rf230.h: corrected comment before TRX_CMD field to indicate
that the register is called TRX_STATE
Files: atusb/fw/atspi/atspi.c (5 diffs)
atusb/fw/atspi/ep0.c (2 diffs)
atusb/fw/common/io.h (1 diff)
atusb/fw/include/at86rf230.h (3 diffs)
atusb/fw/include/atspi/ep0.h (3 diffs)

Change Details

atusb/fw/atspi/atspi.c
1818#include "version.h"
1919
2020
21static int in_test_mode = 0;
22
23
24static void set_test_mode(int on)
25{
26    in_test_mode = on;
27    if (on) {
28        TST_MODE |= 1 << TST_BIT;
29        TST = 1;
30        LED_MODE |= 1 << LED_BIT;
31    } else {
32        TST = 0;
33        TST_MODE &= ~(1 << TST_BIT);
34        LED_MODE &= ~(1 << LED_BIT);
35        LED = 0;
36    }
37}
38
39
2140void reset_rf(void)
2241{
2342    int i;
2443
44    set_test_mode(0);
45
2546    nRST_RF = 0;
2647    /*
2748     * 11.4.12: min 625 ns.
...... 
3253}
3354
3455
56void test_mode(void)
57{
58    set_test_mode(1);
59}
60
61
3562static void init_io(void)
3663{
3764    /*
...... 
4471     * nRST_RF push-pull 1
4572     * IRQ_RF open drain 1 (input)
4673     * SLP_TR push-pull 0
74     * TST open drain 0
4775     *
4876     * LED push-pull 0 (set up by boot loader)
4977     *
...... 
6391    SLP_TR = 0;
6492    SLP_TR_MODE |= 1 << SLP_TR_BIT;
6593
66    P0 = 1; /* IRQ_RF = 1; LED = 0; the rest is unused */
94    P0 = 1; /* IRQ_RF = 1; LED = 0; TST = Z; the rest is unused */
6795    P3 = 0;
6896
6997#if 0
...... 
104132    ep0_init();
105133
106134    while (1) {
135        if (in_test_mode) {
136            i++;
137            LED = !(i >> 13);
138        }
107139        usb_poll();
108140    }
109141}
atusb/fw/atspi/ep0.c
2626
2727
2828extern void reset_rf(void);
29extern void test_mode(void);
2930
3031
3132#define debug(...)
...... 
151152        usb_send(&ep0, buf, 1, NULL, NULL);
152153        return 1;
153154
155    case ATSPI_TO_DEV(ATSPI_TEST):
156        debug("ATSPI_TEST\n");
157        test_mode();
158        return 1;
159
154160    case ATSPI_TO_DEV(ATSPI_REG_WRITE):
155161        debug("ATSPI_REG_WRITE\n");
156162        nSS = 0;
atusb/fw/common/io.h
3030#define nRST_RF P2_0
3131#define IRQ_RF P0_0
3232#define SLP_TR P2_1
33#define TST P0_7
3334
3435#endif /* !IO_H */
atusb/fw/include/at86rf230.h
6767    REG_XAH_CTRL = 0x2c,
6868    REG_CSMA_SEED_0 = 0x2d,
6969    REG_CSMA_SEED_1 = 0x2e,
70
71    REG_CONT_TX_0 = 0x36,
72    REG_CONT_TX_1 = 0x3d,
7073};
7174
7275/* --- TRX_STATUS [7] ------------------------------------------------------ */
...... 
113116    TRAC_STATUS_INVALID = 7
114117};
115118
116/* --- TRX_CMD [4:0] ----------------------------------------------------- */
119/* --- TRX_STATE [4:0] ----------------------------------------------------- */
117120
118121#define TRX_CMD_SHIFT 0
119122#define TRX_CMD_MASK 7
...... 
285288#define CSMA_SEED_1_SHIFT 0
286289#define CSMA_SEED_1_MASK 7
287290
291/* --- REG_CONT_TX_0 [7:0] ------------------------------------------------- */
292
293#define CONT_TX_MAGIC 0x0f
294
295/* --- REG_CONT_TX_1 [7:0] ------------------------------------------------- */
296
297#define CONT_TX_MOD 0x00 /* modulated */
298#define CONT_TX_M2M 0x10 /* f_CH-2 MHz */
299#define CONT_TX_M500K 0x80 /* f_CH-0.5 MHz */
300#define CONT_TX_P500K 0xc0 /* f_CH+0.5 MHz */
301
288302#endif /* !AT86RF230_H */
atusb/fw/include/atspi/ep0.h
2323 *
2424 * host-> ATSPI_RF_RESET - - 0
2525 * ->host ATSPI_POLL_INT - - 1
26 * host-> ATSPI_TEST - - 0
2627 *
2728 * host-> ATSPI_REG_WRITE value addr 0
2829 * ->host ATSPI_REG_READ - addr 1
...... 
3637 * EP0 protocol:
3738 *
3839 * 0.0 initial release
40 * 0.1 addition of ATSPI_TEST
3941 */
4042
4143#define EP0ATSPI_MAJOR 0 /* EP0 protocol, major revision */
42#define EP0ATSPI_MINOR 0 /* EP0 protocol, minor revision */
44#define EP0ATSPI_MINOR 1 /* EP0 protocol, minor revision */
4345
4446#define HW_TYPE_100813 0 /* 100813 */
4547
...... 
6567    ATSPI_RESET,
6668    ATSPI_RF_RESET = 0x10,
6769    ATSPI_POLL_INT,
70    ATSPI_TEST,
6871    ATSPI_REG_WRITE = 0x20,
6972    ATSPI_REG_READ,
7073    ATSPI_BUF_WRITE,

Archive Download the corresponding diff file



interactive