aboutsummaryrefslogtreecommitdiff
path: root/src/stm32
diff options
context:
space:
mode:
authorGareth McMullin2011-02-17 15:06:27 +1300
committerGareth McMullin2011-02-17 15:06:27 +1300
commitb36242d0219668f939ec5e4e83a39dd68f28f179 (patch)
tree0b81b52e08f6484542f952ade094cbd765621797 /src/stm32
parentf08914ec1f2ee8630653278971e087cc358d98dc (diff)
CDC-ACM now asserts DCD to allow opening tty devs in BSD/MacOS.
Cleaned up compiler warnings.
Diffstat (limited to 'src/stm32')
-rw-r--r--src/stm32/cdcacm.c21
-rw-r--r--src/stm32/gdb_if.c2
-rw-r--r--src/stm32/platform.c3
-rw-r--r--src/stm32/platform.h5
4 files changed, 30 insertions, 1 deletions
diff --git a/src/stm32/cdcacm.c b/src/stm32/cdcacm.c
index 31fc024..9cbd44b 100644
--- a/src/stm32/cdcacm.c
+++ b/src/stm32/cdcacm.c
@@ -341,6 +341,8 @@ static int cdcacm_control_request(struct usb_setup_data *req, uint8_t **buf,
uint16_t *len, void (**complete)(struct usb_setup_data *req))
{
(void)complete;
+ (void)buf;
+ (void)len;
switch(req->bRequest) {
case USB_CDC_REQ_SET_CONTROL_LINE_STATE:
@@ -432,6 +434,25 @@ static void cdcacm_set_config(u16 wValue)
USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE,
USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT,
cdcacm_control_request);
+
+ /* Notify the host that DCD is asserted.
+ * Allows the use of /dev/tty* devices on *BSD/MacOS
+ */
+ char buf[10];
+ struct usb_cdc_notification *notif = (void*)buf;
+ /* We echo signals back to host as notification */
+ notif->bmRequestType = 0xA1;
+ notif->bNotification = USB_CDC_NOTIFY_SERIAL_STATE;
+ notif->wValue = 0;
+ notif->wIndex = 0;
+ notif->wLength = 2;
+ buf[8] = 3; /* DCD | DSR */
+ buf[9] = 0;
+ usbd_ep_write_packet(0x82, buf, 10);
+#ifdef INCLUDE_UART_INTERFACE
+ notif->wIndex = 2;
+ usbd_ep_write_packet(0x84, buf, 10);
+#endif
}
/* We need a special large control buffer for this device: */
diff --git a/src/stm32/gdb_if.c b/src/stm32/gdb_if.c
index c825707..08dfa03 100644
--- a/src/stm32/gdb_if.c
+++ b/src/stm32/gdb_if.c
@@ -23,7 +23,7 @@
* uses the USB CDC-ACM device bulk endpoints to implement the channel.
*/
#include "platform.h"
-#include <usbd.h>
+#include <libopencm3/usb/usbd.h>
#include "gdb_if.h"
diff --git a/src/stm32/platform.c b/src/stm32/platform.c
index 246daa9..77ae453 100644
--- a/src/stm32/platform.c
+++ b/src/stm32/platform.c
@@ -41,7 +41,10 @@ jmp_buf fatal_error_jmpbuf;
void morse(const char *msg, char repeat);
static void morse_update(void);
+
+#ifdef INCLUDE_UART_INTERFACE
static void uart_init(void);
+#endif
int platform_init(void)
{
diff --git a/src/stm32/platform.h b/src/stm32/platform.h
index 923e478..b202ff5 100644
--- a/src/stm32/platform.h
+++ b/src/stm32/platform.h
@@ -119,6 +119,11 @@ extern const char *morse_msg;
int platform_init(void);
void morse(const char *msg, char repeat);
+/* <cdcacm.c> */
+void cdcacm_init(void);
+/* Returns current usb configuration, or 0 if not configured. */
+int cdcacm_get_config(void);
+
/* Use newlib provided integer only stdio functions */
#define sscanf siscanf
#define sprintf siprintf