This commit is contained in:
rusefillc 2022-01-26 17:09:59 -05:00
parent f3ae1ae8e2
commit be202296cf
7 changed files with 73 additions and 5 deletions

View File

@ -122,12 +122,14 @@ LDSCRIPT= $(STARTUPLD)/STM32F429xI.ld
# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC = $(ALLCSRC)
CSRC = $(ALLCSRC) \
source/usbcfg.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC = $(ALLCPPSRC) \
main.cpp \
source\usbconsole.cpp \
# List ASM source files here.

View File

@ -149,7 +149,7 @@
* @brief Enables the SERIAL over USB subsystem.
*/
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
#define HAL_USE_SERIAL_USB FALSE
#define HAL_USE_SERIAL_USB TRUE
#endif
/**
@ -184,7 +184,7 @@
* @brief Enables the USB subsystem.
*/
#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
#define HAL_USE_USB FALSE
#define HAL_USE_USB TRUE
#endif
/**

View File

@ -343,7 +343,7 @@
/*
* USB driver system settings.
*/
#define STM32_USB_USE_OTG1 FALSE
#define STM32_USB_USE_OTG1 TRUE
#define STM32_USB_USE_OTG2 FALSE
#define STM32_USB_OTG1_IRQ_PRIORITY 14
#define STM32_USB_OTG2_IRQ_PRIORITY 14

View File

@ -0,0 +1 @@
st-link_cli -c SWD ur -P build\dinputs.hex -Rst -Run

View File

@ -335,7 +335,7 @@ const USBConfig usbcfg = {
* Serial over USB driver configuration.
*/
const SerialUSBConfig serusbcfg = {
&USBD2,
&USBD1,
USBD2_DATA_REQUEST_EP,
USBD2_DATA_AVAILABLE_EP,
USBD2_INTERRUPT_REQUEST_EP

View File

@ -0,0 +1,45 @@
/**
* @file usbconsole.cpp
* @brief USB-over-serial configuration
*
* @date Oct 14, 2013
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "global.h"
#include "usbconsole.h"
#include "usbcfg.h"
static bool isUsbSerialInitialized = false;
/**
* start USB serial using hard-coded communications pins (see comments inside the code)
*/
void usb_serial_start() {
palSetPadMode(EFI_USB_SERIAL_PORT, EFI_USB_SERIAL_PIN_DM, PAL_MODE_ALTERNATE(EFI_USB_AF));
palSetPadMode(EFI_USB_SERIAL_PORT, EFI_USB_SERIAL_PIN_DP, PAL_MODE_ALTERNATE(EFI_USB_AF));
/*
* Initializes a serial-over-USB CDC driver.
*/
sduObjectInit(&SDU1);
sduStart(&SDU1, &serusbcfg);
/*
* Activates the USB driver and then the USB bus pull-up on D+.
* Note, a delay is inserted in order to not have to disconnect the cable
* after a reset.
*/
usbDisconnectBus(serusbcfg.usbp);
chThdSleepMilliseconds(250);
usbStart(serusbcfg.usbp, &usbcfg);
usbConnectBus(serusbcfg.usbp);
isUsbSerialInitialized = true;
}
bool is_usb_serial_ready() {
return isUsbSerialInitialized && SDU1.config->usbp->state == USB_ACTIVE;
}

View File

@ -0,0 +1,20 @@
/**
* @file usbconsole.h
*
* @date Oct 14, 2013
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
void usb_serial_start(void);
bool is_usb_serial_ready(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */