ADC¶
Overview¶
API Reference¶
-
group
adc_interface
ADC driver APIs.
Defines
-
ADC_ACQ_TIME_MICROSECONDS
¶ Acquisition time is expressed in microseconds.
-
ADC_ACQ_TIME_NANOSECONDS
¶ Acquisition time is expressed in nanoseconds.
-
ADC_ACQ_TIME_TICKS
¶ Acquisition time is expressed in ADC ticks.
-
ADC_ACQ_TIME
(unit, value)¶ Macro for composing the acquisition time value in given units.
-
ADC_ACQ_TIME_DEFAULT
¶ Value indicating that the default acquisition time should be used.
-
ADC_ACQ_TIME_UNIT
(time)¶
-
ADC_ACQ_TIME_VALUE
(time)¶
Typedefs
-
typedef enum adc_action (*
adc_sequence_callback
)(struct device *dev, const struct adc_sequence *sequence, u16_t sampling_index)¶ Type definition of the optional callback function to be called after a requested sampling is done.
- Return
- Action to be performed by the driver. See adc_action.
- Parameters
dev
: Pointer to the device structure for the driver instance.sequence
: Pointer to the sequence structure that triggered the sampling.sampling_index
: Index (0-65535) of the sampling done.
-
typedef int (*
adc_api_channel_setup
)(struct device *dev, const struct adc_channel_cfg *channel_cfg)¶ Type definition of ADC API function for configuring a channel. See adc_channel_setup() for argument descriptions.
-
typedef int (*
adc_api_read
)(struct device *dev, const struct adc_sequence *sequence)¶ Type definition of ADC API function for setting a read request. See adc_read() for argument descriptions.
Enums
-
enum
adc_gain
¶ ADC channel gain factors.
Values:
-
ADC_GAIN_1_6
¶ x 1/6.
-
ADC_GAIN_1_5
¶ x 1/5.
-
ADC_GAIN_1_4
¶ x 1/4.
-
ADC_GAIN_1_3
¶ x 1/3.
-
ADC_GAIN_1_2
¶ x 1/2.
-
ADC_GAIN_2_3
¶ x 2/3.
-
ADC_GAIN_1
¶ x 1.
-
ADC_GAIN_2
¶ x 2.
-
ADC_GAIN_3
¶ x 3.
-
ADC_GAIN_4
¶ x 4.
-
ADC_GAIN_8
¶ x 8.
-
ADC_GAIN_16
¶ x 16.
-
ADC_GAIN_32
¶ x 32.
-
ADC_GAIN_64
¶ x 64.
-
-
enum
adc_reference
¶ ADC references.
Values:
-
ADC_REF_VDD_1
¶ VDD.
-
ADC_REF_VDD_1_2
¶ VDD/2.
-
ADC_REF_VDD_1_3
¶ VDD/3.
-
ADC_REF_VDD_1_4
¶ VDD/4.
-
ADC_REF_INTERNAL
¶ Internal.
-
ADC_REF_EXTERNAL0
¶ External, input 0.
-
ADC_REF_EXTERNAL1
¶ External, input 1.
-
-
enum
adc_action
¶ Action to be performed after a sampling is done.
Values:
-
ADC_ACTION_CONTINUE
= 0¶ The sequence should be continued normally.
-
ADC_ACTION_REPEAT
¶ The sampling should be repeated. New samples or sample should be read from the ADC and written in the same place as the recent ones.
-
ADC_ACTION_FINISH
¶ The sequence should be finished immediately.
-
Functions
-
int
adc_channel_setup
(struct device *dev, const struct adc_channel_cfg *channel_cfg)¶ Configure an ADC channel.
It is required to call this function and configure each channel before it is selected for a read request.
- Parameters
dev
: Pointer to the device structure for the driver instance.channel_cfg
: Channel configuration.
- Return Value
0
: On success.-EINVAL
: If a parameter with an invalid value has been provided.
-
static int
z_impl_adc_channel_setup
(struct device *dev, const struct adc_channel_cfg *channel_cfg)¶
-
int
adc_read
(struct device *dev, const struct adc_sequence *sequence)¶ Set a read request.
If invoked from user mode, any sequence struct options for callback must be NULL.
- Parameters
dev
: Pointer to the device structure for the driver instance.sequence
: Structure specifying requested sequence of samplings.
- Return Value
0
: On success.-EINVAL
: If a parameter with an invalid value has been provided.-ENOMEM
: If the provided buffer is to small to hold the results of all requested samplings.-ENOTSUP
: If the requested mode of operation is not supported.-EBUSY
: If another sampling was triggered while the previous one was still in progress. This may occur only when samplings are done with intervals, and it indicates that the selected interval was too small. All requested samples are written in the buffer, but at least some of them were taken with an extra delay compared to what was scheduled.
-
static int
z_impl_adc_read
(struct device *dev, const struct adc_sequence *sequence)¶
-
struct
adc_channel_cfg
¶ - #include <adc.h>
Structure for specifying the configuration of an ADC channel.
-
struct
adc_sequence_options
¶ - #include <adc.h>
Structure defining additional options for an ADC sampling sequence.
-
struct
adc_sequence
¶ - #include <adc.h>
Structure defining an ADC sampling sequence.
-
struct
adc_driver_api
¶ - #include <adc.h>
ADC driver API.
This is the mandatory API any ADC driver needs to expose.
-