Skip to content

Commit 088209c

Browse files
ABOSTMfpistm
authored andcommitted
Group system IP clock enable in separate function called at init
This new function could be called by STM32duino_Low_Power library Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent ba52cf2 commit 088209c

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed

cores/arduino/stm32/clock.h

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ typedef enum {
3737
uint32_t getCurrentMillis(void);
3838
uint32_t getCurrentMicros(void);
3939

40+
void configIPClock(void);
4041
void enableClock(sourceClock_t source);
4142
void configHSECapacitorTuning(void);
4243

cores/arduino/stm32/usb/usbd_if.c

-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ WEAK void USBD_reenumerate(void)
151151
* do not manage the internal pull-up, so manage
152152
* internal pull-up manually.
153153
*/
154-
__HAL_RCC_SYSCFG_CLK_ENABLE();
155154
LL_SYSCFG_DisableUSBPullUp();
156155
delay(USBD_ENUM_DELAY);
157156
LL_SYSCFG_EnableUSBPullUp();

libraries/SrcWrapper/src/stm32/clock.c

+22
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,28 @@ void configHSECapacitorTuning(void)
152152
#endif
153153
}
154154

155+
/**
156+
* @brief This function enables clocks for some system IP
157+
* @param None
158+
* @retval None
159+
*/
160+
void configIPClock(void)
161+
{
162+
#ifdef HSEM_BASE
163+
__HAL_RCC_HSEM_CLK_ENABLE();
164+
#endif
165+
166+
#if defined(__HAL_RCC_PWR_CLK_ENABLE)
167+
/* Enable PWR clock, needed for example: voltage scaling, low power ... */
168+
__HAL_RCC_PWR_CLK_ENABLE();
169+
#endif
170+
171+
#if defined(__HAL_RCC_SYSCFG_CLK_ENABLE)
172+
/* Enable SYSCFG clock, needed for example: Pin remap or Analog switch ... */
173+
__HAL_RCC_SYSCFG_CLK_ENABLE();
174+
#endif
175+
}
176+
155177
#ifdef __cplusplus
156178
}
157179
#endif

libraries/SrcWrapper/src/stm32/hw_config.c

+2-9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ extern "C" {
2626
*/
2727
void hw_config_init(void)
2828
{
29+
configIPClock();
30+
2931
/* Init DWT if present */
3032
#ifdef DWT_BASE
3133
dwt_init();
@@ -34,17 +36,8 @@ void hw_config_init(void)
3436
/* Initialize the HAL */
3537
HAL_Init();
3638

37-
#ifdef HSEM_BASE
38-
__HAL_RCC_HSEM_CLK_ENABLE();
39-
#endif
40-
4139
configHSECapacitorTuning();
4240

43-
#if defined(__HAL_RCC_PWR_CLK_ENABLE)
44-
/* Enable PWR clock, needed for example: voltage scaling, low power ... */
45-
__HAL_RCC_PWR_CLK_ENABLE();
46-
#endif
47-
4841
/* Configure the system clock */
4942
SystemClock_Config();
5043

libraries/SrcWrapper/src/stm32/pinmap.c

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ void pin_function(PinName pin, int function)
7474

7575
/* Handle pin remap if any */
7676
#if defined(LL_SYSCFG_PIN_RMP_PA11) && defined(LL_SYSCFG_PIN_RMP_PA12) || defined(SYSCFG_CFGR1_PA11_PA12_RMP)
77-
__HAL_RCC_SYSCFG_CLK_ENABLE();
7877
switch (pin & PNAME_MASK) {
7978
#if defined(SYSCFG_CFGR1_PA11_PA12_RMP)
8079
/* Disable PIN pair PA11/12 mapped instead of PA9/10 */

libraries/SrcWrapper/src/stm32/uart.c

-6
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,6 @@ void uart_init(serial_t *obj, uint32_t baudrate, uint32_t databits, uint32_t par
272272
}
273273
#endif
274274

275-
#if defined(STM32F091xC) || defined (STM32F098xx)
276-
/* Enable SYSCFG Clock */
277-
/* Required to get SYSCFG interrupt status register */
278-
__HAL_RCC_SYSCFG_CLK_ENABLE();
279-
#endif
280-
281275
/* Configure UART GPIO pins */
282276
pinmap_pinout(obj->pin_tx, PinMap_UART_TX);
283277
if (uart_rx != NP) {

0 commit comments

Comments
 (0)