mirror of
https://github.com/mist-devel/mist-firmware.git
synced 2026-05-04 15:26:29 +00:00
USB: add some grace time after address setup
This commit is contained in:
@@ -13,6 +13,11 @@ msec_t timer_get_msec() {
|
||||
return GetRTTC();
|
||||
}
|
||||
|
||||
bool timer_check(msec_t ref, msec_t delay) {
|
||||
msec_t now = GetRTTC();
|
||||
return ((now-ref) >= delay);
|
||||
}
|
||||
|
||||
void timer_delay_msec(msec_t t) {
|
||||
msec_t now = GetRTTC();
|
||||
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
#define TIMER_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
typedef uint32_t msec_t;
|
||||
|
||||
void timer_init();
|
||||
msec_t timer_get_msec();
|
||||
void timer_delay_msec(msec_t t);
|
||||
bool timer_check(msec_t ref, msec_t delay);
|
||||
|
||||
#endif // TIMER_H
|
||||
|
||||
@@ -80,9 +80,11 @@ uint8_t usb_configure(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||
iprintf("failed to assign address (rcode=%d)", rcode);
|
||||
return rcode;
|
||||
}
|
||||
|
||||
if(rcode = usb_get_dev_descr( d, 8, &dev_desc ))
|
||||
return rcode;
|
||||
uint32_t timer = timer_get_msec();
|
||||
do {
|
||||
rcode = usb_get_dev_descr( d, 8, &dev_desc );
|
||||
} while (rcode && !timer_check(timer, 5)); // Some recovery interval (2 ms as USB 2.0 9.2.6.3)
|
||||
if(rcode) return rcode;
|
||||
|
||||
// --- enumerate device ---
|
||||
if(rcode = usb_get_dev_descr( d, sizeof(usb_device_descriptor_t), &dev_desc ))
|
||||
|
||||
Reference in New Issue
Block a user