drivers: timer: stm32 lptim: Fix the st,timeout runtime check
Existing check failed on correct settings. Add an assert to fasten the debug. Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
This commit is contained in:
parent
e99db0ddd2
commit
a884e3b537
@ -456,15 +456,13 @@ static int sys_clock_driver_init(void)
|
||||
#if DT_PROP(DT_NODELABEL(stm32_lp_tick_source), st_timeout)
|
||||
uint32_t timeout = DT_PROP(DT_NODELABEL(stm32_lp_tick_source), st_timeout);
|
||||
|
||||
/*
|
||||
* Check if prescaler corresponding to 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 (timeout > (lptim_clock_presc / lptim_clock_freq) * 0xFFFF) {
|
||||
if (timeout > (lptim_clock_presc * 0xFFFF) / lptim_clock_freq) {
|
||||
__ASSERT(0,
|
||||
"st,timeout can't be higher than range defined by LPTIM presc and freq");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Define the lptim_time_base that should be set to expire at "timeout" seconds
|
||||
* running counter at (lptim_clock_freq divided by lptim_clock_presc) Hz
|
||||
|
||||
Loading…
Reference in New Issue
Block a user