4 Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with simavr. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef __AVR_ADC_H___
23 #define __AVR_ADC_H___
27 typedef struct avr_adc_t {
31 // if the last bit exists in the mux, we are an extended ADC
33 avr_regbit_t ref[3]; // reference voltage
34 avr_regbit_t adlar; // left/right adjustment bit
36 uint8_t r_adcsra; // ADC Control and Status Register A
37 avr_regbit_t aden; // ADC Enabled
38 avr_regbit_t adsc; // ADC Start Conversion
39 avr_regbit_t adate; // ADC Auto Trigger Enable
41 avr_regbit_t adps[3]; // Prescaler bits. Note that it's a frequency bit shift
43 uint8_t r_adcl, r_adch; // Data Registers
45 uint8_t r_adcsrb; // ADC Control and Status Register B
46 avr_regbit_t adts[3]; // Timing Source
47 avr_regbit_t bin; // Bipolar Input Mode (tinyx5 have it)
48 avr_regbit_t ipr; // Input Polarity Reversal (tinyx5 have it)
51 // use ADIF and ADIE bits
55 void avr_adc_init(avr_t * avr, avr_adc_t * port);
57 #endif /* __AVR_ADC_H___ */