diff options
author | Damien George <damien.p.george@gmail.com> | 2016-01-29 22:44:43 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-01-29 22:44:43 +0000 |
commit | a8a4b01af6501ff7ab61b251fc30fcf8a286f8d1 (patch) | |
tree | 635f0e2dd81d6391ca77f4866f93ba1b3d8a06b9 /stmhal/timer.h | |
parent | ea89b80ff4f842b010f9f8ec3280675f81bc6bc5 (diff) | |
download | micropython-a8a4b01af6501ff7ab61b251fc30fcf8a286f8d1.tar.gz micropython-a8a4b01af6501ff7ab61b251fc30fcf8a286f8d1.zip |
stmhal: Add PWM capability for LED(3) and LED(4) on pyboards.
USB CDC no longer needs TIM3 (which was originally used for LED(4) PWM)
and so TIM3 has been freed for general purpose use by the user. Hence
LED(4) lost its PWM capabilities.
This patch reinstates the PWM capabilities using a semi-generic piece
of code which allows to configure a timer and PWM channel to use for any
LED. But the PWM capability is only configured if the LED is set to an
intensity between 1 and 254 (ie only when needed). In that case the
relevant timer is configured for PWM. It's up to the user to make sure
the timers are not used if PWM is active.
This patch also makes sure that PWM LEDs are turned off using standard
GPIO when calling led.off() or led.intensity(0), instead of just setting
the PWM counter to zero.
Diffstat (limited to 'stmhal/timer.h')
-rw-r--r-- | stmhal/timer.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/stmhal/timer.h b/stmhal/timer.h index 89b3c79f4f..a18d7cf104 100644 --- a/stmhal/timer.h +++ b/stmhal/timer.h @@ -31,9 +31,8 @@ extern const mp_obj_type_t pyb_timer_type; void timer_init0(void); void timer_tim5_init(void); TIM_HandleTypeDef *timer_tim6_init(uint freq); - void timer_deinit(void); - +uint32_t timer_get_source_freq(uint32_t tim_id); void timer_irq_handler(uint tim_id); TIM_HandleTypeDef *pyb_timer_get_handle(mp_obj_t timer); |