Skip to content

Commit

Permalink
nimble/ll: Update ticks conversions for MCUs with idiv support
Browse files Browse the repository at this point in the history
We can use simple calculations for MCUs that support idiv. This has also
larger range of allowed values on uint32_t values.
  • Loading branch information
andrzej-kaczmarek authored and rymanluk committed Aug 5, 2024
1 parent f4702af commit c8de4cc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nimble/controller/include/controller/ble_ll_tmr.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,17 @@ ble_ll_tmr_u2t(uint32_t usecs)
return usecs / 32;
#endif
#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
#if __ARM_FEATURE_IDIV
if (usecs < 131072) {
return (usecs * 32768) / 1000000;
} else {
return ((uint64_t)usecs * 32768) / 1000000;
}
#else
if (usecs <= 31249) {
return (usecs * 137439) / 4194304;
}
#endif
#endif

return os_cputime_usecs_to_ticks(usecs);
Expand Down

0 comments on commit c8de4cc

Please sign in to comment.