stlink: Update to current libopencm3 usb api.
This commit is contained in:
parent
ebb48245aa
commit
16b9c1e83f
|
@ -27,17 +27,19 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <libopencm3/stm32/f1/rcc.h>
|
#include <libopencm3/stm32/f1/rcc.h>
|
||||||
#include <libopencm3/stm32/nvic.h>
|
#include <libopencm3/cm3/nvic.h>
|
||||||
#include <libopencm3/stm32/exti.h>
|
#include <libopencm3/stm32/exti.h>
|
||||||
#include <libopencm3/stm32/f1/gpio.h>
|
#include <libopencm3/stm32/f1/gpio.h>
|
||||||
#include <libopencm3/usb/usbd.h>
|
#include <libopencm3/usb/usbd.h>
|
||||||
#include <libopencm3/usb/cdc.h>
|
#include <libopencm3/usb/cdc.h>
|
||||||
#include <libopencm3/stm32/f1/scb.h>
|
#include <libopencm3/cm3/scb.h>
|
||||||
#include <libopencm3/usb/dfu.h>
|
#include <libopencm3/usb/dfu.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
|
usbd_device * usbdev;
|
||||||
|
|
||||||
static char *get_dev_unique_id(char *serial_no);
|
static char *get_dev_unique_id(char *serial_no);
|
||||||
|
|
||||||
static int configured;
|
static int configured;
|
||||||
|
@ -197,9 +199,12 @@ static const char *usb_strings[] = {
|
||||||
"Black Magic GDB Server",
|
"Black Magic GDB Server",
|
||||||
};
|
};
|
||||||
|
|
||||||
static int cdcacm_control_request(struct usb_setup_data *req, uint8_t **buf,
|
static int cdcacm_control_request(
|
||||||
uint16_t *len, void (**complete)(struct usb_setup_data *req))
|
usbd_device *dev,
|
||||||
|
struct usb_setup_data *req, uint8_t **buf, uint16_t *len,
|
||||||
|
void (**complete)(usbd_device *dev, struct usb_setup_data *req))
|
||||||
{
|
{
|
||||||
|
(void)dev;
|
||||||
(void)complete;
|
(void)complete;
|
||||||
(void)buf;
|
(void)buf;
|
||||||
(void)len;
|
(void)len;
|
||||||
|
@ -237,16 +242,18 @@ int cdcacm_get_dtr(void)
|
||||||
return cdcacm_gdb_dtr;
|
return cdcacm_gdb_dtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cdcacm_set_config(u16 wValue)
|
static void cdcacm_set_config(usbd_device *dev, u16 wValue)
|
||||||
{
|
{
|
||||||
configured = wValue;
|
configured = wValue;
|
||||||
|
|
||||||
/* GDB interface */
|
/* GDB interface */
|
||||||
usbd_ep_setup(0x01, USB_ENDPOINT_ATTR_BULK, CDCACM_PACKET_SIZE, NULL);
|
usbd_ep_setup(dev, 0x01, USB_ENDPOINT_ATTR_BULK,
|
||||||
usbd_ep_setup(0x81, USB_ENDPOINT_ATTR_BULK, CDCACM_PACKET_SIZE, NULL);
|
CDCACM_PACKET_SIZE, NULL);
|
||||||
usbd_ep_setup(0x82, USB_ENDPOINT_ATTR_INTERRUPT, 16, NULL);
|
usbd_ep_setup(dev, 0x81, USB_ENDPOINT_ATTR_BULK,
|
||||||
|
CDCACM_PACKET_SIZE, NULL);
|
||||||
|
usbd_ep_setup(dev, 0x82, USB_ENDPOINT_ATTR_INTERRUPT, 16, NULL);
|
||||||
|
|
||||||
usbd_register_control_callback(
|
usbd_register_control_callback(dev,
|
||||||
USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE,
|
USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE,
|
||||||
USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT,
|
USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT,
|
||||||
cdcacm_control_request);
|
cdcacm_control_request);
|
||||||
|
@ -264,24 +271,29 @@ static void cdcacm_set_config(u16 wValue)
|
||||||
notif->wLength = 2;
|
notif->wLength = 2;
|
||||||
buf[8] = 3; /* DCD | DSR */
|
buf[8] = 3; /* DCD | DSR */
|
||||||
buf[9] = 0;
|
buf[9] = 0;
|
||||||
usbd_ep_write_packet(0x82, buf, 10);
|
usbd_ep_write_packet(dev, 0x82, buf, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We need a special large control buffer for this device: */
|
||||||
|
uint8_t usbd_control_buffer[256];
|
||||||
|
|
||||||
void cdcacm_init(void)
|
void cdcacm_init(void)
|
||||||
{
|
{
|
||||||
void exti15_10_isr(void);
|
void exti15_10_isr(void);
|
||||||
|
|
||||||
get_dev_unique_id(serial_no);
|
get_dev_unique_id(serial_no);
|
||||||
|
|
||||||
usbd_init(&stm32f103_usb_driver, &dev, &config, usb_strings);
|
usbdev = usbd_init(&stm32f103_usb_driver,
|
||||||
usbd_register_set_config_callback(cdcacm_set_config);
|
&dev, &config, usb_strings, 7);
|
||||||
|
usbd_set_control_buffer_size(usbdev, sizeof(usbd_control_buffer));
|
||||||
|
usbd_register_set_config_callback(usbdev, cdcacm_set_config);
|
||||||
|
|
||||||
nvic_enable_irq(NVIC_USB_LP_CAN_RX0_IRQ);
|
nvic_enable_irq(NVIC_USB_LP_CAN_RX0_IRQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_lp_can_rx0_isr(void)
|
void usb_lp_can_rx0_isr(void)
|
||||||
{
|
{
|
||||||
usbd_poll();
|
usbd_poll(usbdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_dev_unique_id(char *s)
|
static char *get_dev_unique_id(char *s)
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <libopencm3/stm32/f1/rcc.h>
|
#include <libopencm3/stm32/f1/rcc.h>
|
||||||
#include <libopencm3/stm32/systick.h>
|
#include <libopencm3/cm3/systick.h>
|
||||||
#include <libopencm3/stm32/f1/scb.h>
|
#include <libopencm3/cm3/scb.h>
|
||||||
#include <libopencm3/stm32/nvic.h>
|
#include <libopencm3/cm3/nvic.h>
|
||||||
#include <libopencm3/stm32/usart.h>
|
#include <libopencm3/stm32/usart.h>
|
||||||
#include <libopencm3/usb/usbd.h>
|
#include <libopencm3/usb/usbd.h>
|
||||||
#include <libopencm3/stm32/f1/adc.h>
|
#include <libopencm3/stm32/f1/adc.h>
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#define __PLATFORM_H
|
#define __PLATFORM_H
|
||||||
|
|
||||||
#include <libopencm3/stm32/f1/gpio.h>
|
#include <libopencm3/stm32/f1/gpio.h>
|
||||||
|
#include <libopencm3/usb/usbd.h>
|
||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
|
@ -33,6 +34,8 @@
|
||||||
|
|
||||||
#define INLINE_GPIO
|
#define INLINE_GPIO
|
||||||
#define CDCACM_PACKET_SIZE 64
|
#define CDCACM_PACKET_SIZE 64
|
||||||
|
|
||||||
|
extern usbd_device *usbdev;
|
||||||
#define CDCACM_GDB_ENDPOINT 1
|
#define CDCACM_GDB_ENDPOINT 1
|
||||||
|
|
||||||
/* Important pin mappings for STM32 implementation:
|
/* Important pin mappings for STM32 implementation:
|
||||||
|
|
Loading…
Reference in New Issue