timer_reset -> rcc_periph_reset_pulse() replace

timer_reset wasn't fully implemented for all timers on all series, and
was simply a wrapper of the RST bits in the RCC registers anyway.

First part of https://github.com/libopencm3/libopencm3/issues/709
This commit is contained in:
Karl Palsson
2016-12-14 15:15:17 +00:00
committed by Karl Palsson
parent 833da68c18
commit 1260b16772
11 changed files with 12 additions and 11 deletions

View File

@@ -131,7 +131,7 @@ int _write(int file, char *ptr, int len)
*/
static void setup_button_press_timer(void)
{
timer_reset(TIMER_BUTTON_PRESS);
rcc_periph_reset_pulse(TIMER_BUTTON_PRESS_RST);
timer_set_prescaler(TIMER_BUTTON_PRESS, 3999); /* 4Mhz/1000hz - 1 */
timer_set_period(TIMER_BUTTON_PRESS, 0xffff);
timer_enable_counter(TIMER_BUTTON_PRESS);

View File

@@ -44,6 +44,7 @@ extern "C" {
#define BUTTON_DISCO_USER_isr exti0_isr
#define BUTTON_DISCO_USER_NVIC NVIC_EXTI0_IRQ
#define TIMER_BUTTON_PRESS TIM7
#define TIMER_BUTTON_PRESS_RST RST_TIM7
struct state_t {
bool falling;

View File

@@ -137,7 +137,7 @@ void tim6_isr(void)
*/
static void setup_tim6(void)
{
timer_reset(TIM6);
rcc_periph_reset_pulse(RST_TIM6);
/* 24Mhz / 10khz -1. */
timer_set_prescaler(TIM6, 2399); /* 24Mhz/10000hz - 1 */
/* 10khz for 10 ticks = 1 khz overflow = 1ms overflow interrupts */
@@ -154,7 +154,7 @@ static void setup_tim6(void)
*/
static void setup_tim7(void)
{
timer_reset(TIM7);
rcc_periph_reset_pulse(RST_TIM7);
timer_set_prescaler(TIM7, 23999); /* 24Mhz/1000hz - 1 */
timer_set_period(TIM7, 0xffff);
timer_enable_counter(TIM7);