adc_at91.h
Go to the documentation of this file.00001
00041 #ifndef DRV_ADC_AT91_H
00042 #define DRV_ADC_AT91_H
00043
00044 #include <hw/hw_cpufreq.h>
00045
00046 #include "cfg/cfg_adc.h"
00047
00048 #include <cfg/compiler.h>
00049
00053 #define ADC_MUX_MAXCH 8 //Max number of channel for ADC.
00054 #define ADC_BITS 10 //Bit resolution for ADC converter.
00055
00060 #define ADC_COMPUTED_PRESCALER (DIV_ROUNDUP(CPU_FREQ, 2 * CONFIG_ADC_CLOCK) - 1)
00061 #define ADC_COMPUTED_CLOCK (CPU_FREQ / ((ADC_COMPUTED_PRESCALER + 1) * 2))
00062 #define ADC_COMPUTED_STARTUPTIME (((CONFIG_ADC_STARTUP_TIME * ADC_COMPUTED_CLOCK) / 8000000UL) - 1)
00063 #define ADC_COMPUTED_SHTIME ((uint32_t)((CONFIG_ADC_SHTIME * (uint64_t)ADC_COMPUTED_CLOCK) / 1000000000UL) - 1)
00064
00073 #if CPU_ARM_SAM7X
00074 #define ADC_PIO_DISABLE PIOB_PDR
00075 #define ADC_PIO_EN_FUNC PIOB_ASR
00076
00077 #elif CPU_ARM_SAM7S_LARGE
00078 #define ADC_PIO_DISABLE PIOA_PDR
00079 #define ADC_PIO_EN_FUNC PIOA_BSR
00080
00081 #else
00082 #error No ADC pins name definitions for selected ARM CPU
00083 #endif
00084
00085
00090 #define ADC_INIT_PINS() \
00091 do { \
00092 } while (0)
00093
00094 void adc_hw_select_ch(uint8_t ch);
00095 uint16_t adc_hw_read(void);
00096 void adc_hw_init(void);
00097
00098 #endif