26#include "../../usb/usb_private.h"
27#include "st_usbfs_core.h"
66 size = ((size - 1) >> 5) & 0x1F;
67 realsize = (size + 1) << 5;
72 size = (size + 1) >> 1;
86 const uint16_t typelookup[] = {
92 uint8_t dir = addr & 0x80;
99 if (dir || (addr == 0)) {
102 dev->user_callback_ctr[addr][USB_TRANSACTION_IN] =
107 dev->pm_top += max_size;
115 dev->user_callback_ctr[addr][USB_TRANSACTION_OUT] =
120 dev->pm_top += realsize;
129 for (i = 1; i < 8; i++) {
133 dev->pm_top = USBD_PM_TOP + (2 * dev->desc->bMaxPacketSize0);
201 const void *buf, uint16_t len)
218 void *buf, uint16_t len)
242 dev->pm_top = USBD_PM_TOP;
254 type = USB_TRANSACTION_SETUP;
257 type = USB_TRANSACTION_OUT;
260 type = USB_TRANSACTION_IN;
264 if (dev->user_callback_ctr[ep][type]) {
265 dev->user_callback_ctr[ep][type] (dev, ep);
273 if (dev->user_callback_suspend) {
274 dev->user_callback_suspend();
280 if (dev->user_callback_resume) {
281 dev->user_callback_resume();
287 if (dev->user_callback_sof) {
288 dev->user_callback_sof();
292 if (dev->user_callback_sof) {
#define USB_CLR_EP_TX_CTR(EP)
#define USB_EP_TX_STAT_DISABLED
#define USB_EP_TYPE_CONTROL
#define USB_EP_TX_STAT_NAK
#define USB_EP_TX_STAT_STALL
#define USB_GET_EP_RX_COUNT(EP)
#define USB_SET_EP_RX_STAT(EP, STAT)
#define USB_CLR_ISTR_SUSP()
#define USB_EP_RX_STAT_VALID
#define USB_EP_RX_STAT_STALL
#define USB_SET_EP_TX_STAT(EP, STAT)
#define USB_SET_EP_RX_ADDR(EP, ADDR)
#define USB_CLR_ISTR_WKUP()
#define USB_SET_EP_ADDR(EP, ADDR)
#define USB_EP_TYPE_INTERRUPT
#define USB_EP_RX_STAT_NAK
#define USB_CLR_EP_TX_DTOG(EP)
#define USB_SET_EP_TX_ADDR(EP, ADDR)
#define USB_CLR_ISTR_RESET()
#define USB_SET_EP_TX_COUNT(EP, COUNT)
#define USB_CLR_EP_RX_DTOG(EP)
#define USB_EP_RX_STAT_DISABLED
#define USB_SET_EP_TYPE(EP, TYPE)
#define USB_CLR_EP_RX_CTR(EP)
#define USB_CLR_ISTR_SOF()
#define USB_EP_TX_STAT_VALID
#define USB_SET_EP_RX_COUNT(EP, COUNT)
struct _usbd_device usbd_device
void _usbd_reset(usbd_device *usbd_dev)
#define USB_ENDPOINT_ATTR_BULK
#define USB_ENDPOINT_ATTR_INTERRUPT
#define USB_ENDPOINT_ATTR_CONTROL
#define USB_ENDPOINT_ATTR_ISOCHRONOUS
void st_usbfs_poll(usbd_device *dev)
void st_usbfs_ep_nak_set(usbd_device *dev, uint8_t addr, uint8_t nak)
uint16_t st_usbfs_ep_write_packet(usbd_device *dev, uint8_t addr, const void *buf, uint16_t len)
struct _usbd_device st_usbfs_dev
void st_usbfs_ep_setup(usbd_device *dev, uint8_t addr, uint8_t type, uint16_t max_size, void(*callback)(usbd_device *usbd_dev, uint8_t ep))
uint8_t st_usbfs_force_nak[8]
uint8_t st_usbfs_ep_stall_get(usbd_device *dev, uint8_t addr)
void st_usbfs_endpoints_reset(usbd_device *dev)
uint16_t st_usbfs_ep_read_packet(usbd_device *dev, uint8_t addr, void *buf, uint16_t len)
uint16_t st_usbfs_set_ep_rx_bufsize(usbd_device *dev, uint8_t ep, uint32_t size)
Set the receive buffer size for a given USB endpoint.
void st_usbfs_ep_stall_set(usbd_device *dev, uint8_t addr, uint8_t stall)
void st_usbfs_set_address(usbd_device *dev, uint8_t addr)
void st_usbfs_copy_to_pm(volatile void *vPM, const void *buf, uint16_t len)
void st_usbfs_copy_from_pm(void *buf, const volatile void *vPM, uint16_t len)
Copy a data buffer from packet memory.
#define USB_GET_EP_TX_BUFF(EP)
#define USB_GET_EP_RX_BUFF(EP)
static struct _usbd_device usbd_dev