/** * @brief Prepares for a receive operation. * * @param[in] usbp pointer to the @p USBDriver object * @param[in] ep endpoint number * * @notapi */ void usb_lld_prepare_receive(USBDriver *usbp, usbep_t ep) { uint32_t pcnt; USBOutEndpointState *osp = usbp->epc[ep]->out_state; /* Transfer initialization.*/ pcnt = (osp->rxsize + usbp->epc[ep]->out_maxsize - 1) / usbp->epc[ep]->out_maxsize; usbp->otg->oe[ep].DOEPTSIZ = DOEPTSIZ_STUPCNT(3) | DOEPTSIZ_PKTCNT(pcnt) | DOEPTSIZ_XFRSIZ(usbp->epc[ep]->out_maxsize); }
void Endpoint_t::Receive(uint32_t Len) { Uart.Printf("PrepRX L=%u\r\n", Len); // if(IsReceiving) return; // Prepare reception uint32_t Cnt = (Len + OutMaxSz - 1) / OutMaxSz; OTG_FS->oe[SelfN].DOEPTSIZ &= ~((uint32_t) 0x7F); OTG_FS->oe[SelfN].DOEPTSIZ |= DOEPTSIZ_PKTCNT(Cnt) | DOEPTSIZ_XFRSIZ(OutMaxSz); Uart.Printf("DOEPTSIZ: %X\r\n", OTG_FS->oe[0].DOEPTSIZ); // Start reception chSysLockFromIsr(); // IsReceiving = true; ClearOutNAK(); EnableOut(); chSysUnlockFromIsr(); }