summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-12-09 17:39:34 +0000
committerDamien George <damien.p.george@gmail.com>2015-12-09 17:39:34 +0000
commitf54a96d6a20df998eb70a5cffe63f5ea885595c8 (patch)
tree9944fc64738623a03c388ba2740605dd9715a0b5
parent3ff259a262a6619325211909bbf3781538232b6f (diff)
downloadmicropython-f54a96d6a20df998eb70a5cffe63f5ea885595c8.tar.gz
micropython-f54a96d6a20df998eb70a5cffe63f5ea885595c8.zip
stmhal/timer: Use mp_float_t instead of float.
This way mp_float_t can be changed to, eg, double.
-rw-r--r--stmhal/timer.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/stmhal/timer.c b/stmhal/timer.c
index bca3f5457a..a97f1f259c 100644
--- a/stmhal/timer.c
+++ b/stmhal/timer.c
@@ -361,13 +361,13 @@ STATIC uint32_t compute_pwm_value_from_percent(uint32_t period, mp_obj_t percent
if (0) {
#if MICROPY_PY_BUILTINS_FLOAT
} else if (MP_OBJ_IS_TYPE(percent_in, &mp_type_float)) {
- float percent = mp_obj_get_float(percent_in);
+ mp_float_t percent = mp_obj_get_float(percent_in);
if (percent <= 0.0) {
cmp = 0;
} else if (percent >= 100.0) {
cmp = period;
} else {
- cmp = percent / 100.0 * ((float)period);
+ cmp = percent / 100.0 * ((mp_float_t)period);
}
#endif
} else {
@@ -391,11 +391,11 @@ STATIC uint32_t compute_pwm_value_from_percent(uint32_t period, mp_obj_t percent
// Helper function to compute percentage from timer perion and PWM value.
STATIC mp_obj_t compute_percent_from_pwm_value(uint32_t period, uint32_t cmp) {
#if MICROPY_PY_BUILTINS_FLOAT
- float percent;
+ mp_float_t percent;
if (cmp >= period) {
percent = 100.0;
} else {
- percent = (float)cmp * 100.0 / ((float)period);
+ percent = (mp_float_t)cmp * 100.0 / ((mp_float_t)period);
}
return mp_obj_new_float(percent);
#else