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)
174174 ap3_change_channel (padNumber); // Point ADC channel at this pad
175175
176176 // Clear the ADC interrupt.
177+ am_hal_adc_interrupt_status (g_ADCHandle, &ui32IntMask, false );
177178 if (AM_HAL_STATUS_SUCCESS != am_hal_adc_interrupt_clear (g_ADCHandle, ui32IntMask))
178179 {
179180 // Serial.println("Error clearing ADC interrupt status");
@@ -297,13 +298,6 @@ ap3_err_t ap3_adc_setup()
297298 return AP3_ERR;
298299 }
299300
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-
307301 return AP3_OK;
308302}
309303
@@ -350,6 +344,11 @@ ap3_err_t ap3_change_channel(uint8_t padNumber)
350344 ADCSlotConfig.eMeasToAvg = AM_HAL_ADC_SLOT_AVG_1;
351345 ADCSlotConfig.ePrecisionMode = AM_HAL_ADC_SLOT_14BIT;
352346
347+ if (AM_HAL_STATUS_SUCCESS != am_hal_adc_disable (g_ADCHandle))
348+ {
349+ return AP3_ERR;
350+ }
351+
353352 // Look up adc channel based on pad number
354353 uint8_t indi;
355354 for (indi = 0 ; indi < AP3_ANALOG_CHANNELS; indi++)
@@ -375,6 +374,11 @@ ap3_err_t ap3_change_channel(uint8_t padNumber)
375374 return AP3_ERR;
376375 }
377376
377+ if (AM_HAL_STATUS_SUCCESS != am_hal_adc_enable (g_ADCHandle))
378+ {
379+ return AP3_ERR;
380+ }
381+
378382 return AP3_OK;
379383}
380384
You can’t perform that action at this time.
0 commit comments