From 44d5a9d084752d705eacb4ae539b6e28c8cb79b1 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 8 Nov 2017 10:50:18 +0000 Subject: Experimental. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10973 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld_alt.c | 41 +++++++++++++++++++++----- os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld_alt.h | 2 ++ 2 files changed, 35 insertions(+), 8 deletions(-) (limited to 'os') diff --git a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld_alt.c b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld_alt.c index bcbee9975..77793b3aa 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld_alt.c +++ b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld_alt.c @@ -325,8 +325,10 @@ static bool otg_txfifo_handler(USBDriver *usbp, usbep_t ep) { uint32_t n; /* Transaction end condition.*/ - if (usbp->epc[ep]->in_state->txcnt >= usbp->epc[ep]->in_state->txsize) + if (usbp->epc[ep]->in_state->txcnt >= usbp->epc[ep]->in_state->txsize) { + usbp->otg->DIEPEMPMSK &= ~DIEPEMPMSK_INEPTXFEM(ep); return true; + } /* Number of bytes remaining in current transaction.*/ n = usbp->epc[ep]->in_state->txsize - usbp->epc[ep]->in_state->txcnt; @@ -390,12 +392,17 @@ static void otg_epin_handler(USBDriver *usbp, usbep_t ep) { } if ((epint & DIEPINT_TXFE) && (otgp->DIEPEMPMSK & DIEPEMPMSK_INEPTXFEM(ep))) { +#if 0 /* The thread is made ready, it will be scheduled on ISR exit.*/ osalSysLockFromISR(); usbp->txpending |= (1 << ep); otgp->DIEPEMPMSK &= ~(1 << ep); osalThreadResumeI(&usbp->wait, MSG_OK); osalSysUnlockFromISR(); +#else + /* TX FIFO empty or emptying.*/ + otg_txfifo_handler(usbp, ep); +#endif } } @@ -483,12 +490,17 @@ static void otg_isoc_in_failed_handler(USBDriver *usbp) { /* Prepare data for next frame */ _usb_isr_invoke_in_cb(usbp, ep); +#if 0 /* Pump out data for next frame */ osalSysLockFromISR(); otgp->DIEPEMPMSK &= ~(1 << ep); usbp->txpending |= (1 << ep); osalThreadResumeI(&usbp->wait, MSG_OK); osalSysUnlockFromISR(); +#else + /* TX FIFO empty or emptying.*/ + otg_txfifo_handler(usbp, ep); +#endif } } } @@ -536,10 +548,10 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) { /* Reset interrupt handling.*/ if (sts & GINTSTS_USBRST) { - +#if 0 /* Resetting pending operations.*/ usbp->txpending = 0; - +#endif /* Default reset action.*/ _usb_reset(usbp); @@ -564,10 +576,10 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) { /* Suspend handling.*/ if (sts & GINTSTS_USBSUSP) { - +#if 0 /* Resetting pending operations.*/ usbp->txpending = 0; - +#endif /* Default suspend action.*/ _usb_suspend(usbp); } @@ -732,10 +744,13 @@ void usb_lld_init(void) { /* Driver initialization.*/ #if STM32_USB_USE_OTG1 usbObjectInit(&USBD1); +#if 0 USBD1.wait = NULL; +#endif USBD1.otg = OTG_FS; USBD1.otgparams = &fsparams; +#if 0 #if defined(_CHIBIOS_RT_) USBD1.tr = NULL; /* Filling the thread working area here because the function @@ -750,13 +765,17 @@ void usb_lld_init(void) { #endif /* CH_DBG_FILL_THREADS */ #endif /* defined(_CHIBIOS_RT_) */ #endif +#endif #if STM32_USB_USE_OTG2 usbObjectInit(&USBD2); +#if 0 USBD2.wait = NULL; +#endif USBD2.otg = OTG_HS; USBD2.otgparams = &hsparams; +#if 0 #if defined(_CHIBIOS_RT_) USBD2.tr = NULL; /* Filling the thread working area here because the function @@ -771,6 +790,7 @@ void usb_lld_init(void) { #endif /* CH_DBG_FILL_THREADS */ #endif /* defined(_CHIBIOS_RT_) */ #endif +#endif } /** @@ -854,9 +874,10 @@ void usb_lld_start(USBDriver *usbp) { } #endif +#if 0 /* Clearing mask of TXFIFOs to be filled.*/ usbp->txpending = 0; - +#endif /* PHY enabled.*/ otgp->PCGCCTL = 0; @@ -906,6 +927,7 @@ void usb_lld_start(USBDriver *usbp) { /* Clears all pending IRQs, if any. */ otgp->GINTSTS = 0xFFFFFFFF; +#if 0 #if defined(_CHIBIOS_RT_) /* Creates the data pump thread. Note, it is created only once.*/ if (usbp->tr == NULL) { @@ -922,7 +944,7 @@ void usb_lld_start(USBDriver *usbp) { chSchRescheduleS(); } #endif - +#endif /* Global interrupts enable.*/ otgp->GAHBCFG |= GAHBCFG_GINTMSK; } @@ -945,8 +967,9 @@ void usb_lld_stop(USBDriver *usbp) { active.*/ otg_disable_ep(usbp); +#if 0 usbp->txpending = 0; - +#endif otgp->DAINTMSK = 0; otgp->GAHBCFG = 0; otgp->GCCFG = 0; @@ -1325,6 +1348,7 @@ void usb_lld_clear_in(USBDriver *usbp, usbep_t ep) { usbp->otg->ie[ep].DIEPCTL &= ~DIEPCTL_STALL; } +#if 0 /** * @brief USB data transfer loop. * @details This function must be executed by a system thread in order to @@ -1391,6 +1415,7 @@ void usb_lld_pump(void *p) { osalSysLock(); } } +#endif #endif /* HAL_USE_USB */ diff --git a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld_alt.h b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld_alt.h index ba5e4fc2f..83fe2e5ae 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld_alt.h +++ b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld_alt.h @@ -508,6 +508,7 @@ struct USBDriver { * @brief Pointer to the next address in the packet memory. */ uint32_t pmnext; +#if 0 /** * @brief Mask of TXFIFOs to be filled by the pump thread. */ @@ -526,6 +527,7 @@ struct USBDriver { */ THD_WORKING_AREA(wa_pump, STM32_USB_OTG_THREAD_STACK_SIZE); #endif +#endif }; /*===========================================================================*/ -- cgit v1.2.3