Zephyr API Documentation 4.4.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
dac.h File Reference

Main header file for DAC (Digital-to-Analog Converter) driver API. More...

#include <zephyr/device.h>
#include <zephyr/syscalls/dac.h>

Go to the source code of this file.

Data Structures

struct  dac_channel_cfg
 Structure for specifying the configuration of a DAC channel. More...
struct  dac_dt_spec
 Container for DAC channel information specified in devicetree. More...

Macros

#define DAC_CHANNEL_BROADCAST   0xFF
 Broadcast channel identifier for DACs that support it.
#define DAC_CHANNEL_CFG_DT(node_id)
 Get DAC channel configuration from a given devicetree node.
#define DAC_DT_SPEC_GET_BY_NAME(node_id, name)
 Get DAC io-channel information from devicetree by name.
#define DAC_DT_SPEC_GET_BY_NAME_OR(node_id, name, default_value)
 Like DAC_DT_SPEC_GET_BY_NAME(), with a fallback to a default value.
#define DAC_DT_SPEC_INST_GET_BY_NAME(inst, name)
 Get DAC io-channel information from a DT_DRV_COMPAT devicetree instance by name.
#define DAC_DT_SPEC_INST_GET_BY_NAME_OR(inst, name, default_value)
 Like DAC_DT_SPEC_INST_GET_BY_NAME(), with a fallback to a default value.
#define DAC_DT_SPEC_GET_BY_IDX(node_id, idx)
 Get DAC io-channel information from devicetree.
#define DAC_DT_SPEC_GET_BY_IDX_OR(node_id, idx, default_value)
 Like DAC_DT_SPEC_GET_BY_IDX(), with a fallback to a default value.
#define DAC_DT_SPEC_INST_GET_BY_IDX(inst, idx)
 Get DAC io-channel information from a DT_DRV_COMPAT devicetree instance.
#define DAC_DT_SPEC_INST_GET_BY_IDX_OR(inst, idx, default_value)
 Like DAC_DT_SPEC_INST_GET_BY_IDX(), with a fallback to a default value.
#define DAC_DT_SPEC_GET(node_id)
 Equivalent to DAC_DT_SPEC_GET_BY_IDX(node_id, 0).
#define DAC_DT_SPEC_GET_OR(node_id, default_value)
 Equivalent to DAC_DT_SPEC_GET_BY_IDX_OR(node_id, 0, default_value).
#define DAC_DT_SPEC_INST_GET(inst)
 Equivalent to DAC_DT_SPEC_INST_GET_BY_IDX(inst, 0).
#define DAC_DT_SPEC_INST_GET_OR(inst, default_value)
 Equivalent to DAC_DT_SPEC_INST_GET_BY_IDX_OR(inst, 0, default).

Typedefs

typedef int(* dac_x_to_raw_fn) (uint32_t ref_mv, uint8_t resolution, uint32_t *valp)
 Conversion from specified input units to raw DAC units.

Functions

int dac_channel_setup (const struct device *dev, const struct dac_channel_cfg *channel_cfg)
 Configure a DAC channel.
static int dac_channel_setup_dt (const struct dac_dt_spec *spec)
 Configure an DAC channel from a struct dac_dt_spec.
int dac_write_value (const struct device *dev, uint8_t channel, uint32_t value)
 Write a single value to a DAC channel.
static int dac_write_value_dt (const struct dac_dt_spec *spec, uint32_t value)
 Write a single value to a DAC channel from a struct dac_dt_spec.
static int dac_millivolts_to_raw (uint32_t ref_mv, uint8_t resolution, uint32_t *valp)
 Convert a millivolts value to a raw DAC value.
static int dac_microvolts_to_raw (uint32_t ref_mv, uint8_t resolution, uint32_t *valp)
 Convert a raw DAC value to microvolts.
static int dac_x_to_raw_dt_chan (dac_x_to_raw_fn conv_func, const struct dac_dt_spec *spec, uint32_t *valp)
 Convert a raw DAC value to an arbitrary output unit.
static int dac_millivolts_to_raw_dt (const struct dac_dt_spec *spec, uint32_t *valp)
 Convert a millivolts value to raw DAC using information stored in a struct dac_dt_spec.
static int dac_microvolts_to_raw_dt (const struct dac_dt_spec *spec, uint32_t *valp)
 Convert a microvolts value to raw DAC value using information stored in a struct dac_dt_spec.
static bool dac_is_ready_dt (const struct dac_dt_spec *spec)
 Validate that the DAC device is ready.

Detailed Description

Main header file for DAC (Digital-to-Analog Converter) driver API.