This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit b438b7a0838e8644563c314680c78e47ca4220e7 Author: ouyangxiangzhen <[email protected]> AuthorDate: Wed May 20 09:51:02 2026 +0800 timers/clkcnt: Round-up when converting nsec to cnt Use round-up logic in clkcnt_delta_time2cnt() to prevent timer sleep duration being too short due to truncation. Signed-off-by: ouyangxiangzhen <[email protected]> --- include/nuttx/timers/clkcnt.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/nuttx/timers/clkcnt.h b/include/nuttx/timers/clkcnt.h index e9ed6487936..b835ea03249 100644 --- a/include/nuttx/timers/clkcnt.h +++ b/include/nuttx/timers/clkcnt.h @@ -178,7 +178,9 @@ clkcnt_t clkcnt_delta_time2cnt(uint64_t time, uint32_t freq, uint32_t scale) DEBUGASSERT(time <= CLKCNT_MAX / freq); - return div_const(time * freq, scale); + /* Round-up to the scale. */ + + return div_const(time * freq + (scale - 1u), scale); } /****************************************************************************
