File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
cores/arduino/ard_sup/analog Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,7 @@ uint16_t analogRead(uint8_t pinNumber)
174
174
ap3_change_channel (padNumber); // Point ADC channel at this pad
175
175
176
176
// Clear the ADC interrupt.
177
+ am_hal_adc_interrupt_status (g_ADCHandle, &ui32IntMask, false );
177
178
if (AM_HAL_STATUS_SUCCESS != am_hal_adc_interrupt_clear (g_ADCHandle, ui32IntMask))
178
179
{
179
180
// Serial.println("Error clearing ADC interrupt status");
@@ -297,13 +298,6 @@ ap3_err_t ap3_adc_setup()
297
298
return AP3_ERR;
298
299
}
299
300
300
- // Enable the ADC.
301
- if (AM_HAL_STATUS_SUCCESS != am_hal_adc_enable (g_ADCHandle))
302
- {
303
- // Serial.println("Error - enabling ADC failed.\n");
304
- return AP3_ERR;
305
- }
306
-
307
301
return AP3_OK;
308
302
}
309
303
@@ -350,6 +344,11 @@ ap3_err_t ap3_change_channel(uint8_t padNumber)
350
344
ADCSlotConfig.eMeasToAvg = AM_HAL_ADC_SLOT_AVG_1;
351
345
ADCSlotConfig.ePrecisionMode = AM_HAL_ADC_SLOT_14BIT;
352
346
347
+ if (AM_HAL_STATUS_SUCCESS != am_hal_adc_disable (g_ADCHandle))
348
+ {
349
+ return AP3_ERR;
350
+ }
351
+
353
352
// Look up adc channel based on pad number
354
353
uint8_t indi;
355
354
for (indi = 0 ; indi < AP3_ANALOG_CHANNELS; indi++)
@@ -375,6 +374,11 @@ ap3_err_t ap3_change_channel(uint8_t padNumber)
375
374
return AP3_ERR;
376
375
}
377
376
377
+ if (AM_HAL_STATUS_SUCCESS != am_hal_adc_enable (g_ADCHandle))
378
+ {
379
+ return AP3_ERR;
380
+ }
381
+
378
382
return AP3_OK;
379
383
}
380
384
You can’t perform that action at this time.
0 commit comments