Experimental.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10973 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
gdisirio 2017-11-08 10:50:18 +00:00
parent 46e19e85b9
commit 44d5a9d084
2 changed files with 35 additions and 8 deletions

View File

@ -325,8 +325,10 @@ static bool otg_txfifo_handler(USBDriver *usbp, usbep_t ep) {
uint32_t n; uint32_t n;
/* Transaction end condition.*/ /* 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; return true;
}
/* Number of bytes remaining in current transaction.*/ /* Number of bytes remaining in current transaction.*/
n = usbp->epc[ep]->in_state->txsize - usbp->epc[ep]->in_state->txcnt; 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) && if ((epint & DIEPINT_TXFE) &&
(otgp->DIEPEMPMSK & DIEPEMPMSK_INEPTXFEM(ep))) { (otgp->DIEPEMPMSK & DIEPEMPMSK_INEPTXFEM(ep))) {
#if 0
/* The thread is made ready, it will be scheduled on ISR exit.*/ /* The thread is made ready, it will be scheduled on ISR exit.*/
osalSysLockFromISR(); osalSysLockFromISR();
usbp->txpending |= (1 << ep); usbp->txpending |= (1 << ep);
otgp->DIEPEMPMSK &= ~(1 << ep); otgp->DIEPEMPMSK &= ~(1 << ep);
osalThreadResumeI(&usbp->wait, MSG_OK); osalThreadResumeI(&usbp->wait, MSG_OK);
osalSysUnlockFromISR(); 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 */ /* Prepare data for next frame */
_usb_isr_invoke_in_cb(usbp, ep); _usb_isr_invoke_in_cb(usbp, ep);
#if 0
/* Pump out data for next frame */ /* Pump out data for next frame */
osalSysLockFromISR(); osalSysLockFromISR();
otgp->DIEPEMPMSK &= ~(1 << ep); otgp->DIEPEMPMSK &= ~(1 << ep);
usbp->txpending |= (1 << ep); usbp->txpending |= (1 << ep);
osalThreadResumeI(&usbp->wait, MSG_OK); osalThreadResumeI(&usbp->wait, MSG_OK);
osalSysUnlockFromISR(); 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.*/ /* Reset interrupt handling.*/
if (sts & GINTSTS_USBRST) { if (sts & GINTSTS_USBRST) {
#if 0
/* Resetting pending operations.*/ /* Resetting pending operations.*/
usbp->txpending = 0; usbp->txpending = 0;
#endif
/* Default reset action.*/ /* Default reset action.*/
_usb_reset(usbp); _usb_reset(usbp);
@ -564,10 +576,10 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) {
/* Suspend handling.*/ /* Suspend handling.*/
if (sts & GINTSTS_USBSUSP) { if (sts & GINTSTS_USBSUSP) {
#if 0
/* Resetting pending operations.*/ /* Resetting pending operations.*/
usbp->txpending = 0; usbp->txpending = 0;
#endif
/* Default suspend action.*/ /* Default suspend action.*/
_usb_suspend(usbp); _usb_suspend(usbp);
} }
@ -732,10 +744,13 @@ void usb_lld_init(void) {
/* Driver initialization.*/ /* Driver initialization.*/
#if STM32_USB_USE_OTG1 #if STM32_USB_USE_OTG1
usbObjectInit(&USBD1); usbObjectInit(&USBD1);
#if 0
USBD1.wait = NULL; USBD1.wait = NULL;
#endif
USBD1.otg = OTG_FS; USBD1.otg = OTG_FS;
USBD1.otgparams = &fsparams; USBD1.otgparams = &fsparams;
#if 0
#if defined(_CHIBIOS_RT_) #if defined(_CHIBIOS_RT_)
USBD1.tr = NULL; USBD1.tr = NULL;
/* Filling the thread working area here because the function /* Filling the thread working area here because the function
@ -750,13 +765,17 @@ void usb_lld_init(void) {
#endif /* CH_DBG_FILL_THREADS */ #endif /* CH_DBG_FILL_THREADS */
#endif /* defined(_CHIBIOS_RT_) */ #endif /* defined(_CHIBIOS_RT_) */
#endif #endif
#endif
#if STM32_USB_USE_OTG2 #if STM32_USB_USE_OTG2
usbObjectInit(&USBD2); usbObjectInit(&USBD2);
#if 0
USBD2.wait = NULL; USBD2.wait = NULL;
#endif
USBD2.otg = OTG_HS; USBD2.otg = OTG_HS;
USBD2.otgparams = &hsparams; USBD2.otgparams = &hsparams;
#if 0
#if defined(_CHIBIOS_RT_) #if defined(_CHIBIOS_RT_)
USBD2.tr = NULL; USBD2.tr = NULL;
/* Filling the thread working area here because the function /* Filling the thread working area here because the function
@ -771,6 +790,7 @@ void usb_lld_init(void) {
#endif /* CH_DBG_FILL_THREADS */ #endif /* CH_DBG_FILL_THREADS */
#endif /* defined(_CHIBIOS_RT_) */ #endif /* defined(_CHIBIOS_RT_) */
#endif #endif
#endif
} }
/** /**
@ -854,9 +874,10 @@ void usb_lld_start(USBDriver *usbp) {
} }
#endif #endif
#if 0
/* Clearing mask of TXFIFOs to be filled.*/ /* Clearing mask of TXFIFOs to be filled.*/
usbp->txpending = 0; usbp->txpending = 0;
#endif
/* PHY enabled.*/ /* PHY enabled.*/
otgp->PCGCCTL = 0; otgp->PCGCCTL = 0;
@ -906,6 +927,7 @@ void usb_lld_start(USBDriver *usbp) {
/* Clears all pending IRQs, if any. */ /* Clears all pending IRQs, if any. */
otgp->GINTSTS = 0xFFFFFFFF; otgp->GINTSTS = 0xFFFFFFFF;
#if 0
#if defined(_CHIBIOS_RT_) #if defined(_CHIBIOS_RT_)
/* Creates the data pump thread. Note, it is created only once.*/ /* Creates the data pump thread. Note, it is created only once.*/
if (usbp->tr == NULL) { if (usbp->tr == NULL) {
@ -922,7 +944,7 @@ void usb_lld_start(USBDriver *usbp) {
chSchRescheduleS(); chSchRescheduleS();
} }
#endif #endif
#endif
/* Global interrupts enable.*/ /* Global interrupts enable.*/
otgp->GAHBCFG |= GAHBCFG_GINTMSK; otgp->GAHBCFG |= GAHBCFG_GINTMSK;
} }
@ -945,8 +967,9 @@ void usb_lld_stop(USBDriver *usbp) {
active.*/ active.*/
otg_disable_ep(usbp); otg_disable_ep(usbp);
#if 0
usbp->txpending = 0; usbp->txpending = 0;
#endif
otgp->DAINTMSK = 0; otgp->DAINTMSK = 0;
otgp->GAHBCFG = 0; otgp->GAHBCFG = 0;
otgp->GCCFG = 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; usbp->otg->ie[ep].DIEPCTL &= ~DIEPCTL_STALL;
} }
#if 0
/** /**
* @brief USB data transfer loop. * @brief USB data transfer loop.
* @details This function must be executed by a system thread in order to * @details This function must be executed by a system thread in order to
@ -1391,6 +1415,7 @@ void usb_lld_pump(void *p) {
osalSysLock(); osalSysLock();
} }
} }
#endif
#endif /* HAL_USE_USB */ #endif /* HAL_USE_USB */

View File

@ -508,6 +508,7 @@ struct USBDriver {
* @brief Pointer to the next address in the packet memory. * @brief Pointer to the next address in the packet memory.
*/ */
uint32_t pmnext; uint32_t pmnext;
#if 0
/** /**
* @brief Mask of TXFIFOs to be filled by the pump thread. * @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); THD_WORKING_AREA(wa_pump, STM32_USB_OTG_THREAD_STACK_SIZE);
#endif #endif
#endif
}; };
/*===========================================================================*/ /*===========================================================================*/