analog_util.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
21 #ifndef ANALOG_UTIL_H
22 #define ANALOG_UTIL_H
23 
24 #include <stdint.h>
25 
26 #include "periph/adc.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
45 int32_t adc_util_map(int sample, adc_res_t res, int32_t min, int32_t max);
46 
60 float adc_util_mapf(int sample, adc_res_t res, float min, float max);
61 
74 uint16_t dac_util_map(int value, int min, int max);
75 
87 uint16_t dac_util_mapf(float value, float min, float max);
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif /* ANALOG_UTIL_H */
94 
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.
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.
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.
adc_res_t
adc_res_t
Possible ADC resolution settings.
Definition: adc.h:93
adc.h
Low-level ADC peripheral driver interface definitions.
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)