Commit 009eebf2 authored by Dean Camera's avatar Dean Camera
Browse files

Fix incorrect ADC driver documentation for the parameters of ADC_Init(), fix...

Fix incorrect ADC driver documentation for the parameters of ADC_Init(), fix incorrect call to ADC_Init() in the TemperatureDatalogger project.
parent 1afe51fa
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
/** \file /** \file
* \brief ADC peripheral driver for the U7, U6 and U4 USB AVRs. * \brief ADC peripheral driver for the U7, U6 and U4 USB AVRs.
* *
* ADC driver for the AT90USB1287, AT90USB1286, AT90USB647, AT90USB646, ATMEGA16U4 and ATMEGA32U4 AVRs. * On-chip Analogue-to-Digital converter (ADC) driver for supported U4, U6 and U7 model AVRs that contain an ADC
* peripheral internally.
* *
* \note This file should not be included directly. It is automatically included as needed by the ADC driver * \note This file should not be included directly. It is automatically included as needed by the ADC driver
* dispatch header located in LUFA/Drivers/Peripheral/ADC.h. * dispatch header located in LUFA/Drivers/Peripheral/ADC.h.
...@@ -40,7 +41,8 @@ ...@@ -40,7 +41,8 @@
/** \ingroup Group_ADC /** \ingroup Group_ADC
* @defgroup Group_ADC_AVRU4U6U7 Series U4, U6 and U7 Model ADC Driver * @defgroup Group_ADC_AVRU4U6U7 Series U4, U6 and U7 Model ADC Driver
* *
* ADC driver for the AT90USB1287, AT90USB1286, AT90USB647, AT90USB646, ATMEGA16U4 and ATMEGA32U4 AVRs. * On-chip Analogue-to-Digital converter (ADC) driver for supported U4, U6 and U7 model AVRs that contain an ADC
* peripheral internally.
* *
* \note This file should not be included directly. It is automatically included as needed by the ADC driver * \note This file should not be included directly. It is automatically included as needed by the ADC driver
* dispatch header located in LUFA/Drivers/Peripheral/ADC.h. * dispatch header located in LUFA/Drivers/Peripheral/ADC.h.
...@@ -208,35 +210,35 @@ ...@@ -208,35 +210,35 @@
* *
* \note The channel number must be specified as an integer, and NOT a ADC_CHANNELx mask. * \note The channel number must be specified as an integer, and NOT a ADC_CHANNELx mask.
* *
* \param[in] Channel ADC channel number to set up for conversions. * \param[in] ChannelIndex ADC channel number to set up for conversions.
*/ */
static inline void ADC_SetupChannel(const uint8_t Channel) static inline void ADC_SetupChannel(const uint8_t ChannelIndex)
{ {
#if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
defined(__AVR_ATmega32U6__)) defined(__AVR_ATmega32U6__))
DDRF &= ~(1 << Channel); DDRF &= ~(1 << ChannelIndex);
DIDR0 |= (1 << Channel); DIDR0 |= (1 << ChannelIndex);
#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
if (Channel < 8) if (ChannelIndex < 8)
{ {
DDRF &= ~(1 << Channel); DDRF &= ~(1 << ChannelIndex);
DIDR0 |= (1 << Channel); DIDR0 |= (1 << ChannelIndex);
} }
else if (Channel == 8) else if (ChannelIndex == 8)
{ {
DDRD &= ~(1 << 4); DDRD &= ~(1 << 4);
DIDR2 |= (1 << 0); DIDR2 |= (1 << 0);
} }
else if (Channel < 11) else if (ChannelIndex < 11)
{ {
DDRD &= ~(1 << (Channel - 3)); DDRD &= ~(1 << (ChannelIndex - 3));
DIDR2 |= (1 << (Channel - 8)); DIDR2 |= (1 << (ChannelIndex - 8));
} }
else else
{ {
DDRB &= ~(1 << (Channel - 7)); DDRB &= ~(1 << (ChannelIndex - 7));
DIDR2 |= (1 << (Channel - 8)); DIDR2 |= (1 << (ChannelIndex - 8));
} }
#endif #endif
} }
...@@ -251,35 +253,35 @@ ...@@ -251,35 +253,35 @@
* *
* \note The channel number must be specified as an integer, and NOT a ADC_CHANNELx mask. * \note The channel number must be specified as an integer, and NOT a ADC_CHANNELx mask.
* *
* \param[in] Channel ADC channel number to set up for conversions. * \param[in] ChannelIndex ADC channel number to set up for conversions.
*/ */
static inline void ADC_DisableChannel(const uint8_t Channel) static inline void ADC_DisableChannel(const uint8_t ChannelIndex)
{ {
#if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
defined(__AVR_ATmega32U6__)) defined(__AVR_ATmega32U6__))
DDRF &= ~(1 << Channel); DDRF &= ~(1 << ChannelIndex);
DIDR0 &= ~(1 << Channel); DIDR0 &= ~(1 << ChannelIndex);
#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
if (Channel < 8) if (ChannelIndex < 8)
{ {
DDRF &= ~(1 << Channel); DDRF &= ~(1 << ChannelIndex);
DIDR0 &= ~(1 << Channel); DIDR0 &= ~(1 << ChannelIndex);
} }
else if (Channel == 8) else if (ChannelIndex == 8)
{ {
DDRD &= ~(1 << 4); DDRD &= ~(1 << 4);
DIDR2 &= ~(1 << 0); DIDR2 &= ~(1 << 0);
} }
else if (Channel < 11) else if (ChannelIndex < 11)
{ {
DDRD &= ~(1 << (Channel - 3)); DDRD &= ~(1 << (ChannelIndex - 3));
DIDR2 &= ~(1 << (Channel - 8)); DIDR2 &= ~(1 << (ChannelIndex - 8));
} }
else else
{ {
DDRB &= ~(1 << (Channel - 7)); DDRB &= ~(1 << (ChannelIndex - 7));
DIDR2 &= ~(1 << (Channel - 8)); DIDR2 &= ~(1 << (ChannelIndex - 8));
} }
#endif #endif
} }
...@@ -292,7 +294,7 @@ ...@@ -292,7 +294,7 @@
* conversions. If the ADC is in single conversion mode (or the channel to convert from is to be changed), * conversions. If the ADC is in single conversion mode (or the channel to convert from is to be changed),
* this function must be called each time a conversion is to take place. * this function must be called each time a conversion is to take place.
* *
* \param[in] MUXMask Mask comprising of an ADC channel mask, reference mask and adjustment mask. * \param[in] MUXMask ADC channel mask, reference mask and adjustment mask.
*/ */
static inline void ADC_StartReading(const uint16_t MUXMask) static inline void ADC_StartReading(const uint16_t MUXMask)
{ {
...@@ -354,7 +356,7 @@ ...@@ -354,7 +356,7 @@
* The "mode" parameter should be a mask comprised of a conversion mode (free running or single) and * The "mode" parameter should be a mask comprised of a conversion mode (free running or single) and
* prescaler masks. * prescaler masks.
* *
* \param[in] Mode Mask of ADC settings, including adjustment, prescale, mode and reference. * \param[in] Mode Mask of ADC prescale and mode settings.
*/ */
static inline void ADC_Init(uint8_t Mode) ATTR_ALWAYS_INLINE; static inline void ADC_Init(uint8_t Mode) ATTR_ALWAYS_INLINE;
static inline void ADC_Init(uint8_t Mode) static inline void ADC_Init(uint8_t Mode)
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
* - Ghetto Drum, a MIDI drum controller: http://noisybox.net/art/gdrum/ * - Ghetto Drum, a MIDI drum controller: http://noisybox.net/art/gdrum/
* - IR Remote to Keyboard decoder: http://netzhansa.blogspot.com/2010/04/our-living-room-hi-fi-setup-needs-mp3.html * - IR Remote to Keyboard decoder: http://netzhansa.blogspot.com/2010/04/our-living-room-hi-fi-setup-needs-mp3.html
* - LED Panel controller: http://projects.peterpolidoro.net/caltech/panelscontroller/panelscontroller.htm * - LED Panel controller: http://projects.peterpolidoro.net/caltech/panelscontroller/panelscontroller.htm
* - Single LED Matrix Display: http://guysoft.wordpress.com/2009/10/08/bumble-b/
* - Linux Secure Storage Dongle: http://github.com/TomMD/teensy * - Linux Secure Storage Dongle: http://github.com/TomMD/teensy
* - MakeTV Episode Dispenser: http://www.youtube.com/watch?v=BkWUi18hl3g * - MakeTV Episode Dispenser: http://www.youtube.com/watch?v=BkWUi18hl3g
* - MidiMonster, a USB-to-MIDI gateway board: http://www.dorkbotpdx.org/wiki/midimonster * - MidiMonster, a USB-to-MIDI gateway board: http://www.dorkbotpdx.org/wiki/midimonster
...@@ -61,6 +62,7 @@ ...@@ -61,6 +62,7 @@
* - SD Card reader: http://elasticsheep.com/2010/04/teensy2-usb-mass-storage-with-an-sd-card/ * - SD Card reader: http://elasticsheep.com/2010/04/teensy2-usb-mass-storage-with-an-sd-card/
* - SEGA Megadrive/Genesis Development Cartridge: http://www.makestuff.eu/wordpress/?page_id=398 * - SEGA Megadrive/Genesis Development Cartridge: http://www.makestuff.eu/wordpress/?page_id=398
* - Stripe Snoop, a Magnetic Card reader: http://www.ossguy.com/ss_usb/ * - Stripe Snoop, a Magnetic Card reader: http://www.ossguy.com/ss_usb/
* - Teensy SD Card .WAV file player: http://elasticsheep.com/2010/04/teensy2-usb-wav-player-part-1/
* - Touchscreen Input Device: http://capnstech.blogspot.com/2010/07/touchscreen-update.html * - Touchscreen Input Device: http://capnstech.blogspot.com/2010/07/touchscreen-update.html
* - USB Interface for Playstation Portable Devices: http://forums.ps2dev.org/viewtopic.php?t=11001 * - USB Interface for Playstation Portable Devices: http://forums.ps2dev.org/viewtopic.php?t=11001
* - Userial, a USB to Serial converter with SPI, I2C and other protocols: http://www.tty1.net/userial/ * - Userial, a USB to Serial converter with SPI, I2C and other protocols: http://www.tty1.net/userial/
......
...@@ -57,7 +57,7 @@ void V2Protocol_Init(void) ...@@ -57,7 +57,7 @@ void V2Protocol_Init(void)
/* Initialize the ADC converter for VTARGET level detection on supported AVR models */ /* Initialize the ADC converter for VTARGET level detection on supported AVR models */
ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128); ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128);
ADC_SetupChannel(VTARGET_ADC_CHANNEL); ADC_SetupChannel(VTARGET_ADC_CHANNEL);
ADC_StartReading(VTARGET_ADC_CHANNEL_MASK | ADC_RIGHT_ADJUSTED | ADC_REFERENCE_AVCC); ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | VTARGET_ADC_CHANNEL_MASK);
#endif #endif
/* Timeout timer initialization (10ms period) */ /* Timeout timer initialization (10ms period) */
......
...@@ -201,7 +201,7 @@ void SetupHardware(void) ...@@ -201,7 +201,7 @@ void SetupHardware(void)
/* Hardware Initialization */ /* Hardware Initialization */
LEDs_Init(); LEDs_Init();
SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER); SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
ADC_Init(ADC_REFERENCE_AVCC | ADC_FREE_RUNNING | ADC_PRESCALE_128); ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128);
Temperature_Init(); Temperature_Init();
Dataflash_Init(); Dataflash_Init();
USB_Init(); USB_Init();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment