mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-05 04:20:37 +02:00
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
This commit is contained in:
parent
e5571a26c3
commit
d233c04c86
@ -57,6 +57,7 @@ int main(void)
|
|||||||
|
|
||||||
led(0);
|
led(0);
|
||||||
|
|
||||||
|
usb_reset();
|
||||||
run_payload();
|
run_payload();
|
||||||
|
|
||||||
while (1); /* not reached */
|
while (1); /* not reached */
|
||||||
|
@ -171,6 +171,12 @@ void usb_poll(void)
|
|||||||
{
|
{
|
||||||
uint8_t flags, i;
|
uint8_t flags, i;
|
||||||
|
|
||||||
|
flags = UDINT;
|
||||||
|
if (flags & EORSTI) {
|
||||||
|
UDINT &= ~(1 << EORSTI);
|
||||||
|
if (user_reset)
|
||||||
|
user_reset();
|
||||||
|
}
|
||||||
flags = UEINT;
|
flags = UEINT;
|
||||||
for (i = 0; i != NUM_EPS; i++)
|
for (i = 0; i != NUM_EPS; i++)
|
||||||
if (1 || flags & (1 << i))
|
if (1 || flags & (1 << i))
|
||||||
@ -194,6 +200,13 @@ static void ep_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void usb_reset(void)
|
||||||
|
{
|
||||||
|
UDCON |= 1 << DETACH; /* detach the pull-up */
|
||||||
|
_delay_ms(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void usb_init(void)
|
void usb_init(void)
|
||||||
{
|
{
|
||||||
USBCON |= 1 << FRZCLK; /* freeze the clock */
|
USBCON |= 1 << FRZCLK; /* freeze the clock */
|
||||||
|
@ -264,21 +264,21 @@ static int my_descr(uint8_t type, uint8_t index, const uint8_t **reply,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void my_reset(void)
|
static void my_reset(void)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
/* @@@ not nice -- think about where this should go */
|
/* @@@ not nice -- think about where this should go */
|
||||||
extern void run_payload(void);
|
extern void run_payload(void);
|
||||||
|
|
||||||
if (did_download)
|
if (did_download)
|
||||||
run_payload();
|
run_payload();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void dfu_init(void)
|
void dfu_init(void)
|
||||||
{
|
{
|
||||||
user_setup = my_setup;
|
user_setup = my_setup;
|
||||||
user_get_descriptor = my_descr;
|
user_get_descriptor = my_descr;
|
||||||
// user_reset = my_reset;
|
user_reset = my_reset;
|
||||||
}
|
}
|
||||||
|
@ -141,6 +141,7 @@ void usb_io(struct ep_descr *ep, enum ep_state state, uint8_t *buf,
|
|||||||
|
|
||||||
int handle_setup(const struct setup_request *setup);
|
int handle_setup(const struct setup_request *setup);
|
||||||
int set_addr(uint8_t addr);
|
int set_addr(uint8_t addr);
|
||||||
|
void usb_reset(void);
|
||||||
void usb_init(void);
|
void usb_init(void);
|
||||||
void usb_poll(void);
|
void usb_poll(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user