Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
92a47b4d
Commit
92a47b4d
authored
Jul 02, 2014
by
Damien George
Browse files
Merge branch 'add-timer-deinit' of github.com:dhylands/micropython into dhylands-add-timer-deinit
parents
9cd96cf2
0d81c133
Changes
3
Hide whitespace changes
Inline
Side-by-side
stmhal/main.c
View file @
92a47b4d
...
...
@@ -548,6 +548,8 @@ soft_reset:
printf
(
"PYB: sync filesystems
\n
"
);
storage_flush
();
timer_deinit
();
printf
(
"PYB: soft reboot
\n
"
);
first_soft_reset
=
false
;
...
...
stmhal/timer.c
View file @
92a47b4d
...
...
@@ -366,13 +366,20 @@ STATIC mp_obj_t pyb_timer_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_KW
(
pyb_timer_init_obj
,
1
,
pyb_timer_init
);
STATIC
mp_obj_t
pyb_timer_callback
(
mp_obj_t
self_in
,
mp_obj_t
callback
);
/// \method deinit()
/// Deinitialises the timer.
///
/// *This function is not yet implemented.*
/// Disables the callback (and the associated irq).
/// Stops the timer, and disables the timer peripheral.
STATIC
mp_obj_t
pyb_timer_deinit
(
mp_obj_t
self_in
)
{
//pyb_timer_obj_t *self = self_in;
// TODO implement me
pyb_timer_obj_t
*
self
=
self_in
;
// Disable the interrupt
pyb_timer_callback
(
self_in
,
mp_const_none
);
HAL_TIM_Base_DeInit
(
&
self
->
tim
);
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_timer_deinit_obj
,
pyb_timer_deinit
);
...
...
@@ -464,6 +471,16 @@ const mp_obj_type_t pyb_timer_type = {
.
locals_dict
=
(
mp_obj_t
)
&
pyb_timer_locals_dict
,
};
// Unregister all interrupt sources
void
timer_deinit
(
void
)
{
for
(
uint
i
=
0
;
i
<
PYB_TIMER_OBJ_ALL_NUM
;
i
++
)
{
pyb_timer_obj_t
*
tim
=
pyb_timer_obj_all
[
i
];
if
(
tim
!=
NULL
)
{
pyb_timer_deinit
(
tim
);
}
}
}
void
timer_irq_handler
(
uint
tim_id
)
{
if
(
tim_id
-
1
<
PYB_TIMER_OBJ_ALL_NUM
)
{
// get the timer object
...
...
stmhal/timer.h
View file @
92a47b4d
...
...
@@ -40,4 +40,6 @@ void timer_tim3_init(void);
void
timer_tim5_init
(
void
);
void
timer_tim6_init
(
uint
freq
);
void
timer_deinit
(
void
);
void
timer_irq_handler
(
uint
tim_id
);
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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