File tree 1 file changed +28
-0
lines changed
cores/arduino/ard_sup/analog
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,34 @@ uint16_t analogRead(uint8_t pinNumber)
202
202
}
203
203
}
204
204
205
+ // Power down ADC. Comes from adc_lpmode2.c example from Ambiq SDK
206
+ bool power_adc_disable ()
207
+ {
208
+ // Disable the ADC.
209
+ if (AM_HAL_STATUS_SUCCESS != am_hal_adc_disable (g_ADCHandle))
210
+ {
211
+ // am_util_stdio_printf("Error - disable ADC failed.\n");
212
+ return (false );
213
+ }
214
+
215
+ // Enable the ADC power domain.
216
+ if (AM_HAL_STATUS_SUCCESS != am_hal_pwrctrl_periph_disable (AM_HAL_PWRCTRL_PERIPH_ADC))
217
+ {
218
+ // am_util_stdio_printf("Error - disabling the ADC power domain failed.\n");
219
+ return (false );
220
+ }
221
+
222
+ // Deinitialize the ADC
223
+ if (AM_HAL_STATUS_SUCCESS != am_hal_adc_deinitialize (g_ADCHandle))
224
+ {
225
+ // am_util_stdio_printf("Error - return of the ADC instance failed.\n");
226
+ return (false );
227
+ }
228
+
229
+ g_ADCHandle = NULL ;
230
+ return (true );
231
+ }
232
+
205
233
// Apollo3 is capapble of 14-bit ADC but Arduino defaults to 10-bit
206
234
// This modifies the global var that controls what is returned from analogRead()
207
235
void analogReadResolution (uint8_t bits)
You can’t perform that action at this time.
0 commit comments