diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2012-06-07 04:39:22 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2012-06-07 19:15:04 -0400 |
commit | 0acbcb9c50d6eeb41d6036b2706a7b3d2b5e4b3c (patch) | |
tree | 98c658ba38cf1821702e2d3beb3164979f1d46ab | |
parent | cb15495943b560cb0ca45e652bbcf7e14df2eadc (diff) | |
download | librambutan-0acbcb9c50d6eeb41d6036b2706a7b3d2b5e4b3c.tar.gz librambutan-0acbcb9c50d6eeb41d6036b2706a7b3d2b5e4b3c.zip |
Tweak some timer_private APIs.
The current versions of DELARE_*_TIMER() don't play well with cscope,
which is a bad sign. Fix that.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
-rw-r--r-- | libmaple/stm32f1/timer.c | 28 | ||||
-rw-r--r-- | libmaple/stm32f2/timer.c | 33 | ||||
-rw-r--r-- | libmaple/timer_private.h | 16 |
3 files changed, 36 insertions, 41 deletions
diff --git a/libmaple/stm32f1/timer.c b/libmaple/stm32f1/timer.c index 002b9d6..8671695 100644 --- a/libmaple/stm32f1/timer.c +++ b/libmaple/stm32f1/timer.c @@ -54,10 +54,10 @@ * Defer to the timer_private API. */ -static DECLARE_ADVANCED_TIMER(timer1, 1); -static DECLARE_GENERAL_TIMER(timer2, 2); -static DECLARE_GENERAL_TIMER(timer3, 3); -static DECLARE_GENERAL_TIMER(timer4, 4); +static timer_dev timer1 = ADVANCED_TIMER(1); +static timer_dev timer2 = GENERAL_TIMER(2); +static timer_dev timer3 = GENERAL_TIMER(3); +static timer_dev timer4 = GENERAL_TIMER(4); /** Timer 1 device (advanced) */ timer_dev *TIMER1 = &timer1; @@ -69,10 +69,10 @@ timer_dev *TIMER3 = &timer3; timer_dev *TIMER4 = &timer4; #if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) -static DECLARE_GENERAL_TIMER(timer5, 5); -static DECLARE_BASIC_TIMER(timer6, 6); -static DECLARE_BASIC_TIMER(timer7, 7); -static DECLARE_ADVANCED_TIMER(timer8, 8); +static timer_dev timer5 = GENERAL_TIMER(5); +static timer_dev timer6 = BASIC_TIMER(6); +static timer_dev timer7 = BASIC_TIMER(7); +static timer_dev timer8 = ADVANCED_TIMER(8); /** Timer 5 device (general-purpose) */ timer_dev *TIMER5 = &timer5; @@ -86,17 +86,17 @@ timer_dev *TIMER8 = &timer8; #ifdef STM32_XL_DENSITY /* TIM9 has UIE, CC1IE, CC2IE, TIE bits in DIER. */ -static DECLARE_RESTRICTED_GENERAL_TIMER(timer9, 9, TIMER_DIER_TIE_BIT); +static timer_dev timer9 = RESTRICTED_GENERAL_TIMER(9, TIMER_DIER_TIE_BIT); /* TIM10 has UIE, CC1IE. */ -static DECLARE_RESTRICTED_GENERAL_TIMER(timer10, 10, TIMER_DIER_CC1IE_BIT); +static timer_dev timer10 = RESTRICTED_GENERAL_TIMER(10, TIMER_DIER_CC1IE_BIT); /* TIM11 has UIE, CC1IE. */ -static DECLARE_RESTRICTED_GENERAL_TIMER(timer11, 11, TIMER_DIER_CC1IE_BIT); +static timer_dev timer11 = RESTRICTED_GENERAL_TIMER(11, TIMER_DIER_CC1IE_BIT); /* TIM12 has UIE, CC1IE, CC2IE, TIE. */ -static DECLARE_RESTRICTED_GENERAL_TIMER(timer12, 12, TIMER_DIER_TIE_BIT); +static timer_dev timer12 = RESTRICTED_GENERAL_TIMER(12, TIMER_DIER_TIE_BIT); /* TIM13 has UIE, CC1IE. */ -static DECLARE_RESTRICTED_GENERAL_TIMER(timer13, 13, TIMER_DIER_CC1IE_BIT); +static timer_dev timer13 = RESTRICTED_GENERAL_TIMER(13, TIMER_DIER_CC1IE_BIT); /* TIM14 has UIE, CC1IE. */ -static DECLARE_RESTRICTED_GENERAL_TIMER(timer14, 14, TIMER_DIER_CC1IE_BIT); +static timer_dev timer14 = RESTRICTED_GENERAL_TIMER(14, TIMER_DIER_CC1IE_BIT); /** Timer 9 device (general-purpose) */ timer_dev *TIMER9 = &timer9; diff --git a/libmaple/stm32f2/timer.c b/libmaple/stm32f2/timer.c index f644b16..99dbf48 100644 --- a/libmaple/stm32f2/timer.c +++ b/libmaple/stm32f2/timer.c @@ -39,26 +39,26 @@ * Defer to the timer_private API for declaring these. */ -static DECLARE_ADVANCED_TIMER(timer1, 1); -static DECLARE_GENERAL_TIMER(timer2, 2); -static DECLARE_GENERAL_TIMER(timer3, 3); -static DECLARE_GENERAL_TIMER(timer4, 4); -static DECLARE_GENERAL_TIMER(timer5, 5); -static DECLARE_BASIC_TIMER(timer6, 6); -static DECLARE_BASIC_TIMER(timer7, 7); -static DECLARE_ADVANCED_TIMER(timer8, 8); +static timer_dev timer1 = ADVANCED_TIMER(1); +static timer_dev timer2 = GENERAL_TIMER(2); +static timer_dev timer3 = GENERAL_TIMER(3); +static timer_dev timer4 = GENERAL_TIMER(4); +static timer_dev timer5 = GENERAL_TIMER(5); +static timer_dev timer6 = BASIC_TIMER(6); +static timer_dev timer7 = BASIC_TIMER(7); +static timer_dev timer8 = ADVANCED_TIMER(8); /* TIM9 has UIE, CC1IE, CC2IE, TIE bits in DIER. */ -static DECLARE_RESTRICTED_GENERAL_TIMER(timer9, 9, TIMER_DIER_TIE_BIT); +static timer_dev timer9 = RESTRICTED_GENERAL_TIMER(9, TIMER_DIER_TIE_BIT); /* TIM10 has UIE, CC1IE. */ -static DECLARE_RESTRICTED_GENERAL_TIMER(timer10, 10, TIMER_DIER_CC1IE_BIT); +static timer_dev timer10 = RESTRICTED_GENERAL_TIMER(10, TIMER_DIER_CC1IE_BIT); /* TIM11 has UIE, CC1IE. */ -static DECLARE_RESTRICTED_GENERAL_TIMER(timer11, 11, TIMER_DIER_CC1IE_BIT); +static timer_dev timer11 = RESTRICTED_GENERAL_TIMER(11, TIMER_DIER_CC1IE_BIT); /* TIM12 has UIE, CC1IE, CC2IE, TIE. */ -static DECLARE_RESTRICTED_GENERAL_TIMER(timer12, 12, TIMER_DIER_TIE_BIT); +static timer_dev timer12 = RESTRICTED_GENERAL_TIMER(12, TIMER_DIER_TIE_BIT); /* TIM13 has UIE, CC1IE. */ -static DECLARE_RESTRICTED_GENERAL_TIMER(timer13, 13, TIMER_DIER_CC1IE_BIT); +static timer_dev timer13 = RESTRICTED_GENERAL_TIMER(13, TIMER_DIER_CC1IE_BIT); /* TIM14 has UIE, CC1IE. */ -static DECLARE_RESTRICTED_GENERAL_TIMER(timer14, 14, TIMER_DIER_CC1IE_BIT); +static timer_dev timer14 = RESTRICTED_GENERAL_TIMER(14, TIMER_DIER_CC1IE_BIT); /** Timer 1 device (advanced) */ timer_dev *TIMER1 = &timer1; @@ -121,11 +121,6 @@ void timer_foreach(void (*fn)(timer_dev*)) { * GPIO_AF_TIM_1_2. This is useful for e.g. using gpio_set_af() to set * a pin's alternate function to a timer. * - * Note that the timer gpio_afs are shared with other timers (and - * sometimes with CAN). For example, timers 1 and 2 both use - * GPIO_AF_TIM_1_2. Because of that, it can pay to e.g not point two - * timers at the same pin. - * * @param dev Timer device, must not be TIMER6 or TIMER7. * @return gpio_af corresponding to dev * @see gpio_set_af diff --git a/libmaple/timer_private.h b/libmaple/timer_private.h index 0eb569d..320c636 100644 --- a/libmaple/timer_private.h +++ b/libmaple/timer_private.h @@ -58,8 +58,8 @@ #define NR_BAS_HANDLERS 1 /* For declaring advanced timers. */ -#define DECLARE_ADVANCED_TIMER(name, num) \ - timer_dev name = { \ +#define ADVANCED_TIMER(num) \ + { \ .regs = { .adv = TIMER##num##_BASE }, \ .clk_id = RCC_TIMER##num, \ .type = TIMER_ADVANCED, \ @@ -67,8 +67,8 @@ } /* For declaring full-featured general purpose timers. */ -#define DECLARE_GENERAL_TIMER(name, num) \ - timer_dev name = { \ +#define GENERAL_TIMER(num) \ + { \ .regs = { .gen = TIMER##num##_BASE }, \ .clk_id = RCC_TIMER##num, \ .type = TIMER_GENERAL, \ @@ -78,8 +78,8 @@ /* For declaring general purpose timers with limited interrupt * capability (e.g. timers 9 through 14 on STM32F2 and XL-density * STM32F1). */ -#define DECLARE_RESTRICTED_GENERAL_TIMER(name, num, max_dier_bit) \ - timer_dev name = { \ +#define RESTRICTED_GENERAL_TIMER(num, max_dier_bit) \ + { \ .regs = { .gen = TIMER##num##_BASE }, \ .clk_id = RCC_TIMER##num, \ .type = TIMER_GENERAL, \ @@ -87,8 +87,8 @@ } /* For declaring basic timers (e.g. TIM6 and TIM7). */ -#define DECLARE_BASIC_TIMER(name, num) \ - timer_dev name = { \ +#define BASIC_TIMER(num) \ + { \ .regs = { .bas = TIMER##num##_BASE }, \ .clk_id = RCC_TIMER##num, \ .type = TIMER_BASIC, \ |