libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
adc.h
Go to the documentation of this file.
1#pragma once
2#ifndef DSY_ADC_H
3#define DSY_ADC_H
4#include <stdint.h>
5#include <stdlib.h>
6#include "daisy_core.h"
7#include "per/gpio.h"
8
9#define DSY_ADC_MAX_CHANNELS 16
11namespace daisy
12{
17/* While there may not be many configuration options here,
18using a struct like this allows us to add more configuration
19later without breaking existing functionality.
20*/
21
86
91{
92 public:
108
117 void
118 Init(AdcChannelConfig *cfg, size_t num_channels, OverSampling ovs = OVS_32);
119
121 void Start();
122
124 void Stop();
125
131 uint16_t Get(uint8_t chn) const;
132
139
145 float GetFloat(uint8_t chn) const;
146
154
162
169 float GetMuxFloat(uint8_t chn, uint8_t idx) const;
170
171 private:
172 OverSampling oversampling_;
173 size_t num_channels_;
174};
175
177} // namespace daisy
178
179#endif // DSY_ADC_H
Handler for analog to digital conversion.
Definition adc.h:91
uint16_t * GetMuxPtr(uint8_t chn, uint8_t idx) const
float GetMuxFloat(uint8_t chn, uint8_t idx) const
~AdcHandle()
Definition adc.h:110
AdcHandle()
Definition adc.h:109
float GetFloat(uint8_t chn) const
void Init(AdcChannelConfig *cfg, size_t num_channels, OverSampling ovs=OVS_32)
uint16_t GetMux(uint8_t chn, uint8_t idx) const
OverSampling
Definition adc.h:95
@ OVS_512
Definition adc.h:104
@ OVS_32
Definition adc.h:100
@ OVS_16
Definition adc.h:99
@ OVS_4
Definition adc.h:97
@ OVS_1024
Definition adc.h:105
@ OVS_128
Definition adc.h:102
@ OVS_LAST
Definition adc.h:106
@ OVS_256
Definition adc.h:103
@ OVS_64
Definition adc.h:101
@ OVS_NONE
Definition adc.h:96
@ OVS_8
Definition adc.h:98
uint16_t Get(uint8_t chn) const
uint16_t * GetPtr(uint8_t chn) const
General Purpose I/O control.
Definition gpio.h:22
Definition leddriver.h:33
Hardware defines and helpers for daisy field platform.
Definition index.h:2
@ PORTX
Definition daisy_core.h:188
Configuration Structure for an ADC Channel.
Definition adc.h:32
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)
GPIO pin_
Definition adc.h:81
GPIO mux_pin_[MUX_SEL_LAST]
Definition adc.h:82
void InitSingle(Pin pin, ConversionSpeed speed=SPEED_8CYCLES_5)
ConversionSpeed speed_
Definition adc.h:84
uint8_t mux_channels_
Definition adc.h:83
ConversionSpeed
per channel conversion speed added to fixed time based on bitdepth, etc.
Definition adc.h:44
@ SPEED_1CYCLES_5
Definition adc.h:45
@ SPEED_2CYCLES_5
Definition adc.h:46
@ SPEED_8CYCLES_5
Definition adc.h:47
@ SPEED_387CYCLES_5
Definition adc.h:51
@ SPEED_32CYCLES_5
Definition adc.h:49
@ SPEED_16CYCLES_5
Definition adc.h:48
@ SPEED_810CYCLES_5
Definition adc.h:52
@ SPEED_64CYCLES_5
Definition adc.h:50
MuxPin
Definition adc.h:35
@ MUX_SEL_LAST
Definition adc.h:39
@ MUX_SEL_1
Definition adc.h:37
@ MUX_SEL_0
Definition adc.h:36
@ MUX_SEL_2
Definition adc.h:38
representation of hardware port/pin combination
Definition daisy_core.h:193