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 2022/01/31 08:20:27 UTC

[mynewt-core] branch master updated (2127bbd -> 5c81230)

This is an automated email from the ASF dual-hosted git repository.

andk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.


    from 2127bbd  ublox-bmd-345: Enable PA/LNA by default
     new e57a369  kernel/os: Add support for (1MHz/powerof2) cputime
     new 5c81230  kernel/os: Fix integer overlow on tickless calculations

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 kernel/os/include/os/os_cputime.h | 23 ++++++++++++++++++++---
 kernel/os/src/os.c                |  4 ++--
 2 files changed, 22 insertions(+), 5 deletions(-)

[mynewt-core] 02/02: kernel/os: Fix integer overlow on tickless calculations

Posted by an...@apache.org.
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

commit 5c81230f3ae5c6bc45604fba594e9f9340cb6d3a
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Sat Jan 29 11:29:55 2022 +0100

    kernel/os: Fix integer overlow on tickless calculations
    
    When using large OS_TICKS_PER_SEC value there will be integer overflow
    error on multiplication. We can just explicitly perform calculations
    using uint64_t, this done at build time anyway and the result will be
    uint32_t unless some really big values are used in which case we do not
    care. This is to allow CMAC work at 31250 ticks per sec.
---
 kernel/os/src/os.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/os/src/os.c b/kernel/os/src/os.c
index bc88ef9..e926337 100644
--- a/kernel/os/src/os.c
+++ b/kernel/os/src/os.c
@@ -79,8 +79,8 @@ static struct hal_timer os_wdog_monitor;
  */
 int g_os_started;
 
-#define MIN_IDLE_TICKS  (MYNEWT_VAL(OS_IDLE_TICKLESS_MS_MIN) * OS_TICKS_PER_SEC / 1000)
-#define MAX_IDLE_TICKS  (MYNEWT_VAL(OS_IDLE_TICKLESS_MS_MAX) * OS_TICKS_PER_SEC / 1000)
+#define MIN_IDLE_TICKS  (uint32_t)((uint64_t)MYNEWT_VAL(OS_IDLE_TICKLESS_MS_MIN) * OS_TICKS_PER_SEC / 1000)
+#define MAX_IDLE_TICKS  (uint32_t)((uint64_t)MYNEWT_VAL(OS_IDLE_TICKLESS_MS_MAX) * OS_TICKS_PER_SEC / 1000)
 
 /**
  * Idle operating system task, runs when no other tasks are running.

[mynewt-core] 01/02: kernel/os: Add support for (1MHz/powerof2) cputime

Posted by an...@apache.org.
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

commit e57a369870934b60f82b185b3f65c0dfed5b4be3
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Jan 28 15:22:58 2022 +0100

    kernel/os: Add support for (1MHz/powerof2) cputime
    
    This adds support for os_cputime working at frequency of 1MHz divided
    by power of 2. All integral frequencies are supported. This is to allow
    CMAC work at 31250 Hz.
---
 kernel/os/include/os/os_cputime.h | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/kernel/os/include/os/os_cputime.h b/kernel/os/include/os/os_cputime.h
index f0f1869..a6565e7 100644
--- a/kernel/os/include/os/os_cputime.h
+++ b/kernel/os/include/os/os_cputime.h
@@ -44,7 +44,13 @@ extern "C" {
  * definition for OS_CPUTIME_FREQ to the desired frequency in your project,
  * target or bsp.
  */
-#if (MYNEWT_VAL(OS_CPUTIME_FREQ) == 1000000)
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 15625      ||  \
+    MYNEWT_VAL(OS_CPUTIME_FREQ) == 31250      ||  \
+    MYNEWT_VAL(OS_CPUTIME_FREQ) == 62500      ||  \
+    MYNEWT_VAL(OS_CPUTIME_FREQ) == 125000     ||  \
+    MYNEWT_VAL(OS_CPUTIME_FREQ) == 250000     ||  \
+    MYNEWT_VAL(OS_CPUTIME_FREQ) == 500000     ||  \
+    MYNEWT_VAL(OS_CPUTIME_FREQ) == 1000000
 
 #define OS_CPUTIME_FREQ_1MHZ
 
@@ -143,8 +149,19 @@ void os_cputime_delay_nsecs(uint32_t nsecs);
 #endif
 
 #if defined(OS_CPUTIME_FREQ_1MHZ)
-#define os_cputime_usecs_to_ticks(x)    (x)
-#define os_cputime_ticks_to_usecs(x)    (x)
+
+static inline uint32_t
+os_cputime_usecs_to_ticks(uint32_t usecs)
+{
+    return usecs / (1000000 / MYNEWT_VAL(OS_CPUTIME_FREQ));
+}
+
+static inline uint32_t
+os_cputime_ticks_to_usecs(uint32_t ticks)
+{
+    return ticks * (1000000 / MYNEWT_VAL(OS_CPUTIME_FREQ));
+}
+
 #else
 
 /**