Loading...
Searching...
No Matches
Analog data conversion utilities

Utility functions for converting analog data samples. More...

Detailed Description

Utility functions for converting analog data samples.

Files

file  analog_util.h
 Analog utility function interfaces.
 

Functions

int32_t adc_util_map (int sample, adc_res_t res, int32_t min, int32_t max)
 Map a sampled ADC value to a given range.
 
float adc_util_mapf (int sample, adc_res_t res, float min, float max)
 Map a sampled ADC value to a given range (using floating point arithmetic)
 
uint16_t dac_util_map (int value, int min, int max)
 Map a value out of the given range to a 16-bit unsigned int.
 
uint16_t dac_util_mapf (float value, float min, float max)
 Helper function to map a given float value range to a valid DAC value.
 

Function Documentation

◆ adc_util_map()

int32_t adc_util_map ( int  sample,
adc_res_t  res,
int32_t  min,
int32_t  max 
)

Map a sampled ADC value to a given range.

This function is useful for converting sampled ADC values into their physical representation.

Parameters
[in]samplesampled ADC value
[in]resADC resolution
[in]minthe lower bound of the target interval
[in]maxthe upper bound of the target interval
Returns
the mapped value

◆ adc_util_mapf()

float adc_util_mapf ( int  sample,
adc_res_t  res,
float  min,
float  max 
)

Map a sampled ADC value to a given range (using floating point arithmetic)

See also
adc_util_map
Parameters
[in]samplesampled ADC value
[in]resADC resolution
[in]minthe lower bound of the target interval
[in]maxthe upper bound of the target interval
Returns
the mapped value

◆ dac_util_map()

uint16_t dac_util_map ( int  value,
int  min,
int  max 
)

Map a value out of the given range to a 16-bit unsigned int.

The min value is assumed to be smaller than max value and value is assumed to be between min and max.

Parameters
[in]valuevalue to map to a DAC set value
[in]minthe lower bound of the source interval
[in]maxthe upper bound of the source interval
Returns
the mapped value

◆ dac_util_mapf()

uint16_t dac_util_mapf ( float  value,
float  min,
float  max 
)

Helper function to map a given float value range to a valid DAC value.

See also
dac_util_map
Parameters
[in]valuevalue to map to a DAC set value
[in]minthe lower bound of the source interval
[in]maxthe upper bound of the source interval
Returns
the mapped value