BeRTOS
adc_at91.h
Go to the documentation of this file.
00001 
00038 #ifndef DRV_ADC_AT91_H
00039 #define DRV_ADC_AT91_H
00040 
00041 #include <hw/hw_cpufreq.h>
00042 
00043 #include "cfg/cfg_adc.h"
00044 
00045 #include <cfg/compiler.h>
00046 
00050 #define ADC_MUX_MAXCH          8 //Max number of channel for ADC.
00051 #define ADC_BITS              10 //Bit resolution for ADC converter.
00052 
00057 #define ADC_COMPUTED_PRESCALER    (DIV_ROUNDUP(CPU_FREQ, 2 * CONFIG_ADC_CLOCK) - 1)
00058 #define ADC_COMPUTED_CLOCK        (CPU_FREQ / ((ADC_COMPUTED_PRESCALER + 1) * 2))
00059 #define ADC_COMPUTED_STARTUPTIME  (((CONFIG_ADC_STARTUP_TIME * ADC_COMPUTED_CLOCK) / 8000000UL) - 1)
00060 #define ADC_COMPUTED_SHTIME       ((uint32_t)((CONFIG_ADC_SHTIME * (uint64_t)ADC_COMPUTED_CLOCK) / 1000000000UL) - 1)
00061 
00070 #if CPU_ARM_SAM7X
00071     #define ADC_PIO_DISABLE           PIOB_PDR
00072     #define ADC_PIO_EN_FUNC           PIOB_ASR
00073 
00074 #elif CPU_ARM_SAM7S_LARGE
00075     #define ADC_PIO_DISABLE           PIOA_PDR
00076     #define ADC_PIO_EN_FUNC           PIOA_BSR
00077 
00078 #else
00079     #error No ADC pins name definitions for selected ARM CPU
00080 #endif
00081 /*\}*/
00082 
00087 #define ADC_INIT_PINS() \
00088     do { \
00089     } while (0)
00090 
00091 void adc_hw_select_ch(uint8_t ch);
00092 uint16_t adc_hw_read(void);
00093 void adc_hw_init(void);
00094 
00095 #endif /* DRV_ADC_AT91_H */