Zephyr Project API 4.0.0
A Scalable Open Source RTOS
|
Emulated ADC backend API. More...
Typedefs | |
typedef int(* | adc_emul_value_func) (const struct device *dev, unsigned int chan, void *data, uint32_t *result) |
Type definition of the function which is used to obtain ADC mV input values. | |
Functions | |
int | adc_emul_const_value_set (const struct device *dev, unsigned int chan, uint32_t value) |
Set constant mV value input for emulated ADC chan . | |
int | adc_emul_value_func_set (const struct device *dev, unsigned int chan, adc_emul_value_func func, void *data) |
Set function used to obtain voltage for input of emulated ADC chan . | |
int | adc_emul_ref_voltage_set (const struct device *dev, enum adc_reference ref, uint16_t value) |
Set reference voltage. | |
Emulated ADC backend API.
Behaviour of emulated ADC is application-defined. As-such, each application may
An example of an appropriate Device Tree overlay file is in tests/drivers/adc/adc_api/boards/native_sim.overlay
An example of using emulated ADC backend API is in the file tests/drivers/adc/adc_emul/src/main.c
typedef int(* adc_emul_value_func) (const struct device *dev, unsigned int chan, void *data, uint32_t *result) |
#include <include/zephyr/drivers/adc/adc_emul.h>
Type definition of the function which is used to obtain ADC mV input values.
dev | Pointer to the device structure for the driver instance |
chan | ADC channel to sample |
data | User data which was passed on adc_emul_value_func_set |
result | The result value which will be set as input for ADC chan |
#include <include/zephyr/drivers/adc/adc_emul.h>
Set constant mV value input for emulated ADC chan
.
dev | The emulated ADC device |
chan | The channel of ADC which input is assigned |
value | New voltage in mV to assign to chan input |
int adc_emul_ref_voltage_set | ( | const struct device * | dev, |
enum adc_reference | ref, | ||
uint16_t | value | ||
) |
#include <include/zephyr/drivers/adc/adc_emul.h>
Set reference voltage.
dev | The emulated ADC device |
ref | Reference config which is changed |
value | New reference voltage in mV |
int adc_emul_value_func_set | ( | const struct device * | dev, |
unsigned int | chan, | ||
adc_emul_value_func | func, | ||
void * | data | ||
) |
#include <include/zephyr/drivers/adc/adc_emul.h>
Set function used to obtain voltage for input of emulated ADC chan
.
dev | The emulated ADC device |
chan | The channel of ADC to which func is assigned |
func | New function to assign to chan |
data | Pointer to data passed to func on call |