Skip to content

Commit 9936a53

Browse files
committed
STM32H7 STM32Cube FW V1.5.0 => V1.7.0: HAL Driver part
1 parent 21f262b commit 9936a53

File tree

177 files changed

+38731
-11729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+38731
-11729
lines changed

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/Legacy/stm32_hal_legacy.h

Lines changed: 157 additions & 27 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal.c

Lines changed: 78 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
/* Private typedef -----------------------------------------------------------*/
4848
/* Private define ------------------------------------------------------------*/
4949
/**
50-
* @brief STM32H7xx HAL Driver version number V1.6.0
50+
* @brief STM32H7xx HAL Driver version number V1.8.0
5151
*/
5252
#define __STM32H7xx_HAL_VERSION_MAIN (0x01UL) /*!< [31:24] main version */
53-
#define __STM32H7xx_HAL_VERSION_SUB1 (0x06UL) /*!< [23:16] sub1 version */
53+
#define __STM32H7xx_HAL_VERSION_SUB1 (0x08UL) /*!< [23:16] sub1 version */
5454
#define __STM32H7xx_HAL_VERSION_SUB2 (0x00UL) /*!< [15:8] sub2 version */
5555
#define __STM32H7xx_HAL_VERSION_RC (0x00UL) /*!< [7:0] release candidate */
5656
#define __STM32H7xx_HAL_VERSION ((__STM32H7xx_HAL_VERSION_MAIN << 24)\
@@ -134,6 +134,8 @@ HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */
134134
HAL_StatusTypeDef HAL_Init(void)
135135
{
136136

137+
uint32_t common_system_clock;
138+
137139
#if defined(DUAL_CORE) && defined(CORE_CM4)
138140
/* Configure Cortex-M4 Instruction cache through ART accelerator */
139141
__HAL_RCC_ART_CLK_ENABLE(); /* Enable the Cortex-M4 ART Clock */
@@ -145,10 +147,24 @@ HAL_StatusTypeDef HAL_Init(void)
145147
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
146148

147149
/* Update the SystemCoreClock global variable */
148-
SystemD1Clock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]) & 0x1FU);
150+
#if defined(RCC_D1CFGR_D1CPRE)
151+
common_system_clock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]) & 0x1FU);
152+
#else
153+
common_system_clock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos]) & 0x1FU);
154+
#endif
149155

150156
/* Update the SystemD2Clock global variable */
151-
SystemD2Clock = (SystemD1Clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU));
157+
#if defined(RCC_D1CFGR_HPRE)
158+
SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU));
159+
#else
160+
SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU));
161+
#endif
162+
163+
#if defined(DUAL_CORE) && defined(CORE_CM4)
164+
SystemCoreClock = SystemD2Clock;
165+
#else
166+
SystemCoreClock = common_system_clock;
167+
#endif /* DUAL_CORE && CORE_CM4 */
152168

153169
/* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
154170
if(HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK)
@@ -340,14 +356,26 @@ uint32_t HAL_GetTickPrio(void)
340356
HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq)
341357
{
342358
HAL_StatusTypeDef status = HAL_OK;
359+
HAL_TickFreqTypeDef prevTickFreq;
360+
343361
assert_param(IS_TICKFREQ(Freq));
344362

345363
if (uwTickFreq != Freq)
346364
{
365+
366+
/* Back up uwTickFreq frequency */
367+
prevTickFreq = uwTickFreq;
368+
369+
/* Update uwTickFreq global variable used by HAL_InitTick() */
347370
uwTickFreq = Freq;
348371

349372
/* Apply the new tick Freq */
350373
status = HAL_InitTick(uwTickPrio);
374+
if (status != HAL_OK)
375+
{
376+
/* Restore previous tick frequency */
377+
uwTickFreq = prevTickFreq;
378+
}
351379
}
352380

353381
return status;
@@ -560,6 +588,7 @@ void HAL_SYSCFG_DisableVREFBUF(void)
560588
CLEAR_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR);
561589
}
562590

591+
#if defined(SYSCFG_PMCR_EPIS_SEL)
563592
/**
564593
* @brief Ethernet PHY Interface Selection either MII or RMII
565594
* @param SYSCFG_ETHInterface: Selects the Ethernet PHY interface
@@ -575,7 +604,7 @@ void HAL_SYSCFG_ETHInterfaceSelect(uint32_t SYSCFG_ETHInterface)
575604

576605
MODIFY_REG(SYSCFG->PMCR, SYSCFG_PMCR_EPIS_SEL, (uint32_t)(SYSCFG_ETHInterface));
577606
}
578-
607+
#endif /* SYSCFG_PMCR_EPIS_SEL */
579608

