adc.h File Reference
#include "pico.h"
#include "hardware/structs/adc.h"
#include "hardware/gpio.h"
Include dependency graph for adc.h:

Go to the source code of this file.

Macros

#define PARAM_ASSERTIONS_ENABLED_ADC   0
 

Functions

void adc_init (void)
 Initialise the ADC HW.
 
static void adc_gpio_init (uint gpio)
 Initialise the gpio for use as an ADC pinPrepare a GPIO for use with ADC by disabling all digital functions. More...
 
static void adc_select_input (uint input)
 ADC input selectSelect an ADC input. 0...3 are GPIOs 26...29 respectively. Input 4 is the onboard temperature sensor. More...
 
static uint adc_get_selected_input (void)
 Get the currently selected ADC input channel. More...
 
static void adc_set_round_robin (uint input_mask)
 Round Robin sampling selectorThis function sets which inputs are to be run through in round robin mode. Value between 0 and 0x1f (bit 0 to bit 4 for GPIO 26 to 29 and temperature sensor input respectively) More...
 
static void adc_set_temp_sensor_enabled (bool enable)
 Enable the onboard temperature sensor. More...
 
static uint16_t adc_read (void)
 Perform a single conversionPerforms an ADC conversion, waits for the result, and then returns it. More...
 
static void adc_run (bool run)
 Enable or disable free-running sampling mode. More...
 
static void adc_set_clkdiv (float clkdiv)
 Set the ADC Clock divisorPeriod of samples will be (1 + div) cycles on average. Note it takes 96 cycles to perform a conversion, so any period less than that will be clamped to 96. More...
 
static void adc_fifo_setup (bool en, bool dreq_en, uint16_t dreq_thresh, bool err_in_fifo, bool byte_shift)
 Setup the ADC FIFOFIFO is 4 samples long, if a conversion is completed and the FIFO is full, the result is dropped. More...
 
static bool adc_fifo_is_empty (void)
 Check FIFO empty state. More...
 
static uint8_t adc_fifo_get_level (void)
 Get number of entries in the ADC FIFOThe ADC FIFO is 4 entries long. This function will return how many samples are currently present.
 
static uint16_t adc_fifo_get (void)
 Get ADC result from FIFOPops the latest result from the ADC FIFO.
 
static uint16_t adc_fifo_get_blocking (void)
 Wait for the ADC FIFO to have data.Blocks until data is present in the FIFO.
 
static void adc_fifo_drain (void)
 Drain the ADC FIFOWill wait for any conversion to complete then drain the FIFO, discarding any results.
 
static void adc_irq_set_enabled (bool enabled)
 Enable/Disable ADC interrupts. More...