libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
#include <string.h>
#include <libopencm3/cm3/common.h>
#include <libopencm3/usb/usbd.h>
#include <libopencm3/usb/dwc/otg_common.h>
#include "usb_private.h"
#include "usb_dwc_common.h"
Go to the source code of this file.
Macros | |
#define | dev_base_address (usbd_dev->driver->base_address) |
#define | REBASE(x) MMIO32((x) + (dev_base_address)) |
Functions | |
void | dwc_set_address (usbd_device *usbd_dev, uint8_t addr) |
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_endpoints_reset (usbd_device *usbd_dev) |
void | dwc_ep_stall_set (usbd_device *usbd_dev, uint8_t addr, uint8_t stall) |
uint8_t | dwc_ep_stall_get (usbd_device *usbd_dev, uint8_t addr) |
void | dwc_ep_nak_set (usbd_device *usbd_dev, uint8_t addr, uint8_t nak) |
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) |
static void | dwc_flush_txfifo (usbd_device *usbd_dev, int ep) |
void | dwc_poll (usbd_device *usbd_dev) |
void | dwc_disconnect (usbd_device *usbd_dev, bool disconnected) |
#define dev_base_address (usbd_dev->driver->base_address) |
Definition at line 30 of file usb_dwc_common.c.
#define REBASE | ( | x | ) | MMIO32((x) + (dev_base_address)) |
Definition at line 31 of file usb_dwc_common.c.
void dwc_disconnect | ( | usbd_device * | usbd_dev, |
bool | disconnected | ||
) |
Definition at line 441 of file usb_dwc_common.c.
References OTG_DCTL, OTG_DCTL_SDIS, and REBASE.
void dwc_endpoints_reset | ( | usbd_device * | usbd_dev | ) |
Definition at line 115 of file usb_dwc_common.c.
References OTG_DIEPCTL, OTG_DIEPCTL0_EPDIS, OTG_DIEPCTL0_EPENA, OTG_DOEPCTL, OTG_DOEPCTL0_EPDIS, OTG_DOEPCTL0_EPENA, OTG_GRSTCTL, OTG_GRSTCTL_RXFFLSH, OTG_GRSTCTL_TXFFLSH, OTG_GRSTCTL_TXFNUM_ALL, REBASE, and usbd_dev.
void dwc_ep_nak_set | ( | usbd_device * | usbd_dev, |
uint8_t | addr, | ||
uint8_t | nak | ||
) |
Definition at line 177 of file usb_dwc_common.c.
References OTG_DOEPCTL, OTG_DOEPCTL0_CNAK, OTG_DOEPCTL0_SNAK, REBASE, and usbd_dev.
uint16_t dwc_ep_read_packet | ( | usbd_device * | usbd_dev, |
uint8_t | addr, | ||
void * | buf, | ||
uint16_t | len | ||
) |
Definition at line 241 of file usb_dwc_common.c.
References OTG_FIFO, REBASE, and usbd_dev.
Referenced by dwc_poll().
void dwc_ep_setup | ( | usbd_device * | usbd_dev, |
uint8_t | addr, | ||
uint8_t | type, | ||
uint16_t | max_size, | ||
void(*)(usbd_device *usbd_dev, uint8_t ep) | callback | ||
) |
Definition at line 38 of file usb_dwc_common.c.
References OTG_DIEPCTL, OTG_DIEPCTL0, OTG_DIEPCTL0_CNAK, OTG_DIEPCTL0_EPENA, OTG_DIEPCTL0_MPSIZ_16, OTG_DIEPCTL0_MPSIZ_32, OTG_DIEPCTL0_MPSIZ_64, OTG_DIEPCTL0_MPSIZ_8, OTG_DIEPCTL0_SNAK, OTG_DIEPCTL0_USBAEP, OTG_DIEPCTLX_SD0PID, OTG_DIEPSIZ0_PKTCNT, OTG_DIEPSIZ0_STUPCNT_1, OTG_DIEPSIZ0_XFRSIZ_MASK, OTG_DIEPTSIZ, OTG_DIEPTSIZ0, OTG_DIEPTXF, OTG_DOEPCTL, OTG_DOEPCTL0_EPENA, OTG_DOEPCTL0_USBAEP, OTG_DOEPCTLX_SD0PID, OTG_DOEPTSIZ, OTG_GNPTXFSIZ, REBASE, and usbd_dev.
uint8_t dwc_ep_stall_get | ( | usbd_device * | usbd_dev, |
uint8_t | addr | ||
) |
Definition at line 165 of file usb_dwc_common.c.
References OTG_DIEPCTL, OTG_DIEPCTL0_STALL, OTG_DOEPCTL, OTG_DOEPCTL0_STALL, and REBASE.
void dwc_ep_stall_set | ( | usbd_device * | usbd_dev, |
uint8_t | addr, | ||
uint8_t | stall | ||
) |
Definition at line 136 of file usb_dwc_common.c.
References OTG_DIEPCTL, OTG_DIEPCTL0_STALL, OTG_DIEPCTLX_SD0PID, OTG_DOEPCTL, OTG_DOEPCTL0_STALL, OTG_DOEPCTLX_SD0PID, and REBASE.
uint16_t dwc_ep_write_packet | ( | usbd_device * | usbd_dev, |
uint8_t | addr, | ||
const void * | buf, | ||
uint16_t | len | ||
) |
Definition at line 193 of file usb_dwc_common.c.
References OTG_DIEPCTL, OTG_DIEPCTL0_CNAK, OTG_DIEPCTL0_EPENA, OTG_DIEPSIZ0_PKTCNT, OTG_DIEPTSIZ, OTG_FIFO, and REBASE.
|
static |
Definition at line 300 of file usb_dwc_common.c.
References OTG_DIEPCTL, OTG_DIEPCTL0_SNAK, OTG_DIEPCTL0_TXFNUM_MASK, OTG_DIEPINT, OTG_DIEPINTX_INEPNE, OTG_DIEPTSIZ, OTG_GRSTCTL, OTG_GRSTCTL_AHBIDL, OTG_GRSTCTL_TXFFLSH, and REBASE.
Referenced by dwc_poll().
void dwc_poll | ( | usbd_device * | usbd_dev | ) |
Definition at line 324 of file usb_dwc_common.c.
References _usbd_reset(), dwc_ep_read_packet(), dwc_flush_txfifo(), OTG_DIEPINT, OTG_DIEPINTX_XFRC, OTG_DIEPSIZ0_PKTCNT, OTG_DIEPTSIZ, OTG_DOEPCTL, OTG_DOEPCTL0_CNAK, OTG_DOEPCTL0_EPENA, OTG_DOEPCTL0_SNAK, OTG_DOEPTSIZ, OTG_FIFO, OTG_GINTMSK, OTG_GINTMSK_SOFM, OTG_GINTSTS, OTG_GINTSTS_ENUMDNE, OTG_GINTSTS_RXFLVL, OTG_GINTSTS_SOF, OTG_GINTSTS_USBSUSP, OTG_GINTSTS_WKUPINT, OTG_GRXSTSP, OTG_GRXSTSP_BCNT_MASK, OTG_GRXSTSP_EPNUM_MASK, OTG_GRXSTSP_PKTSTS_MASK, OTG_GRXSTSP_PKTSTS_OUT, OTG_GRXSTSP_PKTSTS_OUT_COMP, OTG_GRXSTSP_PKTSTS_SETUP, OTG_GRXSTSP_PKTSTS_SETUP_COMP, REBASE, and usbd_dev.
void dwc_set_address | ( | usbd_device * | usbd_dev, |
uint8_t | addr | ||
) |
Definition at line 33 of file usb_dwc_common.c.