580609
/**
581610
* @brief Analog Switch control for dual analog pads.
@@ -607,7 +636,7 @@ void HAL_SYSCFG_AnalogSwitchConfig(uint32_t SYSCFG_AnalogSwitch , uint32_t SYSCF
607636
MODIFY_REG(SYSCFG->PMCR, (uint32_t) SYSCFG_AnalogSwitch, (uint32_t)(SYSCFG_SwitchState));
608637
}
609638

610-
639+
#if defined(SYSCFG_PMCR_BOOSTEN)
611640
/**
612641
* @brief Enables the booster to reduce the total harmonic distortion of the analog
613642
* switch when the supply voltage is lower than 2.7 V.
@@ -632,8 +661,9 @@ void HAL_SYSCFG_DisableBOOST(void)
632661
{
633662
CLEAR_BIT(SYSCFG->PMCR, SYSCFG_PMCR_BOOSTEN) ;
634663
}
664+
#endif /* SYSCFG_PMCR_BOOSTEN */
635665

636-
666+
#if defined (SYSCFG_UR2_BOOT_ADD0) || defined (SYSCFG_UR2_BCM7_ADD0)
637667
/**
638668
* @brief BootCM7 address 0 configuration
639669
* @param BootRegister :Specifies the Boot Address register (Address0 or Address1)
@@ -666,8 +696,8 @@ void HAL_SYSCFG_CM7BootAddConfig(uint32_t BootRegister, uint32_t BootAddress)
666696
MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BOOT_ADD1, (BootAddress >> 16));
667697
#endif /*DUAL_CORE*/
668698
}
669-
670699
}
700+
#endif /* SYSCFG_UR2_BOOT_ADD0 || SYSCFG_UR2_BCM7_ADD0 */
671701

672702
#if defined(DUAL_CORE)
673703
/**
@@ -736,7 +766,6 @@ void HAL_SYSCFG_DisableCM4BOOT(void)
736766
CLEAR_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM4);
737767
}
738768
#endif /*DUAL_CORE*/
739-
740769
/**
741770
* @brief Enables the I/O Compensation Cell.
742771
* @note The I/O compensation cell can be used only when the device supply
@@ -769,7 +798,11 @@ void HAL_DisableCompensationCell(void)
769798
*/
770799
void HAL_SYSCFG_EnableIOSpeedOptimize(void)
771800
{
801+
#if defined(SYSCFG_CCCSR_HSLV)
772802
SET_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_HSLV);
803+
#else
804+
SET_BIT(SYSCFG->CCCSR, (SYSCFG_CCCSR_HSLV0| SYSCFG_CCCSR_HSLV1 | SYSCFG_CCCSR_HSLV2 | SYSCFG_CCCSR_HSLV3));
805+
#endif /* SYSCFG_CCCSR_HSLV */
773806
}
774807

775808
/**
@@ -781,7 +814,11 @@ void HAL_SYSCFG_EnableIOSpeedOptimize(void)
781814
*/
782815
void HAL_SYSCFG_DisableIOSpeedOptimize(void)
783816
{
817+
#if defined(SYSCFG_CCCSR_HSLV)
784818
CLEAR_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_HSLV);
819+
#else
820+
CLEAR_BIT(SYSCFG->CCCSR, (SYSCFG_CCCSR_HSLV0| SYSCFG_CCCSR_HSLV1 | SYSCFG_CCCSR_HSLV2 | SYSCFG_CCCSR_HSLV3));
821+
#endif /* SYSCFG_CCCSR_HSLV */
785822
}
786823

787824
/**
@@ -817,9 +854,28 @@ void HAL_SYSCFG_CompensationCodeConfig(uint32_t SYSCFG_PMOSCode, uint32_t SYSCFG
817854
MODIFY_REG(SYSCFG->CCCR, SYSCFG_CCCR_NCC|SYSCFG_CCCR_PCC, (((uint32_t)(SYSCFG_PMOSCode)<< 4)|(uint32_t)(SYSCFG_NMOSCode)) );
818855
}
819856

857+
#if defined(SYSCFG_CCCR_NCC_MMC)
858+
/**
859+
* @brief Code selection for the I/O Compensation cell
860+
* @param SYSCFG_PMOSCode: VDDMMC PMOS compensation code
861+
* This code is applied to the I/O compensation cell when the CS bit of the
862+
* SYSCFG_CMPCR is set
863+
* @param SYSCFG_NMOSCode: VDDMMC NMOS compensation code
864+
* This code is applied to the I/O compensation cell when the CS bit of the
865+
* SYSCFG_CMPCR is set
866+
* @retval None
867+
*/
868+
void HAL_SYSCFG_VDDMMC_CompensationCodeConfig(uint32_t SYSCFG_PMOSCode, uint32_t SYSCFG_NMOSCode )
869+
{
870+
/* Check the parameter */
871+
assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_PMOSCode));
872+
assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_NMOSCode));
873+
MODIFY_REG(SYSCFG->CCCR, (SYSCFG_CCCR_NCC_MMC | SYSCFG_CCCR_PCC_MMC), (((uint32_t)(SYSCFG_PMOSCode)<< 4)|(uint32_t)(SYSCFG_NMOSCode)) );
874+
}
875+
#endif /* SYSCFG_CCCR_NCC_MMC */
820876

