Skip to content

Commit 9187b81

Browse files
kernel/os: Allow 32000Hz for os_cputime
This allows to run NimBLE LL with 32000Hz LFXO.
1 parent 190d120 commit 9187b81

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

kernel/os/include/os/os_cputime.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ extern "C" {
5454

5555
#define OS_CPUTIME_FREQ_1MHZ
5656

57+
#elif MYNEWT_VAL(OS_CPUTIME_FREQ) == 32000
58+
59+
#define OS_CPUTIME_FREQ_32000HZ
60+
5761
#elif MYNEWT_VAL(OS_CPUTIME_FREQ) == 256 || \
5862
MYNEWT_VAL(OS_CPUTIME_FREQ) == 512 || \
5963
MYNEWT_VAL(OS_CPUTIME_FREQ) == 1024 || \
@@ -171,6 +175,20 @@ os_cputime_ticks_to_usecs(uint32_t ticks)
171175
return ticks * (1000000 / MYNEWT_VAL(OS_CPUTIME_FREQ));
172176
}
173177

178+
#elif defined(OS_CPUTIME_FREQ_32000HZ)
179+
180+
static inline uint32_t
181+
os_cputime_usecs_to_ticks(uint32_t usecs)
182+
{
183+
return usecs * 4 / 125;
184+
}
185+
186+
static inline uint32_t
187+
os_cputime_ticks_to_usecs(uint32_t ticks)
188+
{
189+
return ticks * 125 / 4;
190+
}
191+
174192
#else
175193

176194
/**

0 commit comments

Comments
 (0)