Analog data conversion utilities¶
Utility functions for converting analog data samples.
-
int32_t
adc_util_map
(int sample,cc2538/include/periph_cpu.h::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
sample: sampled ADC value res: ADC resolution min: the lower bound of the target interval max: the upper bound of the target interval Return values
- the mapped value
-
float
adc_util_mapf
(int sample,cc2538/include/periph_cpu.h::adc_res_t
res, float min, float max)¶ Map a sampled ADC value to a given range (using floating point arithmetics)
See also
Parameters
sample: sampled ADC value res: ADC resolution min: the lower bound of the target interval max: the upper bound of the target interval Return values
- the mapped value
-
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
value: value to map to a DAC set value min: the lower bound of the source interval max: the upper bound of the source interval Return values
- the mapped value
-
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
Parameters
value: value to map to a DAC set value min: the lower bound of the source interval max: the upper bound of the source interval Return values
- the mapped value