diff options
author | Joey Castillo <jose.castillo@gmail.com> | 2021-08-29 15:50:46 -0400 |
---|---|---|
committer | Joey Castillo <jose.castillo@gmail.com> | 2021-08-29 17:11:31 -0400 |
commit | 34ec77c7fdb29afaca981624153fa0f16350c632 (patch) | |
tree | cc9661f5c92322ec529d088ac80e270a7f60775e /watch-library/hpl | |
parent | 74950b110ebed7baf5cd2fa9e86cbf6d40e0fcb1 (diff) | |
download | Sensor-Watch-34ec77c7fdb29afaca981624153fa0f16350c632.tar.gz Sensor-Watch-34ec77c7fdb29afaca981624153fa0f16350c632.tar.bz2 Sensor-Watch-34ec77c7fdb29afaca981624153fa0f16350c632.zip |
handle changing CPU speed
Diffstat (limited to 'watch-library/hpl')
-rw-r--r-- | watch-library/hpl/core/hpl_core_m0plus_base.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/watch-library/hpl/core/hpl_core_m0plus_base.c b/watch-library/hpl/core/hpl_core_m0plus_base.c index 1d32300a..4a79ac3e 100644 --- a/watch-library/hpl/core/hpl_core_m0plus_base.c +++ b/watch-library/hpl/core/hpl_core_m0plus_base.c @@ -41,6 +41,7 @@ #endif #include <utils_assert.h> #include <peripheral_clk_config.h> +#include "watch.h" #ifndef CONF_CPU_FREQUENCY #define CONF_CPU_FREQUENCY 1000000 @@ -167,7 +168,9 @@ static inline uint32_t _get_cycles_for_us_internal(const uint16_t us, const uint */ uint32_t _get_cycles_for_us(const uint16_t us) { - return _get_cycles_for_us_internal(us, CONF_CPU_FREQUENCY, CPU_FREQ_POWER); + uint32_t freq = watch_get_cpu_speed(); + if (freq > 10000000) return _get_cycles_for_us_internal(us, freq, 8); + else return _get_cycles_for_us_internal(us, freq, 7); } /** @@ -196,5 +199,7 @@ static inline uint32_t _get_cycles_for_ms_internal(const uint16_t ms, const uint */ uint32_t _get_cycles_for_ms(const uint16_t ms) { - return _get_cycles_for_ms_internal(ms, CONF_CPU_FREQUENCY, CPU_FREQ_POWER); + uint32_t freq = watch_get_cpu_speed(); + if (freq > 10000000) return _get_cycles_for_ms_internal(ms, freq, 8); + else return _get_cycles_for_ms_internal(ms, freq, 7); } |