Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thirdpin/libopencm3.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/usb
diff options
context:
space:
mode:
authorSebastian Holzapfel <seb.holzapfel@data61.csiro.au>2018-02-13 00:33:03 +0300
committerKarl Palsson <karlp@tweak.net.au>2018-03-03 01:42:05 +0300
commita2ee90fbfedf41230b2ec0ccd5d84c3e55d1f7d0 (patch)
treea3c509aedae78b9e5812d61d73e82cb398d31694 /lib/usb
parent3c855e75d1c2af46ce80de21594535fc6f43f645 (diff)
usb: stm32fx07 -> usb_dwc_common
The stm32fx07 is common DesignWare IP, used in both STM32 and EFM32 chips. Rename the files to make this more clear, and easier to use in other targets.
Diffstat (limited to 'lib/usb')
-rw-r--r--lib/usb/usb_dwc_common.c (renamed from lib/usb/usb_fx07_common.c)32
-rw-r--r--lib/usb/usb_dwc_common.h (renamed from lib/usb/usb_fx07_common.h)26
-rw-r--r--lib/usb/usb_f107.c24
-rw-r--r--lib/usb/usb_f207.c24
4 files changed, 52 insertions, 54 deletions
diff --git a/lib/usb/usb_fx07_common.c b/lib/usb/usb_dwc_common.c
index dae91409..4518adbd 100644
--- a/lib/usb/usb_fx07_common.c
+++ b/lib/usb/usb_dwc_common.c
@@ -19,12 +19,10 @@
#include <string.h>
#include <libopencm3/cm3/common.h>
-#include <libopencm3/stm32/tools.h>
-#include <libopencm3/stm32/otg_fs.h>
-#include <libopencm3/stm32/otg_hs.h>
#include <libopencm3/usb/usbd.h>
+#include <libopencm3/usb/dwc/otg_common.h>
#include "usb_private.h"
-#include "usb_fx07_common.h"
+#include "usb_dwc_common.h"
/* The FS core and the HS core have the same register layout.
* As the code can be used on both cores, the registers offset is modified
@@ -32,12 +30,12 @@
#define dev_base_address (usbd_dev->driver->base_address)
#define REBASE(x) MMIO32((x) + (dev_base_address))
-void stm32fx07_set_address(usbd_device *usbd_dev, uint8_t addr)
+void dwc_set_address(usbd_device *usbd_dev, uint8_t addr)
{
REBASE(OTG_DCFG) = (REBASE(OTG_DCFG) & ~OTG_DCFG_DAD) | (addr << 4);
}
-void stm32fx07_ep_setup(usbd_device *usbd_dev, uint8_t addr, uint8_t type,
+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))
{
@@ -114,7 +112,7 @@ void stm32fx07_ep_setup(usbd_device *usbd_dev, uint8_t addr, uint8_t type,
}
}
-void stm32fx07_endpoints_reset(usbd_device *usbd_dev)
+void dwc_endpoints_reset(usbd_device *usbd_dev)
{
int i;
/* The core resets the endpoints automatically on reset. */
@@ -135,7 +133,7 @@ void stm32fx07_endpoints_reset(usbd_device *usbd_dev)
| OTG_GRSTCTL_RXFFLSH;
}
-void stm32fx07_ep_stall_set(usbd_device *usbd_dev, uint8_t addr, uint8_t stall)
+void dwc_ep_stall_set(usbd_device *usbd_dev, uint8_t addr, uint8_t stall)
{
if (addr == 0) {
if (stall) {
@@ -164,7 +162,7 @@ void stm32fx07_ep_stall_set(usbd_device *usbd_dev, uint8_t addr, uint8_t stall)
}
}
-uint8_t stm32fx07_ep_stall_get(usbd_device *usbd_dev, uint8_t addr)
+uint8_t dwc_ep_stall_get(usbd_device *usbd_dev, uint8_t addr)
{
/* Return non-zero if STALL set. */
if (addr & 0x80) {
@@ -176,7 +174,7 @@ uint8_t stm32fx07_ep_stall_get(usbd_device *usbd_dev, uint8_t addr)
}
}
-void stm32fx07_ep_nak_set(usbd_device *usbd_dev, uint8_t addr, uint8_t nak)
+void dwc_ep_nak_set(usbd_device *usbd_dev, uint8_t addr, uint8_t nak)
{
/* It does not make sense to force NAK on IN endpoints. */
if (addr & 0x80) {
@@ -192,7 +190,7 @@ void stm32fx07_ep_nak_set(usbd_device *usbd_dev, uint8_t addr, uint8_t nak)
}
}
-uint16_t stm32fx07_ep_write_packet(usbd_device *usbd_dev, uint8_t addr,
+uint16_t dwc_ep_write_packet(usbd_device *usbd_dev, uint8_t addr,
const void *buf, uint16_t len)
{
const uint32_t *buf32 = buf;
@@ -218,7 +216,7 @@ uint16_t stm32fx07_ep_write_packet(usbd_device *usbd_dev, uint8_t addr,
return len;
}
-uint16_t stm32fx07_ep_read_packet(usbd_device *usbd_dev, uint8_t addr,
+uint16_t dwc_ep_read_packet(usbd_device *usbd_dev, uint8_t addr,
void *buf, uint16_t len)
{
int i;
@@ -251,7 +249,7 @@ uint16_t stm32fx07_ep_read_packet(usbd_device *usbd_dev, uint8_t addr,
return len;
}
-static void stm32fx07_flush_txfifo(usbd_device *usbd_dev, int ep)
+static void dwc_flush_txfifo(usbd_device *usbd_dev, int ep)
{
uint32_t fifo;
/* set IN endpoint NAK */
@@ -275,7 +273,7 @@ static void stm32fx07_flush_txfifo(usbd_device *usbd_dev, int ep)
}
}
-void stm32fx07_poll(usbd_device *usbd_dev)
+void dwc_poll(usbd_device *usbd_dev)
{
/* Read interrupt status register. */
uint32_t intsts = REBASE(OTG_GINTSTS);
@@ -338,10 +336,10 @@ void stm32fx07_poll(usbd_device *usbd_dev)
/* SETUP received but there is still something stuck
* in the transmit fifo. Flush it.
*/
- stm32fx07_flush_txfifo(usbd_dev, ep);
+ dwc_flush_txfifo(usbd_dev, ep);
}
- /* Save packet size for stm32f107_ep_read_packet(). */
+ /* Save packet size for dwc_ep_read_packet(). */
usbd_dev->rxbcnt = (rxstsp & OTG_GRXSTSP_BCNT_MASK) >> 4;
if (usbd_dev->user_callback_ctr[ep][type]) {
@@ -385,7 +383,7 @@ void stm32fx07_poll(usbd_device *usbd_dev)
}
}
-void stm32fx07_disconnect(usbd_device *usbd_dev, bool disconnected)
+void dwc_disconnect(usbd_device *usbd_dev, bool disconnected)
{
if (disconnected) {
REBASE(OTG_DCTL) |= OTG_DCTL_SDIS;
diff --git a/lib/usb/usb_fx07_common.h b/lib/usb/usb_dwc_common.h
index 31c40304..34ed3002 100644
--- a/lib/usb/usb_fx07_common.h
+++ b/lib/usb/usb_dwc_common.h
@@ -17,23 +17,23 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __USB_FX07_COMMON_H_
-#define __USB_FX07_COMMON_H_
+#ifndef __USB_DWC_COMMON_H_
+#define __USB_DWC_COMMON_H_
-void stm32fx07_set_address(usbd_device *usbd_dev, uint8_t addr);
-void stm32fx07_ep_setup(usbd_device *usbd_dev, uint8_t addr, uint8_t type,
+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 stm32fx07_endpoints_reset(usbd_device *usbd_dev);
-void stm32fx07_ep_stall_set(usbd_device *usbd_dev, uint8_t addr, uint8_t stall);
-uint8_t stm32fx07_ep_stall_get(usbd_device *usbd_dev, uint8_t addr);
-void stm32fx07_ep_nak_set(usbd_device *usbd_dev, uint8_t addr, uint8_t nak);
-uint16_t stm32fx07_ep_write_packet(usbd_device *usbd_dev, uint8_t addr,
+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 stm32fx07_ep_read_packet(usbd_device *usbd_dev, uint8_t addr,
+uint16_t dwc_ep_read_packet(usbd_device *usbd_dev, uint8_t addr,
void *buf, uint16_t len);
-void stm32fx07_poll(usbd_device *usbd_dev);
-void stm32fx07_disconnect(usbd_device *usbd_dev, bool disconnected);
+void dwc_poll(usbd_device *usbd_dev);
+void dwc_disconnect(usbd_device *usbd_dev, bool disconnected);
-#endif /* __USB_FX07_COMMON_H_ */
+#endif /* __USB_DWC_COMMON_H_ */
diff --git a/lib/usb/usb_f107.c b/lib/usb/usb_f107.c
index 7f7902cc..52df7172 100644
--- a/lib/usb/usb_f107.c
+++ b/lib/usb/usb_f107.c
@@ -20,11 +20,11 @@
#include <string.h>
#include <libopencm3/cm3/common.h>
#include <libopencm3/stm32/tools.h>
-#include <libopencm3/stm32/otg_fs.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/usb/usbd.h>
+#include <libopencm3/usb/dwc/otg_fs.h>
#include "usb_private.h"
-#include "usb_fx07_common.h"
+#include "usb_dwc_common.h"
/* Receive FIFO size in 32-bit words. */
#define RX_FIFO_SIZE 128
@@ -35,16 +35,16 @@ static struct _usbd_device usbd_dev;
const struct _usbd_driver stm32f107_usb_driver = {
.init = stm32f107_usbd_init,
- .set_address = stm32fx07_set_address,
- .ep_setup = stm32fx07_ep_setup,
- .ep_reset = stm32fx07_endpoints_reset,
- .ep_stall_set = stm32fx07_ep_stall_set,
- .ep_stall_get = stm32fx07_ep_stall_get,
- .ep_nak_set = stm32fx07_ep_nak_set,
- .ep_write_packet = stm32fx07_ep_write_packet,
- .ep_read_packet = stm32fx07_ep_read_packet,
- .poll = stm32fx07_poll,
- .disconnect = stm32fx07_disconnect,
+ .set_address = dwc_set_address,
+ .ep_setup = dwc_ep_setup,
+ .ep_reset = dwc_endpoints_reset,
+ .ep_stall_set = dwc_ep_stall_set,
+ .ep_stall_get = dwc_ep_stall_get,
+ .ep_nak_set = dwc_ep_nak_set,
+ .ep_write_packet = dwc_ep_write_packet,
+ .ep_read_packet = dwc_ep_read_packet,
+ .poll = dwc_poll,
+ .disconnect = dwc_disconnect,
.base_address = USB_OTG_FS_BASE,
.set_address_before_status = 1,
.rx_fifo_size = RX_FIFO_SIZE,
diff --git a/lib/usb/usb_f207.c b/lib/usb/usb_f207.c
index 40f1efce..4a1190aa 100644
--- a/lib/usb/usb_f207.c
+++ b/lib/usb/usb_f207.c
@@ -20,11 +20,11 @@
#include <string.h>
#include <libopencm3/cm3/common.h>
#include <libopencm3/stm32/tools.h>
-#include <libopencm3/stm32/otg_hs.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/usb/usbd.h>
+#include <libopencm3/usb/dwc/otg_hs.h>
#include "usb_private.h"
-#include "usb_fx07_common.h"
+#include "usb_dwc_common.h"
/* Receive FIFO size in 32-bit words. */
#define RX_FIFO_SIZE 512
@@ -35,16 +35,16 @@ static struct _usbd_device usbd_dev;
const struct _usbd_driver stm32f207_usb_driver = {
.init = stm32f207_usbd_init,
- .set_address = stm32fx07_set_address,
- .ep_setup = stm32fx07_ep_setup,
- .ep_reset = stm32fx07_endpoints_reset,
- .ep_stall_set = stm32fx07_ep_stall_set,
- .ep_stall_get = stm32fx07_ep_stall_get,
- .ep_nak_set = stm32fx07_ep_nak_set,
- .ep_write_packet = stm32fx07_ep_write_packet,
- .ep_read_packet = stm32fx07_ep_read_packet,
- .poll = stm32fx07_poll,
- .disconnect = stm32fx07_disconnect,
+ .set_address = dwc_set_address,
+ .ep_setup = dwc_ep_setup,
+ .ep_reset = dwc_endpoints_reset,
+ .ep_stall_set = dwc_ep_stall_set,
+ .ep_stall_get = dwc_ep_stall_get,
+ .ep_nak_set = dwc_ep_nak_set,
+ .ep_write_packet = dwc_ep_write_packet,
+ .ep_read_packet = dwc_ep_read_packet,
+ .poll = dwc_poll,
+ .disconnect = dwc_disconnect,
.base_address = USB_OTG_HS_BASE,
.set_address_before_status = 1,
.rx_fifo_size = RX_FIFO_SIZE,