33#include "usb_private.h"
38#define RX_FIFO_SIZE 256
50#define ENDPOINT_COUNT 4
109 void (*callback) (
usbd_device *usbd_dev, uint8_t ep))
115 uint8_t dir = addr & 0x80;
120 if (max_size >= 64) {
122 }
else if (max_size >= 32) {
124 }
else if (max_size >= 16) {
144 usbd_dev->driver->rx_fifo_size;
145 usbd_dev->fifo_mem_top += max_size / 4;
146 usbd_dev->fifo_mem_top_ep0 = usbd_dev->fifo_mem_top;
153 usbd_dev->fifo_mem_top;
154 usbd_dev->fifo_mem_top += max_size / 4;
161 | (addr << 22) | max_size;
164 usbd_dev->user_callback_ctr[addr][USB_TRANSACTION_IN] =
178 usbd_dev->user_callback_ctr[addr][USB_TRANSACTION_OUT] =
187 usbd_dev->fifo_mem_top = usbd_dev->fifo_mem_top_ep0;
242 usbd_dev->force_nak[addr] = nak;
252 const void *buf, uint16_t len)
255 const uint32_t *buf32 = buf;
272 for (i = len; i > 0; i -= 4) {
280 void *buf, uint16_t len)
283 uint32_t *buf32 = buf;
286 len = MIN(len, usbd_dev->rxbcnt);
287 usbd_dev->rxbcnt -= len;
290 for (i = len; i >= 4; i -= 4) {
296 memcpy(buf32, &extra, i);
301 (usbd_dev->force_nak[addr] ?
316 usbd_dev->fifo_mem_top = usbd_dev->driver->rx_fifo_size;
334 type = USB_TRANSACTION_SETUP;
336 type = USB_TRANSACTION_OUT;
347 for (i = 0; i < 1000; i++) {
351 if (usbd_dev->user_callback_ctr[ep][type]) {
352 usbd_dev->user_callback_ctr[ep][type] (usbd_dev, ep);
356 for (i = 0; i < usbd_dev->rxbcnt; i += 4) {
360 usbd_dev->rxbcnt = 0;
370 if (usbd_dev->user_callback_ctr[i]
371 [USB_TRANSACTION_IN]) {
372 usbd_dev->user_callback_ctr[i]
373 [USB_TRANSACTION_IN](usbd_dev, i);
381 if (usbd_dev->user_callback_suspend) {
382 usbd_dev->user_callback_suspend();
388 if (usbd_dev->user_callback_resume) {
389 usbd_dev->user_callback_resume();
395 if (usbd_dev->user_callback_sof) {
396 usbd_dev->user_callback_sof();
401 if (usbd_dev->user_callback_sof) {
432 .set_address_before_status = 1,
Dispatcher for the base address definitions, depending on the particular Gecko family.
#define CMU_HFCORECLKEN0_USBC
#define CMU_HFCORECLKEN0_USB
#define CMU_STATUS_USBCHFCLKSEL
#define CMU_CMD_USBCCLKSEL_HFCLKNODIV
#define USB_GRXSTSP_PKTSTS_OUT
#define USB_DIEP0TSIZ_STUPCNT_1
#define USB_GAHBCFG_GLBLINTRMSK
#define USB_GRXSTSP_EPNUM_MASK
#define USB_DIEP_INT_XFRC
#define USB_DIEP0CTL_SNAK
#define USB_DIEP0CTL_MPSIZ_16
#define USB_DOEP0CTL_EPENA
#define USB_GRSTCTL_AHBIDL
#define USB_DIEP0CTL_USBAEP
#define USB_DIEPx_TSIZ(x)
#define USB_GINTMSK_IEPINT
#define USB_GRSTCTL_CSRST
#define USB_GINTMSK_RXFLVLM
#define USB_DOEP0CTL_SD0PID
#define USB_ROUTE_DMPUPEN
#define USB_GRXSTSP_PKTSTS_MASK
#define USB_DIEP0CTL_SD0PID
#define USB_DIEP0CTL_MPSIZ_8
#define USB_GUSBCFG_TRDT_16BIT
#define USB_DIEP0CTL_EPENA
#define USB_GINTSTS_ENUMDNE
#define USB_DOEP0CTL_STALL
#define USB_DIEP0CTL_MPSIZ_32
#define USB_GINTSTS_WKUPINT
#define USB_GINTMSK_USBSUSPM
#define USB_GINTSTS_USBSUSP
#define USB_GINTSTS_RXFLVL
#define USB_DIEPMSK_XFRCM
#define USB_DIEP0CTL_STALL
#define USB_DIEP0TSIZ_XFRSIZ_MASK
#define USB_GRXSTSP_PKTSTS_SETUP
#define USB_GUSBCFG_FDMOD
#define USB_DOEPx_TSIZ(x)
#define USB_DIEP0TSIZ_PKTCNT
#define USB_DIEP0CTL_CNAK
#define USB_GRXSTSP_BCNT_MASK
#define USB_DOEP0CTL_USBAEP
#define USB_GINTMSK_ENUMDNEM
#define USB_DIEP0CTL_MPSIZ_64
#define USB_DOEP0CTL_SNAK
#define USB_DOEP0CTL_CNAK
struct _usbd_device usbd_device
void _usbd_reset(usbd_device *usbd_dev)
static void efm32lg_disconnect(usbd_device *usbd_dev, bool disconnected)
static void efm32lg_endpoints_reset(usbd_device *usbd_dev)
static struct _usbd_device _usbd_dev
static void efm32lg_ep_nak_set(usbd_device *usbd_dev, uint8_t addr, uint8_t nak)
static uint8_t efm32lg_ep_stall_get(usbd_device *usbd_dev, uint8_t addr)
static void efm32lg_set_address(usbd_device *usbd_dev, uint8_t addr)
static void efm32lg_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))
static uint16_t efm32lg_ep_write_packet(usbd_device *usbd_dev, uint8_t addr, const void *buf, uint16_t len)
static uint16_t efm32lg_ep_read_packet(usbd_device *usbd_dev, uint8_t addr, void *buf, uint16_t len)
const struct _usbd_driver efm32lg_usb_driver
static void efm32lg_poll(usbd_device *usbd_dev)
static usbd_device * efm32lg_usbd_init(void)
Initialize the USB_FS device controller hardware of the STM32.
static void efm32lg_ep_stall_set(usbd_device *usbd_dev, uint8_t addr, uint8_t stall)