821877
/**
822-
* @brief Enable the Debug Module during Domain1 SLEEP mode
878+
* @brief Enable the Debug Module during Domain1/CDomain SLEEP mode
823879
* @retval None
824880
*/
825881
void HAL_EnableDBGSleepMode(void)
@@ -828,16 +884,17 @@ void HAL_EnableDBGSleepMode(void)
828884
}
829885

830886
/**
831-
* @brief Disable the Debug Module during Domain1 SLEEP mode
887+
* @brief Disable the Debug Module during Domain1/CDomain SLEEP mode
832888
* @retval None
833889
*/
834890
void HAL_DisableDBGSleepMode(void)
835891
{
836892
CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD1);
837893
}
838894

895+
839896
/**
840-
* @brief Enable the Debug Module during Domain1 STOP mode
897+
* @brief Enable the Debug Module during Domain1/CDomain STOP mode
841898
* @retval None
842899
*/
843900
void HAL_EnableDBGStopMode(void)
@@ -846,7 +903,7 @@ void HAL_EnableDBGStopMode(void)
846903
}
847904

848905
/**
849-
* @brief Disable the Debug Module during Domain1 STOP mode
906+
* @brief Disable the Debug Module during Domain1/CDomain STOP mode
850907
* @retval None
851908
*/
852909
void HAL_DisableDBGStopMode(void)
@@ -855,7 +912,7 @@ void HAL_DisableDBGStopMode(void)
855912
}
856913

857914
/**
858-
* @brief Enable the Debug Module during Domain1 STANDBY mode
915+
* @brief Enable the Debug Module during Domain1/CDomain STANDBY mode
859916
* @retval None
860917
*/
861918
void HAL_EnableDBGStandbyMode(void)
@@ -864,7 +921,7 @@ void HAL_EnableDBGStandbyMode(void)
864921
}
865922

866923
/**
867-
* @brief Disable the Debug Module during Domain1 STANDBY mode
924+
* @brief Disable the Debug Module during Domain1/CDomain STANDBY mode
868925
* @retval None
869926
*/
870927
void HAL_DisableDBGStandbyMode(void)
@@ -928,18 +985,16 @@ void HAL_DisableDomain2DBGStandbyMode(void)
928985
}
929986
#endif /*DUAL_CORE*/
930987

931-
932988
/**
933-
* @brief Enable the Debug Module during Domain3 STOP mode
989+
* @brief Enable the Debug Module during Domain3/SRDomain STOP mode
934990
* @retval None
935991
*/
936992
void HAL_EnableDomain3DBGStopMode(void)
937993
{
938994
SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD3);
939995
}
940-
941996
/**
942-
* @brief Disable the Debug Module during Domain3 STOP mode
997+
* @brief Disable the Debug Module during Domain3/SRDomain STOP mode
943998
* @retval None
944999
*/
9451000
void HAL_DisableDomain3DBGStopMode(void)
@@ -948,7 +1003,7 @@ void HAL_DisableDomain3DBGStopMode(void)
9481003
}
9491004

9501005
/**
951-
* @brief Enable the Debug Module during Domain3 STANDBY mode
1006+
* @brief Enable the Debug Module during Domain3/SRDomain STANDBY mode
9521007
* @retval None
9531008
*/
9541009
void HAL_EnableDomain3DBGStandbyMode(void)
@@ -957,7 +1012,7 @@ void HAL_EnableDomain3DBGStandbyMode(void)
9571012
}
9581013

9591014
/**
960-
* @brief Disable the Debug Module during Domain3 STANDBY mode
1015+
* @brief Disable the Debug Module during Domain3/SRDomain STANDBY mode
9611016
* @retval None
9621017
*/
9631018
void HAL_DisableDomain3DBGStandbyMode(void)
@@ -1045,7 +1100,7 @@ void HAL_EXTI_D1_ClearFlag(uint32_t EXTI_Line)
10451100
{
10461101
/* Check the parameters */
10471102
assert_param(IS_EXTI_D1_LINE(EXTI_Line));
1048-
SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1103+
WRITE_REG(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
10491104

10501105
}
10511106

@@ -1060,7 +1115,7 @@ void HAL_EXTI_D2_ClearFlag(uint32_t EXTI_Line)
10601115
{
10611116
/* Check the parameters */
10621117
assert_param(IS_EXTI_D2_LINE(EXTI_Line));
1063-
SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1118+
WRITE_REG(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
10641119
}
10651120

10661121
#endif /*DUAL_CORE*/

0 commit comments

Comments
 (0)