From 552da8705245a876c2e816bab93edc2cb39f94e3 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Sun, 5 Sep 2010 23:22:19 -0400 Subject: timer fixes for maple native --- libmaple/nvic.h | 1 + libmaple/timers.c | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libmaple/nvic.h b/libmaple/nvic.h index 4e425c5..4f4972d 100644 --- a/libmaple/nvic.h +++ b/libmaple/nvic.h @@ -64,6 +64,7 @@ enum { NVIC_TIMER5 = 50, // high density only (Maple Native) NVIC_TIMER6 = 54, // high density only (Maple Native) NVIC_TIMER7 = 55, // high density only (Maple Native) + NVIC_TIMER8 = 46, // high density only (Maple Native) NVIC_USART1 = 37, NVIC_USART2 = 38, NVIC_USART3 = 39, diff --git a/libmaple/timers.c b/libmaple/timers.c index 2941cd6..266ac76 100644 --- a/libmaple/timers.c +++ b/libmaple/timers.c @@ -182,18 +182,33 @@ void timer_disable_all(void) { // TODO: refactor // Note: this must be very robust because it gets called from, eg, ASSERT timer_port *timer; + #if NR_TIMERS >= 8 + timer_port *timers[6] = { (timer_port*)TIMER1_BASE, + (timer_port*)TIMER2_BASE, + (timer_port*)TIMER3_BASE, + (timer_port*)TIMER4_BASE, + (timer_port*)TIMER5_BASE, + (timer_port*)TIMER8_BASE, + }; + uint8 i; + for (i = 0; i < 6; i++) { + timer = timers[i]; + timer->CR1 = 0; + timer->CCER = 0; + } + #else timer_port *timers[4] = { (timer_port*)TIMER1_BASE, (timer_port*)TIMER2_BASE, (timer_port*)TIMER3_BASE, (timer_port*)TIMER4_BASE, }; - int i; - + uint8 i; for (i = 0; i < 4; i++) { timer = timers[i]; timer->CR1 = 0; timer->CCER = 0; } + #endif } // Sets the mode of individual timer channels, including a DISABLE mode -- cgit v1.2.3