usb: Moved usb_get_state() into the main usb implementation

This commit is contained in:
dragonmux 2022-08-10 10:04:40 +01:00 committed by Piotr Esden-Tempski
parent bf6c146786
commit 832c056e6d
4 changed files with 11 additions and 9 deletions

View File

@ -48,8 +48,6 @@
#include <libopencm3/usb/cdc.h> #include <libopencm3/usb/cdc.h>
static int configured;
static bool gdb_uart_dtr = true; static bool gdb_uart_dtr = true;
static void usb_serial_set_state(usbd_device *dev, uint16_t iface, uint8_t ep); 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; return USBD_REQ_NOTSUPP;
} }
int usb_get_config(void)
{
return configured;
}
bool gdb_uart_get_dtr(void) bool gdb_uart_get_dtr(void)
{ {
return gdb_uart_dtr; 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) void usb_serial_set_config(usbd_device *dev, uint16_t wValue)
{ {
configured = wValue; usb_config = wValue;
/* GDB interface */ /* GDB interface */
#if defined(STM32F4) || defined(LM4F) #if defined(STM32F4) || defined(LM4F)

View File

@ -28,12 +28,13 @@
#ifndef __CDCACM_H #ifndef __CDCACM_H
#define __CDCACM_H #define __CDCACM_H
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "usb.h" #include "usb.h"
void usb_serial_set_config(usbd_device *dev, uint16_t wValue); void usb_serial_set_config(usbd_device *dev, uint16_t wValue);
/* Returns current usb configuration, or 0 if not configured. */ /* 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); bool gdb_uart_get_dtr(void);

View File

@ -28,6 +28,7 @@
#include "serialno.h" #include "serialno.h"
usbd_device *usbdev = NULL; usbd_device *usbdev = NULL;
uint16_t usb_config;
/* We need a special large control buffer for this device: */ /* We need a special large control buffer for this device: */
static uint8_t usbd_control_buffer[256]; static uint8_t usbd_control_buffer[256];
@ -46,6 +47,11 @@ void blackmagic_usb_init(void)
nvic_enable_irq(USB_IRQ); nvic_enable_irq(USB_IRQ);
} }
uint16_t usb_get_config(void)
{
return usb_config;
}
void USB_ISR(void) void USB_ISR(void)
{ {
usbd_poll(usbdev); usbd_poll(usbdev);

View File

@ -21,9 +21,11 @@
#ifndef USB_H #ifndef USB_H
#define USB_H #define USB_H
#include <stdint.h>
#include <libopencm3/usb/usbd.h> #include <libopencm3/usb/usbd.h>
extern usbd_device *usbdev; extern usbd_device *usbdev;
extern uint16_t usb_config;
#define CDCACM_PACKET_SIZE 64 #define CDCACM_PACKET_SIZE 64