You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2021/10/05 15:28:49 UTC
[mynewt-core] branch master updated: hw/mcu/cmac: Fix hal_timer_read
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new d8737c0 hw/mcu/cmac: Fix hal_timer_read
d8737c0 is described below
commit d8737c05cdfb1f0615962e13feb2cf7968c70dee
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Oct 4 22:47:47 2021 +0200
hw/mcu/cmac: Fix hal_timer_read
This is regression after c9f72793d712365e6bdc0b5a3386f6e3caebee11.
LLT value stored for given HAL value needs to correspond precisely to
HAL value converted to LLT, otherwise conversion from HAL to LLL will
not be accurate and calculated times e.g. for scheduling may be off by
up to 1 tick.
---
hw/mcu/dialog/cmac/include/mcu/cmac_timer.h | 2 +-
hw/mcu/dialog/cmac/src/hal_timer.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/mcu/dialog/cmac/include/mcu/cmac_timer.h b/hw/mcu/dialog/cmac/include/mcu/cmac_timer.h
index 8e5ad8d..ca93ef7 100644
--- a/hw/mcu/dialog/cmac/include/mcu/cmac_timer.h
+++ b/hw/mcu/dialog/cmac/include/mcu/cmac_timer.h
@@ -184,7 +184,7 @@ cmac_timer_write_eq_hal_os_tick(uint64_t val)
}
/* Convert ll_timer value to hal_timer value */
-static inline uint32_t
+static inline uint64_t
cmac_timer_convert_llt2hal(uint64_t val)
{
return (val << 9) / 15625;
diff --git a/hw/mcu/dialog/cmac/src/hal_timer.c b/hw/mcu/dialog/cmac/src/hal_timer.c
index 1860ba1..92983eb 100644
--- a/hw/mcu/dialog/cmac/src/hal_timer.c
+++ b/hw/mcu/dialog/cmac/src/hal_timer.c
@@ -209,12 +209,13 @@ uint32_t
hal_timer_read(int timer_num)
{
uint64_t llt;
- uint32_t val;
+ uint64_t val;
assert(timer_num == 0);
llt = cmac_timer_read64();
val = cmac_timer_convert_llt2hal(llt);
+ llt = (val * 15625) >> 9;
__disable_irq();