Date:2011-06-20 19:34:08 (7 years 5 months ago)
Author:Werner Almesberger
Commit:244e4491319edccc4bdbb97bf03a4a15b3dc242b
Message:atusb/fw/usb/: added support for bulk IN EP 1

The code is quite special-cased. Some more changes will be necessary
for interrupt or OUT EPs.

- atu2.c (NUM_EPS): increased from 1 to 2
- atu2.c (ep_rx): send zero-length packet also for EPs != 0
- atu2.c (handle_ep): clear FIFOCON when sending data on EP != 0
- atu2.c (ep_init): configure EP 1 as bulk IN with size 64
- usb.c (NUM_EPS): we don't need to define NUM_EPS here
Files: atusb/fw/usb/atu2.c (5 diffs)
atusb/fw/usb/usb.c (1 diff)

Change Details

atusb/fw/usb/atu2.c
4040#endif
4141
4242
43#define NUM_EPS 1
43#define NUM_EPS 2
4444
4545
4646struct ep_descr eps[NUM_EPS];
...... 
112112        ep->state = EP_IDLE;
113113        if (ep->callback)
114114            ep->callback(ep->user);
115        if (ep == &eps[0])
115// if (ep == &eps[0])
116116            usb_send(ep, NULL, 0, NULL, NULL);
117117    }
118118    return 1;
...... 
137137static void handle_ep(int n)
138138{
139139    struct ep_descr *ep = eps+n;
140    uint8_t mask;
140141
141142    UENUM = n;
142143    if (UEINTX & (1 << RXSTPI)) {
...... 
163164        /* @@ EP_RX: cancel (?) */
164165        if (ep->state == EP_TX) {
165166            ep_tx(ep);
166            UEINTX = ~(1 << TXINI);
167            mask = 1 << TXINI;
168            if (n)
169                mask |= 1 << FIFOCON;
170            UEINTX = ~mask;
167171            if (ep->state == EP_IDLE && ep->callback)
168172                ep->callback(ep->user);
169173        } else {
...... 
194198
195199    eps[0].state = EP_IDLE;
196200    eps[0].size = 64;
201
202    UENUM = 1;
203    UECONX = (1 << RSTDT) | (1 << EPEN); /* enable */
204    UECFG0X = (1 << EPTYPE1) | (1 << EPDIR); /* bulk IN */
205    UECFG1X = 3 << EPSIZE0; /* 64 bytes */
206    UECFG1X |= 1 << ALLOC;
207
208    while (!(UESTA0X & (1 << CFGOK)));
209
210    UEIENX = (1 << STALLEDE) | (1 << TXINE);
211
212    eps[1].state = EP_IDLE;
213    eps[1].size = 64;
197214}
198215
199216
atusb/fw/usb/usb.c
2626#define NULL 0
2727#endif
2828
29#define NUM_EPS 1
30
3129#if 1
3230extern void panic(void);
3331#define BUG_ON(cond) do { if (cond) panic(); } while (0)

Archive Download the corresponding diff file



interactive