aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGareth McMullin2015-02-28 22:48:26 -0800
committerGareth McMullin2015-02-28 22:48:26 -0800
commit476f83b69ad86c71ee57c8633f09667e9caa0a5f (patch)
tree55a43cf35d8a258774528d8f9c8b17a62aecd72b
parent5eff0ab5d648408cf4df528d2be3d29b04034083 (diff)
Move common USB stuff out of platform header files.
-rw-r--r--src/platforms/f4discovery/platform.h14
-rw-r--r--src/platforms/native/platform.c1
-rw-r--r--src/platforms/native/platform.h14
-rw-r--r--src/platforms/stlink/platform.h14
-rw-r--r--src/platforms/stm32/cdcacm.c5
-rw-r--r--src/platforms/stm32/cdcacm.h45
-rw-r--r--src/platforms/stm32/gdb_if.c3
-rw-r--r--src/platforms/stm32/traceswo.c3
-rw-r--r--src/platforms/stm32/traceswo.h (renamed from src/include/traceswo.h)0
-rw-r--r--src/platforms/stm32/usbuart.c3
-rw-r--r--src/platforms/stm32/usbuart.h (renamed from src/include/usbuart.h)0
-rw-r--r--src/platforms/swlink/platform.h14
12 files changed, 53 insertions, 63 deletions
diff --git a/src/platforms/f4discovery/platform.h b/src/platforms/f4discovery/platform.h
index dcad8a0..140e8d1 100644
--- a/src/platforms/f4discovery/platform.h
+++ b/src/platforms/f4discovery/platform.h
@@ -37,17 +37,12 @@
#include "gpio.h"
#include "morse.h"
-#define CDCACM_PACKET_SIZE 64
#define PLATFORM_HAS_TRACESWO
#define BOARD_IDENT "Black Magic Probe (F4Discovery), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
#define BOARD_IDENT_DFU "Black Magic (Upgrade) for F4Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
#define DFU_IDENT "Black Magic Firmware Upgrade (F4Discovery"
#define DFU_IFACE_STRING "@Internal Flash /0x08000000/1*016Ka,3*016Kg,1*064Kg,7*128Kg"
-extern usbd_device *usbdev;
-#define CDCACM_GDB_ENDPOINT 1
-#define CDCACM_UART_ENDPOINT 3
-
/* Important pin mappings for STM32 implementation:
*
* LED0 = PD12 (Green LED : Running)
@@ -186,15 +181,6 @@ static inline int platform_hwversion(void)
return 0;
}
-/* <cdcacm.c> */
-void cdcacm_init(void);
-/* Returns current usb configuration, or 0 if not configured. */
-int cdcacm_get_config(void);
-int cdcacm_get_dtr(void);
-
-/* <platform.h> */
-void uart_usb_buf_drain(uint8_t ep);
-
/* Use newlib provided integer only stdio functions */
#define sscanf siscanf
#define sprintf siprintf
diff --git a/src/platforms/native/platform.c b/src/platforms/native/platform.c
index 3e269d9..3f61f5f 100644
--- a/src/platforms/native/platform.c
+++ b/src/platforms/native/platform.c
@@ -34,6 +34,7 @@
#include <libopencm3/stm32/f1/adc.h>
#include "jtag_scan.h"
+#include "cdcacm.h"
#include "usbuart.h"
#include "morse.h"
diff --git a/src/platforms/native/platform.h b/src/platforms/native/platform.h
index 2fa1e84..321c3f3 100644
--- a/src/platforms/native/platform.h
+++ b/src/platforms/native/platform.h
@@ -38,7 +38,6 @@
#include "gpio.h"
#include "morse.h"
-#define CDCACM_PACKET_SIZE 64
#define PLATFORM_HAS_TRACESWO
#define PLATFORM_HAS_POWER_SWITCH
#define BOARD_IDENT "Black Magic Probe"
@@ -48,10 +47,6 @@
#define DFU_IFACE_STRING "@Internal Flash /0x08000000/8*001Ka,120*001Kg"
#define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg"
-extern usbd_device *usbdev;
-#define CDCACM_GDB_ENDPOINT 1
-#define CDCACM_UART_ENDPOINT 3
-
/* Important pin mappings for STM32 implementation:
*
* LED0 = PB2 (Yellow LED : Running)
@@ -185,15 +180,6 @@ void platform_set_timeout(uint32_t ms);
bool platform_timeout_expired(void);
void platform_delay(uint32_t delay);
-/* <cdcacm.c> */
-void cdcacm_init(void);
-/* Returns current usb configuration, or 0 if not configured. */
-int cdcacm_get_config(void);
-int cdcacm_get_dtr(void);
-
-/* <platform.h> */
-void uart_usb_buf_drain(uint8_t ep);
-
/* Use newlib provided integer only stdio functions */
#define sscanf siscanf
#define sprintf siprintf
diff --git a/src/platforms/stlink/platform.h b/src/platforms/stlink/platform.h
index a49e73a..a33ca06 100644
--- a/src/platforms/stlink/platform.h
+++ b/src/platforms/stlink/platform.h
@@ -37,7 +37,6 @@
#include "gdb_packet.h"
#include "gpio.h"
-#define CDCACM_PACKET_SIZE 64
#define BOARD_IDENT "Black Magic Probe (STLINK), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
#define BOARD_IDENT_DFU "Black Magic (Upgrade) for STLink/Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade) for STLink/Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
@@ -45,10 +44,6 @@
#define DFU_IFACE_STRING "@Internal Flash /0x08000000/8*001Ka,56*001Kg"
#define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg"
-extern usbd_device *usbdev;
-#define CDCACM_GDB_ENDPOINT 1
-#define CDCACM_UART_ENDPOINT 3
-
/* Important pin mappings for STM32 implementation:
*
* LED0 = PB2 (Yellow LED : Running)
@@ -161,15 +156,6 @@ const char *platform_target_voltage(void);
void platform_delay(uint32_t delay);
void platform_srst_set_val(bool assert);
-/* <cdcacm.c> */
-void cdcacm_init(void);
-/* Returns current usb configuration, or 0 if not configured. */
-int cdcacm_get_config(void);
-int cdcacm_get_dtr(void);
-
-/* <platform.h> */
-void uart_usb_buf_drain(uint8_t ep);
-
/* Use newlib provided integer only stdio functions */
#define sscanf siscanf
#define sprintf siprintf
diff --git a/src/platforms/stm32/cdcacm.c b/src/platforms/stm32/cdcacm.c
index 9694cf0..074b534 100644
--- a/src/platforms/stm32/cdcacm.c
+++ b/src/platforms/stm32/cdcacm.c
@@ -35,10 +35,11 @@
#include "platform.h"
#include "gdb_if.h"
+#include "cdcacm.h"
#if defined(PLATFORM_HAS_TRACESWO)
-#include <traceswo.h>
+#include "traceswo.h"
#endif
-#include <usbuart.h>
+#include "usbuart.h"
#define DFU_IF_NO 4
diff --git a/src/platforms/stm32/cdcacm.h b/src/platforms/stm32/cdcacm.h
new file mode 100644
index 0000000..f64399d
--- /dev/null
+++ b/src/platforms/stm32/cdcacm.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the Black Magic Debug project.
+ *
+ * Copyright (C) 2015 Black Sphere Technologies Ltd.
+ * Written by Gareth McMullin <gareth@blacksphere.co.nz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This file implements a the USB Communications Device Class - Abstract
+ * Control Model (CDC-ACM) as defined in CDC PSTN subclass 1.2.
+ * A Device Firmware Upgrade (DFU 1.1) class interface is provided for
+ * field firmware upgrade.
+ *
+ * The device's unique id is used as the USB serial number string.
+ */
+#ifndef __CDCACM_H
+#define __CDCACM_H
+
+#include <libopencm3/usb/usbd.h>
+
+#define CDCACM_PACKET_SIZE 64
+
+#define CDCACM_GDB_ENDPOINT 1
+#define CDCACM_UART_ENDPOINT 3
+
+extern usbd_device *usbdev;
+
+void cdcacm_init(void);
+/* Returns current usb configuration, or 0 if not configured. */
+int cdcacm_get_config(void);
+int cdcacm_get_dtr(void);
+
+#endif
diff --git a/src/platforms/stm32/gdb_if.c b/src/platforms/stm32/gdb_if.c
index c8208b3..6cc9084 100644
--- a/src/platforms/stm32/gdb_if.c
+++ b/src/platforms/stm32/gdb_if.c
@@ -23,8 +23,7 @@
* uses the USB CDC-ACM device bulk endpoints to implement the channel.
*/
#include "platform.h"
-#include <libopencm3/usb/usbd.h>
-
+#include "cdcacm.h"
#include "gdb_if.h"
static uint32_t count_out;
diff --git a/src/platforms/stm32/traceswo.c b/src/platforms/stm32/traceswo.c
index 01ad728..29bae8f 100644
--- a/src/platforms/stm32/traceswo.c
+++ b/src/platforms/stm32/traceswo.c
@@ -37,10 +37,9 @@
#include <libopencm3/stm32/timer.h>
#include <libopencm3/stm32/f1/rcc.h>
-#include <libopencm3/usb/usbd.h>
-
#include <string.h>
#include "platform.h"
+#include "cdcacm.h"
void traceswo_init(void)
{
diff --git a/src/include/traceswo.h b/src/platforms/stm32/traceswo.h
index 5566f94..5566f94 100644
--- a/src/include/traceswo.h
+++ b/src/platforms/stm32/traceswo.h
diff --git a/src/platforms/stm32/usbuart.c b/src/platforms/stm32/usbuart.c
index f8f56bf..970a609 100644
--- a/src/platforms/stm32/usbuart.c
+++ b/src/platforms/stm32/usbuart.c
@@ -27,7 +27,8 @@
#include <libopencm3/usb/usbd.h>
#include <libopencm3/usb/cdc.h>
-#include <platform.h>
+#include "platform.h"
+#include "cdcacm.h"
#define USBUART_TIMER_FREQ_HZ 1000000U /* 1us per tick */
#define USBUART_RUN_FREQ_HZ 5000U /* 200us (or 100 characters at 2Mbps) */
diff --git a/src/include/usbuart.h b/src/platforms/stm32/usbuart.h
index 39f7dcd..39f7dcd 100644
--- a/src/include/usbuart.h
+++ b/src/platforms/stm32/usbuart.h
diff --git a/src/platforms/swlink/platform.h b/src/platforms/swlink/platform.h
index 4b26466..26cb7a6 100644
--- a/src/platforms/swlink/platform.h
+++ b/src/platforms/swlink/platform.h
@@ -37,7 +37,6 @@
#include "gdb_packet.h"
#include "gpio.h"
-#define CDCACM_PACKET_SIZE 64
#define BOARD_IDENT "Black Magic Probe (SWLINK), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
#define BOARD_IDENT_DFU "Black Magic (Upgrade), STM8S Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade), STM8S Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
@@ -45,10 +44,6 @@
#define DFU_IFACE_STRING "@Internal Flash /0x08000000/8*001Ka,56*001Kg"
#define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg"
-extern usbd_device *usbdev;
-#define CDCACM_GDB_ENDPOINT 1
-#define CDCACM_UART_ENDPOINT 3
-
/* Pin mappings:
*
* nTRST = PB1
@@ -158,15 +153,6 @@ int platform_init(void);
const char *platform_target_voltage(void);
void platform_delay(uint32_t delay);
-/* <cdcacm.c> */
-void cdcacm_init(void);
-/* Returns current usb configuration, or 0 if not configured. */
-int cdcacm_get_config(void);
-int cdcacm_get_dtr(void);
-
-/* <platform.h> */
-void uart_usb_buf_drain(uint8_t ep);
-
/* Use newlib provided integer only stdio functions */
#define sscanf siscanf
#define sprintf siprintf