Skip to content

Commit 37630b2

Browse files
authored
Merge pull request #8778 from jeromecoutant/PR_LPTIM_DIV
STM32 LPTICKER with LPTIM : reduce clock feature
2 parents 02266db + 1ec222f commit 37630b2

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

targets/TARGET_STM/lp_ticker.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ const ticker_info_t *lp_ticker_get_info()
4444
{
4545
static const ticker_info_t info = {
4646
#if MBED_CONF_TARGET_LSE_AVAILABLE
47-
LSE_VALUE,
47+
LSE_VALUE / MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK,
4848
#else
49-
LSI_VALUE,
49+
LSI_VALUE / MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK,
5050
#endif
5151
16
5252
};
@@ -119,7 +119,17 @@ void lp_ticker_init(void)
119119
LptimHandle.Instance = LPTIM1;
120120
LptimHandle.State = HAL_LPTIM_STATE_RESET;
121121
LptimHandle.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC;
122+
#if defined(MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK)
123+
#if (MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK == 4)
124+
LptimHandle.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV4;
125+
#elif (MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK == 2)
126+
LptimHandle.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV2;
127+
#else
128+
LptimHandle.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1;
129+
#endif
130+
#else
122131
LptimHandle.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1;
132+
#endif /* MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK */
123133

124134
LptimHandle.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE;
125135
LptimHandle.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH;

targets/targets.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,10 @@
17121712
"help": "https://os.mbed.com/docs/latest/porting/low-power-ticker.html",
17131713
"value": 1,
17141714
"macro_name": "LPTICKER_DELAY_TICKS"
1715+
},
1716+
"lpticker_lptim_clock": {
1717+
"help": "Default value for LPTIM clock (lpticker_lptim == 1). Value is the dividing factor. Choose 1, 2 or 4",
1718+
"value": 1
17151719
}
17161720
},
17171721
"device_has": [

0 commit comments

Comments
 (0)