Date:2011-03-11 21:52:03 (8 years 3 months ago)
Author:Werner Almesberger
Commit:d233c04c86c2fde39b5e069bb6750caef3393f32
Message:atusb/fw: implemented USB bus reset (to host) and polling of reset from host

- usb/usb.h, usb/atu2.c (usb_reset): reset the USB bus by detaching and
re-attaching the device
- boot.c (main): force a USB reset before running the payload
- usb/atu2.c (usb_poll): test for USB reset from the host (in progress)
- usb/dfu.c (my_reset, dfu_init): register user USB reset handler
Files: atusb/fw/boot.c (1 diff)
atusb/fw/usb/atu2.c (2 diffs)
atusb/fw/usb/dfu.c (1 diff)
atusb/fw/usb/usb.h (1 diff)

Change Details

atusb/fw/boot.c
5757
5858    led(0);
5959
60    usb_reset();
6061    run_payload();
6162
6263    while (1); /* not reached */
atusb/fw/usb/atu2.c
171171{
172172    uint8_t flags, i;
173173
174    flags = UDINT;
175    if (flags & EORSTI) {
176        UDINT &= ~(1 << EORSTI);
177        if (user_reset)
178            user_reset();
179    }
174180    flags = UEINT;
175181    for (i = 0; i != NUM_EPS; i++)
176182        if (1 || flags & (1 << i))
...... 
194200}
195201
196202
203void usb_reset(void)
204{
205    UDCON |= 1 << DETACH; /* detach the pull-up */
206    _delay_ms(1);
207}
208
209
197210void usb_init(void)
198211{
199212    USBCON |= 1 << FRZCLK; /* freeze the clock */
atusb/fw/usb/dfu.c
264264}
265265
266266
267#if 0
268267static void my_reset(void)
269268{
269#if 0
270270    /* @@@ not nice -- think about where this should go */
271271    extern void run_payload(void);
272272
273273    if (did_download)
274274        run_payload();
275}
276275#endif
276}
277277
278278
279279void dfu_init(void)
280280{
281281    user_setup = my_setup;
282282    user_get_descriptor = my_descr;
283// user_reset = my_reset;
283    user_reset = my_reset;
284284}
atusb/fw/usb/usb.h
141141
142142int handle_setup(const struct setup_request *setup);
143143int set_addr(uint8_t addr);
144void usb_reset(void);
144145void usb_init(void);
145146void usb_poll(void);
146147

Archive Download the corresponding diff file



interactive