/* \method callback(fun) Set the function to be called when the timer triggers.  */
STATIC mp_obj_t pyb_timer_callback(mp_obj_t self_in, mp_obj_t callback)
/* \method callback(fun) Set the function to be called when the timer triggers.  */
STATIC mp_obj_t pyb_timer_callback(mp_obj_t self_in, mp_obj_t callback)
{
        __HAL_TIM_DISABLE_IT(&self->tim, TIM_IT_UPDATE);
        self->callback = mp_const_none;
    } else if (mp_obj_is_callable(callback)) {
        __HAL_TIM_DISABLE_IT(&self->tim, TIM_IT_UPDATE);
        self->callback = callback;
        __HAL_TIM_CLEAR_FLAG(&self->tim, TIM_IT_UPDATE);
        HAL_TIM_Base_Stop(&self->tim);
        HAL_TIM_Base_Start_IT(&self->tim);
        HAL_NVIC_EnableIRQ(self->irqn);
    } else {
        mp_raise_ValueError(MP_ERROR_TEXT("callback must be None or a callable object"));
    }
    return mp_const_none;
}