#ifndef ADC_H
#define ADC_H

// Table 24-5 : prescaler ADC
#define ADC_PRESCALE_SET(value)  \
									((value) == 2   ? (0<<ADPS2 | 0<<ADPS1 | 1<<ADPS0) : \
									 (value) == 4   ? (0<<ADPS2 | 1<<ADPS1 | 0<<ADPS0) : \
									 (value) == 8   ? (0<<ADPS2 | 1<<ADPS1 | 1<<ADPS0) : \
									 (value) == 16  ? (1<<ADPS2 | 0<<ADPS1 | 0<<ADPS0) : \
									 (value) == 32  ? (1<<ADPS2 | 0<<ADPS1 | 1<<ADPS0) : \
									 (value) == 64  ? (1<<ADPS2 | 1<<ADPS1 | 0<<ADPS0) : \
									 (value) == 128 ? (1<<ADPS2 | 1<<ADPS1 | 1<<ADPS0) : \
													  (0<<ADPS2 | 0<<ADPS1 | 0<<ADPS0))

// Table 24-6 : ADC Auto Trigger Source Selections
#define ADC_TRIGGER_FREE_RUNNING				(0 << ADTS2) | (0 << ADTS1) | (0 << ADTS0)
#define ADC_TRIGGER_ANALOG_COMPARE				(0 << ADTS2) | (0 << ADTS1) | (1 << ADTS0)
#define ADC_TRIGGER_EXTERNAL_INTERRUPT_0		(0 << ADTS2) | (1 << ADTS1) | (0 << ADTS0)
#define ADC_TRIGGER_TIMER_0_COMPARE_A			(0 << ADTS2) | (1 << ADTS1) | (1 << ADTS0)
#define ADC_TRIGGER_TIMER_0_OVERFLOW			(1 << ADTS2) | (0 << ADTS1) | (0 << ADTS0)
#define ADC_TRIGGER_TIMER_1_COMPARE_B			(1 << ADTS2) | (0 << ADTS1) | (1 << ADTS0)
#define ADC_TRIGGER_TIMER_1_OVERFLOW			(1 << ADTS2) | (1 << ADTS1) | (0 << ADTS0)
#define ADC_TRIGGER_TIMER_1_CAPTURE_EVENT		(1 << ADTS2) | (1 << ADTS1) | (1 << ADTS0)

#endif // ADC_H