From 2a17d9457a7459414d70ca3ce1ce8dd0edeeb524 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 4 Jun 2016 20:45:00 -0400 Subject: [PATCH] avr: Eliminate gpio_adc_info struct in gpio adc pin definitions The gpio_adc_info only contains a single uint8_t field - it's simpler to use an array of uint8_t instead. Signed-off-by: Kevin O'Connor --- src/avr/gpio.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/avr/gpio.c b/src/avr/gpio.c index 365053a9..af127ba1 100644 --- a/src/avr/gpio.c +++ b/src/avr/gpio.c @@ -98,25 +98,21 @@ static const struct gpio_pwm_info pwm_regs[] PROGMEM = { #endif }; -struct gpio_adc_info { - uint8_t pin; -}; - -static const struct gpio_adc_info adc_pins[] PROGMEM = { +static const uint8_t adc_pins[] PROGMEM = { #if CONFIG_MACH_atmega168 - { GPIO('C', 0) }, { GPIO('C', 1) }, { GPIO('C', 2) }, { GPIO('C', 3) }, - { GPIO('C', 4) }, { GPIO('C', 5) }, { GPIO('E', 0) }, { GPIO('E', 1) }, + GPIO('C', 0), GPIO('C', 1), GPIO('C', 2), GPIO('C', 3), + GPIO('C', 4), GPIO('C', 5), GPIO('E', 0), GPIO('E', 1), #elif CONFIG_MACH_atmega644p - { GPIO('A', 0) }, { GPIO('A', 1) }, { GPIO('A', 2) }, { GPIO('A', 3) }, - { GPIO('A', 4) }, { GPIO('A', 5) }, { GPIO('A', 6) }, { GPIO('A', 7) }, + GPIO('A', 0), GPIO('A', 1), GPIO('A', 2), GPIO('A', 3), + GPIO('A', 4), GPIO('A', 5), GPIO('A', 6), GPIO('A', 7), #elif CONFIG_MACH_at90usb1286 - { GPIO('F', 0) }, { GPIO('F', 1) }, { GPIO('F', 2) }, { GPIO('F', 3) }, - { GPIO('F', 4) }, { GPIO('F', 5) }, { GPIO('F', 6) }, { GPIO('F', 7) }, + GPIO('F', 0), GPIO('F', 1), GPIO('F', 2), GPIO('F', 3), + GPIO('F', 4), GPIO('F', 5), GPIO('F', 6), GPIO('F', 7), #elif CONFIG_MACH_atmega1280 || CONFIG_MACH_atmega2560 - { GPIO('F', 0) }, { GPIO('F', 1) }, { GPIO('F', 2) }, { GPIO('F', 3) }, - { GPIO('F', 4) }, { GPIO('F', 5) }, { GPIO('F', 6) }, { GPIO('F', 7) }, - { GPIO('K', 0) }, { GPIO('K', 1) }, { GPIO('K', 2) }, { GPIO('K', 3) }, - { GPIO('K', 4) }, { GPIO('K', 5) }, { GPIO('K', 6) }, { GPIO('K', 7) }, + GPIO('F', 0), GPIO('F', 1), GPIO('F', 2), GPIO('F', 3), + GPIO('F', 4), GPIO('F', 5), GPIO('F', 6), GPIO('F', 7), + GPIO('K', 0), GPIO('K', 1), GPIO('K', 2), GPIO('K', 3), + GPIO('K', 4), GPIO('K', 5), GPIO('K', 6), GPIO('K', 7), #endif }; @@ -264,8 +260,7 @@ gpio_adc_setup(uint8_t pin) { uint8_t chan; for (chan=0; chanpin) != pin) + if (READP(adc_pins[chan]) != pin) continue; // Enable ADC