From 832c056e6db83ba2ec8117f9a435e302662b4f01 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Wed, 10 Aug 2022 10:04:40 +0100 Subject: [PATCH] usb: Moved usb_get_state() into the main usb implementation --- src/platforms/common/cdcacm.c | 9 +-------- src/platforms/common/cdcacm.h | 3 ++- src/platforms/common/usb.c | 6 ++++++ src/platforms/common/usb.h | 2 ++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/platforms/common/cdcacm.c b/src/platforms/common/cdcacm.c index 75c2a5d..a6bb4f5 100644 --- a/src/platforms/common/cdcacm.c +++ b/src/platforms/common/cdcacm.c @@ -48,8 +48,6 @@ #include -static int configured; - static bool gdb_uart_dtr = true; static void usb_serial_set_state(usbd_device *dev, uint16_t iface, uint8_t ep); @@ -103,11 +101,6 @@ static enum usbd_request_return_codes debug_uart_control_request(usbd_device *de return USBD_REQ_NOTSUPP; } -int usb_get_config(void) -{ - return configured; -} - bool gdb_uart_get_dtr(void) { return gdb_uart_dtr; @@ -130,7 +123,7 @@ void usb_serial_set_state(usbd_device *const dev, const uint16_t iface, const ui void usb_serial_set_config(usbd_device *dev, uint16_t wValue) { - configured = wValue; + usb_config = wValue; /* GDB interface */ #if defined(STM32F4) || defined(LM4F) diff --git a/src/platforms/common/cdcacm.h b/src/platforms/common/cdcacm.h index d59a662..ea84ef1 100644 --- a/src/platforms/common/cdcacm.h +++ b/src/platforms/common/cdcacm.h @@ -28,12 +28,13 @@ #ifndef __CDCACM_H #define __CDCACM_H +#include #include #include "usb.h" void usb_serial_set_config(usbd_device *dev, uint16_t wValue); /* Returns current usb configuration, or 0 if not configured. */ -int usb_get_config(void); +uint16_t usb_get_config(void); bool gdb_uart_get_dtr(void); diff --git a/src/platforms/common/usb.c b/src/platforms/common/usb.c index 6410445..1d0ef2d 100644 --- a/src/platforms/common/usb.c +++ b/src/platforms/common/usb.c @@ -28,6 +28,7 @@ #include "serialno.h" usbd_device *usbdev = NULL; +uint16_t usb_config; /* We need a special large control buffer for this device: */ static uint8_t usbd_control_buffer[256]; @@ -46,6 +47,11 @@ void blackmagic_usb_init(void) nvic_enable_irq(USB_IRQ); } +uint16_t usb_get_config(void) +{ + return usb_config; +} + void USB_ISR(void) { usbd_poll(usbdev); diff --git a/src/platforms/common/usb.h b/src/platforms/common/usb.h index 656f4f2..7becdfe 100644 --- a/src/platforms/common/usb.h +++ b/src/platforms/common/usb.h @@ -21,9 +21,11 @@ #ifndef USB_H #define USB_H +#include #include extern usbd_device *usbdev; +extern uint16_t usb_config; #define CDCACM_PACKET_SIZE 64