Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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]>
  • Loading branch information
ABOSTM committed Apr 16, 2021
commit cd49498a4323f66c95af523dfe25b5b6ce1349d6
1 change: 1 addition & 0 deletions cores/arduino/stm32/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef enum {
uint32_t getCurrentMillis(void);
uint32_t getCurrentMicros(void);

void configIPClock(void);
void enableClock(sourceClock_t source);
void configHSECapacitorTuning(void);

Expand Down
1 change: 0 additions & 1 deletion cores/arduino/stm32/usb/usbd_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ WEAK void USBD_reenumerate(void)
* do not manage the internal pull-up, so manage
* internal pull-up manually.
*/
__HAL_RCC_SYSCFG_CLK_ENABLE();
LL_SYSCFG_DisableUSBPullUp();
delay(USBD_ENUM_DELAY);
LL_SYSCFG_EnableUSBPullUp();
Expand Down
22 changes: 22 additions & 0 deletions libraries/SrcWrapper/src/stm32/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,28 @@ void configHSECapacitorTuning(void)
#endif
}

/**
* @brief This function enables clocks for some system IP
* @param None
* @retval None
*/
void configIPClock(void)
{
#ifdef HSEM_BASE
__HAL_RCC_HSEM_CLK_ENABLE();
#endif

#if defined(__HAL_RCC_PWR_CLK_ENABLE)
/* Enable PWR clock, needed for example: voltage scaling, low power ... */
__HAL_RCC_PWR_CLK_ENABLE();
#endif

#if defined(__HAL_RCC_SYSCFG_CLK_ENABLE)
/* Enable SYSCFG clock, needed for example: Pin remap or Analog switch ... */
__HAL_RCC_SYSCFG_CLK_ENABLE();
#endif
}

#ifdef __cplusplus
}
#endif
Expand Down
11 changes: 2 additions & 9 deletions libraries/SrcWrapper/src/stm32/hw_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ extern "C" {
*/
void hw_config_init(void)
{
configIPClock();

/* Init DWT if present */
#ifdef DWT_BASE
dwt_init();
Expand All @@ -34,17 +36,8 @@ void hw_config_init(void)
/* Initialize the HAL */
HAL_Init();

#ifdef HSEM_BASE
__HAL_RCC_HSEM_CLK_ENABLE();
#endif

configHSECapacitorTuning();

#if defined(__HAL_RCC_PWR_CLK_ENABLE)
/* Enable PWR clock, needed for example: voltage scaling, low power ... */
__HAL_RCC_PWR_CLK_ENABLE();
#endif

/* Configure the system clock */
SystemClock_Config();

Expand Down
1 change: 0 additions & 1 deletion libraries/SrcWrapper/src/stm32/pinmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ void pin_function(PinName pin, int function)

/* Handle pin remap if any */
#if defined(LL_SYSCFG_PIN_RMP_PA11) && defined(LL_SYSCFG_PIN_RMP_PA12) || defined(SYSCFG_CFGR1_PA11_PA12_RMP)
__HAL_RCC_SYSCFG_CLK_ENABLE();
switch (pin & PNAME_MASK) {
#if defined(SYSCFG_CFGR1_PA11_PA12_RMP)
/* Disable PIN pair PA11/12 mapped instead of PA9/10 */
Expand Down
6 changes: 0 additions & 6 deletions libraries/SrcWrapper/src/stm32/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,6 @@ void uart_init(serial_t *obj, uint32_t baudrate, uint32_t databits, uint32_t par
}
#endif

#if defined(STM32F091xC) || defined (STM32F098xx)
/* Enable SYSCFG Clock */
/* Required to get SYSCFG interrupt status register */
__HAL_RCC_SYSCFG_CLK_ENABLE();
#endif

/* Configure UART GPIO pins */
pinmap_pinout(obj->pin_tx, PinMap_UART_TX);
if (uart_rx != NP) {
Expand Down