Skip to content

Commit 1eaecd3

Browse files
committed
enable ICACHE, LPTICKER, TRNG and WATCHDOG for STM32H5
1 parent 7d9fbaf commit 1eaecd3

File tree

5 files changed

+50
-13
lines changed

5 files changed

+50
-13
lines changed

targets/TARGET_STM/TARGET_STM32H5/clock_cfg/system_clock.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* This file configures the system clock as follows:
1818
*--------------------------------------------------------------------
19-
* System clock source | 1- USE_PLL_HSE_EXTC
19+
* System clock source | 1- USE_PLL_HSE_EXTC
2020
* | 2- USE_PLL_HSE_XTAL
2121
* | 3- USE_PLL_HSI (internal 64 MHz clock)
2222
*--------------------------------------------------------------------
@@ -45,6 +45,43 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass);
4545
uint8_t SetSysClock_PLL_HSI(void);
4646
#endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */
4747

48+
/**
49+
* @brief Enable ICACHE
50+
* @param None
51+
* @retval None
52+
*/
53+
54+
static void EnableICache()
55+
{
56+
MPU_Attributes_InitTypeDef attr;
57+
MPU_Region_InitTypeDef region;
58+
59+
/* Disable MPU before perloading and config update */
60+
HAL_MPU_Disable();
61+
62+
/* Define cacheable memory via MPU */
63+
attr.Number = MPU_ATTRIBUTES_NUMBER5;
64+
attr.Attributes = INNER_OUTER(MPU_NOT_CACHEABLE);
65+
HAL_MPU_ConfigMemoryAttributes(&attr);
66+
67+
/* BaseAddress-LimitAddress configuration */
68+
region.Enable = MPU_REGION_ENABLE;
69+
region.Number = MPU_REGION_NUMBER5;
70+
region.AttributesIndex = MPU_ATTRIBUTES_NUMBER5;
71+
region.BaseAddress = 0x08FFF800;
72+
region.LimitAddress = 0x08FFFFFF;
73+
region.AccessPermission = MPU_REGION_ALL_RW;
74+
region.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
75+
region.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
76+
HAL_MPU_ConfigRegion(&region);
77+
78+
/* Enable the MPU */
79+
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
80+
81+
/* Enable ICACHE */
82+
HAL_ICACHE_Enable();
83+
}
84+
4885
/**
4986
* @brief Configures the System clock source
5087
* @note This function should be called only once the RCC clock configuration
@@ -74,6 +111,7 @@ void SetSysClock(void)
74111
}
75112
}
76113
}
114+
EnableICache();
77115
}
78116

79117

@@ -108,7 +146,7 @@ MBED_WEAK uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
108146
#endif
109147
if(HSE_VALUE % 2000000 == 0)
110148
{
111-
RCC_OscInitStruct.PLL.PLLM = HSE_VALUE / 2000000; // Divide down input clock to 2MHz
149+
RCC_OscInitStruct.PLL.PLLM = HSE_VALUE / 2000000; // Divide down input clock to 2MHz
112150
RCC_OscInitStruct.PLL.PLLN = 250; // Multiply up to 500MHz VCO clock
113151
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1_VCIRANGE_1;
114152
}

targets/TARGET_STM/lp_ticker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void lp_ticker_init(void)
266266
#if defined (LPTIM_ACTIVEEDGE_FALLING)
267267
LptimHandle.Init.Trigger.ActiveEdge = LPTIM_ACTIVEEDGE_FALLING;
268268
#endif
269-
#if defined(TARGET_STM32U5) || defined(TARGET_STM32U0)
269+
#if defined(TARGET_STM32U5) || defined(TARGET_STM32H5) || defined(TARGET_STM32U0)
270270
LptimHandle.Init.Period = 0xFFFF;
271271
#endif
272272
#if defined (LPTIM_TRIGSAMPLETIME_DIRECTTRANSITION)

targets/TARGET_STM/trng_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void trng_init(trng_t *obj)
8888
}
8989
}
9090

91-
#elif defined(TARGET_STM32G4) || defined(TARGET_STM32U0)
91+
#elif defined(TARGET_STM32G4) || defined(TARGET_STM32H5) || defined(TARGET_STM32U0)
9292
/* RNG and USB clocks have the same HSI48 source which has been enabled in SetSysClock */
9393
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
9494

targets/TARGET_STM/watchdog_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ watchdog_features_t hal_watchdog_get_platform_features(void)
137137
features.clock_max_frequency = 47000;
138138
#elif defined(STM32F0) || defined(STM32F3)
139139
features.clock_max_frequency = 50000;
140-
#elif defined(STM32H7) || defined(STM32L4) || defined(STM32U5)
140+
#elif defined(STM32H7) || defined(STM32L4) || defined(STM32U5) || defined(STM32H5)
141141
features.clock_max_frequency = 33600;
142142
#elif defined(STM32G0) || defined(STM32L5) || defined(STM32G4) || defined(STM32WB) || defined(STM32WL) || defined(STM32U0)
143143
features.clock_max_frequency = 34000;

targets/targets.json5

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3060,7 +3060,7 @@ mode is recommended for target MCUs with small amounts of flash and RAM.",
30603060
"STM32G4A1xx"
30613061
]
30623062
},
3063-
3063+
30643064
// STM32H5 Targets -------------------------------------------------------------------------------------------------
30653065
"MCU_STM32H5": {
30663066
"inherits": [
@@ -3104,14 +3104,13 @@ mode is recommended for target MCUs with small amounts of flash and RAM.",
31043104
"device_has_add": [
31053105
"MPU",
31063106
"ANALOGOUT",
3107-
"SPI_32BIT_WORDS"
3107+
"SPI_32BIT_WORDS",
3108+
"TRNG"
31083109
],
31093110
"device_has_remove": [
31103111
"FLASH",
3111-
"LPTICKER",
31123112
"CAN",
3113-
"SERIAL_FC",
3114-
"WATCHDOG"
3113+
"SERIAL_FC"
31153114
],
31163115
"is_mcu_family_target": true
31173116
},
@@ -3193,7 +3192,7 @@ mode is recommended for target MCUs with small amounts of flash and RAM.",
31933192
"device_name": "STM32H563ZITx",
31943193
"image_url": "https://www.st.com/bin/ecommerce/api/image.PF274337.en.feature-description-include-personalized-no-cpn-medium.jpg"
31953194
},
3196-
3195+
31973196
// STM32H7 Targets -------------------------------------------------------------------------------------------------
31983197
"MCU_STM32H7": {
31993198
"inherits": [
@@ -3435,7 +3434,7 @@ mode is recommended for target MCUs with small amounts of flash and RAM.",
34353434
],
34363435
"device_name": "STM32H745ZITx"
34373436
},
3438-
3437+
34393438
// These targets contain the extra bits to add to the MCU_STM32H745xI target to set it for the
34403439
// CM4 or CM7 core.
34413440
"MCU_STM32H745xI_CM4": {
@@ -4894,7 +4893,7 @@ mode is recommended for target MCUs with small amounts of flash and RAM.",
48944893
],
48954894
"image_url": "https://www.st.com/bin/ecommerce/api/image.PF273876.en.feature-description-include-personalized-no-cpn-large.jpg"
48964895
},
4897-
4896+
48984897
// STM32U5 Targets -------------------------------------------------------------------------------------------------
48994898
"MCU_STM32U5": {
49004899
"inherits": [

0 commit comments

Comments
 (0)