analog_util.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2015 Freie Universität Berlin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
20 #include <stdint.h>
21 
22 #include "periph/adc.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
41 int32_t adc_util_map(int sample, adc_res_t res, int32_t min, int32_t max);
42 
56 float adc_util_mapf(int sample, adc_res_t res, float min, float max);
57 
70 uint16_t dac_util_map(int value, int min, int max);
71 
83 uint16_t dac_util_mapf(float value, float min, float max);
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
Low-level ADC peripheral driver interface definitions.
adc_res_t
Possible ADC resolution settings.
Definition: adc.h:92
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.
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.
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.