summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-02-13 11:57:29 +0000
committerDamien George <damien.p.george@gmail.com>2015-02-13 11:57:29 +0000
commit418ec8bbbab70ec21486b37860f106f09f2e6f11 (patch)
tree3f9a9b25b9c5ef85d067485ac537d14c4724a72a /stmhal
parent192d536fe40010cc26d2d69d8bc6cdb30928e68d (diff)
downloadmicropython-418ec8bbbab70ec21486b37860f106f09f2e6f11.tar.gz
micropython-418ec8bbbab70ec21486b37860f106f09f2e6f11.zip
stmhal: Properly deinit timer object.
Addresses issue #1113.
Diffstat (limited to 'stmhal')
-rw-r--r--stmhal/timer.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/stmhal/timer.c b/stmhal/timer.c
index 1342d33ecf..e8ea33e682 100644
--- a/stmhal/timer.c
+++ b/stmhal/timer.c
@@ -668,12 +668,7 @@ STATIC mp_obj_t pyb_timer_init(mp_uint_t n_args, const mp_obj_t *args, mp_map_t
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_timer_init_obj, 1, pyb_timer_init);
-/// \method deinit()
-/// Deinitialises the timer.
-///
-/// Disables the callback (and the associated irq).
-/// Disables any channel callbacks (and the associated irq).
-/// Stops the timer, and disables the timer peripheral.
+// timer.deinit()
STATIC mp_obj_t pyb_timer_deinit(mp_obj_t self_in) {
pyb_timer_obj_t *self = self_in;
@@ -691,7 +686,9 @@ STATIC mp_obj_t pyb_timer_deinit(mp_obj_t self_in) {
prev_chan->next = NULL;
}
- HAL_TIM_Base_DeInit(&self->tim);
+ self->tim.Instance->CCER = 0x0000; // disable all capture/compare outputs
+ self->tim.Instance->CR1 = 0x0000; // disable the timer and reset its state
+
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_timer_deinit_obj, pyb_timer_deinit);