diff options
-rw-r--r-- | os/hal/platforms/STM32/OTGv1/usb_lld.c | 22 | ||||
-rw-r--r-- | testhal/STM32F4xx/USB_CDC/main.c | 2 |
2 files changed, 10 insertions, 14 deletions
diff --git a/os/hal/platforms/STM32/OTGv1/usb_lld.c b/os/hal/platforms/STM32/OTGv1/usb_lld.c index fae5f500f..0f927cd85 100644 --- a/os/hal/platforms/STM32/OTGv1/usb_lld.c +++ b/os/hal/platforms/STM32/OTGv1/usb_lld.c @@ -381,13 +381,6 @@ static void otg_txfifo_handler(USBDriver *usbp, usbep_t ep) { usbp->epc[ep]->in_state->mode.linear.txbuf += n;
}
usbp->epc[ep]->in_state->txcnt += n;
- /* TODO: Potential issue, txcnt can be less than txsize after the planned
- number of packets have been received, better disable the interrupt
- at the end of the transaction in otg_epin_handler().*/
- if (usbp->epc[ep]->in_state->txcnt >= usbp->epc[ep]->in_state->txsize) {
- /* Transfer finished.*/
- OTG->DIEPEMPMSK &= ~DIEPEMPMSK_INEPTXFEM(ep);
- }
}
/**
@@ -401,20 +394,21 @@ static void otg_txfifo_handler(USBDriver *usbp, usbep_t ep) { static void otg_epin_handler(USBDriver *usbp, usbep_t ep) {
uint32_t epint = OTG->ie[ep].DIEPINT;
- /* Resets all EP IRQ sources.*/
- OTG->ie[ep].DIEPINT = 0xFFFFFFFF;
-
+ if (epint & DIEPINT_TOC) {
+ /* Timeouts not handled yet, not sure how to handle.*/
+ OTG->ie[ep].DIEPINT = DIEPINT_TOC;
+ }
if (epint & DIEPINT_XFRC) {
/* Transmit transfer complete.*/
+ OTG->ie[ep].DIEPINT = DIEPINT_XFRC;
_usb_isr_invoke_in_cb(usbp, ep);
+ OTG->DIEPEMPMSK &= ~DIEPEMPMSK_INEPTXFEM(ep);
}
- if (epint & DIEPINT_TXFE) {
+ else if (epint & DIEPINT_TXFE) {
/* TX FIFO empty or emptying.*/
+ OTG->ie[ep].DIEPINT = DIEPINT_TXFE;
otg_txfifo_handler(usbp, ep);
}
- if (epint & DIEPINT_TOC) {
- /* Timeouts not handled yet, not sure how to handle.*/
- }
}
/**
diff --git a/testhal/STM32F4xx/USB_CDC/main.c b/testhal/STM32F4xx/USB_CDC/main.c index e36ce3dc9..a880e86f9 100644 --- a/testhal/STM32F4xx/USB_CDC/main.c +++ b/testhal/STM32F4xx/USB_CDC/main.c @@ -443,12 +443,14 @@ int main(void) { * sleeping in a loop and check the button state.
*/
while (TRUE) {
+#if 0
if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE))
shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
else if (chThdTerminated(shelltp)) {
chThdRelease(shelltp); /* Recovers memory of the previous shell. */
shelltp = NULL; /* Triggers spawning of a new shell. */
}
+#endif
chThdSleepMilliseconds(1000);
}
}
|