mirror of https://github.com/ARMmbed/mbed-os.git
STM32F3 - enable USB_DEVICE for NUCLEO_F303ZE
parent
d93843a694
commit
8d3587919e
|
@ -355,6 +355,9 @@ typedef enum {
|
|||
#define LED3 PB_14 // LD3 [Red]
|
||||
#define BUTTON1 PC_13 // USER_Btn [B1]
|
||||
|
||||
// USB
|
||||
#define USB_PULLUP_CONTROL PG_6 // USB_Disconnect in the schematics
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -93,7 +93,6 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
|
|||
{
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit;
|
||||
|
||||
/* Enable HSE oscillator and activate PLL with HSE as source */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
|
@ -120,11 +119,14 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
|
|||
return 0; // FAIL
|
||||
}
|
||||
|
||||
#if DEVICE_USBDEVICE
|
||||
RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit;
|
||||
RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
|
||||
RCC_PeriphClkInit.USBClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) {
|
||||
return 0; // FAIL
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Output clock on MCO1 pin(PA8) for debugging purpose */
|
||||
//if (bypass == 0)
|
||||
|
@ -144,7 +146,6 @@ uint8_t SetSysClock_PLL_HSI(void)
|
|||
{
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit;
|
||||
|
||||
/* Enable HSI oscillator and activate PLL with HSI as source */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE;
|
||||
|
@ -169,11 +170,14 @@ uint8_t SetSysClock_PLL_HSI(void)
|
|||
return 0; // FAIL
|
||||
}
|
||||
|
||||
#if DEVICE_USBDEVICE
|
||||
RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit;
|
||||
RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
|
||||
RCC_PeriphClkInit.USBClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) {
|
||||
return 0; // FAIL
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Output clock on MCO1 pin(PA8) for debugging purpose */
|
||||
//HAL_RCC_MCOConfig(RCC_MCO, RCC_MCOSOURCE_HSI, RCC_MCO_DIV1); // 8 MHz
|
||||
|
|
|
@ -43,8 +43,10 @@
|
|||
|
||||
#if MBED_CONF_TARGET_USB_SPEED == USE_USB_NO_OTG
|
||||
|
||||
#if defined(TARGET_STM32F1) || defined(TARGET_STM32F3) || defined(TARGET_STM32L1) || defined(TARGET_STM32WB) || defined(TARGET_STM32G4)
|
||||
#if defined(TARGET_STM32F1) || defined(TARGET_STM32L1) || defined(TARGET_STM32WB) || defined(TARGET_STM32G4)
|
||||
#define USBHAL_IRQn USB_LP_IRQn
|
||||
#elif defined(TARGET_STM32F3)
|
||||
#define USBHAL_IRQn USB_LP_CAN_RX0_IRQn
|
||||
#elif defined(TARGET_STM32L5)
|
||||
#define USBHAL_IRQn USB_FS_IRQn
|
||||
#else
|
||||
|
|
|
@ -192,7 +192,7 @@ USBPhyHw::~USBPhyHw()
|
|||
|
||||
}
|
||||
|
||||
#if defined(TARGET_STM32F1) || defined(SYSCFG_PMC_USB_PU)
|
||||
#if defined(TARGET_STM32F1) || defined(TARGET_STM32F3) || defined(SYSCFG_PMC_USB_PU)
|
||||
|
||||
#include "drivers/DigitalOut.h"
|
||||
|
||||
|
@ -203,9 +203,14 @@ void USB_reenumerate()
|
|||
LL_SYSCFG_DisableUSBPullUp();
|
||||
wait_us(10000); // 10ms
|
||||
LL_SYSCFG_EnableUSBPullUp();
|
||||
#elif defined(USB_PULLUP_CONTROL)
|
||||
mbed::DigitalOut usb_dp_pin(USB_PULLUP_CONTROL, 0);
|
||||
wait_us(1000);
|
||||
usb_dp_pin = 1;
|
||||
wait_us(1000);
|
||||
#else
|
||||
// Force USB_DP pin (with external pull up) to 0
|
||||
mbed::DigitalOut usb_dp_pin(USB_DP, 0) ;
|
||||
mbed::DigitalOut usb_dp_pin(USB_DP, 0);
|
||||
wait_us(10000); // 10ms
|
||||
#endif
|
||||
}
|
||||
|
@ -295,7 +300,7 @@ void USBPhyHw::init(USBPhyEvents *events)
|
|||
|
||||
map = PinMap_USB_FS;
|
||||
|
||||
#if defined(TARGET_STM32F1) || defined(SYSCFG_PMC_USB_PU)
|
||||
#if defined(TARGET_STM32F1) || defined(TARGET_STM32F3) || defined(SYSCFG_PMC_USB_PU)
|
||||
// USB_DevConnect is empty
|
||||
USB_reenumerate();
|
||||
#endif
|
||||
|
@ -418,7 +423,7 @@ void USBPhyHw::connect()
|
|||
// Initializes the USB controller registers
|
||||
USB_DevInit(hpcd.Instance, hpcd.Init); // hpcd.Init not used
|
||||
|
||||
#if defined(TARGET_STM32F1) || defined(SYSCFG_PMC_USB_PU)
|
||||
#if defined(TARGET_STM32F1) || defined(TARGET_STM32F3) || defined(SYSCFG_PMC_USB_PU)
|
||||
// USB_DevConnect is empty
|
||||
USB_reenumerate();
|
||||
#endif
|
||||
|
|
|
@ -1718,6 +1718,9 @@
|
|||
"detect_code": [
|
||||
"0747"
|
||||
],
|
||||
"device_has_add": [
|
||||
"USBDEVICE"
|
||||
],
|
||||
"device_name": "STM32F303ZETx"
|
||||
},
|
||||
"MCU_STM32F334x8": {
|
||||
|
|
Loading…
Reference in New Issue