24#include "usb_private.h"
25#include "usb_dwc_common.h"
30#define dev_base_address (usbd_dev->driver->base_address)
31#define REBASE(x) MMIO32((x) + (dev_base_address))
46 uint8_t dir = addr & 0x80;
53 }
else if (max_size >= 32) {
55 }
else if (max_size >= 16) {
76 usbd_dev->fifo_mem_top += max_size / 4;
85 usbd_dev->fifo_mem_top += max_size / 4;
92 | (addr << 22) | max_size;
95 usbd_dev->user_callback_ctr[addr][USB_TRANSACTION_IN] =
109 usbd_dev->user_callback_ctr[addr][USB_TRANSACTION_OUT] =
122 for (i = 1; i < 4; i++) {
194 const void *buf, uint16_t len)
196 const uint32_t *buf32 = buf;
197#if defined(__ARM_ARCH_6M__)
198 const uint8_t *buf8 = buf;
217#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
218 for (i = len; i > 0; i -= 4) {
223#if defined(__ARM_ARCH_6M__)
225 if (((uint32_t)buf8 & 0x3) == 0) {
226 for (i = len; i > 0; i -= 4) {
230 for (i = len; i > 0; i -= 4) {
231 memcpy(&word32, buf8, 4);
242 void *buf, uint16_t len)
245 uint32_t *buf32 = buf;
246#if defined(__ARM_ARCH_6M__)
259#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
260 for (i = len; i >= 4; i -= 4) {
266#if defined(__ARM_ARCH_6M__)
268 if (((uint32_t)buf8 & 0x3) == 0) {
269 for (i = len; i >= 4; i -= 4) {
274 for (i = len; i >= 4; i -= 4) {
276 memcpy(buf8, &word32, 4);
281 buf32 = (uint32_t *)buf8;
294 memcpy(buf32, &extra, i);
342 for (i = 0; i < 4; i++) {
346 [USB_TRANSACTION_IN]) {
382 type = USB_TRANSACTION_SETUP;
384 type = USB_TRANSACTION_OUT;
387 if (type == USB_TRANSACTION_SETUP
398 if (type == USB_TRANSACTION_SETUP) {
400 }
else if (
usbd_dev->user_callback_ctr[ep][type]) {
405 for (i = 0; i <
usbd_dev->rxbcnt; i += 4) {
414 if (
usbd_dev->user_callback_suspend) {
421 if (
usbd_dev->user_callback_resume) {
struct _usbd_device usbd_device
void _usbd_reset(usbd_device *usbd_dev)
#define OTG_DIEPCTL0_MPSIZ_32
#define OTG_DIEPCTL0_MPSIZ_8
#define OTG_DIEPCTL0_TXFNUM_MASK
#define OTG_GRSTCTL_AHBIDL
#define OTG_DIEPCTL0_USBAEP
#define OTG_GRXSTSP_PKTSTS_MASK
#define OTG_GINTSTS_RXFLVL
#define OTG_DIEPSIZ0_XFRSIZ_MASK
#define OTG_DIEPCTL0_MPSIZ_64
#define OTG_DIEPSIZ0_STUPCNT_1
#define OTG_DIEPCTLX_SD0PID
#define OTG_GRXSTSP_PKTSTS_SETUP_COMP
#define OTG_GRXSTSP_EPNUM_MASK
#define OTG_DIEPCTL0_SNAK
#define OTG_DIEPINTX_XFRC
#define OTG_DOEPCTL0_EPENA
#define OTG_DIEPCTL0_STALL
#define OTG_GRXSTSP_PKTSTS_OUT_COMP
#define OTG_GRXSTSP_BCNT_MASK
#define OTG_DOEPCTL0_EPDIS
#define OTG_DOEPCTL0_CNAK
#define OTG_DOEPCTL0_USBAEP
#define OTG_GRXSTSP_PKTSTS_SETUP
#define OTG_GRSTCTL_TXFFLSH
#define OTG_DIEPCTL0_MPSIZ_16
#define OTG_GRXSTSP_PKTSTS_OUT
#define OTG_DIEPCTL0_EPDIS
#define OTG_GINTSTS_WKUPINT
#define OTG_DOEPCTL0_STALL
#define OTG_DOEPCTL0_SNAK
#define OTG_DIEPINTX_INEPNE
#define OTG_GRSTCTL_TXFNUM_ALL
#define OTG_DIEPCTL0_CNAK
#define OTG_GINTSTS_ENUMDNE
#define OTG_GRSTCTL_RXFFLSH
#define OTG_DIEPSIZ0_PKTCNT
#define OTG_GINTSTS_USBSUSP
#define OTG_DIEPCTL0_EPENA
#define OTG_DOEPCTLX_SD0PID
uint8_t dwc_ep_stall_get(usbd_device *usbd_dev, uint8_t addr)
void dwc_disconnect(usbd_device *usbd_dev, bool disconnected)
void dwc_endpoints_reset(usbd_device *usbd_dev)
static void dwc_flush_txfifo(usbd_device *usbd_dev, int ep)
uint16_t dwc_ep_write_packet(usbd_device *usbd_dev, uint8_t addr, const void *buf, uint16_t len)
uint16_t dwc_ep_read_packet(usbd_device *usbd_dev, uint8_t addr, void *buf, uint16_t len)
void dwc_set_address(usbd_device *usbd_dev, uint8_t addr)
void dwc_ep_nak_set(usbd_device *usbd_dev, uint8_t addr, uint8_t nak)
void dwc_ep_stall_set(usbd_device *usbd_dev, uint8_t addr, uint8_t stall)
void dwc_ep_setup(usbd_device *usbd_dev, uint8_t addr, uint8_t type, uint16_t max_size, void(*callback)(usbd_device *usbd_dev, uint8_t ep))
void dwc_poll(usbd_device *usbd_dev)
static struct _usbd_device usbd_dev