From 88fb5a300170328eed00bb9846077cbe8c90a736 Mon Sep 17 00:00:00 2001 From: tfateba Date: Wed, 4 Jan 2017 15:13:59 +0000 Subject: Fixed AVR GPT Warning (Control reaches end of non void function., array define but not used.) git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10013 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/AVR/hal_gpt_lld.c | 62 ++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 32 deletions(-) (limited to 'os/hal/ports/AVR/hal_gpt_lld.c') diff --git a/os/hal/ports/AVR/hal_gpt_lld.c b/os/hal/ports/AVR/hal_gpt_lld.c index 8bf0f13cf..49d1082d6 100644 --- a/os/hal/ports/AVR/hal_gpt_lld.c +++ b/os/hal/ports/AVR/hal_gpt_lld.c @@ -94,16 +94,16 @@ GPTDriver GPTD5; static uint16_t ratio_base[] = { 1024, 256, 64, 8, 1 }; static uint8_t clock_source_base[]= { 5, 4, 3, 2, 1 }; -static uint16_t ratio_extended[] = { 1024, 256, 128, 64, 32, 8, 1 }; -static uint8_t clock_source_extended[] = { 7, 6, 5, 4, 3, 2, 1 }; +//static uint16_t ratio_extended[] = { 1024, 256, 128, 64, 32, 8, 1 }; +//static uint8_t clock_source_extended[] = { 7, 6, 5, 4, 3, 2, 1 }; /*===========================================================================*/ /* Driver local functions. */ /*===========================================================================*/ -static uint8_t prescaler(uint16_t freq, uint16_t *ratio, uint8_t n) -{ +static uint8_t prescaler(uint16_t freq, uint16_t *ratio, uint8_t n) { uint8_t i; + for (i = 0; i < n; ++i) { uint32_t result = F_CPU / ratio[i] / freq; if (result > 256UL) @@ -111,10 +111,10 @@ static uint8_t prescaler(uint16_t freq, uint16_t *ratio, uint8_t n) if ((result * ratio[i] * freq) == F_CPU) return i; } + return -1; // TO check } -static void gpt_lld_serve_interrupt(GPTDriver *gptp) -{ +static void gpt_lld_serve_interrupt(GPTDriver *gptp) { gptp->counter++; if (gptp->counter == gptp->period) { gptp->counter = 0; @@ -126,12 +126,10 @@ static void gpt_lld_serve_interrupt(GPTDriver *gptp) } } -static void gpt_lld_dummy_callback(GPTDriver *gptp) -{ +static void gpt_lld_dummy_callback(GPTDriver *gptp) { } -static uint8_t getTimerIndex(GPTDriver *gptp) -{ +static uint8_t getTimerIndex(GPTDriver *gptp) { uint8_t index = 0; #if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__) if (gptp == &GPTD1) return index; @@ -153,6 +151,7 @@ static uint8_t getTimerIndex(GPTDriver *gptp) if (gptp == &GPTD5) return index; else index++; #endif + return -1; // To check } /*===========================================================================*/ @@ -160,8 +159,8 @@ static uint8_t getTimerIndex(GPTDriver *gptp) /*===========================================================================*/ #if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__) -OSAL_IRQ_HANDLER(TIMER1_COMPA_vect) -{ +OSAL_IRQ_HANDLER(TIMER1_COMPA_vect) { + OSAL_IRQ_PROLOGUE(); gpt_lld_serve_interrupt(&GPTD1); OSAL_IRQ_EPILOGUE(); @@ -169,8 +168,8 @@ OSAL_IRQ_HANDLER(TIMER1_COMPA_vect) #endif #if AVR_GPT_USE_TIM2 || defined(__DOXYGEN__) -OSAL_IRQ_HANDLER(TIMER2_COMPA_vect) -{ +OSAL_IRQ_HANDLER(TIMER2_COMPA_vect) { + OSAL_IRQ_PROLOGUE(); gpt_lld_serve_interrupt(&GPTD2); OSAL_IRQ_EPILOGUE(); @@ -178,8 +177,8 @@ OSAL_IRQ_HANDLER(TIMER2_COMPA_vect) #endif #if AVR_GPT_USE_TIM3 || defined(__DOXYGEN__) -OSAL_IRQ_HANDLER(TIMER3_COMPA_vect) -{ +OSAL_IRQ_HANDLER(TIMER3_COMPA_vect) { + OSAL_IRQ_PROLOGUE(); gpt_lld_serve_interrupt(&GPTD3); OSAL_IRQ_EPILOGUE(); @@ -187,8 +186,8 @@ OSAL_IRQ_HANDLER(TIMER3_COMPA_vect) #endif #if AVR_GPT_USE_TIM4 || defined(__DOXYGEN__) -OSAL_IRQ_HANDLER(TIMER4_COMPA_vect) -{ +OSAL_IRQ_HANDLER(TIMER4_COMPA_vect) { + OSAL_IRQ_PROLOGUE(); gpt_lld_serve_interrupt(&GPTD4); OSAL_IRQ_EPILOGUE(); @@ -196,8 +195,8 @@ OSAL_IRQ_HANDLER(TIMER4_COMPA_vect) #endif #if AVR_GPT_USE_TIM5 || defined(__DOXYGEN__) -OSAL_IRQ_HANDLER(TIMER5_COMPA_vect) -{ +OSAL_IRQ_HANDLER(TIMER5_COMPA_vect) { + OSAL_IRQ_PROLOGUE(); gpt_lld_serve_interrupt(&GPTD5); OSAL_IRQ_EPILOGUE(); @@ -213,8 +212,8 @@ OSAL_IRQ_HANDLER(TIMER5_COMPA_vect) * * @notapi */ -void gpt_lld_init(void) -{ +void gpt_lld_init(void) { + #if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__) gptObjectInit(&GPTD1); #endif @@ -239,8 +238,7 @@ void gpt_lld_init(void) * * @notapi */ -void gpt_lld_start(GPTDriver *gptp) -{ +void gpt_lld_start(GPTDriver *gptp) { uint8_t psc; if (gptp->state == GPT_STOP) { @@ -281,8 +279,8 @@ void gpt_lld_start(GPTDriver *gptp) * * @notapi */ -void gpt_lld_stop(GPTDriver *gptp) -{ +void gpt_lld_stop(GPTDriver *gptp) { + /* nothing to be done */ if (gptp->state == GPT_READY) { /* Clock de-activation.*/ @@ -298,8 +296,8 @@ void gpt_lld_stop(GPTDriver *gptp) * * @notapi */ -void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t period) -{ +void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t period) { + gptp->callback = gptp->config->callback; gptp->period = period; gptp->counter = 0; @@ -319,9 +317,9 @@ void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t period) * * @notapi */ -void gpt_lld_stop_timer(GPTDriver *gptp) -{ +void gpt_lld_stop_timer(GPTDriver *gptp) { uint8_t i = getTimerIndex(gptp); + *regs_table[i].tccrb &= ~((7 << CS10) | (1 << OCIE1A)); *regs_table[i].tifr = (1 << OCF1A); } @@ -337,8 +335,8 @@ void gpt_lld_stop_timer(GPTDriver *gptp) * * @notapi */ -void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval) -{ +void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval) { + gptp->callback = gpt_lld_dummy_callback; gpt_lld_start_timer(gptp, interval); //FIX -- cgit v1.2.3