libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
daisy::AdcChannelConfig Struct Reference

Configuration Structure for an ADC Channel. More...

Detailed Description

Configuration Structure for an ADC Channel.

This can be used to configure a a single input, or a multiplexed input, allowing up to 8 inputs on one channel.

Note
Sharing data lines to multiple muxes is possible, but each channel sharing data lines must be set to the maximum number of channels, even if some multiplexers have fewer inputs connected.

#include <adc.h>

Public Types

enum  MuxPin { MUX_SEL_0 , MUX_SEL_1 , MUX_SEL_2 , MUX_SEL_LAST }
 
enum  ConversionSpeed {
  SPEED_1CYCLES_5 , SPEED_2CYCLES_5 , SPEED_8CYCLES_5 , SPEED_16CYCLES_5 ,
  SPEED_32CYCLES_5 , SPEED_64CYCLES_5 , SPEED_387CYCLES_5 , SPEED_810CYCLES_5
}
 per channel conversion speed added to fixed time based on bitdepth, etc. More...
 

Public Member Functions

void InitSingle (dsy_gpio_pin pin, ConversionSpeed speed=SPEED_8CYCLES_5)
 
void InitMux (dsy_gpio_pin adc_pin, size_t mux_channels, dsy_gpio_pin mux_0, dsy_gpio_pin mux_1={DSY_GPIOX, 0}, dsy_gpio_pin mux_2={DSY_GPIOX, 0}, ConversionSpeed speed=SPEED_8CYCLES_5)
 

Public Attributes

dsy_gpio pin_
 
dsy_gpio mux_pin_ [MUX_SEL_LAST]
 
uint8_t mux_channels_
 
ConversionSpeed speed_
 

Member Enumeration Documentation

◆ ConversionSpeed

per channel conversion speed added to fixed time based on bitdepth, etc.

Enumerator
SPEED_1CYCLES_5 
SPEED_2CYCLES_5 
SPEED_8CYCLES_5 
SPEED_16CYCLES_5 
SPEED_32CYCLES_5 
SPEED_64CYCLES_5 
SPEED_387CYCLES_5 
SPEED_810CYCLES_5 

◆ MuxPin

Which pin to use for multiplexing

Enumerator
MUX_SEL_0 

&

MUX_SEL_1 

&

MUX_SEL_2 

&

MUX_SEL_LAST 

&

Member Function Documentation

◆ InitMux()

void daisy::AdcChannelConfig::InitMux ( dsy_gpio_pin  adc_pin,
size_t  mux_channels,
dsy_gpio_pin  mux_0,
dsy_gpio_pin  mux_1 = {DSY_GPIOX, 0},
dsy_gpio_pin  mux_2 = {DSY_GPIOX, 0},
ConversionSpeed  speed = SPEED_8CYCLES_5 
)

Initializes a single ADC pin as a Multiplexed ADC. Requires a CD405X Multiplexer connected to the pin. You only need to supply the mux pins that are required, e.g. a 4052 mux would only require mux_0 and mux_1. Internal Callbacks handle the pin addressing.

Parameters
adc_pin&
mux_channelsmust be 1-8
mux_0First mux pin
mux_1Second mux pin
mux_2Third mux pin
speedconversion speed for this pin defaults to 8.5 cycles

◆ InitSingle()

void daisy::AdcChannelConfig::InitSingle ( dsy_gpio_pin  pin,
ConversionSpeed  speed = SPEED_8CYCLES_5 
)

Initializes a single ADC pin as an ADC.

Parameters
pinPin to init.
speedconversion speed for this pin defaults to 8.5 cycles

Member Data Documentation

◆ mux_channels_

uint8_t daisy::AdcChannelConfig::mux_channels_

&

◆ mux_pin_

dsy_gpio daisy::AdcChannelConfig::mux_pin_[MUX_SEL_LAST]

&

◆ pin_

dsy_gpio daisy::AdcChannelConfig::pin_

&

◆ speed_

ConversionSpeed daisy::AdcChannelConfig::speed_

The documentation for this struct was generated from the following file: