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
This commit is contained in:
tfateba 2017-01-04 15:13:59 +00:00
parent 238c8d1f08
commit 88fb5a3001
1 changed files with 30 additions and 32 deletions

View File

@ -94,16 +94,16 @@ GPTDriver GPTD5;
static uint16_t ratio_base[] = { 1024, 256, 64, 8, 1 }; static uint16_t ratio_base[] = { 1024, 256, 64, 8, 1 };
static uint8_t clock_source_base[]= { 5, 4, 3, 2, 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 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 uint8_t clock_source_extended[] = { 7, 6, 5, 4, 3, 2, 1 };
/*===========================================================================*/ /*===========================================================================*/
/* Driver local functions. */ /* 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; uint8_t i;
for (i = 0; i < n; ++i) { for (i = 0; i < n; ++i) {
uint32_t result = F_CPU / ratio[i] / freq; uint32_t result = F_CPU / ratio[i] / freq;
if (result > 256UL) 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) if ((result * ratio[i] * freq) == F_CPU)
return i; return i;
} }
return -1; // TO check
} }
static void gpt_lld_serve_interrupt(GPTDriver *gptp) static void gpt_lld_serve_interrupt(GPTDriver *gptp) {
{
gptp->counter++; gptp->counter++;
if (gptp->counter == gptp->period) { if (gptp->counter == gptp->period) {
gptp->counter = 0; 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; uint8_t index = 0;
#if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__) #if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__)
if (gptp == &GPTD1) return index; if (gptp == &GPTD1) return index;
@ -153,6 +151,7 @@ static uint8_t getTimerIndex(GPTDriver *gptp)
if (gptp == &GPTD5) return index; if (gptp == &GPTD5) return index;
else index++; else index++;
#endif #endif
return -1; // To check
} }
/*===========================================================================*/ /*===========================================================================*/
@ -160,8 +159,8 @@ static uint8_t getTimerIndex(GPTDriver *gptp)
/*===========================================================================*/ /*===========================================================================*/
#if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__) #if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__)
OSAL_IRQ_HANDLER(TIMER1_COMPA_vect) OSAL_IRQ_HANDLER(TIMER1_COMPA_vect) {
{
OSAL_IRQ_PROLOGUE(); OSAL_IRQ_PROLOGUE();
gpt_lld_serve_interrupt(&GPTD1); gpt_lld_serve_interrupt(&GPTD1);
OSAL_IRQ_EPILOGUE(); OSAL_IRQ_EPILOGUE();
@ -169,8 +168,8 @@ OSAL_IRQ_HANDLER(TIMER1_COMPA_vect)
#endif #endif
#if AVR_GPT_USE_TIM2 || defined(__DOXYGEN__) #if AVR_GPT_USE_TIM2 || defined(__DOXYGEN__)
OSAL_IRQ_HANDLER(TIMER2_COMPA_vect) OSAL_IRQ_HANDLER(TIMER2_COMPA_vect) {
{
OSAL_IRQ_PROLOGUE(); OSAL_IRQ_PROLOGUE();
gpt_lld_serve_interrupt(&GPTD2); gpt_lld_serve_interrupt(&GPTD2);
OSAL_IRQ_EPILOGUE(); OSAL_IRQ_EPILOGUE();
@ -178,8 +177,8 @@ OSAL_IRQ_HANDLER(TIMER2_COMPA_vect)
#endif #endif
#if AVR_GPT_USE_TIM3 || defined(__DOXYGEN__) #if AVR_GPT_USE_TIM3 || defined(__DOXYGEN__)
OSAL_IRQ_HANDLER(TIMER3_COMPA_vect) OSAL_IRQ_HANDLER(TIMER3_COMPA_vect) {
{
OSAL_IRQ_PROLOGUE(); OSAL_IRQ_PROLOGUE();
gpt_lld_serve_interrupt(&GPTD3); gpt_lld_serve_interrupt(&GPTD3);
OSAL_IRQ_EPILOGUE(); OSAL_IRQ_EPILOGUE();
@ -187,8 +186,8 @@ OSAL_IRQ_HANDLER(TIMER3_COMPA_vect)
#endif #endif
#if AVR_GPT_USE_TIM4 || defined(__DOXYGEN__) #if AVR_GPT_USE_TIM4 || defined(__DOXYGEN__)
OSAL_IRQ_HANDLER(TIMER4_COMPA_vect) OSAL_IRQ_HANDLER(TIMER4_COMPA_vect) {
{
OSAL_IRQ_PROLOGUE(); OSAL_IRQ_PROLOGUE();
gpt_lld_serve_interrupt(&GPTD4); gpt_lld_serve_interrupt(&GPTD4);
OSAL_IRQ_EPILOGUE(); OSAL_IRQ_EPILOGUE();
@ -196,8 +195,8 @@ OSAL_IRQ_HANDLER(TIMER4_COMPA_vect)
#endif #endif
#if AVR_GPT_USE_TIM5 || defined(__DOXYGEN__) #if AVR_GPT_USE_TIM5 || defined(__DOXYGEN__)
OSAL_IRQ_HANDLER(TIMER5_COMPA_vect) OSAL_IRQ_HANDLER(TIMER5_COMPA_vect) {
{
OSAL_IRQ_PROLOGUE(); OSAL_IRQ_PROLOGUE();
gpt_lld_serve_interrupt(&GPTD5); gpt_lld_serve_interrupt(&GPTD5);
OSAL_IRQ_EPILOGUE(); OSAL_IRQ_EPILOGUE();
@ -213,8 +212,8 @@ OSAL_IRQ_HANDLER(TIMER5_COMPA_vect)
* *
* @notapi * @notapi
*/ */
void gpt_lld_init(void) void gpt_lld_init(void) {
{
#if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__) #if AVR_GPT_USE_TIM1 || defined(__DOXYGEN__)
gptObjectInit(&GPTD1); gptObjectInit(&GPTD1);
#endif #endif
@ -239,8 +238,7 @@ void gpt_lld_init(void)
* *
* @notapi * @notapi
*/ */
void gpt_lld_start(GPTDriver *gptp) void gpt_lld_start(GPTDriver *gptp) {
{
uint8_t psc; uint8_t psc;
if (gptp->state == GPT_STOP) { if (gptp->state == GPT_STOP) {
@ -281,8 +279,8 @@ void gpt_lld_start(GPTDriver *gptp)
* *
* @notapi * @notapi
*/ */
void gpt_lld_stop(GPTDriver *gptp) void gpt_lld_stop(GPTDriver *gptp) {
{
/* nothing to be done */ /* nothing to be done */
if (gptp->state == GPT_READY) { if (gptp->state == GPT_READY) {
/* Clock de-activation.*/ /* Clock de-activation.*/
@ -298,8 +296,8 @@ void gpt_lld_stop(GPTDriver *gptp)
* *
* @notapi * @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->callback = gptp->config->callback;
gptp->period = period; gptp->period = period;
gptp->counter = 0; gptp->counter = 0;
@ -319,9 +317,9 @@ void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t period)
* *
* @notapi * @notapi
*/ */
void gpt_lld_stop_timer(GPTDriver *gptp) void gpt_lld_stop_timer(GPTDriver *gptp) {
{
uint8_t i = getTimerIndex(gptp); uint8_t i = getTimerIndex(gptp);
*regs_table[i].tccrb &= ~((7 << CS10) | (1 << OCIE1A)); *regs_table[i].tccrb &= ~((7 << CS10) | (1 << OCIE1A));
*regs_table[i].tifr = (1 << OCF1A); *regs_table[i].tifr = (1 << OCF1A);
} }
@ -337,8 +335,8 @@ void gpt_lld_stop_timer(GPTDriver *gptp)
* *
* @notapi * @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; gptp->callback = gpt_lld_dummy_callback;
gpt_lld_start_timer(gptp, interval); gpt_lld_start_timer(gptp, interval);
//FIX //FIX