Skip to content

Commit 67c78b9

Browse files
committed
[WB] Move HSE Capacitor Tuning api to clock api file
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 64b7d90 commit 67c78b9

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

Diff for: cores/arduino/stm32/clock.h

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ uint32_t getCurrentMillis(void);
6262
uint32_t getCurrentMicros(void);
6363

6464
void enableClock(sourceClock_t source);
65+
void configHSECapacitorTuning(void);
66+
6567
#ifdef __cplusplus
6668
}
6769
#endif

Diff for: libraries/SrcWrapper/src/stm32/clock.c

+14
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
*/
3838
#include "backup.h"
3939
#include "clock.h"
40+
#include "otp.h"
4041
#include "stm32yyxx_ll_cortex.h"
42+
#include "stm32yyxx_ll_rcc.h"
4143

4244
#ifdef __cplusplus
4345
extern "C" {
@@ -160,6 +162,18 @@ void enableClock(sourceClock_t source)
160162
}
161163
}
162164

165+
void configHSECapacitorTuning(void)
166+
{
167+
#if defined(OTP_AREA_BASE) && defined(STM32WBxx)
168+
OTP_BT_t *p_otp;
169+
/* Read HSE_Tuning from OTP with index 0 */
170+
p_otp = (OTP_BT_t *) OTP_Read(0);
171+
if (p_otp) {
172+
LL_RCC_HSE_SetCapacitorTuning(p_otp->hse_tuning);
173+
}
174+
#endif
175+
}
176+
163177
#ifdef __cplusplus
164178
}
165179
#endif

Diff for: variants/PNUCLEO_WB55RG/variant.cpp

+2-15
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
#include "pins_arduino.h"
20-
#include "otp.h"
20+
#include "clock.h"
2121

2222
#ifdef __cplusplus
2323
extern "C" {
@@ -89,19 +89,6 @@ const PinName digitalPin[] = {
8989
extern "C" {
9090
#endif
9191

92-
static void Config_HSE(void)
93-
{
94-
OTP_BT_t *p_otp;
95-
96-
/**
97-
* Read HSE_Tuning from OTP
98-
*/
99-
p_otp = (OTP_BT_t *) OTP_Read(0);
100-
if (p_otp) {
101-
LL_RCC_HSE_SetCapacitorTuning(p_otp->hse_tuning);
102-
}
103-
}
104-
10592
/**
10693
* @brief System Clock Configuration
10794
* @param None
@@ -113,7 +100,7 @@ WEAK void SystemClock_Config(void)
113100
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
114101
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {};
115102

116-
Config_HSE();
103+
configHSECapacitorTuning();
117104

118105
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
119106
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

0 commit comments

Comments
 (0)