1 /* 2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include "pico.h" 8 #include "hardware/adc.h" 9 #include "hardware/resets.h" 10 adc_init(void)11void adc_init(void) { 12 // ADC is in an unknown state. We should start by resetting it 13 reset_unreset_block_num_wait_blocking(RESET_ADC); 14 15 // Now turn it back on. Staging of clock etc is handled internally 16 adc_hw->cs = ADC_CS_EN_BITS; 17 18 // Internal staging completes in a few cycles, but poll to be sure 19 while (!(adc_hw->cs & ADC_CS_READY_BITS)) { 20 tight_loop_contents(); 21 } 22 } 23