Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

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.
 

Detailed Description

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 Documentation

◆ adc_emul_value_func

typedef int(* adc_emul_value_func) (const struct device *dev, unsigned int chan, void *data, uint32_t *result)

#include <zephyr/drivers/adc/adc_emul.h>

Type definition of the function which is used to obtain ADC mV input values.

Parameters
devPointer to the device structure for the driver instance
chanADC channel to sample
dataUser data which was passed on adc_emul_value_func_set
resultThe result value which will be set as input for ADC chan
Returns
0 on success
other as error code which ends ADC context

Function Documentation

◆ adc_emul_const_value_set()

int adc_emul_const_value_set ( const struct device * dev,
unsigned int chan,
uint32_t value )

#include <zephyr/drivers/adc/adc_emul.h>

Set constant mV value input for emulated ADC chan.

Parameters
devThe emulated ADC device
chanThe channel of ADC which input is assigned
valueNew voltage in mV to assign to chan input
Returns
0 on success
-EINVAL if an invalid argument is provided

◆ adc_emul_ref_voltage_set()

int adc_emul_ref_voltage_set ( const struct device * dev,
enum adc_reference ref,
uint16_t value )

#include <zephyr/drivers/adc/adc_emul.h>

Set reference voltage.

Parameters
devThe emulated ADC device
refReference config which is changed
valueNew reference voltage in mV
Returns
0 on success
-EINVAL if an invalid argument is provided

◆ adc_emul_value_func_set()

int adc_emul_value_func_set ( const struct device * dev,
unsigned int chan,
adc_emul_value_func func,
void * data )

#include <zephyr/drivers/adc/adc_emul.h>

Set function used to obtain voltage for input of emulated ADC chan.

Parameters
devThe emulated ADC device
chanThe channel of ADC to which func is assigned
funcNew function to assign to chan
dataPointer to data passed to func on call
Returns
0 on success
-EINVAL if an invalid argument is provided