Revision 956
Added by markw about 6 years ago
| firmware_eclairexl/usb/hid.c | ||
|---|---|---|
|
|
||
|
if(iface->device_type != HID_DEVICE_UNKNOWN) {
|
||
|
|
||
|
if (iface->qNextPollTime <= timer_get_msec()) {
|
||
|
if (timer_elapsed(iface->qNextPollTime)) {
|
||
|
// hid_debugf("poll %d...", iface->ep.epAddr);
|
||
|
|
||
|
uint16_t read = iface->ep.maxPktSize;
|
||
| firmware_eclairexl/usb/hub.c | ||
|---|---|---|
|
if (!info->bPollEnable)
|
||
|
return 0;
|
||
|
|
||
|
if (info->qNextPollTime <= timer_get_msec()) {
|
||
|
if (timer_elapsed(info->qNextPollTime)) {
|
||
|
rcode = usb_hub_check_hub_status(dev, info->bNbrPorts);
|
||
|
//info->qNextPollTime = timer_get_msec() + 100; // poll 10 times a second
|
||
|
info->qNextPollTime = timer_get_msec() + 2000; // poll every 2 seconds
|
||
| firmware_eclairexl/usb/timer.c | ||
|---|---|---|
|
msec_t timer_get_msec() {
|
||
|
int res = *zpu_timer;
|
||
|
res = res >> 10; // Divide by 1024, good enough for here!
|
||
|
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
bool timer_elapsed(msec_t until)
|
||
|
{
|
||
|
msec_t now = timer_get_msec();
|
||
|
if (now>=until)
|
||
|
return true;
|
||
|
else
|
||
|
{
|
||
|
unsigned int delay = until - now;
|
||
|
|
||
|
if (delay > 0x200000)
|
||
|
return true; //overflow
|
||
|
else
|
||
|
return false; //normal case
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif
|
||
|
|
||
| firmware_eclairexl/usb/timer.h | ||
|---|---|---|
|
void timer_init();
|
||
|
msec_t timer_get_msec();
|
||
|
|
||
|
bool timer_elapsed(msec_t end);
|
||
|
|
||
|
#endif // TIMER_H
|
||
| firmware_eclairexl/usb/usb.c | ||
|---|---|---|
|
uint8_t retry_count = 0;
|
||
|
uint16_t nak_count = 0;
|
||
|
|
||
|
while( timeout > timer_get_msec() ) {
|
||
|
while( !timer_elapsed(timeout) ) {
|
||
|
//MWW max3421e_write_u08( MAX3421E_HXFR, ( token|ep )); //launch the transfer
|
||
|
USBHOSTSLAVE_WRITE(OHS900_TXENDPREG, ep);
|
||
|
uint8_t control = OHS900_HCTLMASK_TRANS_REQ|controlAdj;
|
||
| ... | ... | |
|
|
||
|
// wait for transfer completion
|
||
|
//printf("Wait:%x %x ", timer_get_msec(), timeout);
|
||
|
while( timer_get_msec() < timeout ) {
|
||
|
while( !timer_elapsed(timeout) ) {
|
||
|
//tmpdata = max3421e_read_u08( MAX3421E_HIRQ );
|
||
|
// MWW
|
||
|
tmpdata = USBHOSTSLAVE_READ(OHS900_IRQ_STATUS);
|
||
| ... | ... | |
|
usbhostslave = host->addr;
|
||
|
|
||
|
// max poll 1ms
|
||
|
if(timer_get_msec() > host->poll) {
|
||
|
if(timer_elapsed(host->poll)) {
|
||
|
host->poll = timer_get_msec()+1;
|
||
|
|
||
|
// poll underlaying hardware layer
|
||
| ... | ... | |
|
break;
|
||
|
|
||
|
case USB_ATTACHED_SUBSTATE_SETTLE: //settle time for just attached device
|
||
|
if( host->delay < timer_get_msec() )
|
||
|
if( timer_elapsed(host->delay) )
|
||
|
host->usb_task_state = USB_ATTACHED_SUBSTATE_RESET_DEVICE;
|
||
|
break;
|
||
|
|
||
| ... | ... | |
|
break;
|
||
|
|
||
|
case USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE:
|
||
|
if( host->delay < timer_get_msec() )
|
||
|
if( timer_elapsed(host->delay) )
|
||
|
{
|
||
|
USBHOSTSLAVE_WRITE(OHS900_SOFENREG, OHS900_MASK_SOF_ENA);
|
||
|
USBHOSTSLAVE_WRITE(OHS900_TXLINECTLREG, OHS900_TXLCTL_MASK_NORMAL);
|
||
| ... | ... | |
|
if (USBHOSTSLAVE_READ(OHS900_IRQ_STATUS)&OHS900_INTMASK_SOFINTR)
|
||
|
{
|
||
|
USBHOSTSLAVE_WRITE(OHS900_IRQ_STATUS, OHS900_INTMASK_SOFINTR);
|
||
|
if( host->delay < timer_get_msec() ) //20ms passed
|
||
|
if( timer_elapsed(host->delay) ) //20ms passed
|
||
|
host->usb_task_state = USB_STATE_CONFIGURING;
|
||
|
}
|
||
|
break;
|
||
Bug#75: Fix USB keyboard hang after 70 minutes