Squashed 'third_party/pico-sdk/' content from commit 2062372d2

Change-Id: Ic20f199d3ed0ea8d3a6a1bbf513f875ec7500cc6
git-subtree-dir: third_party/pico-sdk
git-subtree-split: 2062372d203b372849d573f252cf7c6dc2800c0a
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/src/rp2_common/hardware_adc/adc.c b/src/rp2_common/hardware_adc/adc.c
new file mode 100644
index 0000000..9058de0
--- /dev/null
+++ b/src/rp2_common/hardware_adc/adc.c
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "pico.h"
+#include "hardware/adc.h"
+#include "hardware/resets.h"
+
+void adc_init(void) {
+    // ADC is in an unknown state. We should start by resetting it
+    reset_block(RESETS_RESET_ADC_BITS);
+    unreset_block_wait(RESETS_RESET_ADC_BITS);
+
+    // Now turn it back on. Staging of clock etc is handled internally
+    adc_hw->cs = ADC_CS_EN_BITS;
+
+    // Internal staging completes in a few cycles, but poll to be sure
+    while (!(adc_hw->cs & ADC_CS_READY_BITS)) {
+        tight_loop_contents();
+    }
+}