Interface for A/D Converters.
Summary
The ADC interface provides standard ADC functionality including one-shot mode (single scan), continuous scan and group scan. It also allows configuration of hardware and software triggers for starting scans. After each conversion an interrupt can be triggered, and if a callback function is provided, the call back is invoked with the appropriate event information.
◆ adc_status_t
◆ adc_callback_args_t
struct adc_callback_args_t |
ADC callback arguments definitions
Data Fields |
uint16_t |
unit |
ADC device in use. |
adc_event_t |
event |
ADC callback event. |
void const * |
p_context |
Placeholder for user data. |
adc_channel_t |
channel |
Channel of conversion result. |
uint64_t |
channel_mask |
Channel mask for conversion result. Only valid for r_adc_b and r_sdadc_b. |
adc_group_mask_t |
group_mask |
Group Mask. |
◆ adc_info_t
ADC Information Structure for Transfer Interface
Data Fields |
__I void * |
p_address |
The address to start reading the data from. |
uint32_t |
length |
The total number of transfers to read. |
transfer_size_t |
transfer_size |
The size of each transfer. |
elc_peripheral_t |
elc_peripheral |
Name of the peripheral in the ELC list. |
elc_event_t |
elc_event |
Name of the ELC event for the peripheral. |
uint32_t |
calibration_data |
Temperature sensor calibration data (0xFFFFFFFF if unsupported) for reference voltage. |
int16_t |
slope_microvolts |
Temperature sensor slope in microvolts/degrees C. |
bool |
calibration_ongoing |
Calibration is in progress. |
volatile const void * |
p_address |
The address to start reading the data from. |
uint32_t |
calibration_data1 |
Temperature sensor calibration data1. |
uint32_t |
calibration_data2 |
Temperature sensor calibration data2. |
◆ adc_cfg_t
ADC general configuration
◆ adc_api_t
ADC functions implemented at the HAL layer will follow this API.
Data Fields |
fsp_err_t(* | open )(adc_ctrl_t *const p_ctrl, adc_cfg_t const *const p_cfg) |
|
fsp_err_t(* | scanCfg )(adc_ctrl_t *const p_ctrl, void const *const p_extend) |
|
fsp_err_t(* | scanStart )(adc_ctrl_t *const p_ctrl) |
|
fsp_err_t(* | scanGroupStart )(adc_ctrl_t *p_ctrl, adc_group_mask_t group_mask) |
|
fsp_err_t(* | scanStop )(adc_ctrl_t *const p_ctrl) |
|
fsp_err_t(* | scanStatusGet )(adc_ctrl_t *const p_ctrl, adc_status_t *p_status) |
|
fsp_err_t(* | read )(adc_ctrl_t *const p_ctrl, adc_channel_t const reg_id, uint16_t *const p_data) |
|
fsp_err_t(* | read32 )(adc_ctrl_t *const p_ctrl, adc_channel_t const reg_id, uint32_t *const p_data) |
|
fsp_err_t(* | calibrate )(adc_ctrl_t *const p_ctrl, void const *p_extend) |
|
fsp_err_t(* | offsetSet )(adc_ctrl_t *const p_ctrl, adc_channel_t const reg_id, int32_t const offset) |
|
fsp_err_t(* | callbackSet )(adc_ctrl_t *const p_ctrl, void(*p_callback)(adc_callback_args_t *), void const *const p_context, adc_callback_args_t *const p_callback_memory) |
|
fsp_err_t(* | close )(adc_ctrl_t *const p_ctrl) |
|
fsp_err_t(* | infoGet )(adc_ctrl_t *const p_ctrl, adc_info_t *const p_adc_info) |
|
◆ open
Initialize ADC Unit; apply power, set the operational mode, trigger sources, interrupt priority, and configurations common to all channels and sensors.
- Precondition
- Configure peripheral clocks, ADC pins and IRQs prior to calling this function.
- Parameters
-
[in] | p_ctrl | Pointer to control handle structure |
[in] | p_cfg | Pointer to configuration structure |
◆ scanCfg
Configure the scan including the channels, groups, and scan triggers to be used for the unit that was initialized in the open call. Some configurations are not supported for all implementations. See implementation for details.
- Parameters
-
[in] | p_ctrl | Pointer to control handle structure |
[in] | p_extend | See implementation for details |
◆ scanStart
Start the scan (in case of a software trigger), or enable the hardware trigger.
- Parameters
-
[in] | p_ctrl | Pointer to control handle structure |
◆ scanGroupStart
Start the scan group (in case of a software trigger), or enable the hardware trigger.
- Parameters
-
[in] | p_ctrl | Pointer to control handle structure |
[in] | group_mask | Mask of groups to start |
◆ scanStop
Stop the ADC scan (in case of a software trigger), or disable the hardware trigger.
- Parameters
-
[in] | p_ctrl | Pointer to control handle structure |
◆ scanStatusGet
Check scan status.
- Parameters
-
[in] | p_ctrl | Pointer to control handle structure |
[out] | p_status | Pointer to store current status in |
◆ read
Read ADC conversion result.
- Parameters
-
[in] | p_ctrl | Pointer to control handle structure |
[in] | reg_id | ADC channel to read (see enumeration adc_channel_t) |
[in] | p_data | Pointer to variable to load value into. |
◆ read32
Read ADC conversion result into a 32-bit word.
- Parameters
-
[in] | p_ctrl | Pointer to control handle structure |
[in] | reg_id | ADC channel to read (see enumeration adc_channel_t) |
[in] | p_data | Pointer to variable to load value into. |
◆ calibrate
Calibrate ADC or associated PGA (programmable gain amplifier). The driver may require implementation specific arguments to the p_extend input. Not supported for all implementations. See implementation for details.
- Parameters
-
[in] | p_ctrl | Pointer to control handle structure |
[in] | p_extend | Pointer to implementation specific arguments |
◆ offsetSet
Set offset for input PGA configured for differential input. Not supported for all implementations. See implementation for details.
- Parameters
-
[in] | p_ctrl | Pointer to control handle structure |
[in] | reg_id | ADC channel to read (see enumeration adc_channel_t) |
[in] | offset | See implementation for details. |
◆ callbackSet
Specify callback function and optional context pointer and working memory pointer.
- Parameters
-
[in] | p_ctrl | Pointer to the ADC control block. |
[in] | p_callback | Callback function |
[in] | p_context | Pointer to send to callback function |
[in] | p_working_memory | Pointer to volatile memory where callback structure can be allocated. Callback arguments allocated here are only valid during the callback. |
◆ close
Close the specified ADC unit by ending any scan in progress, disabling interrupts, and removing power to the specified A/D unit.
- Parameters
-
[in] | p_ctrl | Pointer to control handle structure |
◆ infoGet
Return the ADC data register address of the first (lowest number) channel and the total number of bytes to be read in order for the DTC/DMAC to read the conversion results of all configured channels. Return the temperature sensor calibration and slope data.
- Parameters
-
[in] | p_ctrl | Pointer to control handle structure |
[out] | p_adc_info | Pointer to ADC information structure |
◆ adc_instance_t
This structure encompasses everything that is needed to use an instance of this interface.
Data Fields |
adc_ctrl_t * |
p_ctrl |
Pointer to the control structure for this instance. |
adc_cfg_t const * |
p_cfg |
Pointer to the configuration structure for this instance. |
void const * |
p_channel_cfg |
Pointer to the channel configuration structure for this instance. |
adc_api_t const * |
p_api |
Pointer to the API structure for this instance. |
◆ adc_ctrl_t
ADC control block. Allocate using driver instance control structure from driver instance header file.
◆ adc_mode_t
ADC operation mode definitions
Enumerator |
---|
ADC_MODE_SINGLE_SCAN | Single scan - one or more channels.
|
ADC_MODE_GROUP_SCAN | Two trigger sources to trigger scan for two groups which contain one or more channels.
|
ADC_MODE_CONTINUOUS_SCAN | Continuous scan - one or more channels.
|
◆ adc_resolution_t
ADC data resolution definitions
Enumerator |
---|
ADC_RESOLUTION_12_BIT | 12 bit resolution
|
ADC_RESOLUTION_10_BIT | 10 bit resolution
|
ADC_RESOLUTION_8_BIT | 8 bit resolution
|
ADC_RESOLUTION_14_BIT | 14 bit resolution
|
ADC_RESOLUTION_16_BIT | 16 bit resolution
|
ADC_RESOLUTION_24_BIT | 24 bit resolution
|
◆ adc_alignment_t
ADC data alignment definitions
Enumerator |
---|
ADC_ALIGNMENT_RIGHT | Data alignment right.
|
ADC_ALIGNMENT_LEFT | Data alignment left.
|
◆ adc_trigger_t
ADC trigger mode definitions
Enumerator |
---|
ADC_TRIGGER_SOFTWARE | Software trigger; not for group modes.
|
ADC_TRIGGER_SYNC_ELC | Synchronous trigger via ELC.
|
ADC_TRIGGER_ASYNC_EXTERNAL | External asynchronous trigger; not for group modes.
|
◆ adc_event_t
ADC callback event definitions
Enumerator |
---|
ADC_EVENT_SCAN_COMPLETE | Normal/Group A scan complete.
|
ADC_EVENT_SCAN_COMPLETE_GROUP_B | Group B scan complete.
|
ADC_EVENT_SCAN_COMPLETE_GROUP_C | Group C scan complete.
|
ADC_EVENT_CALIBRATION_COMPLETE | Calibration complete.
|
ADC_EVENT_CONVERSION_COMPLETE | Conversion complete.
|
ADC_EVENT_CALIBRATION_REQUEST | Calibration requested.
|
ADC_EVENT_CONVERSION_ERROR | Scan error.
|
ADC_EVENT_OVERFLOW | Overflow occurred.
|
ADC_EVENT_LIMIT_CLIP | Limiter clipping occurred.
|
ADC_EVENT_FIFO_READ_REQUEST | FIFO read requested.
|
ADC_EVENT_FIFO_OVERFLOW | FIFO overflow occurred.
|
ADC_EVENT_WINDOW_COMPARE_A | Window A comparison condition met.
|
ADC_EVENT_WINDOW_COMPARE_B | Window B comparison condition met.
|
ADC_EVENT_ZERO_CROSS_DETECTION | Zero-cross detection interrupt.
|
◆ adc_channel_t
ADC channels
Enumerator |
---|
ADC_CHANNEL_0 | ADC channel 0.
|
ADC_CHANNEL_1 | ADC channel 1.
|
ADC_CHANNEL_2 | ADC channel 2.
|
ADC_CHANNEL_3 | ADC channel 3.
|
ADC_CHANNEL_4 | ADC channel 4.
|
ADC_CHANNEL_5 | ADC channel 5.
|
ADC_CHANNEL_6 | ADC channel 6.
|
ADC_CHANNEL_7 | ADC channel 7.
|
ADC_CHANNEL_8 | ADC channel 8.
|
ADC_CHANNEL_9 | ADC channel 9.
|
ADC_CHANNEL_10 | ADC channel 10.
|
ADC_CHANNEL_11 | ADC channel 11.
|
ADC_CHANNEL_12 | ADC channel 12.
|
ADC_CHANNEL_13 | ADC channel 13.
|
ADC_CHANNEL_14 | ADC channel 14.
|
ADC_CHANNEL_15 | ADC channel 15.
|
ADC_CHANNEL_16 | ADC channel 16.
|
ADC_CHANNEL_17 | ADC channel 17.
|
ADC_CHANNEL_18 | ADC channel 18.
|
ADC_CHANNEL_19 | ADC channel 19.
|
ADC_CHANNEL_20 | ADC channel 20.
|
ADC_CHANNEL_21 | ADC channel 21.
|
ADC_CHANNEL_22 | ADC channel 22.
|
ADC_CHANNEL_23 | ADC channel 23.
|
ADC_CHANNEL_24 | ADC channel 24.
|
ADC_CHANNEL_25 | ADC channel 25.
|
ADC_CHANNEL_26 | ADC channel 26.
|
ADC_CHANNEL_27 | ADC channel 27.
|
ADC_CHANNEL_28 | ADC channel 28.
|
ADC_CHANNEL_DUPLEX_A | Data duplexing register A.
|
ADC_CHANNEL_DUPLEX_B | Data duplexing register B.
|
ADC_CHANNEL_DUPLEX | Data duplexing register.
|
ADC_CHANNEL_TEMPERATURE | Temperature sensor output.
|
ADC_CHANNEL_VOLT | Internal reference voltage.
|
◆ adc_group_id_t
Enumerator |
---|
ADC_GROUP_ID_0 | Group ID 0.
|
ADC_GROUP_ID_1 | Group ID 1.
|
ADC_GROUP_ID_2 | Group ID 2.
|
ADC_GROUP_ID_3 | Group ID 3.
|
ADC_GROUP_ID_4 | Group ID 4.
|
ADC_GROUP_ID_5 | Group ID 5.
|
ADC_GROUP_ID_6 | Group ID 6.
|
ADC_GROUP_ID_7 | Group ID 7.
|
ADC_GROUP_ID_8 | Group ID 8.
|
◆ adc_group_mask_t
Enumerator |
---|
ADC_GROUP_MASK_NONE | Group Mask Unknown or None.
|
ADC_GROUP_MASK_0 | Group Mask 0.
|
ADC_GROUP_MASK_1 | Group Mask 1.
|
ADC_GROUP_MASK_2 | Group Mask 2.
|
ADC_GROUP_MASK_3 | Group Mask 3.
|
ADC_GROUP_MASK_4 | Group Mask 4.
|
ADC_GROUP_MASK_5 | Group Mask 5.
|
ADC_GROUP_MASK_6 | Group Mask 6.
|
ADC_GROUP_MASK_7 | Group Mask 7.
|
ADC_GROUP_MASK_8 | Group Mask 8.
|
ADC_GROUP_MASK_ALL | All Groups.
|
◆ adc_state_t
ADC states.
Enumerator |
---|
ADC_STATE_IDLE | ADC is idle.
|
ADC_STATE_SCAN_IN_PROGRESS | ADC scan in progress.
|
ADC_STATE_CALIBRATION_IN_PROGRESS | ADC calibration in progress - Not used by all ADC instances.
|