From 9970f28cb9a705c7b502c4cf95f2dffb39b7164f Mon Sep 17 00:00:00 2001 From: utzig Date: Mon, 8 Jul 2013 22:26:33 +0000 Subject: [AVR] use better defines for timer based drivers git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5943 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/AVR/gpt_lld.c | 52 ++++++++++++++++++++-------------------- os/hal/platforms/AVR/gpt_lld.h | 30 +++++++++++------------ os/hal/platforms/AVR/icu_lld.c | 44 +++++++++++++++++----------------- os/hal/platforms/AVR/icu_lld.h | 24 +++++++++---------- os/hal/platforms/AVR/pwm_lld.c | 54 +++++++++++++++++++++--------------------- os/hal/platforms/AVR/pwm_lld.h | 30 +++++++++++------------ 6 files changed, 117 insertions(+), 117 deletions(-) (limited to 'os/hal') diff --git a/os/hal/platforms/AVR/gpt_lld.c b/os/hal/platforms/AVR/gpt_lld.c index 829bb69d2..4f3b535b6 100644 --- a/os/hal/platforms/AVR/gpt_lld.c +++ b/os/hal/platforms/AVR/gpt_lld.c @@ -52,19 +52,19 @@ typedef struct { } timer_registers_t; const timer_registers_t regs_table[] = { -#if AVR_GPT_USE_GPT1 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__) { &TCCR1A, &TCCR1B, &OCR1AH, &OCR1AL, &TCNT1H, &TCNT1L, &TIFR1, &TIMSK1 }, #endif -#if AVR_GPT_USE_GPT2 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM2 || defined(__DOXYGEN__) { &TCCR2A, &TCCR2B, &OCR2A, &OCR2A, &TCNT2, &TCNT2, &TIFR2, &TIMSK2 }, #endif -#if AVR_GPT_USE_GPT3 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM3 || defined(__DOXYGEN__) { &TCCR3A, &TCCR3B, &OCR3AH, &OCR3AL, &TCNT3H, &TCNT3L, &TIFR3, &TIMSK3 }, #endif -#if AVR_GPT_USE_GPT4 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM4 || defined(__DOXYGEN__) { &TCCR4A, &TCCR4B, &OCR4AH, &OCR4AL, &TCNT4H, &TCNT4L, &TIFR4, &TIMSK4 }, #endif -#if AVR_GPT_USE_GPT5 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM5 || defined(__DOXYGEN__) { &TCCR5A, &TCCR5B, &OCR5AH, &OCR5AL, &TCNT5H, &TCNT5L, &TIFR5, &TIMSK5 }, #endif }; @@ -73,19 +73,19 @@ const timer_registers_t regs_table[] = { /* Driver exported variables. */ /*===========================================================================*/ -#if AVR_GPT_USE_GPT1 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__) GPTDriver GPTD1; #endif -#if AVR_GPT_USE_GPT2 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM2 || defined(__DOXYGEN__) GPTDriver GPTD2; #endif -#if AVR_GPT_USE_GPT3 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM3 || defined(__DOXYGEN__) GPTDriver GPTD3; #endif -#if AVR_GPT_USE_GPT4 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM4 || defined(__DOXYGEN__) GPTDriver GPTD4; #endif -#if AVR_GPT_USE_GPT5 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM5 || defined(__DOXYGEN__) GPTDriver GPTD5; #endif @@ -134,23 +134,23 @@ static void gpt_lld_dummy_callback(GPTDriver *gptp) static uint8_t getTimerIndex(GPTDriver *gptp) { uint8_t index = 0; -#if AVR_GPT_USE_GPT1 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__) if (gptp == &GPTD1) return index; else index++; #endif -#if AVR_GPT_USE_GPT2 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM2 || defined(__DOXYGEN__) if (gptp == &GPTD2) return index; else index++; #endif -#if AVR_GPT_USE_GPT3 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM3 || defined(__DOXYGEN__) if (gptp == &GPTD3) return index; else index++; #endif -#if AVR_GPT_USE_GPT4 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM4 || defined(__DOXYGEN__) if (gptp == &GPTD4) return index; else index++; #endif -#if AVR_GPT_USE_GPT5 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM5 || defined(__DOXYGEN__) if (gptp == &GPTD5) return index; else index++; #endif @@ -160,7 +160,7 @@ static uint8_t getTimerIndex(GPTDriver *gptp) /* Driver interrupt handlers. */ /*===========================================================================*/ -#if AVR_GPT_USE_GPT1 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER1_COMPA_vect) { CH_IRQ_PROLOGUE(); @@ -169,7 +169,7 @@ CH_IRQ_HANDLER(TIMER1_COMPA_vect) } #endif -#if AVR_GPT_USE_GPT2 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM2 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER2_COMPA_vect) { CH_IRQ_PROLOGUE(); @@ -178,7 +178,7 @@ CH_IRQ_HANDLER(TIMER2_COMPA_vect) } #endif -#if AVR_GPT_USE_GPT3 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM3 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER3_COMPA_vect) { CH_IRQ_PROLOGUE(); @@ -187,7 +187,7 @@ CH_IRQ_HANDLER(TIMER3_COMPA_vect) } #endif -#if AVR_GPT_USE_GPT4 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM4 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER4_COMPA_vect) { CH_IRQ_PROLOGUE(); @@ -196,7 +196,7 @@ CH_IRQ_HANDLER(TIMER4_COMPA_vect) } #endif -#if AVR_GPT_USE_GPT5 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM5 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER5_COMPA_vect) { CH_IRQ_PROLOGUE(); @@ -216,19 +216,19 @@ CH_IRQ_HANDLER(TIMER5_COMPA_vect) */ void gpt_lld_init(void) { -#if AVR_GPT_USE_GPT1 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__) gptObjectInit(&GPTD1); #endif -#if AVR_GPT_USE_GPT2 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM2 || defined(__DOXYGEN__) gptObjectInit(&GPTD2); #endif -#if AVR_GPT_USE_GPT3 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM3 || defined(__DOXYGEN__) gptObjectInit(&GPTD3); #endif -#if AVR_GPT_USE_GPT4 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM4 || defined(__DOXYGEN__) gptObjectInit(&GPTD4); #endif -#if AVR_GPT_USE_GPT5 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM5 || defined(__DOXYGEN__) gptObjectInit(&GPTD5); #endif } @@ -250,7 +250,7 @@ void gpt_lld_start(GPTDriver *gptp) /* Configuration.*/ -#if AVR_GPT_USE_GPT2 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM2 || defined(__DOXYGEN__) if (gptp == &GPTD2) { psc = prescaler(gptp->config->frequency, ratio_extended, PRESCALER_SIZE_EXTENDED); gptp->clock_source = clock_source_extended[psc] & 0x07; diff --git a/os/hal/platforms/AVR/gpt_lld.h b/os/hal/platforms/AVR/gpt_lld.h index f6aa4ecc9..31a623f39 100644 --- a/os/hal/platforms/AVR/gpt_lld.h +++ b/os/hal/platforms/AVR/gpt_lld.h @@ -45,8 +45,8 @@ * @details If set to @p TRUE the support for GPT1 is included. * @note The default is @p FALSE. */ -#if !defined(AVR_GPT_USE_GPT1) -#define AVR_GPT_USE_GPT1 FALSE +#if !defined(AVR_GPT_USE_TIM1) +#define AVR_GPT_USE_TIM1 FALSE #endif /** @@ -54,8 +54,8 @@ * @details If set to @p TRUE the support for GPT2 is included. * @note The default is @p FALSE. */ -#if !defined(AVR_GPT_USE_GPT2) -#define AVR_GPT_USE_GPT2 FALSE +#if !defined(AVR_GPT_USE_TIM2) +#define AVR_GPT_USE_TIM2 FALSE #endif /** @@ -63,8 +63,8 @@ * @details If set to @p TRUE the support for GPT3 is included. * @note The default is @p FALSE. */ -#if !defined(AVR_GPT_USE_GPT3) -#define AVR_GPT_USE_GPT3 FALSE +#if !defined(AVR_GPT_USE_TIM3) +#define AVR_GPT_USE_TIM3 FALSE #endif /** @@ -72,8 +72,8 @@ * @details If set to @p TRUE the support for GPT4 is included. * @note The default is @p FALSE. */ -#if !defined(AVR_GPT_USE_GPT4) -#define AVR_GPT_USE_GPT4 FALSE +#if !defined(AVR_GPT_USE_TIM4) +#define AVR_GPT_USE_TIM4 FALSE #endif /** @@ -81,8 +81,8 @@ * @details If set to @p TRUE the support for GPT5 is included. * @note The default is @p FALSE. */ -#if !defined(AVR_GPT_USE_GPT5) -#define AVR_GPT_USE_GPT5 FALSE +#if !defined(AVR_GPT_USE_TIM5) +#define AVR_GPT_USE_TIM5 FALSE #endif /*===========================================================================*/ @@ -183,19 +183,19 @@ struct GPTDriver { /* External declarations. */ /*===========================================================================*/ -#if AVR_GPT_USE_GPT1 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__) extern GPTDriver GPTD1; #endif -#if AVR_GPT_USE_GPT2 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM2 || defined(__DOXYGEN__) extern GPTDriver GPTD2; #endif -#if AVR_GPT_USE_GPT3 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM3 || defined(__DOXYGEN__) extern GPTDriver GPTD3; #endif -#if AVR_GPT_USE_GPT4 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM4 || defined(__DOXYGEN__) extern GPTDriver GPTD4; #endif -#if AVR_GPT_USE_GPT5 || defined(__DOXYGEN__) +#if AVR_GPT_USE_TIM5 || defined(__DOXYGEN__) extern GPTDriver GPTD5; #endif diff --git a/os/hal/platforms/AVR/icu_lld.c b/os/hal/platforms/AVR/icu_lld.c index 8a5b38edc..5977f5551 100644 --- a/os/hal/platforms/AVR/icu_lld.c +++ b/os/hal/platforms/AVR/icu_lld.c @@ -40,16 +40,16 @@ typedef struct { static icu_registers_t regs_table[]= { -#if AVR_ICU_USE_ICU1 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM1 || defined(__DOXYGEN__) {&TCCR1A, &TCCR1B, &TCNT1, &TIMSK1}, #endif -#if AVR_ICU_USE_ICU3 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM3 || defined(__DOXYGEN__) {&TCCR3A, &TCCR3B, &TCNT3, &TIMSK3}, #endif -#if AVR_ICU_USE_ICU4 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM4 || defined(__DOXYGEN__) {&TCCR4A, &TCCR4B, &TCNT4, &TIMSK4}, #endif -#if AVR_ICU_USE_ICU5 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM5 || defined(__DOXYGEN__) {&TCCR5A, &TCCR5B, &TCNT5, &TIMSK5}, #endif }; @@ -62,25 +62,25 @@ static icu_registers_t regs_table[]= /** * @brief ICU1 driver identifier. */ -#if AVR_ICU_USE_ICU1 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM1 || defined(__DOXYGEN__) ICUDriver ICUD1; #endif /** * @brief ICU3 driver identifier. */ -#if AVR_ICU_USE_ICU3 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM3 || defined(__DOXYGEN__) ICUDriver ICUD3; #endif /** * @brief ICU4 driver identifier. */ -#if AVR_ICU_USE_ICU4 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM4 || defined(__DOXYGEN__) ICUDriver ICUD4; #endif /** * @brief ICU5 driver identifier. */ -#if AVR_ICU_USE_ICU5 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM5 || defined(__DOXYGEN__) ICUDriver ICUD5; #endif @@ -117,19 +117,19 @@ static inline void handle_capture_isr(ICUDriver *icup, static uint8_t index(ICUDriver *icup) { uint8_t index = 0; -#if AVR_ICU_USE_ICU1 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM1 || defined(__DOXYGEN__) if (icup == &ICUD1) return index; else index++; #endif -#if AVR_ICU_USE_ICU3 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM3 || defined(__DOXYGEN__) if (icup == &ICUD3) return index; else index++; #endif -#if AVR_ICU_USE_ICU4 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM4 || defined(__DOXYGEN__) if (icup == &ICUD4) return index; else index++; #endif -#if AVR_ICU_USE_ICU5 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM5 || defined(__DOXYGEN__) if (icup == &ICUD5) return index; else index++; #endif @@ -139,7 +139,7 @@ static uint8_t index(ICUDriver *icup) /* Driver interrupt handlers. */ /*===========================================================================*/ -#if AVR_ICU_USE_ICU1 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM1 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER1_CAPT_vect) { CH_IRQ_PROLOGUE(); @@ -155,7 +155,7 @@ CH_IRQ_HANDLER(TIMER1_OVF_vect) } #endif -#if AVR_ICU_USE_ICU3 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM3 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER3_CAPT_vect) { CH_IRQ_PROLOGUE(); @@ -171,7 +171,7 @@ CH_IRQ_HANDLER(TIMER3_OVF_vect) } #endif -#if AVR_ICU_USE_ICU4 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM4 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER4_CAPT_vect) { CH_IRQ_PROLOGUE(); @@ -187,7 +187,7 @@ CH_IRQ_HANDLER(TIMER4_OVF_vect) } #endif -#if AVR_ICU_USE_ICU5 || defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM5 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER5_CAPT_vect) { CH_IRQ_PROLOGUE(); @@ -214,16 +214,16 @@ CH_IRQ_HANDLER(TIMER5_OVF_vect) */ void icu_lld_init(void) { -#if AVR_ICU_USE_ICU1 +#if AVR_ICU_USE_TIM1 icuObjectInit(&ICUD1); #endif -#if AVR_ICU_USE_ICU3 +#if AVR_ICU_USE_TIM3 icuObjectInit(&ICUD3); #endif -#if AVR_ICU_USE_ICU4 +#if AVR_ICU_USE_TIM4 icuObjectInit(&ICUD4); #endif -#if AVR_ICU_USE_ICU5 +#if AVR_ICU_USE_TIM5 icuObjectInit(&ICUD5); #endif } @@ -264,11 +264,11 @@ void icu_lld_stop(ICUDriver *icup) { /* Resets the peripheral.*/ /* Disables the peripheral.*/ -#if AVR_ICU_USE_ICU1 +#if AVR_ICU_USE_TIM1 if (&ICUD1 == icup) { } -#endif /* AVR_ICU_USE_ICU1 */ +#endif /* AVR_ICU_USE_TIM1 */ } } diff --git a/os/hal/platforms/AVR/icu_lld.h b/os/hal/platforms/AVR/icu_lld.h index c63967513..a9b420f1a 100644 --- a/os/hal/platforms/AVR/icu_lld.h +++ b/os/hal/platforms/AVR/icu_lld.h @@ -43,29 +43,29 @@ * @brief ICU driver enable switch. * @details If set to @p TRUE the support for ICU1 is included. */ -#if !defined(AVR_ICU_USE_ICU1) || defined(__DOXYGEN__) -#define AVR_ICU_USE_ICU1 FALSE +#if !defined(AVR_ICU_USE_TIM1) || defined(__DOXYGEN__) +#define AVR_ICU_USE_TIM1 FALSE #endif /** * @brief ICU driver enable switch. * @details If set to @p TRUE the support for ICU3 is included. */ -#if !defined(AVR_ICU_USE_ICU3) || defined(__DOXYGEN__) -#define AVR_ICU_USE_ICU3 FALSE +#if !defined(AVR_ICU_USE_TIM3) || defined(__DOXYGEN__) +#define AVR_ICU_USE_TIM3 FALSE #endif /** * @brief ICU driver enable switch. * @details If set to @p TRUE the support for ICU4 is included. */ -#if !defined(AVR_ICU_USE_ICU4) || defined(__DOXYGEN__) -#define AVR_ICU_USE_ICU4 FALSE +#if !defined(AVR_ICU_USE_TIM4) || defined(__DOXYGEN__) +#define AVR_ICU_USE_TIM4 FALSE #endif /** * @brief ICU driver enable switch. * @details If set to @p TRUE the support for ICU5 is included. */ -#if !defined(AVR_ICU_USE_ICU5) || defined(__DOXYGEN__) -#define AVR_ICU_USE_ICU5 FALSE +#if !defined(AVR_ICU_USE_TIM5) || defined(__DOXYGEN__) +#define AVR_ICU_USE_TIM5 FALSE #endif /** @} */ @@ -159,16 +159,16 @@ struct ICUDriver { /* External declarations. */ /*===========================================================================*/ -#if AVR_ICU_USE_ICU1 && !defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM1 && !defined(__DOXYGEN__) extern ICUDriver ICUD1; #endif -#if AVR_ICU_USE_ICU3 && !defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM3 && !defined(__DOXYGEN__) extern ICUDriver ICUD3; #endif -#if AVR_ICU_USE_ICU4 && !defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM4 && !defined(__DOXYGEN__) extern ICUDriver ICUD4; #endif -#if AVR_ICU_USE_ICU5 && !defined(__DOXYGEN__) +#if AVR_ICU_USE_TIM5 && !defined(__DOXYGEN__) extern ICUDriver ICUD5; #endif diff --git a/os/hal/platforms/AVR/pwm_lld.c b/os/hal/platforms/AVR/pwm_lld.c index db3a5adb9..900a7d8d1 100644 --- a/os/hal/platforms/AVR/pwm_lld.c +++ b/os/hal/platforms/AVR/pwm_lld.c @@ -51,23 +51,23 @@ typedef struct { static timer_registers_t regs_table[]= { -#if AVR_PWM_USE_PWM1 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM1 || defined(__DOXYGEN__) #if defined(OCR1C) {&TCCR1A, &TCCR1B, &OCR1AH, &OCR1AL, &OCR1BH, &OCR1BL, &OCR1CH, &OCR1CL, &TIFR1, &TIMSK1}, #else {&TCCR1A, &TCCR1B, &OCR1AH, &OCR1AL, &OCR1BH, &OCR1BL, NULL, NULL, &TIFR1, &TIMSK1}, #endif #endif -#if AVR_PWM_USE_PWM2 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM2 || defined(__DOXYGEN__) {&TCCR2A, &TCCR2B, &OCR2A, &OCR2A, &OCR2B, &OCR2B, NULL, NULL, &TIFR2, &TIMSK2}, #endif -#if AVR_PWM_USE_PWM3 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM3 || defined(__DOXYGEN__) {&TCCR3A, &TCCR3B, &OCR3AH, &OCR3AL, &OCR3BH, &OCR3BL, &OCR3CH, &OCR3CL, &TIFR3, &TIMSK3}, #endif -#if AVR_PWM_USE_PWM4 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM4 || defined(__DOXYGEN__) {&TCCR4A, &TCCR4B, &OCR4AH, &OCR4AL, &OCR4CH, &OCR4CL, &OCR4CH, &OCR4CL, &TIFR4, &TIMSK4}, #endif -#if AVR_PWM_USE_PWM5 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM5 || defined(__DOXYGEN__) {&TCCR5A, &TCCR5B, &OCR5AH, &OCR5AL, &OCR5BH, &OCR5BL, &OCR5CH, &OCR5CL, &TIFR5, &TIMSK5}, #endif }; @@ -77,19 +77,19 @@ static timer_registers_t regs_table[]= /*===========================================================================*/ /** @brief PWM driver identifiers.*/ -#if AVR_PWM_USE_PWM1 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM1 || defined(__DOXYGEN__) PWMDriver PWMD1; #endif -#if AVR_PWM_USE_PWM2 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM2 || defined(__DOXYGEN__) PWMDriver PWMD2; #endif -#if AVR_PWM_USE_PWM3 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM3 || defined(__DOXYGEN__) PWMDriver PWMD3; #endif -#if AVR_PWM_USE_PWM4 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM4 || defined(__DOXYGEN__) PWMDriver PWMD4; #endif -#if AVR_PWM_USE_PWM5 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM5 || defined(__DOXYGEN__) PWMDriver PWMD5; #endif @@ -116,23 +116,23 @@ static void config_channel(volatile uint8_t *tccra, static uint8_t timer_index(PWMDriver *pwmp) { uint8_t index = 0; -#if AVR_PWM_USE_PWM1 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM1 || defined(__DOXYGEN__) if (pwmp == &PWMD1) return index; else index++; #endif -#if AVR_PWM_USE_PWM2 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM2 || defined(__DOXYGEN__) if (pwmp == &PWMD2) return index; else index++; #endif -#if AVR_PWM_USE_PWM3 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM3 || defined(__DOXYGEN__) if (pwmp == &PWMD3) return index; else index++; #endif -#if AVR_PWM_USE_PWM4 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM4 || defined(__DOXYGEN__) if (pwmp == &PWMD4) return index; else index++; #endif -#if AVR_PWM_USE_PWM5 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM5 || defined(__DOXYGEN__) if (pwmp == &PWMD5) return index; else index++; #endif @@ -145,7 +145,7 @@ static uint8_t timer_index(PWMDriver *pwmp) /* * interrupt for compare1&2 and clock overflow. pwmd1 & pwmd2 */ -#if AVR_PWM_USE_PWM1 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM1 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER1_OVF_vect) { CH_IRQ_PROLOGUE(); @@ -176,7 +176,7 @@ CH_IRQ_HANDLER(TIMER1_COMPC_vect) #endif #endif -#if AVR_PWM_USE_PWM2 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM2 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER2_OVF_vect) { CH_IRQ_PROLOGUE(); @@ -199,7 +199,7 @@ CH_IRQ_HANDLER(TIMER2_COMPB_vect) } #endif -#if AVR_PWM_USE_PWM3 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM3 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER3_OVF_vect) { CH_IRQ_PROLOGUE(); @@ -229,7 +229,7 @@ CH_IRQ_HANDLER(TIMER3_COMPC_vect) } #endif -#if AVR_PWM_USE_PWM4 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM4 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER4_OVF_vect) { CH_IRQ_PROLOGUE(); @@ -259,7 +259,7 @@ CH_IRQ_HANDLER(TIMER4_COMPC_vect) } #endif -#if AVR_PWM_USE_PWM5 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM5 || defined(__DOXYGEN__) CH_IRQ_HANDLER(TIMER5_OVF_vect) { CH_IRQ_PROLOGUE(); @@ -300,31 +300,31 @@ CH_IRQ_HANDLER(TIMER5_COMPC_vect) */ void pwm_lld_init(void) { -#if AVR_PWM_USE_PWM1 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM1 || defined(__DOXYGEN__) pwmObjectInit(&PWMD1); TCCR1A = (1 << WGM11) | (1 << WGM10); TCCR1B = (0 << WGM13) | (1 << WGM12); #endif -#if AVR_PWM_USE_PWM2 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM2 || defined(__DOXYGEN__) pwmObjectInit(&PWMD2); TCCR2A = (1 << WGM21) | (1 << WGM20); TCCR2B = (0 << WGM22); #endif -#if AVR_PWM_USE_PWM3 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM3 || defined(__DOXYGEN__) pwmObjectInit(&PWMD3); TCCR3A = (1 << WGM31) | (1 << WGM30); TCCR3B = (0 << WGM33) | (1 << WGM32); #endif -#if AVR_PWM_USE_PWM4 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM4 || defined(__DOXYGEN__) pwmObjectInit(&PWMD4); TCCR4A = (1 << WGM41) | (1 << WGM40); TCCR4B = (0 << WGM43) | (1 << WGM42); #endif -#if AVR_PWM_USE_PWM5 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM5 || defined(__DOXYGEN__) pwmObjectInit(&PWMD5); TCCR5A = (1 << WGM51) | (1 << WGM50); TCCR5B = (0 << WGM53) | (1 << WGM52); @@ -342,7 +342,7 @@ void pwm_lld_start(PWMDriver *pwmp) { if (pwmp->state == PWM_STOP) { -#if AVR_PWM_USE_PWM2 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM2 || defined(__DOXYGEN__) if (pwmp == &PWMD2) { TCCR2B &= ~((1 << CS22) | (1 << CS21)); TCCR2B |= (1 << CS20); @@ -417,7 +417,7 @@ void pwm_lld_enable_channel(PWMDriver *pwmp, if (val > MAX_PWM_VALUE) val = MAX_PWM_VALUE; -#if AVR_PWM_USE_PWM2 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM2 || defined(__DOXYGEN__) if (pwmp == &PWMD2) { config_channel(&TCCR2A, 7 - 2*channel, diff --git a/os/hal/platforms/AVR/pwm_lld.h b/os/hal/platforms/AVR/pwm_lld.h index efe60e29d..51776bb21 100644 --- a/os/hal/platforms/AVR/pwm_lld.h +++ b/os/hal/platforms/AVR/pwm_lld.h @@ -36,20 +36,20 @@ /* Driver constants. */ /*===========================================================================*/ -#if !defined(AVR_PWM_USE_PWM1) -#define AVR_PWM_USE_PWM1 FALSE +#if !defined(AVR_PWM_USE_TIM1) +#define AVR_PWM_USE_TIM1 FALSE #endif -#if !defined(AVR_PWM_USE_PWM2) -#define AVR_PWM_USE_PWM2 FALSE +#if !defined(AVR_PWM_USE_TIM2) +#define AVR_PWM_USE_TIM2 FALSE #endif -#if !defined(AVR_PWM_USE_PWM3) -#define AVR_PWM_USE_PWM3 FALSE +#if !defined(AVR_PWM_USE_TIM3) +#define AVR_PWM_USE_TIM3 FALSE #endif -#if !defined(AVR_PWM_USE_PWM4) -#define AVR_PWM_USE_PWM4 FALSE +#if !defined(AVR_PWM_USE_TIM4) +#define AVR_PWM_USE_TIM4 FALSE #endif -#if !defined(AVR_PWM_USE_PWM5) -#define AVR_PWM_USE_PWM5 FALSE +#if !defined(AVR_PWM_USE_TIM5) +#define AVR_PWM_USE_TIM5 FALSE #endif /*===========================================================================*/ @@ -174,19 +174,19 @@ struct PWMDriver { /* External declarations. */ /*===========================================================================*/ -#if AVR_PWM_USE_PWM1 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM1 || defined(__DOXYGEN__) extern PWMDriver PWMD1; #endif -#if AVR_PWM_USE_PWM2 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM2 || defined(__DOXYGEN__) extern PWMDriver PWMD2; #endif -#if AVR_PWM_USE_PWM3 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM3 || defined(__DOXYGEN__) extern PWMDriver PWMD3; #endif -#if AVR_PWM_USE_PWM4 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM4 || defined(__DOXYGEN__) extern PWMDriver PWMD4; #endif -#if AVR_PWM_USE_PWM5 || defined(__DOXYGEN__) +#if AVR_PWM_USE_TIM5 || defined(__DOXYGEN__) extern PWMDriver PWMD5; #endif -- cgit v1.2.3