Configuration Structure for an ADC Channel. More...
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.
#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 (Pin pin, ConversionSpeed speed=SPEED_8CYCLES_5) |
void | InitMux (Pin adc_pin, size_t mux_channels, Pin mux_0, Pin mux_1=Pin(PORTX, 0), Pin mux_2=Pin(PORTX, 0), ConversionSpeed speed=SPEED_8CYCLES_5) |
Public Attributes | |
GPIO | pin_ |
GPIO | mux_pin_ [MUX_SEL_LAST] |
uint8_t | mux_channels_ |
ConversionSpeed | speed_ |
void daisy::AdcChannelConfig::InitMux | ( | Pin | adc_pin, |
size_t | mux_channels, | ||
Pin | mux_0, | ||
Pin | mux_1 = Pin(PORTX, 0) , |
||
Pin | mux_2 = Pin(PORTX, 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.
adc_pin | & |
mux_channels | must be 1-8 |
mux_0 | First mux pin |
mux_1 | Second mux pin |
mux_2 | Third mux pin |
speed | conversion speed for this pin defaults to 8.5 cycles |
void daisy::AdcChannelConfig::InitSingle | ( | Pin | pin, |
ConversionSpeed | speed = SPEED_8CYCLES_5 |
||
) |
Initializes a single ADC pin as an ADC.
pin | Pin to init. |
speed | conversion speed for this pin defaults to 8.5 cycles |
uint8_t daisy::AdcChannelConfig::mux_channels_ |
&
GPIO daisy::AdcChannelConfig::mux_pin_[MUX_SEL_LAST] |
&
GPIO daisy::AdcChannelConfig::pin_ |
&
ConversionSpeed daisy::AdcChannelConfig::speed_ |