drivers: stm32 lptim driver with a exact LPTIM timeout value
With this change, the LPTIM counter will be able to set its timeout to the st,timeout value. So that system can sleep for that period without interruption. Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
parent
dfa170e909
commit
27bb4961b3
|
@ -450,6 +450,26 @@ static int sys_clock_driver_init(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if DT_INST_NODE_HAS_PROP(0, st_timeout)
|
||||
/*
|
||||
* Check if prescaler corresponding to the DT_INST_PROP(0, st_timeout)
|
||||
* is matching the lptim_clock_presc calculated one from the lptim_clock_freq
|
||||
* max lptim period is 0xFFFF/(lptim_clock_freq/lptim_clock_presc)
|
||||
*/
|
||||
if (DT_INST_PROP(0, st_timeout) >
|
||||
(lptim_clock_presc / lptim_clock_freq) * 0xFFFF) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/*
|
||||
* LPTIM is counting DT_INST_PROP(0, st_timeout),
|
||||
* seconds at lptim_clock_freq divided lptim_clock_presc) Hz",
|
||||
* lptim_time_base is the autoreload counter
|
||||
*/
|
||||
lptim_time_base = 2 * (lptim_clock_freq *
|
||||
(uint32_t)DT_INST_PROP(0, st_timeout))
|
||||
/ lptim_clock_presc;
|
||||
#else
|
||||
/* Set LPTIM time base based on clock source freq */
|
||||
if (lptim_clock_freq == KHZ(32)) {
|
||||
lptim_time_base = 0xF9FF;
|
||||
|
@ -459,6 +479,8 @@ static int sys_clock_driver_init(void)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
#endif /* st_timeout */
|
||||
|
||||
#if !defined(CONFIG_STM32_LPTIM_TICK_FREQ_RATIO_OVERRIDE)
|
||||
/*
|
||||
* Check coherency between CONFIG_SYS_CLOCK_TICKS_PER_SEC
|
||||
|
|
|
@ -45,3 +45,10 @@ properties:
|
|||
- 32
|
||||
- 64
|
||||
- 128
|
||||
|
||||
st,timeout:
|
||||
type: int
|
||||
description: |
|
||||
Gives the LPTIM an exact counting value (s) for timeout expiration.
|
||||
Valid range is [1, 256] and should be consistent with st,prescaler
|
||||
pre-defined setting. If not, an error is raised.
|
||||
|
|
Loading…
Reference in New Issue