Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00070 #ifndef HAL_ADC_H__
00071 #define HAL_ADC_H__
00072
00073 #include <stdint.h>
00074 #include <stdbool.h>
00075
00076 #define ADC_STARTUP_CNT 1;
00077
00078 #define HAL_INP_AIN0 0x00
00079 #define HAL_INP_AIN1 0x01
00080 #define HAL_INP_AIN2 0x02
00081 #define HAL_INP_AIN3 0x03
00082 #define HAL_INP_AIN4 0x04
00083 #define HAL_INP_AIN5 0x05
00084 #define HAL_INP_AIN6 0x06
00085 #define HAL_INP_AIN7 0x07
00086 #define HAL_INP_AIN8 0x08
00087 #define HAL_INP_AIN9 0x09
00088 #define HAL_INP_AIN10 0x0A
00089 #define HAL_INP_AIN11 0x0B
00090 #define HAL_INP_AIN12 0x0C
00091 #define HAL_INP_AIN13 0x0D
00092 #define HAL_INP_VDD1_3 0x0E
00093 #define HAL_INP_VDD2_3 0x0F
00094
00098 typedef enum {
00099 HAL_ADC_INP_AIN0 = HAL_INP_AIN0,
00100 HAL_ADC_INP_AIN1 = HAL_INP_AIN1,
00101 HAL_ADC_INP_AIN2 = HAL_INP_AIN2,
00102 HAL_ADC_INP_AIN3 = HAL_INP_AIN3,
00103 HAL_ADC_INP_AIN4 = HAL_INP_AIN4,
00104 HAL_ADC_INP_AIN5 = HAL_INP_AIN5,
00105 HAL_ADC_INP_AIN6 = HAL_INP_AIN6,
00106 HAL_ADC_INP_AIN7 = HAL_INP_AIN7,
00107 HAL_ADC_INP_AIN8 = HAL_INP_AIN8,
00108 HAL_ADC_INP_AIN9 = HAL_INP_AIN9,
00109 HAL_ADC_INP_AIN10 = HAL_INP_AIN10,
00110 HAL_ADC_INP_AIN11 = HAL_INP_AIN11,
00111 HAL_ADC_INP_AIN12 = HAL_INP_AIN12,
00112 HAL_ADC_INP_AIN13 = HAL_INP_AIN13,
00113 HAL_ADC_INP_VDD1_3 = HAL_INP_VDD1_3,
00114 HAL_ADC_INP_VDD2_3 = HAL_INP_VDD2_3
00115 } hal_adc_input_channel_t;
00116
00120 typedef enum {
00121 HAL_ADC_REF_INT = 0x00,
00122 HAL_ADC_REF_VDD = 0x01,
00123 HAL_ADC_REF_AIN3 = 0x02,
00124 HAL_ADC_REF_AIN9 = 0x03
00125 } hal_adc_reference_t;
00126
00130 typedef enum {
00131 HAL_ADC_SINGLE = 0x00,
00132 HAL_ADC_DIFF_AIN2 = 0x01,
00133 HAL_ADC_DIFF_AIN6 = 0x02
00134 } hal_adc_input_mode_t;
00135
00139 typedef enum {
00140 HAL_ADC_SINGLE_STEP = 0x00,
00141 HAL_ADC_CONTINOUS = 0x01
00142 } hal_adc_conversion_mode_t;
00143
00147 typedef enum {
00148 HAL_ADC_2KSPS = 0x00,
00149 HAL_ADC_4KSPS = 0x01,
00150 HAL_ADC_8KSPS = 0x02,
00151 HAL_ADC_16KSPS = 0x03
00152 } hal_adc_sampling_rate_t;
00153
00157 typedef enum {
00158 HAL_ADC_PDD_0US = 0x00,
00159 HAL_ADC_PDD_6US = 0x01,
00160 HAL_ADC_PDD_24US = 0x02,
00161 HAL_ADC_PDD_INF = 0x03
00162 } hal_adc_power_down_delay_t;
00163
00167 typedef enum {
00168 HAL_ADC_AQW_075US = 0x00,
00169 HAL_ADC_AQW_3US = 0x01,
00170 HAL_ADC_AQW_12US = 0x02,
00171 HAL_ADC_AQW_36US = 0x03
00172 } hal_adc_acq_window_t;
00173
00177 typedef enum {
00178 HAL_ADC_RES_6BIT = 0x00,
00179 HAL_ADC_RES_8BIT = 0x01,
00180 HAL_ADC_RES_10BIT = 0x02,
00181 HAL_ADC_RES_12BIT = 0x03
00182 } hal_adc_resolution_t;
00183
00187 typedef enum {
00188 HAL_ADC_JUST_LEFT = 0x00,
00189 HAL_ADC_JUST_RIGHT = 0x01
00190 } hal_adc_data_just_t;
00191
00195 typedef enum {
00196 HAL_ADC_FLOW_NONE = 0x00,
00197 HAL_ADC_FLOW_OVER = 0x01,
00198 HAL_ADC_FLOW_UNDER = 0x02,
00199 HAL_ADC_FLOW_BOTH = 0x03
00200 } hal_adc_overflow_t;
00201
00204
00205
00211 void hal_adc_set_input_channel(hal_adc_input_channel_t chsel);
00212
00218 void hal_adc_set_reference(hal_adc_reference_t refsel);
00219
00225 void hal_adc_set_input_mode(hal_adc_input_mode_t input_mode);
00226
00232 void hal_adc_set_conversion_mode(hal_adc_conversion_mode_t conv_mode);
00233
00239 void hal_adc_set_sampling_rate(hal_adc_sampling_rate_t rate);
00240
00246 void hal_adc_set_power_down_delay(hal_adc_power_down_delay_t pdd);
00247
00253 void hal_adc_set_acq_window(hal_adc_acq_window_t tacq);
00254
00260 void hal_adc_set_resolution(hal_adc_resolution_t res);
00261
00267 void hal_adc_set_data_just(hal_adc_data_just_t just);
00269
00270
00273
00274
00278 void hal_adc_start(void);
00279
00285 uint8_t hal_adc_read_LSB(void);
00286
00292 uint8_t hal_adc_read_MSB(void);
00294
00297
00298
00306 bool hal_adc_busy(void);
00307
00313 hal_adc_overflow_t hal_adc_get_overflow_status(void);
00315
00316 #endif // HAL_ADC_H__
00317