Improve documentation for the ADC and TWI drivers.
authorDean Camera <dean@fourwalledcubicle.com>
Mon, 15 Mar 2010 05:38:29 +0000 (05:38 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Mon, 15 Mar 2010 05:38:29 +0000 (05:38 +0000)
LUFA/Drivers/Peripheral/AVRU4U6U7/ADC.h
LUFA/Drivers/Peripheral/TWI.c

index 4b120ae..9ab65af 100644 (file)
                        #define  ADC_CHANNEL7                    (0x07 << MUX0)\r
 \r
                        /** MUX mask define for the internal 1.1V bandgap channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */\r
-                       #define  ADC_1100MV_BANDGAP              0x1E\r
+                       #define  ADC_1100MV_BANDGAP              (0x1E << MUX0)\r
                        \r
                        #if (defined(__AVR_ATmega16U4__)  || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))\r
                                /** MUX mask define for the ADC8 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading.\r
                         *  Once executed, the conversion status can be determined via the \ref ADC_IsReadingComplete() macro and\r
                         *  the result read via the \ref ADC_GetResult() macro.\r
                         *\r
+                        *  If the ADC has been initialized in free running mode, calling this function once will begin the repeated\r
+                        *  conversions. If the ADC is in single conversion mode (or the channel to convert from is to be changed),\r
+                        *  this function must be called each time a conversion is to take place.\r
+                        *\r
                         *  \param[in] MUXMask  Mask comprising of an ADC channel mask, reference mask and adjustment mask\r
                         */\r
                        static inline void ADC_StartReading(const uint16_t MUXMask)\r
                        /** Performs a complete single reading from channel, including a polling spin-loop to wait for the\r
                         *  conversion to complete, and the returning of the converted value.\r
                         *\r
+                        *  \note For free running mode, the automated conversions should be initialized with a single call\r
+                        *        to \ref ADC_StartReading() to select the channel and begin the automated conversions, and\r
+                        *        the results read directly from the \ref ADC_GetResult() instead to reduce overhead.\r
+                        *\r
                         *  \param[in] MUXMask  Mask comprising of an ADC channel mask, reference mask and adjustment mask\r
                         */\r
                        static inline uint16_t ADC_GetChannelReading(const uint16_t MUXMask) ATTR_WARN_UNUSED_RESULT;\r
index 7986679..9e0c20d 100644 (file)
@@ -17,7 +17,7 @@ bool TWI_StartTransmission(uint8_t SlaveAddress, uint8_t TimeoutMS)
                TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN));     \r
 \r
                TimeoutRemaining = (TimeoutMS * 100);\r
-               while (TimeoutRemaining-- && !BusCaptured)\r
+               while (TimeoutRemaining-- && !(BusCaptured))\r
                {\r
                        if (TWCR & (1 << TWINT))\r
                        {\r