Rename Drivers/AT90USBXXX to Drivers/Peripheral.
[pub/USBasp.git] / LUFA / Drivers / Peripheral / ADC.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 *
33 * This file is the master dispatch header file for the device-specific ADC driver, for AVRs containing an ADC.
34 *
35 * User code should include this file, which will in turn include the correct ADC driver header file for the
36 * currently selected AVR model.
37 */
38
39 /** \ingroup Group_SubsystemDrivers
40 * @defgroup Group_ADC ADC Driver - LUFA/Drivers/Peripheral/ADC.h
41 */
42
43 #ifndef __ADC_H__
44 #define __ADC_H__
45
46 /* Macros: */
47 #if !defined(__DOXYGEN__)
48 #define INCLUDE_FROM_ADC_H
49 #define INCLUDE_FROM_CHIP_DRIVER
50 #endif
51
52 /* Includes: */
53 #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
54 defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
55 defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \
56 defined(__AVR_ATmega32U6__))
57 #include "AT90USBXXX67/ADC.h"
58 #else
59 #error "ADC is not available for the currently selected AVR model."
60 #endif
61
62 /* Public Interface - May be used in end-application: */
63 /* Inline Functions: */
64 /** Starts the reading of the given channel, but does not wait until the conversion has completed.
65 * Once executed, the conversion status can be determined via the ADC_IsReadingComplete() macro and
66 * the result read via the ADC_GetResult() macro.
67 *
68 * \param MUXMask Mask comprising of an ADC channel number, reference mask and adjustment mask
69 */
70 static inline void ADC_StartReading(const uint8_t MUXMask);
71
72 /** Performs a complete single reading from channel, including a polling spinloop to wait for the
73 * conversion to complete, and the returning of the converted value.
74 *
75 * \param MUXMask Mask comprising of an ADC channel number, reference mask and adjustment mask
76 */
77 static inline uint16_t ADC_GetChannelReading(const uint8_t MUXMask) ATTR_WARN_UNUSED_RESULT;
78
79 /** Configures the given ADC channel, ready for ADC conversions. This function sets the
80 * associated port pin as an input and disables the digital portion of the I/O to reduce
81 * power consumption.
82 *
83 * \param Channel ADC channel number to set up for conversions
84 */
85 static inline void ADC_SetupChannel(const uint8_t Channel);
86
87 #endif