37 #ifdef CORTEXM3_STM32W108
40 typedef int8u ADCUser;
54 #define NUM_ADC_USERS 3 // make sure to update if the above is adjusted
58 typedef int8u ADCReferenceType;
70 typedef int8u ADCRateType;
74 ADC_CONVERSION_TIME_US_32 = 0x0,
76 ADC_CONVERSION_TIME_US_64 = 0x1,
78 ADC_CONVERSION_TIME_US_128 = 0x2,
80 ADC_CONVERSION_TIME_US_256 = 0x3,
82 ADC_CONVERSION_TIME_US_512 = 0x4,
84 ADC_CONVERSION_TIME_US_1024 = 0x5,
86 ADC_CONVERSION_TIME_US_2048 = 0x6,
88 ADC_CONVERSION_TIME_US_4096 = 0x7,
92 #if defined (CORTEXM3)
94 #define ADC_MUX_ADC0 0x0
96 #define ADC_MUX_ADC1 0x1
98 #define ADC_MUX_ADC2 0x2
100 #define ADC_MUX_ADC3 0x3
102 #define ADC_MUX_ADC4 0x4
104 #define ADC_MUX_ADC5 0x5
106 #define ADC_MUX_GND 0x8
108 #define ADC_MUX_VREF2 0x9
110 #define ADC_MUX_VREF 0xA
112 #define ADC_MUX_VREG2 0xB
118 ADC_SOURCE_ADC0_VREF2 = ((ADC_MUX_ADC0 <<ADC_MUXN_BITS) + ADC_MUX_VREF2),
119 ADC_SOURCE_ADC0_GND = ((ADC_MUX_ADC0 <<ADC_MUXN_BITS) + ADC_MUX_GND),
121 ADC_SOURCE_ADC1_VREF2 = ((ADC_MUX_ADC1 <<ADC_MUXN_BITS) + ADC_MUX_VREF2),
122 ADC_SOURCE_ADC1_GND = ((ADC_MUX_ADC1 <<ADC_MUXN_BITS) + ADC_MUX_GND),
124 ADC_SOURCE_ADC2_VREF2 = ((ADC_MUX_ADC2 <<ADC_MUXN_BITS) + ADC_MUX_VREF2),
125 ADC_SOURCE_ADC2_GND = ((ADC_MUX_ADC2 <<ADC_MUXN_BITS) + ADC_MUX_GND),
127 ADC_SOURCE_ADC3_VREF2 = ((ADC_MUX_ADC3 <<ADC_MUXN_BITS) + ADC_MUX_VREF2),
128 ADC_SOURCE_ADC3_GND = ((ADC_MUX_ADC3 <<ADC_MUXN_BITS) + ADC_MUX_GND),
130 ADC_SOURCE_ADC4_VREF2 = ((ADC_MUX_ADC4 <<ADC_MUXN_BITS) + ADC_MUX_VREF2),
131 ADC_SOURCE_ADC4_GND = ((ADC_MUX_ADC4 <<ADC_MUXN_BITS) + ADC_MUX_GND),
133 ADC_SOURCE_ADC5_VREF2 = ((ADC_MUX_ADC5 <<ADC_MUXN_BITS) + ADC_MUX_VREF2),
134 ADC_SOURCE_ADC5_GND = ((ADC_MUX_ADC5 <<ADC_MUXN_BITS) + ADC_MUX_GND),
136 ADC_SOURCE_ADC1_ADC0 = ((ADC_MUX_ADC1 <<ADC_MUXN_BITS) + ADC_MUX_ADC0),
137 ADC_SOURCE_ADC0_ADC1 = ((ADC_MUX_ADC1 <<ADC_MUXN_BITS) + ADC_MUX_ADC0),
139 ADC_SOURCE_ADC3_ADC2 = ((ADC_MUX_ADC3 <<ADC_MUXN_BITS) + ADC_MUX_ADC2),
140 ADC_SOURCE_ADC2_ADC3 = ((ADC_MUX_ADC3 <<ADC_MUXN_BITS) + ADC_MUX_ADC2),
142 ADC_SOURCE_ADC5_ADC4 = ((ADC_MUX_ADC5 <<ADC_MUXN_BITS) + ADC_MUX_ADC4),
144 ADC_SOURCE_GND_VREF2 = ((ADC_MUX_GND <<ADC_MUXN_BITS) + ADC_MUX_VREF2),
145 ADC_SOURCE_VGND = ((ADC_MUX_GND <<ADC_MUXN_BITS) + ADC_MUX_GND),
147 ADC_SOURCE_VREF_VREF2 = ((ADC_MUX_VREF <<ADC_MUXN_BITS) + ADC_MUX_VREF2),
148 ADC_SOURCE_VREF = ((ADC_MUX_VREF <<ADC_MUXN_BITS) + ADC_MUX_GND),
156 #ifdef ENABLE_ADC_EXTENDED_RANGE_BROKEN
157 ADC_SOURCE_VREF2_VREF2 = ((ADC_MUX_VREF2 <<ADC_MUXN_BITS) + ADC_MUX_VREF2),
158 ADC_SOURCE_VREF2 = ((ADC_MUX_VREF2 <<ADC_MUXN_BITS) + ADC_MUX_GND),
161 ADC_SOURCE_VREG2_VREF2 = ((ADC_MUX_VREG2 <<ADC_MUXN_BITS) + ADC_MUX_VREF2),
162 ADC_SOURCE_VDD_GND = ((ADC_MUX_VREG2 <<ADC_MUXN_BITS) + ADC_MUX_GND)
168 #define ADC_SOURCE(P,N) (( P << ADC_MUXN_BITS ) + N)
170 #endif // defined (CORTEXM3)
176 typedef int8u ADCChannelType;
187 int8u halGetADCChannelFromGPIO(int32u io);
192 void halInternalInitAdc(
void);
217 StStatus halStartAdcConversion(ADCUser
id,
218 ADCReferenceType reference,
219 ADCChannelType channel,
240 StStatus halRequestAdcData(ADCUser
id, int16u *value);
258 StStatus halReadAdcBlocking(ADCUser
id, int16u *value);
277 StStatus halAdcCalibrate(ADCUser
id);
291 int16s halConvertValueToVolts(int16u value);
302 void stCalibrateVref(
void);
305 void halAdcSetClock(
boolean fast);
306 void halAdcSetRange(
boolean high);
307 boolean halAdcGetClock(
void);
308 boolean halAdcGetRange(
void);
313 #ifdef CORTEXM3_STM32F103
314 #include "micro/cortexm3/stm32f103ret/adc.h"