Skip to content

Commit

Permalink
stm32/timer: Cannot specify timer callbacks using callback().
Browse files Browse the repository at this point in the history
Fixes issue micropython#8732
  • Loading branch information
yn386 committed Sep 1, 2022
1 parent 0b26efe commit 50caa3b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ports/stm32/timer.c
Expand Up @@ -1576,6 +1576,7 @@ STATIC mp_obj_t pyb_timer_channel_callback(mp_obj_t self_in, mp_obj_t callback)
switch (self->mode) {
case CHANNEL_MODE_PWM_NORMAL:
case CHANNEL_MODE_PWM_INVERTED:
HAL_TIM_PWM_Stop_IT(&self->timer->tim, TIMER_CHANNEL(self));
HAL_TIM_PWM_Start_IT(&self->timer->tim, TIMER_CHANNEL(self));
break;
case CHANNEL_MODE_OC_TIMING:
Expand All @@ -1584,9 +1585,11 @@ STATIC mp_obj_t pyb_timer_channel_callback(mp_obj_t self_in, mp_obj_t callback)
case CHANNEL_MODE_OC_TOGGLE:
case CHANNEL_MODE_OC_FORCED_ACTIVE:
case CHANNEL_MODE_OC_FORCED_INACTIVE:
HAL_TIM_OC_Stop_IT(&self->timer->tim, TIMER_CHANNEL(self));
HAL_TIM_OC_Start_IT(&self->timer->tim, TIMER_CHANNEL(self));
break;
case CHANNEL_MODE_IC:
HAL_TIM_IC_Stop_IT(&self->timer->tim, TIMER_CHANNEL(self));
HAL_TIM_IC_Start_IT(&self->timer->tim, TIMER_CHANNEL(self));
break;
}
Expand Down

0 comments on commit 50caa3b

Please sign in to comment.