Corrected the ADC driver for the ATMEGA16U4 and ATMEGA32U4 (thanks to Opendous Inc.).
[pub/lufa.git] / LUFA / Drivers / Peripheral / AT90USBXXX67 / ADC.h
index 358629c..4cc7c32 100644 (file)
                         */\r
                        static inline void ADC_SetupChannel(const uint8_t Channel)\r
                        {\r
+                               #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \\r
+                                        defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \\r
+                                        defined(__AVR_ATmega32U6__))                           \r
                                DDRF  &= ~(1 << Channel);\r
                                DIDR0 |=  (1 << Channel);\r
+                               #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))\r
+                               if (Channel < 8)\r
+                               {\r
+                                       DDRF  &= ~(1 << Channel);\r
+                                       DIDR0 |=  (1 << Channel);\r
+                               }\r
+                               else if (Channel == 8)\r
+                               {\r
+                                       DDRD  &= ~(1 << 4);\r
+                                       DIDR2 |=  (1 << 0);\r
+                               }\r
+                               else if (Channel < 11)\r
+                               {\r
+                                       DDRD  &= ~(1 << (Channel - 3));\r
+                                       DIDR2 |=  (1 << (Channel - 8));\r
+                               }\r
+                               else\r
+                               {\r
+                                       DDRB  &= ~(1 << (Channel - 7));\r
+                                       DIDR2 |=  (1 << (Channel - 8));\r
+                               }\r
+                               #endif\r
                        }\r
                        \r
                        /** Starts the reading of the given channel, but does not wait until the conversion has completed.\r