File tree Expand file tree Collapse file tree 12 files changed +42
-35
lines changed Expand file tree Collapse file tree 12 files changed +42
-35
lines changed Original file line number Diff line number Diff line change @@ -175,11 +175,12 @@ uint16_t adc_read(analogin_t *obj)
175
175
HAL_ADC_Start (& obj -> handle ); // Start conversion
176
176
177
177
// Wait end of conversion and get value
178
+ uint16_t adcValue = 0 ;
178
179
if (HAL_ADC_PollForConversion (& obj -> handle , 10 ) == HAL_OK ) {
179
- return (uint16_t )HAL_ADC_GetValue (& obj -> handle );
180
- } else {
181
- return 0 ;
180
+ adcValue = (uint16_t )HAL_ADC_GetValue (& obj -> handle );
182
181
}
182
+ LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE ((& obj -> handle )-> Instance ), LL_ADC_PATH_INTERNAL_NONE );
183
+ return adcValue ;
183
184
}
184
185
185
186
const PinMap * analogin_pinmap ()
Original file line number Diff line number Diff line change @@ -173,11 +173,12 @@ uint16_t adc_read(analogin_t *obj)
173
173
HAL_ADC_Start (& obj -> handle ); // Start conversion
174
174
175
175
// Wait end of conversion and get value
176
+ uint16_t adcValue = 0 ;
176
177
if (HAL_ADC_PollForConversion (& obj -> handle , 10 ) == HAL_OK ) {
177
- return (uint16_t )HAL_ADC_GetValue (& obj -> handle );
178
- } else {
179
- return 0 ;
178
+ adcValue = (uint16_t )HAL_ADC_GetValue (& obj -> handle );
180
179
}
180
+ LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE ((& obj -> handle )-> Instance ), LL_ADC_PATH_INTERNAL_NONE );
181
+ return adcValue ;
181
182
}
182
183
183
184
const PinMap * analogin_pinmap ()
Original file line number Diff line number Diff line change 43
43
44
44
/* Includes ------------------------------------------------------------------*/
45
45
#include "stm32f1xx_hal_def.h"
46
+
47
+ /* Include low level driver */
48
+ #include "stm32f1xx_ll_adc.h"
49
+
46
50
/** @addtogroup STM32F1xx_HAL_Driver
47
51
* @{
48
52
*/
Original file line number Diff line number Diff line change @@ -180,11 +180,12 @@ uint16_t adc_read(analogin_t *obj)
180
180
HAL_ADC_Start (& obj -> handle ); // Start conversion
181
181
182
182
// Wait end of conversion and get value
183
+ uint16_t adcValue = 0 ;
183
184
if (HAL_ADC_PollForConversion (& obj -> handle , 10 ) == HAL_OK ) {
184
- return (uint16_t )HAL_ADC_GetValue (& obj -> handle );
185
- } else {
186
- return 0 ;
185
+ adcValue = (uint16_t )HAL_ADC_GetValue (& obj -> handle );
187
186
}
187
+ LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE ((& obj -> handle )-> Instance ), LL_ADC_PATH_INTERNAL_NONE );
188
+ return adcValue ;
188
189
}
189
190
190
191
const PinMap * analogin_pinmap ()
Original file line number Diff line number Diff line change 46
46
/* Includes ------------------------------------------------------------------*/
47
47
#include "stm32f2xx_hal_def.h"
48
48
49
+ /* Include low level driver */
50
+ #include "stm32f2xx_ll_adc.h"
51
+
49
52
/** @addtogroup STM32F2xx_HAL_Driver
50
53
* @{
51
54
*/
Original file line number Diff line number Diff line change @@ -227,7 +227,7 @@ uint16_t adc_read(analogin_t *obj)
227
227
} else {
228
228
debug ("HAL_ADC_PollForConversion issue\n" );
229
229
}
230
-
230
+ LL_ADC_SetCommonPathInternalCh ( __LL_ADC_COMMON_INSTANCE (( & obj -> handle ) -> Instance ), LL_ADC_PATH_INTERNAL_NONE );
231
231
if (HAL_ADC_Stop (& obj -> handle ) != HAL_OK ) {
232
232
debug ("HAL_ADC_Stop issue\n" );;
233
233
}
Original file line number Diff line number Diff line change @@ -186,11 +186,12 @@ uint16_t adc_read(analogin_t *obj)
186
186
HAL_ADC_Start (& obj -> handle ); // Start conversion
187
187
188
188
// Wait end of conversion and get value
189
+ uint16_t adcValue = 0 ;
189
190
if (HAL_ADC_PollForConversion (& obj -> handle , 10 ) == HAL_OK ) {
190
- return (uint16_t )HAL_ADC_GetValue (& obj -> handle );
191
- } else {
192
- return 0 ;
191
+ adcValue = (uint16_t )HAL_ADC_GetValue (& obj -> handle );
193
192
}
193
+ LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE ((& obj -> handle )-> Instance ), LL_ADC_PATH_INTERNAL_NONE );
194
+ return adcValue ;
194
195
}
195
196
196
197
const PinMap * analogin_pinmap ()
Original file line number Diff line number Diff line change @@ -186,11 +186,12 @@ uint16_t adc_read(analogin_t *obj)
186
186
HAL_ADC_Start (& obj -> handle ); // Start conversion
187
187
188
188
// Wait end of conversion and get value
189
+ uint16_t adcValue = 0 ;
189
190
if (HAL_ADC_PollForConversion (& obj -> handle , 10 ) == HAL_OK ) {
190
- return (uint16_t )HAL_ADC_GetValue (& obj -> handle );
191
- } else {
192
- return 0 ;
191
+ adcValue = (uint16_t )HAL_ADC_GetValue (& obj -> handle );
193
192
}
193
+ LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE ((& obj -> handle )-> Instance ), LL_ADC_PATH_INTERNAL_NONE );
194
+ return adcValue ;
194
195
}
195
196
196
197
const PinMap * analogin_pinmap ()
Original file line number Diff line number Diff line change @@ -206,11 +206,12 @@ uint16_t adc_read(analogin_t *obj)
206
206
HAL_ADC_Start (& obj -> handle ); // Start conversion
207
207
208
208
// Wait end of conversion and get value
209
+ uint16_t adcValue = 0 ;
209
210
if (HAL_ADC_PollForConversion (& obj -> handle , 10 ) == HAL_OK ) {
210
- return (uint16_t )HAL_ADC_GetValue (& obj -> handle );
211
- } else {
212
- return 0 ;
211
+ adcValue = (uint16_t )HAL_ADC_GetValue (& obj -> handle );
213
212
}
213
+ LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE ((& obj -> handle )-> Instance ), LL_ADC_PATH_INTERNAL_NONE );
214
+ return adcValue ;
214
215
}
215
216
216
217
const PinMap * analogin_pinmap ()
Original file line number Diff line number Diff line change @@ -179,9 +179,8 @@ uint16_t adc_read(analogin_t *obj)
179
179
if (HAL_ADC_PollForConversion (& obj -> handle , 10 ) == HAL_OK ) {
180
180
adcValue = (uint16_t )HAL_ADC_GetValue (& obj -> handle );
181
181
}
182
- sConfig .Rank = ADC_RANK_NONE ;
183
- HAL_ADC_ConfigChannel (& obj -> handle , & sConfig );
184
- return adcValue ;
182
+ LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE ((& obj -> handle )-> Instance ), LL_ADC_PATH_INTERNAL_NONE );
183
+ return adcValue ;
185
184
}
186
185
187
186
const PinMap * analogin_pinmap ()
Original file line number Diff line number Diff line change @@ -226,11 +226,12 @@ uint16_t adc_read(analogin_t *obj)
226
226
HAL_ADC_Start (& obj -> handle ); // Start conversion
227
227
228
228
// Wait end of conversion and get value
229
+ uint16_t adcValue = 0 ;
229
230
if (HAL_ADC_PollForConversion (& obj -> handle , 10 ) == HAL_OK ) {
230
- return (uint16_t )HAL_ADC_GetValue (& obj -> handle );
231
- } else {
232
- return 0 ;
231
+ adcValue = (uint16_t )HAL_ADC_GetValue (& obj -> handle );
233
232
}
233
+ LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE ((& obj -> handle )-> Instance ), LL_ADC_PATH_INTERNAL_NONE );
234
+ return adcValue ;
234
235
}
235
236
236
237
const PinMap * analogin_pinmap ()
Original file line number Diff line number Diff line change @@ -192,18 +192,12 @@ uint16_t adc_read(analogin_t *obj)
192
192
HAL_ADC_Start (& obj -> handle ); // Start conversion
193
193
194
194
// Wait end of conversion and get value
195
+ uint16_t adcValue = 0 ;
195
196
if (HAL_ADC_PollForConversion (& obj -> handle , 10 ) == HAL_OK ) {
196
-
197
- /* Ref Manual: To prevent any unwanted consumption on the battery,
198
- it is recommended to enable the bridge divider only when needed for ADC conversion */
199
- if (sConfig .Channel == ADC_CHANNEL_VBAT ) {
200
- CLEAR_BIT (__LL_ADC_COMMON_INSTANCE (obj -> handle .Instance )-> CCR , LL_ADC_PATH_INTERNAL_VBAT );
201
- }
202
-
203
- return (uint16_t )HAL_ADC_GetValue (& obj -> handle );
204
- } else {
205
- return 0 ;
197
+ adcValue = (uint16_t )HAL_ADC_GetValue (& obj -> handle );
206
198
}
199
+ LL_ADC_SetCommonPathInternalCh (__LL_ADC_COMMON_INSTANCE ((& obj -> handle )-> Instance ), LL_ADC_PATH_INTERNAL_NONE );
200
+ return adcValue ;
207
201
}
208
202
209
203
const PinMap * analogin_pinmap ()
You can’t perform that action at this time.
0 commit comments