Fixed stability problems in OTGv1.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8651 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
ef8ef298b9
commit
d93fdcd424
|
@ -511,6 +511,19 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) {
|
|||
sts &= otgp->GINTMSK;
|
||||
otgp->GINTSTS = sts;
|
||||
|
||||
/* Reset interrupt handling.*/
|
||||
if (sts & GINTSTS_USBRST) {
|
||||
|
||||
/* Resetting pending operations.*/
|
||||
usbp->txpending = 0;
|
||||
|
||||
/* Default reset action.*/
|
||||
_usb_reset(usbp);
|
||||
|
||||
/* Preventing execution of more handlers, the core has been reset.*/
|
||||
return;
|
||||
}
|
||||
|
||||
/* Wake-up handling.*/
|
||||
if (sts & GINTSTS_WKUPINT) {
|
||||
/* If clocks are gated off, turn them back on (may be the case if
|
||||
|
@ -529,15 +542,13 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) {
|
|||
/* Suspend handling.*/
|
||||
if (sts & GINTSTS_USBSUSP) {
|
||||
|
||||
/* Resetting pending operations.*/
|
||||
usbp->txpending = 0;
|
||||
|
||||
/* Default suspend action.*/
|
||||
_usb_suspend(usbp);
|
||||
}
|
||||
|
||||
/* Reset interrupt handling.*/
|
||||
if (sts & GINTSTS_USBRST) {
|
||||
|
||||
_usb_reset(usbp);
|
||||
}
|
||||
|
||||
/* Enumeration done.*/
|
||||
if (sts & GINTSTS_ENUMDNE) {
|
||||
/* Full or High speed timing selection.*/
|
||||
|
@ -920,18 +931,18 @@ void usb_lld_reset(USBDriver *usbp) {
|
|||
/* Flush the Tx FIFO.*/
|
||||
otg_txfifo_flush(usbp, 0);
|
||||
|
||||
/* Endpoint interrupts all disabled and cleared.*/
|
||||
otgp->DIEPEMPMSK = 0;
|
||||
otgp->DAINTMSK = DAINTMSK_OEPM(0) | DAINTMSK_IEPM(0);
|
||||
|
||||
/* All endpoints in NAK mode, interrupts cleared.*/
|
||||
for (i = 0; i <= usbp->otgparams->num_endpoints; i++) {
|
||||
otgp->ie[i].DIEPCTL = DIEPCTL_SNAK;
|
||||
otgp->oe[i].DOEPCTL = DOEPCTL_SNAK;
|
||||
otgp->ie[i].DIEPINT = 0xFF;
|
||||
otgp->oe[i].DOEPINT = 0xFF;
|
||||
otgp->ie[i].DIEPINT = 0xFFFFFFFF;
|
||||
otgp->oe[i].DOEPINT = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
/* Endpoint interrupts all disabled and cleared.*/
|
||||
otgp->DAINT = 0xFFFFFFFF;
|
||||
otgp->DAINTMSK = DAINTMSK_OEPM(0) | DAINTMSK_IEPM(0);
|
||||
|
||||
/* Resets the FIFO memory allocator.*/
|
||||
otg_ram_reset(usbp);
|
||||
|
||||
|
|
|
@ -380,6 +380,19 @@ void usbDisableEndpointsI(USBDriver *usbp) {
|
|||
usbp->transmitting &= ~1U;
|
||||
usbp->receiving &= ~1U;
|
||||
for (i = 1; i <= (unsigned)USB_MAX_ENDPOINTS; i++) {
|
||||
#if USB_USE_WAIT == TRUE
|
||||
/* Signaling the event to threads waiting on endpoints.*/
|
||||
if (usbp->epc[i] != NULL) {
|
||||
osalSysLockFromISR();
|
||||
if (usbp->epc[i]->in_state != NULL) {
|
||||
osalThreadResumeI(&usbp->epc[i]->in_state->thread, MSG_RESET);
|
||||
}
|
||||
if (usbp->epc[i]->out_state != NULL) {
|
||||
osalThreadResumeI(&usbp->epc[i]->out_state->thread, MSG_RESET);
|
||||
}
|
||||
osalSysUnlockFromISR();
|
||||
}
|
||||
#endif
|
||||
usbp->epc[i] = NULL;
|
||||
}
|
||||
|
||||
|
@ -638,12 +651,14 @@ void _usb_reset(USBDriver *usbp) {
|
|||
#if USB_USE_WAIT == TRUE
|
||||
/* Signaling the event to threads waiting on endpoints.*/
|
||||
if (usbp->epc[i] != NULL) {
|
||||
osalSysLockFromISR();
|
||||
if (usbp->epc[i]->in_state != NULL) {
|
||||
osalThreadResumeI(&usbp->epc[i]->in_state->thread, MSG_RESET);
|
||||
}
|
||||
if (usbp->epc[i]->out_state != NULL) {
|
||||
osalThreadResumeI(&usbp->epc[i]->out_state->thread, MSG_RESET);
|
||||
}
|
||||
osalSysUnlockFromISR();
|
||||
}
|
||||
#endif
|
||||
usbp->epc[i] = NULL;
|
||||
|
@ -671,7 +686,7 @@ void _usb_reset(USBDriver *usbp) {
|
|||
void _usb_suspend(USBDriver *usbp) {
|
||||
|
||||
/* State transition.*/
|
||||
usbp->state = USB_SUSPENDED;
|
||||
usbp->state = USB_SUSPENDED;
|
||||
|
||||
/* Notification of suspend event.*/
|
||||
_usb_isr_invoke_event_cb(usbp, USB_EVENT_SUSPEND);
|
||||
|
@ -683,12 +698,14 @@ void _usb_suspend(USBDriver *usbp) {
|
|||
|
||||
for (i = 0; i <= (unsigned)USB_MAX_ENDPOINTS; i++) {
|
||||
if (usbp->epc[i] != NULL) {
|
||||
osalSysLockFromISR();
|
||||
if (usbp->epc[i]->in_state != NULL) {
|
||||
osalThreadResumeI(&usbp->epc[i]->in_state->thread, MSG_TIMEOUT);
|
||||
}
|
||||
if (usbp->epc[i]->out_state != NULL) {
|
||||
osalThreadResumeI(&usbp->epc[i]->out_state->thread, MSG_TIMEOUT);
|
||||
}
|
||||
osalSysUnlockFromISR();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList/>"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="DAINTMSK-otgp-usb_lld_pump-(format)" val="4"/></contentList>"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList> <memoryBlockExpressionItem> <expression text="0x20000f88"/> </memoryBlockExpressionItem> </memoryBlockExpressionList> "/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32F7xx-USB_RAW"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="vt_delta-null-chVTDoSetI-(format)" val="4"/><content id="r3-(format)" val="4"/></contentList>"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="r3-(format)" val="4"/><content id="vt_delta-null-chVTDoSetI-(format)" val="4"/></contentList>"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList> <memoryBlockExpressionItem> <expression text="0x20010744"/> </memoryBlockExpressionItem> </memoryBlockExpressionList> "/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
|
||||
|
|
Loading…
Reference in New Issue