Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
7a53ac8e
Commit
7a53ac8e
authored
Jan 08, 2015
by
Damien George
Browse files
stmhal: Allow to build without float support if wanted.
parent
c33ecb83
Changes
1
Hide whitespace changes
Inline
Side-by-side
stmhal/timer.c
View file @
7a53ac8e
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment