Add adc support for atmega1280. Signed-off by Fabio Bizzi.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 5 Aug 2010 08:34:20 +0000 (08:34 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 5 Aug 2010 08:34:20 +0000 (08:34 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4144 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/avr/drv/adc_avr.c
bertos/cpu/avr/drv/adc_avr.h

index 3eb08b79c2c2cf84bc582c797e912e19f5e828cb..c42f8e3ba4f9c6ae67db243790e8542f38883575 100644 (file)
@@ -104,12 +104,23 @@ void adc_hw_select_ch(uint8_t ch)
        #elif CPU_AVR_ATMEGA32 || CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA1281 \
              || CPU_AVR_ATMEGA1280
                ADMUX &= ~(BV(MUX4) | BV(MUX3) | BV(MUX2) | BV(MUX1) | BV(MUX0));
+               #if CPU_AVR_ATMEGA1280
+                       ADCSRB &= ~(BV(MUX5));
+               #endif
        #else
                #error Unknown CPU
        #endif
 
-       /* Select channel, only first 8 channel modes are supported for now */
+       /* Select channel, only first 8 channel modes are supported */
        ADMUX |= (ch & 0x07);
+
+       #if CPU_AVR_ATMEGA1280
+               /* Select channel, all 16 channels are supported */
+               if (ch > 0x07)
+                       ADCSRB |= BV(MUX5);
+
+       #endif
+
 }
 
 
index 417e45367051efc8400a621cf8bc250cc455edab..c42cf324cdfce00d5bea42c895efd6d3b7e119bf 100644 (file)
 
 #include <cfg/compiler.h>
 
-#define ADC_MUX_MAXCH 7
+#if CPU_AVR_ATMEGA1280
+       /* 16 channels aivailable */
+       #define ADC_MUX_MAXCH 15
+#else
+       /* only 8 channels aivailable */
+       #define ADC_MUX_MAXCH 7
+#endif
 #define ADC_BITS      10
 
 void adc_hw_select_ch(uint8_t ch);