usb_serial: Moved the "SemiHosting" init into a more suitable spot in bringup

This commit is contained in:
dragonmux 2022-08-18 22:53:23 +01:00 committed by Piotr Esden-Tempski
parent 24ac50ff60
commit 099540cccb
4 changed files with 17 additions and 15 deletions

View File

@ -41,8 +41,8 @@
#include "general.h"
#include "gdb_if.h"
#include "usb_serial.h"
#if defined(PLATFORM_HAS_TRACESWO)
# include "traceswo.h"
#ifdef PLATFORM_HAS_TRACESWO
#include "traceswo.h"
#endif
#include "usbuart.h"
@ -52,6 +52,16 @@ static bool gdb_uart_dtr = true;
static void usb_serial_set_state(usbd_device *dev, uint16_t iface, uint8_t ep);
#ifdef ENABLE_DEBUG
/*
* This call initialises "SemiHosting", only we then do our own SVC interrupt things to
* route all output through to the debug USB serial interface if debug_bmp is true.
*
* https://github.com/mirror/newlib-cygwin/blob/master/newlib/libc/sys/arm/syscalls.c#L115
*/
void initialise_monitor_handles(void);
#endif
static enum usbd_request_return_codes gdb_uart_control_request(usbd_device *dev, struct usb_setup_data *req,
uint8_t **buf, uint16_t *const len, void (**complete)(usbd_device *dev, struct usb_setup_data *req))
{
@ -140,7 +150,7 @@ void usb_serial_set_config(usbd_device *dev, uint16_t value)
dev, CDCACM_UART_ENDPOINT | USB_REQ_TYPE_IN, USB_ENDPOINT_ATTR_BULK, CDCACM_PACKET_SIZE, usbuart_usb_in_cb);
usbd_ep_setup(dev, (CDCACM_UART_ENDPOINT + 1) | USB_REQ_TYPE_IN, USB_ENDPOINT_ATTR_INTERRUPT, 16, NULL);
#if defined(PLATFORM_HAS_TRACESWO)
#ifdef PLATFORM_HAS_TRACESWO
/* Trace interface */
usbd_ep_setup(dev, TRACE_ENDPOINT | USB_REQ_TYPE_IN, USB_ENDPOINT_ATTR_BULK, 64, trace_buf_drain);
#endif
@ -155,4 +165,8 @@ void usb_serial_set_config(usbd_device *dev, uint16_t value)
*/
usb_serial_set_state(dev, GDB_IF_NO, CDCACM_GDB_ENDPOINT);
usb_serial_set_state(dev, UART_IF_NO, CDCACM_UART_ENDPOINT);
#ifdef ENABLE_DEBUG
initialise_monitor_handles();
#endif
}

View File

@ -138,10 +138,6 @@ int platform_hwversion(void)
void platform_init(void)
{
SCS_DEMCR |= SCS_DEMCR_VC_MON_EN;
#ifdef ENABLE_DEBUG
void initialise_monitor_handles(void);
initialise_monitor_handles();
#endif
rcc_clock_setup_pll(&rcc_hse_configs[RCC_CLOCK_HSE8_72MHZ]);

View File

@ -48,10 +48,6 @@ void platform_init(void)
{
rev = detect_rev();
SCS_DEMCR |= SCS_DEMCR_VC_MON_EN;
#ifdef ENABLE_DEBUG
void initialise_monitor_handles(void);
initialise_monitor_handles();
#endif
rcc_clock_setup_pll(&rcc_hse_configs[RCC_CLOCK_HSE8_72MHZ]);
if (rev == 0) {
led_idle_run = GPIO8;

View File

@ -50,10 +50,6 @@ void platform_init(void)
{
uint32_t data;
SCS_DEMCR |= SCS_DEMCR_VC_MON_EN;
#ifdef ENABLE_DEBUG
void initialise_monitor_handles(void);
initialise_monitor_handles();
#endif
rcc_clock_setup_pll(&rcc_hse_configs[RCC_CLOCK_HSE8_72MHZ]);
rev = detect_rev();
/* Enable peripherals */