|
Zephyr API Documentation 4.4.0-rc1
A Scalable Open Source RTOS
|
Main header file for ADC (Analog-to-Digital Converter) driver API. More...
#include <zephyr/device.h>#include <zephyr/dt-bindings/adc/adc.h>#include <zephyr/kernel.h>#include <zephyr/rtio/rtio.h>#include <zephyr/dsp/types.h>#include <zephyr/syscalls/adc.h>Go to the source code of this file.
Data Structures | |
| struct | adc_channel_cfg |
| Structure for specifying the configuration of an ADC channel. More... | |
| struct | adc_dt_spec |
| Container for ADC channel information specified in devicetree. More... | |
| struct | adc_sequence_options |
| Structure defining additional options for an ADC sampling sequence. More... | |
| struct | adc_sequence |
| Structure defining an ADC sampling sequence. More... | |
| struct | adc_data_header |
| struct | adc_data |
| Data for the adc channel. More... | |
| struct | adc_data::adc_sample_data |
| struct | adc_stream_trigger |
| struct | adc_chan_spec |
| ADC Channel Specification. More... | |
| struct | adc_read_config |
| struct | adc_decoder_api |
| Decodes a single raw data buffer. More... | |
| struct | adc_driver_api |
| ADC driver API. More... | |
| struct | adc_data_generic_header |
| Generic header for encoded ADC streaming frames. More... | |
Macros | |
| #define | ADC_CHANNEL_CFG_DT(node_id) |
| Get ADC channel configuration from a given devicetree node. | |
| #define | ADC_DT_SPEC_GET_BY_NAME(node_id, name) |
| Get ADC io-channel information from devicetree by name. | |
| #define | ADC_DT_SPEC_GET_BY_NAME_OR(node_id, name, default_value) |
| Like ADC_DT_SPEC_GET_BY_NAME(), with a fallback to a default value. | |
| #define | ADC_DT_SPEC_INST_GET_BY_NAME(inst, name) |
| Get ADC io-channel information from a DT_DRV_COMPAT devicetree instance by name. | |
| #define | ADC_DT_SPEC_INST_GET_BY_NAME_OR(inst, name, default_value) |
| Like ADC_DT_SPEC_INST_GET_BY_NAME(), with a fallback to a default value. | |
| #define | ADC_DT_SPEC_GET_BY_IDX(node_id, idx) |
| Get ADC io-channel information from devicetree. | |
| #define | ADC_DT_SPEC_GET_BY_IDX_OR(node_id, idx, default_value) |
| Like ADC_DT_SPEC_GET_BY_IDX(), with a fallback to a default value. | |
| #define | ADC_DT_SPEC_INST_GET_BY_IDX(inst, idx) |
| Get ADC io-channel information from a DT_DRV_COMPAT devicetree instance. | |
| #define | ADC_DT_SPEC_INST_GET_BY_IDX_OR(inst, idx, default_value) |
| Like ADC_DT_SPEC_INST_GET_BY_IDX(), with a fallback to a default value. | |
| #define | ADC_DT_SPEC_GET(node_id) |
| Equivalent to ADC_DT_SPEC_GET_BY_IDX(node_id, 0). | |
| #define | ADC_DT_SPEC_GET_OR(node_id, default_value) |
| Equivalent to ADC_DT_SPEC_GET_BY_IDX_OR(node_id, 0, default_value). | |
| #define | ADC_DT_SPEC_INST_GET(inst) |
| Equivalent to ADC_DT_SPEC_INST_GET_BY_IDX(inst, 0). | |
| #define | ADC_DT_SPEC_INST_GET_OR(inst, default_value) |
| Equivalent to ADC_DT_SPEC_INST_GET_BY_IDX_OR(inst, 0, default). | |
| #define | ADC_DECODER_NAME() |
| Get the decoder name for the current driver. | |
| #define | ADC_DECODER_DT_GET(node_id) |
| Statically get the decoder for a given node. | |
| #define | ADC_DECODER_API_DT_DEFINE() |
| Define a decoder API. | |
| #define | ADC_DT_STREAM_IODEV(name, dt_node, adc_dt_spec, ...) |
| Define an RTIO IO device for ADC streaming. | |
Typedefs | |
| typedef enum adc_action(* | adc_sequence_callback) (const struct device *dev, const struct adc_sequence *sequence, uint16_t sampling_index) |
| Type definition of the optional callback function to be called after a requested sampling is done. | |
| typedef int(* | adc_api_channel_setup) (const struct device *dev, const struct adc_channel_cfg *channel_cfg) |
| Type definition of ADC API function for configuring a channel. | |
| typedef int(* | adc_api_read) (const struct device *dev, const struct adc_sequence *sequence) |
| Type definition of ADC API function for setting a read request. | |
| typedef void(* | adc_api_submit) (const struct device *dev, struct rtio_iodev_sqe *sqe) |
| Type definition of ADC API function for submitting a stream request. | |
| typedef int(* | adc_api_get_decoder) (const struct device *dev, const struct adc_decoder_api **api) |
| Get the decoder associate with the given device. | |
| typedef int(* | adc_api_read_async) (const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) |
| Type definition of ADC API function for setting an asynchronous read request. | |
| typedef int(* | adc_raw_to_x_fn) (int32_t ref_mv, enum adc_gain gain, uint8_t resolution, int32_t *valp) |
| Conversion from raw ADC units to a specific output unit. | |
Functions | |
| int | adc_gain_invert (enum adc_gain gain, int32_t *value) |
| Invert the application of gain to a measurement value. | |
| int | adc_gain_invert_64 (enum adc_gain gain, int64_t *value) |
| Invert the application of gain to a measurement value. | |
| int | adc_channel_setup (const struct device *dev, const struct adc_channel_cfg *channel_cfg) |
| Configure an ADC channel. | |
| static int | adc_channel_setup_dt (const struct adc_dt_spec *spec) |
| Configure an ADC channel from a struct adc_dt_spec. | |
| int | adc_read (const struct device *dev, const struct adc_sequence *sequence) |
| Set a read request. | |
| static int | adc_read_dt (const struct adc_dt_spec *spec, const struct adc_sequence *sequence) |
| Set a read request from a struct adc_dt_spec. | |
| int | adc_read_async (const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) |
| Set an asynchronous read request. | |
| static int | adc_read_async_dt (const struct adc_dt_spec *spec, const struct adc_sequence *sequence, struct k_poll_signal *async) |
| Set an asynchronous read request from a struct adc_dt_spec. | |
| int | adc_get_decoder (const struct device *dev, const struct adc_decoder_api **api) |
| Get decoder APIs for that device. | |
| static int | adc_stream (struct rtio_iodev *iodev, struct rtio *ctx, void *userdata, struct rtio_sqe **handle) |
| Start a continuous ADC streaming session. | |
| static uint16_t | adc_ref_internal (const struct device *dev) |
| Get the internal reference voltage. | |
| static int | adc_raw_to_millivolts (int32_t ref_mv, enum adc_gain gain, uint8_t resolution, int32_t *valp) |
| Convert a raw ADC value to millivolts. | |
| static int | adc_raw_to_microvolts (int32_t ref_mv, enum adc_gain gain, uint8_t resolution, int32_t *valp) |
| Convert a raw ADC value to microvolts. | |
| static int | adc_raw_to_x_dt_chan (adc_raw_to_x_fn conv_func, const struct adc_dt_spec *spec, const struct adc_channel_cfg *channel_cfg, int32_t *valp) |
| Convert a raw ADC value to an arbitrary output unit. | |
| static int | adc_raw_to_millivolts_dt (const struct adc_dt_spec *spec, int32_t *valp) |
| Convert a raw ADC value to millivolts using information stored in a struct adc_dt_spec. | |
| static int | adc_raw_to_microvolts_dt (const struct adc_dt_spec *spec, int32_t *valp) |
| Convert a raw ADC value to microvolts using information stored in a struct adc_dt_spec. | |
| static int | adc_sequence_init_dt (const struct adc_dt_spec *spec, struct adc_sequence *seq) |
| Initialize a struct adc_sequence from information stored in struct adc_dt_spec. | |
| static bool | adc_is_ready_dt (const struct adc_dt_spec *spec) |
| Validate that the ADC device is ready. | |
| DT_FOREACH_STATUS_OKAY_NODE (Z_MAYBE_ADC_DECODER_DECLARE_INTERNAL) extern const struct rtio_iodev_api __adc_iodev_api | |
Main header file for ADC (Analog-to-Digital Converter) driver API.
| #define ADC_DECODER_API_DT_DEFINE | ( | ) |
Define a decoder API.
This macro should be created once per compatible string of a adc and will create a statically referenceable decoder API.
| #define ADC_DECODER_DT_GET | ( | node_id | ) |
Statically get the decoder for a given node.
| #define ADC_DECODER_NAME | ( | ) |
Get the decoder name for the current driver.
This function depends on DT_DRV_COMPAT being defined.
| #define ADC_DT_STREAM_IODEV | ( | name, | |
| dt_node, | |||
| adc_dt_spec, | |||
| ... ) |
Define an RTIO IO device for ADC streaming.
This macro creates the static data structures needed to stream ADC samples via the RTIO framework. It associates an ADC controller (identified by a Devicetree node), a set of ADC channel specifications, and one or more trigger definitions.
Example usage:
| name | Variable name for the resulting struct rtio_iodev. |
| dt_node | Devicetree node identifier of the ADC controller. |
| adc_dt_spec | Array of adc_dt_spec channel specifications. |
| ... | One or more adc_stream_trigger initializers. |
| DT_FOREACH_STATUS_OKAY_NODE | ( | Z_MAYBE_ADC_DECODER_DECLARE_INTERNAL | ) | const |