Experimental STM32 OTG fix.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6901 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
18f5f09904
commit
86d3b56bfb
|
@ -33,7 +33,9 @@
|
|||
/* Driver local definitions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#define TRDT_VALUE 5
|
||||
#define TRDT_VALUE 5
|
||||
|
||||
#define EP0_MAX_INSIZE 64
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver exported variables. */
|
||||
|
@ -556,7 +558,23 @@ static void otg_epin_handler(USBDriver *usbp, usbep_t ep) {
|
|||
}
|
||||
if ((epint & DIEPINT_XFRC) && (otgp->DIEPMSK & DIEPMSK_XFRCM)) {
|
||||
/* Transmit transfer complete.*/
|
||||
_usb_isr_invoke_in_cb(usbp, ep);
|
||||
USBInEndpointState *isp = usbp->epc[ep]->in_state;
|
||||
|
||||
if (isp->txsize < isp->totsize) {
|
||||
/* In case the transaction covered only part of the total transfer
|
||||
then another transaction is immediately started in order to
|
||||
cover the remaining.*/
|
||||
isp->txsize = isp->totsize - isp->txsize;
|
||||
isp->txcnt = 0;
|
||||
usb_lld_prepare_transmit(usbp, ep);
|
||||
chSysLockFromIsr();
|
||||
usb_lld_start_in(usbp, ep);
|
||||
chSysUnlockFromIsr();
|
||||
}
|
||||
else {
|
||||
/* End on IN transfer.*/
|
||||
_usb_isr_invoke_in_cb(usbp, ep);
|
||||
}
|
||||
}
|
||||
if ((epint & DIEPINT_TXFE) &&
|
||||
(otgp->DIEPEMPMSK & DIEPEMPMSK_INEPTXFEM(ep))) {
|
||||
|
@ -1215,18 +1233,21 @@ void usb_lld_prepare_transmit(USBDriver *usbp, usbep_t ep) {
|
|||
USBInEndpointState *isp = usbp->epc[ep]->in_state;
|
||||
|
||||
/* Transfer initialization.*/
|
||||
isp->totsize = isp->txsize;
|
||||
if (isp->txsize == 0) {
|
||||
/* Special case, sending zero size packet.*/
|
||||
usbp->otg->ie[ep].DIEPTSIZ = DIEPTSIZ_PKTCNT(1) | DIEPTSIZ_XFRSIZ(0);
|
||||
}
|
||||
else {
|
||||
if ((ep == 0) && (isp->txsize > EP0_MAX_INSIZE))
|
||||
isp->txsize = EP0_MAX_INSIZE;
|
||||
|
||||
/* Normal case.*/
|
||||
uint32_t pcnt = (isp->txsize + usbp->epc[ep]->in_maxsize - 1) /
|
||||
usbp->epc[ep]->in_maxsize;
|
||||
usbp->otg->ie[ep].DIEPTSIZ = DIEPTSIZ_PKTCNT(pcnt) |
|
||||
DIEPTSIZ_XFRSIZ(usbp->epc[ep]->in_state->txsize);
|
||||
DIEPTSIZ_XFRSIZ(isp->txsize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -226,6 +226,10 @@ typedef struct {
|
|||
OutputQueue *txqueue;
|
||||
} queue;
|
||||
} mode;
|
||||
/**
|
||||
* @brief Total transmit transfer size.
|
||||
*/
|
||||
size_t totsize;
|
||||
} USBInEndpointState;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue