diff --git a/arch/arm/soc/st_stm32/stm32f3/dts.fixup b/arch/arm/soc/st_stm32/stm32f3/dts.fixup index 31d3263128e..5141ace7538 100644 --- a/arch/arm/soc/st_stm32/stm32f3/dts.fixup +++ b/arch/arm/soc/st_stm32/stm32f3/dts.fixup @@ -53,4 +53,12 @@ #define FLASH_DEV_BASE_ADDRESS ST_STM32F3_FLASH_CONTROLLER_40022000_BASE_ADDRESS_0 #define FLASH_DEV_NAME ST_STM32F3_FLASH_CONTROLLER_40022000_LABEL +#define CONFIG_USB_BASE_ADDRESS ST_STM32_USB_40005C00_BASE_ADDRESS +#define CONFIG_USB_IRQ ST_STM32_USB_40005C00_IRQ_USB +#define CONFIG_USB_IRQ_PRI ST_STM32_USB_40005C00_IRQ_USB_PRIORITY +#define CONFIG_USB_NUM_BIDIR_ENDPOINTS ST_STM32_USB_40005C00_NUM_BIDIR_ENDPOINTS +#define CONFIG_USB_NUM_IN_ENDPOINTS ST_STM32_USB_40005C00_NUM_IN_ENDPOINTS +#define CONFIG_USB_NUM_OUT_ENDPOINTS ST_STM32_USB_40005C00_NUM_OUT_ENDPOINTS +#define CONFIG_USB_RAM_SIZE ST_STM32_USB_40005C00_RAM_SIZE + /* End of SoC Level DTS fixup file */ diff --git a/arch/arm/soc/st_stm32/stm32f3/soc.c b/arch/arm/soc/st_stm32/stm32f3/soc.c index 56118f63b5a..2bdff8fc33f 100644 --- a/arch/arm/soc/st_stm32/stm32f3/soc.c +++ b/arch/arm/soc/st_stm32/stm32f3/soc.c @@ -27,6 +27,17 @@ uint32_t HAL_GetTick(void) return k_uptime_get_32(); } +/** + * @brief This function provides minimum delay (in milliseconds) based + * on variable incremented. + * @param Delay: specifies the delay time length, in milliseconds. + * @return None + */ +void HAL_Delay(__IO uint32_t Delay) +{ + k_sleep(Delay); +} + /** * @brief Perform basic hardware initialization at boot. * diff --git a/boards/arm/stm32f3_disco/doc/stm32f3_disco.rst b/boards/arm/stm32f3_disco/doc/stm32f3_disco.rst index a7a2b14b260..f75bcc079b9 100644 --- a/boards/arm/stm32f3_disco/doc/stm32f3_disco.rst +++ b/boards/arm/stm32f3_disco/doc/stm32f3_disco.rst @@ -92,6 +92,8 @@ features: +-----------+------------+-------------------------------------+ | SPI | on-chip | spi | +-----------+------------+-------------------------------------+ +| USB | on-chip | USB device | ++-----------+------------+-------------------------------------+ Other hardware features are not yet supported on Zephyr porting. @@ -126,6 +128,8 @@ Default Zephyr Peripheral Mapping: - SPI2_SCK : PB13 - SPI2_MISO : PB14 - SPI2_MOSI : PB15 +- USB_DM : PA11 +- USB_DP : PA12 - USER_PB : PA0 - LD3 : PE9 - LD4 : PE8 @@ -156,6 +160,11 @@ STM32F3DISCOVERY has up to 2 I2Cs. I2C1 is connected to the LSM303DLHC and is an ultra-compact low-power system-in-package featuring a 3D digital linear acceleration sensor and a 3D digital magnetic sensor. +USB +=== +STM32F3DISCOVERY has a USB 2.0 full-speed device interface available through +its mini USB connector (USB USER). + Programming and Debugging ************************* diff --git a/boards/arm/stm32f3_disco/pinmux.c b/boards/arm/stm32f3_disco/pinmux.c index 1e2e58286cf..2ea6fcf16b0 100644 --- a/boards/arm/stm32f3_disco/pinmux.c +++ b/boards/arm/stm32f3_disco/pinmux.c @@ -42,6 +42,10 @@ static const struct pin_config pinconf[] = { {STM32_PIN_PB14, STM32F3_PINMUX_FUNC_PB14_SPI2_MISO}, {STM32_PIN_PB15, STM32F3_PINMUX_FUNC_PB15_SPI2_MOSI}, #endif /* CONFIG_SPI_2 */ +#ifdef CONFIG_USB_DC_STM32 + {STM32_PIN_PA11, STM32F3_PINMUX_FUNC_PA11_USB_DM}, + {STM32_PIN_PA12, STM32F3_PINMUX_FUNC_PA12_USB_DP}, +#endif /* CONFIG_USB_DC_STM */ }; static int pinmux_stm32_init(struct device *port) diff --git a/boards/arm/stm32f3_disco/stm32f3_disco.dts b/boards/arm/stm32f3_disco/stm32f3_disco.dts index 875b31653db..915c0a3926d 100644 --- a/boards/arm/stm32f3_disco/stm32f3_disco.dts +++ b/boards/arm/stm32f3_disco/stm32f3_disco.dts @@ -98,3 +98,7 @@ &spi2 { status = "ok"; }; + +&usb { + status = "ok"; +}; diff --git a/drivers/pinmux/stm32/pinmux_stm32f3.h b/drivers/pinmux/stm32/pinmux_stm32f3.h index 0fe223b2908..87d8747fc10 100644 --- a/drivers/pinmux/stm32/pinmux_stm32f3.h +++ b/drivers/pinmux/stm32/pinmux_stm32f3.h @@ -76,6 +76,10 @@ (STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL) #define STM32F3_PINMUX_FUNC_PA7_SPI1_MOSI \ (STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL) +#define STM32F3_PINMUX_FUNC_PA11_USB_DM \ + (STM32_PINMUX_ALT_FUNC_14 | STM32_PUSHPULL_NOPULL) +#define STM32F3_PINMUX_FUNC_PA12_USB_DP \ + (STM32_PINMUX_ALT_FUNC_14 | STM32_PUSHPULL_NOPULL) #define STM32F3_PINMUX_FUNC_PB8_I2C1_SCL \ (STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP) diff --git a/dts/arm/st/stm32f3.dtsi b/dts/arm/st/stm32f3.dtsi index 8211cdc0c0c..d6784477f51 100644 --- a/dts/arm/st/stm32f3.dtsi +++ b/dts/arm/st/stm32f3.dtsi @@ -154,6 +154,19 @@ status = "disabled"; label = "SPI_1"; }; + + usb: usb@40005c00 { + compatible = "st,stm32-usb"; + reg = <0x40005c00 0x400>; + interrupts = <20 0>; + interrupt-names = "usb"; + num-bidir-endpoints = <8>; + num-in-endpoints = <0>; + num-out-endpoints = <0>; + ram-size = <512>; + status = "disabled"; + label= "USB"; + }; }; };