Date:2011-02-10 11:01:28 (8 years 8 months ago)
Author:Werner Almesberger
Commit:6969e7d6890c0b73b0100bcff775750f5d5b73c3
Message:atusb/fw2/ep0.c: make commands needed for sending work

- ep0.c (do_usb_recv, usb_recv): implemented creepy buffer reception
- ep0.c (my_setup): added dummy for ATUSB_POLL_INT (always return 0)
- ep0.c (my_setup): send a zero-length packet at the end of
ATUSB_RF_RESET and ATUSB_REG_WRITE to indicate status stage
Files: atusb/fw2/ep0.c (3 diffs)

Change Details

atusb/fw2/ep0.c
7171}
7272
7373
74static void do_usb_recv(uint8_t *data, int len, void (*fn)(void *user),
75    void *user)
76{
77    volatile usb_pcb_t *pcb = usb_pcb_get();
78    uint8_t got;
79
80    /* FreakUSB likes to do things this way. Looks dangerous ... */
81    while (len) {
82        for (got = pcb->fifo[EP_CTRL].len; got; got--) {
83            *data++ = usb_buf_read(EP_CTRL);
84            len--;
85        }
86    }
87    pcb->flags &= ~(1 << SETUP_DATA_AVAIL);
88    fn(user);
89    ep_send_zlp(EP_CTRL);
90}
91
92
7493#define usb_send(ep, buf, len, arg1, arg2) do_usb_send(buf, len)
75#define usb_recv(ep, buf, len, fn, arg) /* later */
94#define usb_recv(ep, buf, len, fn, user) do_usb_recv(buf, len, fn, user)
7695
7796
7897#define BUILD_OFFSET 7 /* '#' plus "65535" plus ' ' */
7998
8099
81/* keep things a similar to the original as possible for now */
100/* keep things as similar to the original as possible for now */
82101#define setup_request req_t
83102#define setup req
84103#define bmRequestType type
...... 
128147    case ATUSB_TO_DEV(ATUSB_RF_RESET):
129148        debug("ATUSB_RF_RESET\n");
130149        reset_rf();
150        ep_send_zlp(EP_CTRL);
131151        return 1;
132152
133#ifdef NOTYET
134153    case ATUSB_FROM_DEV(ATUSB_POLL_INT):
135154        debug("ATUSB_POLL_INT\n");
136155        if (setup->wLength < 1)
137156            return 0;
138        *buf = IRQ_RF;
157        *buf = 0;//IRQ_RF;
139158        usb_send(&ep0, buf, 1, NULL, NULL);
140159        return 1;
141#endif
142160
143161    case ATUSB_TO_DEV(ATUSB_REG_WRITE):
144162        debug("ATUSB_REG_WRITE\n");
...... 
146164        spi_send(AT86RF230_REG_WRITE | setup->wIndex);
147165        spi_send(setup->wValue);
148166        spi_end();
167        ep_send_zlp(EP_CTRL);
149168        return 1;
150169    case ATUSB_FROM_DEV(ATUSB_REG_READ):
151170        debug("ATUSB_REG_READ\n");

Archive Download the corresponding diff file



interactive