diff options
author | Damien George <damien.p.george@gmail.com> | 2015-01-08 17:55:55 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-01-08 17:55:55 +0000 |
commit | 7a53ac8ec269c91b9ccb79a521a6ba31b0bb1c9d (patch) | |
tree | a5feb8c4c047c17c901dca4f33ccec01c3417057 /stmhal | |
parent | c33ecb83ba4bc388cd773eec827dc0b85505dce7 (diff) | |
download | micropython-7a53ac8ec269c91b9ccb79a521a6ba31b0bb1c9d.tar.gz micropython-7a53ac8ec269c91b9ccb79a521a6ba31b0bb1c9d.zip |
stmhal: Allow to build without float support if wanted.
Diffstat (limited to 'stmhal')
-rw-r--r-- | stmhal/timer.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/stmhal/timer.c b/stmhal/timer.c index 87239a5b8f..1342d33ecf 100644 --- a/stmhal/timer.c +++ b/stmhal/timer.c @@ -985,10 +985,13 @@ STATIC mp_obj_t pyb_timer_freq(mp_uint_t n_args, const mp_obj_t *args) { uint32_t period = __HAL_TIM_GetAutoreload(&self->tim) & TIMER_CNT_MASK(self); uint32_t source_freq = timer_get_source_freq(self->tim_id); uint32_t divide = ((prescaler + 1) * (period + 1)); - if (source_freq % divide == 0) { - return mp_obj_new_int(source_freq / divide); - } else { + #if MICROPY_PY_BUILTINS_FLOAT + if (source_freq % divide != 0) { return mp_obj_new_float((float)source_freq / (float)divide); + } else + #endif + { + return mp_obj_new_int(source_freq / divide); } } else { // set |