Utility functions for converting analog data samples.
More...
Utility functions for converting analog data samples.
|
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. More...
|
|
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) More...
|
|
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. More...
|
|
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. More...
|
|
◆ 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] | sample | sampled ADC value |
[in] | res | ADC resolution |
[in] | min | the lower bound of the target interval |
[in] | max | the 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] | sample | sampled ADC value |
[in] | res | ADC resolution |
[in] | min | the lower bound of the target interval |
[in] | max | the 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] | value | value to map to a DAC set value |
[in] | min | the lower bound of the source interval |
[in] | max | the 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] | value | value to map to a DAC set value |
[in] | min | the lower bound of the source interval |
[in] | max | the upper bound of the source interval |
- Returns
- the mapped value