27 #ifndef LPC17XX_ADC_H_
28 #define LPC17XX_ADC_H_
50 #define ADC_CR_CH_SEL(n) ((1UL << n))
53 #define ADC_CR_CLKDIV(n) ((n<<8))
55 #define ADC_CR_BURST ((1UL<<16))
57 #define ADC_CR_PDN ((1UL<<21))
59 #define ADC_CR_START_MASK ((7UL<<24))
61 #define ADC_CR_START_MODE_SEL(SEL) ((SEL<<24))
63 #define ADC_CR_START_NOW ((1UL<<24))
65 #define ADC_CR_START_EINT0 ((2UL<<24))
67 #define ADC_CR_START_CAP01 ((3UL<<24))
69 #define ADC_CR_START_MAT01 ((4UL<<24))
71 #define ADC_CR_START_MAT03 ((5UL<<24))
73 #define ADC_CR_START_MAT10 ((6UL<<24))
75 #define ADC_CR_START_MAT11 ((7UL<<24))
77 #define ADC_CR_EDGE ((1UL<<27))
83 #define ADC_GDR_RESULT(n) (((n>>4)&0xFFF))
85 #define ADC_GDR_CH(n) (((n>>24)&0x7))
88 #define ADC_GDR_OVERRUN_FLAG ((1UL<<30))
90 #define ADC_GDR_DONE_FLAG ((1UL<<31))
93 #define ADC_GDR_CH_MASK ((7UL<<24))
99 #define ADC_INTEN_CH(n) ((1UL<<n))
101 #define ADC_INTEN_GLOBAL ((1UL<<8))
107 #define ADC_DR_RESULT(n) (((n>>4)&0xFFF))
110 #define ADC_DR_OVERRUN_FLAG ((1UL<<30))
113 #define ADC_DR_DONE_FLAG ((1UL<<31))
120 #define ADC_STAT_CH_DONE_FLAG(n) ((n&0xFF))
123 #define ADC_STAT_CH_OVERRUN_FLAG(n) (((n>>8)&0xFF))
125 #define ADC_STAT_INT_FLAG ((1UL<<16))
131 #define ADC_ADCOFFS(n) (((n&0xF)<<4))
133 #define ADC_TRIM(n) (((n&0xF)<<8))
137 #define PARAM_ADCx(n) (((uint32_t *)n)==((uint32_t *)LPC_ADC))
140 #define PARAM_ADC_START_ON_EDGE_OPT(OPT) ((OPT == ADC_START_ON_RISING)||(OPT == ADC_START_ON_FALLING))
143 #define PARAM_ADC_DATA_STATUS(OPT) ((OPT== ADC_DATA_BURST)||(OPT== ADC_DATA_DONE))
146 #define PARAM_ADC_RATE(rate) ((rate>0)&&(rate<=200000))
149 #define PARAM_ADC_CHANNEL_SELECTION(SEL) ((SEL == ADC_CHANNEL_0)||(ADC_CHANNEL_1)\
150 ||(SEL == ADC_CHANNEL_2)|(ADC_CHANNEL_3)\
151 ||(SEL == ADC_CHANNEL_4)||(ADC_CHANNEL_5)\
152 ||(SEL == ADC_CHANNEL_6)||(ADC_CHANNEL_7))
155 #define PARAM_ADC_START_OPT(OPT) ((OPT == ADC_START_CONTINUOUS)||(OPT == ADC_START_NOW)\
156 ||(OPT == ADC_START_ON_EINT0)||(OPT == ADC_START_ON_CAP01)\
157 ||(OPT == ADC_START_ON_MAT01)||(OPT == ADC_START_ON_MAT03)\
158 ||(OPT == ADC_START_ON_MAT10)||(OPT == ADC_START_ON_MAT11))
161 #define PARAM_ADC_TYPE_INT_OPT(OPT) ((OPT == ADC_ADINTEN0)||(OPT == ADC_ADINTEN1)\
162 ||(OPT == ADC_ADINTEN2)||(OPT == ADC_ADINTEN3)\
163 ||(OPT == ADC_ADINTEN4)||(OPT == ADC_ADINTEN5)\
164 ||(OPT == ADC_ADINTEN6)||(OPT == ADC_ADINTEN7)\
165 ||(OPT == ADC_ADGINTEN))