Skip to content

daisy::AdcHandle

Module: LIBDAISY / PERIPHERAL / ANALOG

Handler for analog to digital conversion.

#include <adc.h>

Public Types

Name
enum OverSampling

Public Functions

Name
AdcHandle()
~AdcHandle()
void Init(AdcChannelConfig * cfg, size_t num_channels, OverSampling ovs =OVS_32)
void Start()
void Stop()
uint16_t Get(uint8_t chn) const
uint16_t * GetPtr(uint8_t chn) const
float GetFloat(uint8_t chn) const
uint16_t GetMux(uint8_t chn, uint8_t idx) const
uint16_t * GetMuxPtr(uint8_t chn, uint8_t idx) const
float GetMuxFloat(uint8_t chn, uint8_t idx) const

Public Types Documentation

enum OverSampling

Enumerator Value Description
OVS_NONE &
OVS_4 &
OVS_8 &
OVS_16 &
OVS_32 &
OVS_64 &
OVS_128 &
OVS_256 &
OVS_512 &
OVS_1024 &
OVS_LAST &

Supported oversampling amounts

Public Functions Documentation

function AdcHandle

inline AdcHandle()

function ~AdcHandle

inline ~AdcHandle()

function Init

void Init(
    AdcChannelConfig * cfg,
    size_t num_channels,
    OverSampling ovs =OVS_32
)

Parameters:

  • ***cfg** an array of AdcChannelConfig of the desired channel
  • num_channels number of ADC channels to initialize
  • ovs Oversampling amount - Defaults to OVS_32

Initializes the ADC with the pins passed in.


function Start

void Start()

Starts reading from the ADC


function Stop

void Stop()

Stops reading from the ADC


function Get

uint16_t Get(
    uint8_t chn
) const

Parameters:

  • chn channel to get

Return: Converted value

Single channel getter


function GetPtr

uint16_t * GetPtr(
    uint8_t chn
) const

Parameters:

  • chn

Return: Pointer to converted value

Get pointer to a value from a single channel


function GetFloat

float GetFloat(
    uint8_t chn
) const

Parameters:

  • chn Channel to get from

Return: Floating point converted value

Get floating point from single channel


function GetMux

uint16_t GetMux(
    uint8_t chn,
    uint8_t idx
) const

Parameters:

  • chn Channel to get from
  • idx &

Return: data

Getters for multiplexed inputs on a single channel (up to 8 per ADC input).


function GetMuxPtr

uint16_t * GetMuxPtr(
    uint8_t chn,
    uint8_t idx
) const

Parameters:

  • chn Channel to get from
  • idx &

Return: Pointer to data

Getters for multiplexed inputs on a single channel. (Max 8 per chan)


function GetMuxFloat

float GetMuxFloat(
    uint8_t chn,
    uint8_t idx
) const

Parameters:

  • chn Channel to get from
  • idx &

Return: Floating point data

Getters for multiplexed inputs on a single channel (up to 8 per ADC input).

---

Updated on 2024-01-03 at 19:41:01 +0000