From b22d510b47834ddb681c622e67621418c37d98f8 Mon Sep 17 00:00:00 2001 From: wdx04 Date: Wed, 3 May 2023 23:00:45 +0800 Subject: [PATCH] Add OSPI support for STM32H7 --- targets/TARGET_STM/TARGET_STM32H7/objects.h | 22 +++++++++++++++++++++ targets/TARGET_STM/ospi_api.c | 7 +++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32H7/objects.h b/targets/TARGET_STM/TARGET_STM32H7/objects.h index aa2bf285ef1..5f94a8ecd33 100644 --- a/targets/TARGET_STM/TARGET_STM32H7/objects.h +++ b/targets/TARGET_STM/TARGET_STM32H7/objects.h @@ -106,7 +106,11 @@ struct analogin_s { #if DEVICE_QSPI struct qspi_s { +#if defined(OCTOSPI1) + OSPI_HandleTypeDef handle; +#else QSPI_HandleTypeDef handle; +#endif QSPIName qspi; PinName io0; PinName io1; @@ -117,6 +121,24 @@ struct qspi_s { }; #endif +#if DEVICE_OSPI +struct ospi_s { + OSPI_HandleTypeDef handle; + OSPIName ospi; + PinName io0; + PinName io1; + PinName io2; + PinName io3; + PinName io4; + PinName io5; + PinName io6; + PinName io7; + PinName sclk; + PinName ssel; + PinName dqs; +}; +#endif + #define GPIO_IP_WITHOUT_BRR #if defined(DUAL_CORE) diff --git a/targets/TARGET_STM/ospi_api.c b/targets/TARGET_STM/ospi_api.c index f7afd6335ce..4816fd03364 100644 --- a/targets/TARGET_STM/ospi_api.c +++ b/targets/TARGET_STM/ospi_api.c @@ -336,9 +336,12 @@ static ospi_status_t _ospi_init_direct(ospi_t *obj, const ospi_pinmap_t *pinmap, pin_function(pinmap->dqs_pin, pinmap->dqs_function); pin_mode(pinmap->dqs_pin, PullNone); -#if defined(OCTOSPI2) +#if defined(OCTOSPIM) +#if defined(TARGET_STM32H7) + __HAL_RCC_OCTOSPIM_CLK_ENABLE(); +#else __HAL_RCC_OSPIM_CLK_ENABLE(); - +#endif OSPIM_CfgTypeDef OSPIM_Cfg_Struct = {0}; /* The OctoSPI IO Manager OCTOSPIM configuration is supported in a simplified mode in mbed-os