The MCUXpresso SDK provides a peripheral driver for the 12-bit 5MSPS Analog-to-Digital Converter (HSADC) module of MCUXpresso SDK devices.
This section describes the programming interface of the HSADC Peripheral driver. The HSADC driver configures the HSADC module.
The HSADC consists of two separate analog-to-digital converters, each with eight analog inputs and its own sample and hold circuit. A common digital control module configures and controls the functioning of the converters.
To match the hardware feature, the HSADC driver is designed with 4 parts: APIs for configuring common digital control module, APIs for configuring each converter, APIs for operating sample slots, and APIs for calibration.
The common digital control configuration is set when initializing the HSADC module in the application and deciding how the two converters work together. The converter configuration APIs set each converter's attributes and operate them. Finally, the sample slot API configures the sample slot with the input channel and gather them to be a conversion sequence. After triggering (using a software trigger or an external hardware trigger), the sequence is started and the conversion is executed.
Function groups
Initialization and deinitialization
This function group initializes/de-initializes the HSADC. The initialization should be done first before any operation to the HSADC module in the application. It enables the clock and sets the configuration for the common digital control. An API is provided to fill the configuration with available default settings.
Each converter
This function group configures each of the two converters in the HSADC module.
Each sample
This function group is for the operations to sample slot.
Calibration
This function group calibrates to get more accurate result.
Typical use case
Triggered parallel
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/hsadc
|
| enum | _hsadc_status_flags {
kHSADC_ZeroCrossingFlag = (1U << 0U),
kHSADC_HighLimitFlag = (1U << 1U),
kHSADC_LowLimitFlag = (1U << 2U),
kHSADC_ConverterAEndOfScanFlag = (1U << 3U),
kHSADC_ConverterBEndOfScanFlag = (1U << 4U),
kHSADC_ConverterAEndOfCalibrationFlag = (1U << 5U),
kHSADC_ConverterBEndOfCalibrationFlag = (1U << 6U),
kHSADC_ConverterAConvertingFlag = (1U << 7U),
kHSADC_ConverterBConvertingFlag = (1U << 8U),
kHSADC_ConverterADummyConvertingFlag = (1U << 9U),
kHSADC_ConverterBDummyConvertingFlag = (1U << 10U),
kHSADC_ConverterACalibratingFlag = (1U << 11U),
kHSADC_ConverterBCalibratingFlag = (1U << 12U),
kHSADC_ConverterAPowerDownFlag = (1U << 13U),
kHSADC_ConverterBPowerDownFlag = (1U << 14U)
} |
| | HSADC status flags. More...
|
| |
| enum | _hsadc_interrupt_enable {
kHSADC_ZeroCrossingInterruptEnable = (1U << 0U),
kHSADC_HighLimitInterruptEnable = (1U << 1U),
kHSADC_LowLimitInterruptEnable = (1U << 2U),
kHSADC_ConverterAEndOfScanInterruptEnable = (1U << 3U),
kHSADC_ConverterBEndOfScanInterruptEnable = (1U << 4U),
kHSADC_ConverterAEndOfCalibrationInterruptEnable = (1U << 5U),
kHSADC_ConverterBEndOfCalibrationInterruptEnable = (1U << 6U)
} |
| | HSADC Interrupts. More...
|
| |
| enum | _hsadc_converter_id {
kHSADC_ConverterA = (1U << 0U),
kHSADC_ConverterB = (1U << 1U)
} |
| | HSADC Converter identifier. More...
|
| |
| enum | hsadc_dual_converter_scan_mode_t {
kHSADC_DualConverterWorkAsOnceSequential = 0U,
kHSADC_DualConverterWorkAsOnceParallel = 1U,
kHSADC_DualConverterWorkAsLoopSequential = 2U,
kHSADC_DualConverterWorkAsLoopParallel = 3U,
kHSADC_DualConverterWorkAsTriggeredSequential = 4U,
kHSADC_DualConverterWorkAsTriggeredParallel = 5U
} |
| | Defines the enumeration for dual converter scan mode. More...
|
| |
| enum | hsadc_resolution_t {
kHSADC_Resolution6Bit = 0U,
kHSADC_Resolution8Bit = 1U,
kHSADC_Resolution10Bit = 2U,
kHSADC_Resolution12Bit = 3U
} |
| | Defines the enumeration for the hsadc resolution. More...
|
| |
| enum | hsadc_dma_trigger_source_t {
kHSADC_DMATriggerSourceAsEndOfScan = 0U,
kHSADC_DMATriggerSourceAsSampleReady = 1U
} |
| | Defines the enumeration for the DMA trigger source. More...
|
| |
| enum | hsadc_zero_crossing_mode_t {
kHSADC_ZeroCorssingDisabled = 0U,
kHSADC_ZeroCorssingForPtoNSign = 1U,
kHSADC_ZeroCorssingForNtoPSign = 2U,
kHSADC_ZeroCorssingForAnySignChanged = 3U
} |
| | Defines the enumeration for the sample slot's zero crossing event. More...
|
| |
| enum | hsadc_idle_work_mode_t {
kHSADC_IdleKeepNormal = 0U,
kHSADC_IdleAutoStandby = 1U,
kHSADC_IdleAutoPowerDown = 2U
} |
| | Defines the enumeration for the converter's work mode in idle mode. More...
|
| |
| enum | _hsadc_calibration_mode {
kHSADC_CalibrationModeDifferential = (1U << 0U),
kHSADC_CalibrationModeSingleEnded = (1U << 1U)
} |
| | Converter's calibration mode. More...
|
| |
|
| void | HSADC_SetConverterConfig (HSADC_Type *base, uint16_t converterMask, const hsadc_converter_config_t *config) |
| | Configures the converter. More...
|
| |
| void | HSADC_GetDefaultConverterConfig (hsadc_converter_config_t *config) |
| | Gets an available pre-defined settings for each converter's configuration. More...
|
| |
| void | HSADC_EnableConverter (HSADC_Type *base, uint16_t converterMask, bool enable) |
| | Enables the converter's conversion. More...
|
| |
| void | HSADC_EnableConverterSyncInput (HSADC_Type *base, uint16_t converterMask, bool enable) |
| | Enables the input of an external sync signal. More...
|
| |
| void | HSADC_EnableConverterPower (HSADC_Type *base, uint16_t converterMask, bool enable) |
| | Enables power for the converter. More...
|
| |
| void | HSADC_DoSoftwareTriggerConverter (HSADC_Type *base, uint16_t converterMask) |
| | Triggers the converter by using the software trigger. More...
|
| |
| void | HSADC_EnableConverterDMA (HSADC_Type *base, uint16_t converterMask, bool enable) |
| | Enables the DMA feature. More...
|
| |
| void | HSADC_EnableInterrupts (HSADC_Type *base, uint16_t mask) |
| | Enables the interrupts. More...
|
| |
| void | HSADC_DisableInterrupts (HSADC_Type *base, uint16_t mask) |
| | Disables the interrupts. More...
|
| |
| uint16_t | HSADC_GetStatusFlags (HSADC_Type *base) |
| | Gets the status flags. More...
|
| |
| void | HSADC_ClearStatusFlags (HSADC_Type *base, uint16_t mask) |
| | Clears the status flags. More...
|
| |
|
| void | HSADC_SetSampleConfig (HSADC_Type *base, uint16_t sampleIndex, const hsadc_sample_config_t *config) |
| | Configures the sample slot. More...
|
| |
| void | HSADC_GetDefaultSampleConfig (hsadc_sample_config_t *config) |
| | Gets the default sample configuration. More...
|
| |
| static void | HSADC_EnableSample (HSADC_Type *base, uint16_t sampleMask, bool enable) |
| | Enables the sample slot. More...
|
| |
| static void | HSADC_EnableSampleResultReadyInterrupts (HSADC_Type *base, uint16_t sampleMask, bool enable) |
| | Enables the interrupt for each sample slot when its result is ready. More...
|
| |
| static uint16_t | HSADC_GetSampleReadyStatusFlags (HSADC_Type *base) |
| | Returns the sample ready flags of sample slots. More...
|
| |
| static uint16_t | HSADC_GetSampleLowLimitStatusFlags (HSADC_Type *base) |
| | Gets the low-limit flags of sample slots. More...
|
| |
| static void | HSADC_ClearSampleLowLimitStatusFlags (HSADC_Type *base, uint16_t sampleMask) |
| | Clears low-limit flags of sample slots. More...
|
| |
| static uint16_t | HSADC_GetSampleHighLimitStatusFlags (HSADC_Type *base) |
| | Gets the high-limit flags of sample slots. More...
|
| |
| static void | HSADC_ClearSampleHighLimitStatusFlags (HSADC_Type *base, uint16_t sampleMask) |
| | Clears high-limit flags of sample slots. More...
|
| |
| static uint16_t | HSADC_GetSampleZeroCrossingStatusFlags (HSADC_Type *base) |
| | Gets the zero crossing flags of sample slots. More...
|
| |
| static void | HSADC_ClearSampleZeroCrossingStatusFlags (HSADC_Type *base, uint16_t sampleMask) |
| | Clears zero crossing flags of sample slots. More...
|
| |
| static uint16_t | HSADC_GetSampleResultValue (HSADC_Type *base, uint16_t sampleIndex) |
| | Gets the sample result value. More...
|
| |
| bool hsadc_config_t::enableSimultaneousMode |
| uint16_t hsadc_config_t::powerUpDelayCount |
| struct hsadc_converter_config_t |
| uint16_t hsadc_converter_config_t::clockDivisor |
| uint16_t hsadc_converter_config_t::samplingTimeCount |
The resultant sampling time is (1.5 + samplingTimeCount) x clock period. Available range is 0-255.
| uint16_t hsadc_converter_config_t::powerUpCalibrationModeMask |
See the "_hsadc_calibration_mode". If this field isn't zero, call the function HSADC_GetStatusFlags() to check whether the End of Calibration flag is set to wait for sthe calibration process to complete. If this is zero, it indicates no calibration is executed in power up period.
| struct hsadc_sample_config_t |
channelNumber, channel67MuxNumber, and enableDifferentialPair have following relationship: channelNumber equals 0~7 represents channel 0~7 of converter A. channelNumber equals 8~15 represents channel 0~7 of converter B. 1) When channelNumber = 6 and enableDifferentialPair = false, channel67MuxNumber represents converter A's channel 6's sub multiplex channel number. 2) When channelNumber = 6 and enableDifferentialPair = true, channel67MuxNumber represents converter A's channel 6 and channel 7's sub multiplex channel number. 3) When channelNumber = 7 and enableDifferentialPair = false, channel67MuxNumber represents converter A's channel 7's sub multiplex channel number. 4) When channelNumber = 7 and enableDifferentialPair = true, channel67MuxNumber represents converter A's channel 6 and channel 7's sub multiplex channel number. 5) When channelNumber = 14 and enableDifferentialPair = false, channel67MuxNumber represents converter B's channel 6's sub multiplex channel number. 6) When channelNumber = 14 and enableDifferentialPair = true, channel67MuxNumber represents converter B's channel 6 and channel 7's sub multiplex channel number. 7) When channelNumber = 15 and enableDifferentialPair = false, channel67MuxNumber represents converter B's channel 7's sub multiplex channel number. 8) When channelNumber = 15 and enableDifferentialPair = true, channel67MuxNumber represents converter B's channel 6 and channel 7's sub multiplex channel number. 9) In other cases, channel67MuxNumber won't be functional.
| uint16_t hsadc_sample_config_t::channelNumber |
| uint16_t hsadc_sample_config_t::channel67MuxNumber |
When channelNumber = 6 or 14, its available range is 0~6. When channelNumber = 7 or 15, its available range is 0~5.
| bool hsadc_sample_config_t::enableDifferentialPair |
In differential mode, the sub multiplex channel number of channel 6 and channel 7 must be configured to be same.
| uint16_t hsadc_sample_config_t::highLimitValue |
Original value format as hardware register, with 3-bits left shifted.
| uint16_t hsadc_sample_config_t::lowLimitValue |
Original value format as hardware register, with 3-bits left shifted.
| uint16_t hsadc_sample_config_t::offsetValue |
Original value format as hardware register, with 3-bits left shifted.
| bool hsadc_sample_config_t::enableWaitSync |
| #define HSADC_SAMPLE_MASK |
( |
|
index | ) |
(1U << (index)) |
| #define HSADC_CALIBRATION_VALUE_A_SINGLE_ENDED_MASK HSADC_CALVAL_A_CALVSING_MASK |
| #define HSADC_CALIBRATION_VALUE_A_SINGLE_ENDED_SHIFT HSADC_CALVAL_A_CALVSING_SHIFT |
| #define HSADC_CALIBRATION_VALUE_A_DIFFERENTIAL_MASK HSADC_CALVAL_A_CALVDIF_MASK |
| #define HSADC_CALIBRATION_VALUE_A_DIFFERENTIAL_SHIFT HSADC_CALVAL_A_CALVDIF_SHIFT |
| #define HSADC_CALIBRATION_VALUE_B_SINGLE_ENDED_MASK (HSADC_CALVAL_B_CALVSING_MASK << 16U) |
| #define HSADC_CALIBRATION_VALUE_B_SINGLE_ENDED_SHIFT (HSADC_CALVAL_B_CALVSING_SHIFT + 16U) |
| #define HSADC_CALIBRATION_VALUE_B_DIFFERENTIAL_MASK (HSADC_CALVAL_B_CALVDIF_MASK << 16U) |
| #define HSADC_CALIBRATION_VALUE_B_DIFFERENTIAL_SHIFT (HSADC_CALVAL_B_CALVDIF_SHIFT + 16U) |
| Enumerator |
|---|
| kHSADC_ZeroCrossingFlag |
Zero crossing.
|
| kHSADC_HighLimitFlag |
High-limit.
|
| kHSADC_LowLimitFlag |
Low-limit.
|
| kHSADC_ConverterAEndOfScanFlag |
End of Scan, converter A.
|
| kHSADC_ConverterBEndOfScanFlag |
End of Scan, converter B.
|
| kHSADC_ConverterAEndOfCalibrationFlag |
End of Calibration, converter A.
|
| kHSADC_ConverterBEndOfCalibrationFlag |
End of Calibration, converter B.
|
| kHSADC_ConverterAConvertingFlag |
Conversion in progress, converter A.
|
| kHSADC_ConverterBConvertingFlag |
Conversion in progress, converter B.
|
| kHSADC_ConverterADummyConvertingFlag |
Dummy conversion in progress, converter A.
|
| kHSADC_ConverterBDummyConvertingFlag |
Dummy conversion in progress, converter B.
|
| kHSADC_ConverterACalibratingFlag |
Calibration in progress, converter A.
|
| kHSADC_ConverterBCalibratingFlag |
Calibration in progress, converter B.
|
| kHSADC_ConverterAPowerDownFlag |
The converter is powered down, converter A.
|
| kHSADC_ConverterBPowerDownFlag |
The converter is powered down, converter B.
|
| Enumerator |
|---|
| kHSADC_ZeroCrossingInterruptEnable |
Zero crossing interrupt.
|
| kHSADC_HighLimitInterruptEnable |
High-limit interrupt.
|
| kHSADC_LowLimitInterruptEnable |
Low-limit interrupt.
|
| kHSADC_ConverterAEndOfScanInterruptEnable |
End of Scan interrupt, converter A.
|
| kHSADC_ConverterBEndOfScanInterruptEnable |
End of Scan interrupt, converter B.
|
| kHSADC_ConverterAEndOfCalibrationInterruptEnable |
End of Calibration, converter A.
|
| kHSADC_ConverterBEndOfCalibrationInterruptEnable |
End of Calibration, converter B.
|
| Enumerator |
|---|
| kHSADC_ConverterA |
Converter A.
|
| kHSADC_ConverterB |
Converter B.
|
| Enumerator |
|---|
| kHSADC_DualConverterWorkAsOnceSequential |
Once (single) sequential.
|
| kHSADC_DualConverterWorkAsOnceParallel |
Once parallel.
|
| kHSADC_DualConverterWorkAsLoopSequential |
Loop sequential.
|
| kHSADC_DualConverterWorkAsLoopParallel |
Loop parallel.
|
| kHSADC_DualConverterWorkAsTriggeredSequential |
Triggered sequential.
|
| kHSADC_DualConverterWorkAsTriggeredParallel |
Triggered parallel.
|
| Enumerator |
|---|
| kHSADC_Resolution6Bit |
6 bit resolution mode.
|
| kHSADC_Resolution8Bit |
8 bit resolution mode.
|
| kHSADC_Resolution10Bit |
10 bit resolution mode.
|
| kHSADC_Resolution12Bit |
12 bit resolution mode.
|
| Enumerator |
|---|
| kHSADC_DMATriggerSourceAsEndOfScan |
DMA trigger source is end of scan interrupt.
|
| kHSADC_DMATriggerSourceAsSampleReady |
DMA trigger source is RDY bits.
|
| Enumerator |
|---|
| kHSADC_ZeroCorssingDisabled |
Zero Crossing disabled.
|
| kHSADC_ZeroCorssingForPtoNSign |
Zero Crossing enabled for positive to negative sign change.
|
| kHSADC_ZeroCorssingForNtoPSign |
Zero Crossing enabled for negative to positive sign change.
|
| kHSADC_ZeroCorssingForAnySignChanged |
Zero Crossing enabled for any sign change.
|
| Enumerator |
|---|
| kHSADC_IdleKeepNormal |
Keep normal.
|
| kHSADC_IdleAutoStandby |
Fall into standby mode automatically.
|
| kHSADC_IdleAutoPowerDown |
Fall into power down mode automatically.
|
| Enumerator |
|---|
| kHSADC_CalibrationModeDifferential |
Calibration request for differential mode.
|
| kHSADC_CalibrationModeSingleEnded |
Calibration request for single ended mode.
|
This function initializes the HSADC module. The operations are:
- Enable the clock for HSADC.
- Set the global settings for HSADC converter.
- Parameters
-
| base | HSADC peripheral base address. |
| config | Pointer to configuration structure. See the "hsadc_config_t". |
This function initializes the module's configuration structure with an available settings. The default value are:
* config->enableSimultaneousMode = true;
* config->powerUpDelay = 18U;
*
- Parameters
-
| config | Pointer to configuration structure. See the "hsadc_config_t" |
| void HSADC_Deinit |
( |
HSADC_Type * |
base | ) |
|
This function de-initializes the HSADC module. The operations are:
- Power down both converters.
- Disable the clock for HSADC.
- Parameters
-
| base | HSADC peripheral base address. |
- Parameters
-
| base | HSADC peripheral base address. |
| converterMask | Mask for converters to be configured. See the "_hsadc_converter_id". |
| config | Pointer to configuration structure. See the "hsadc_converter_config_t". |
This function initializes each converter's configuration structure with available settings. The default value are:
* config->clockDivisor = 4U;
* config->samplingTimeCount = 0U;
* config->enablePowerUpCalibration = false;
*
- Parameters
-
| config | Pointer to configuration structure. See the "hsadc_converter_config_t" |
| void HSADC_EnableConverter |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
converterMask, |
|
|
bool |
enable |
|
) |
| |
This function enables the converter's conversion by making the converter exit stop mode. The conversion should only be launched after the converter is enabled. When this feature is asserted to be "false", the current scan is stopped and no further scans can start. All the software and hardware triggers are ignored.
- Parameters
-
| base | HSADC peripheral base address. |
| converterMask | Mask for converters to be operated. See the "_hsadc_converter_id". |
| enable | Enable or disable the feature. |
| void HSADC_EnableConverterSyncInput |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
converterMask, |
|
|
bool |
enable |
|
) |
| |
This function enables the input of the external sync signal. The external sync signal could be used to trigger the conversion if the hardware trigger-related setting is used. Note: When in "Once" scan mode, this gate is off automatically after an available sync is received. Enable the input again manually if another sync signal is needed.
- Parameters
-
| base | HSADC peripheral base address. |
| converterMask | Mask for converters to be operated. See the "_hsadc_converter_id". |
| enable | Enable or disable the feature. |
| void HSADC_EnableConverterPower |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
converterMask, |
|
|
bool |
enable |
|
) |
| |
This function enables the power for the converter. The converter should be powered on before conversion. Once this API is called, the converter is powered on after a few moments (so-called power up delay) to make the power stable.
- Parameters
-
| base | HSADC peripheral base address. |
| converterMask | Mask for converters to be operated. See the "_hsadc_converter_id". |
| enable | Enable or disable the feature. |
| void HSADC_DoSoftwareTriggerConverter |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
converterMask |
|
) |
| |
This function triggers the converter using a software trigger. The software trigger can be used to start a conversion sequence.
- Parameters
-
| base | HSADC peripheral base address. |
| converterMask | Mask for converters to be operated. See the "_hsadc_converter_id". |
| void HSADC_EnableConverterDMA |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
converterMask, |
|
|
bool |
enable |
|
) |
| |
- Parameters
-
| base | HSADC peripheral base address. |
| converterMask | Mask for converters to be operated. See the "_hsadc_converter_id". |
| enable | Enable or disable the feature. |
| void HSADC_EnableInterrupts |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
mask |
|
) |
| |
- Parameters
-
| base | HSADC peripheral base address. |
| mask | Mask value for interrupt events. See the "_hsadc_interrupt_enable". |
| void HSADC_DisableInterrupts |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
mask |
|
) |
| |
- Parameters
-
| base | HSADC peripheral base address. |
| mask | Mask value for interrupt events. See the "_hsadc_interrupt_enable". |
| uint16_t HSADC_GetStatusFlags |
( |
HSADC_Type * |
base | ) |
|
- Parameters
-
| base | HSADC peripheral base address. |
- Returns
- Mask value for the event flags. See the "_hsadc_status_flags".
| void HSADC_ClearStatusFlags |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
mask |
|
) |
| |
- Parameters
-
| base | HSADC peripheral base address. |
| mask | Mask value for the event flags to be cleared. See the "_hsadc_status_flags". |
| void HSADC_SetSampleConfig |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
sampleIndex, |
|
|
const hsadc_sample_config_t * |
config |
|
) |
| |
A sample list in this module works like a conversion sequence. Each sample slot can be used to designate to sample which channel is in converter A and converter B. The detail mapping relationship between sample slot and converter's channel can be found in the SoC reference manual.
- Parameters
-
| base | HSADC peripheral base address. |
| sampleIndex | Index of sample slot in conversion sequence. Available range is 0-15. |
| config | Pointer to configuration structure. See the "hsadc_sample_config_t". |
This function initializes each sample's configuration structure with an available settings. The default values are:
* config->channelNumber = 0U;
* config->channel6MuxNumber = 0U;
* config->channel7MuxNumber = 0U;
* config->enableDifferentialPair = false;
* config->highLimitValue = 0x7FF8U;
* config->lowLimitValue = 0U;
* config->offsetValue = 0U;
* config->enableWaitSync = false;
*
- Parameters
-
| config | Pointer to configuration structure. See the "hsadc_sample_config_t". |
| static void HSADC_EnableSample |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
sampleMask, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
This function enables the sample slot. Only the enabled sample slot can join the conversion sequence.
- Parameters
-
| base | HSADC peripheral base address. |
| sampleMask | Mask value of sample slots in conversion sequence. Each bit corresponds to a sample slot. |
| enable | Enable or disable the feature. |
| static void HSADC_EnableSampleResultReadyInterrupts |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
sampleMask, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
| base | HSADC peripheral base address. |
| sampleMask | Mask value of sample slots in conversion sequence. Each bit is corresponding to a sample slot. |
| enable | Enable or disable the feature. |
| static uint16_t HSADC_GetSampleReadyStatusFlags |
( |
HSADC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
| base | HSADC peripheral base address. |
- Returns
- Mask value for the sample slots if their result are ready.
| static uint16_t HSADC_GetSampleLowLimitStatusFlags |
( |
HSADC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
| base | HSADC peripheral base address. |
- Returns
- Mask value for the sample slots if their results exceed the low limit.
| static void HSADC_ClearSampleLowLimitStatusFlags |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
sampleMask |
|
) |
| |
|
inlinestatic |
- Parameters
-
| base | HSADC peripheral base address. |
| sampleMask | Mask value for the sample slots' flags to be cleared. |
| static uint16_t HSADC_GetSampleHighLimitStatusFlags |
( |
HSADC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
| base | HSADC peripheral base address. |
- Returns
- Mask value for the sample slots if their results exceed the high limit.
| static void HSADC_ClearSampleHighLimitStatusFlags |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
sampleMask |
|
) |
| |
|
inlinestatic |
- Parameters
-
| base | HSADC peripheral base address. |
| sampleMask | Mask value for the sample slots to be cleared flags. |
| static uint16_t HSADC_GetSampleZeroCrossingStatusFlags |
( |
HSADC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
| base | HSADC peripheral base address. |
- Returns
- Mask value for the sample slots if their results cause the zero crossing event.
| static void HSADC_ClearSampleZeroCrossingStatusFlags |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
sampleMask |
|
) |
| |
|
inlinestatic |
- Parameters
-
| base | HSADC peripheral base address. |
| sampleMask | Mask value for the sample slots to be cleared flags. |
| static uint16_t HSADC_GetSampleResultValue |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
sampleIndex |
|
) |
| |
|
inlinestatic |
This function gets the sample result value. This returned value keeps its original formation just like in the hardware result register. It includes the sign bit as the MSB and 3-bit left shifted value.
- Parameters
-
| base | HSADC peripheral base address. |
| sampleIndex | Index of sample slot. |
- Returns
- Sample's conversion value.
| void HSADC_DoAutoCalibration |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
converterMask, |
|
|
uint16_t |
calibrationModeMask |
|
) |
| |
This function starts the single ended calibration and differential calibration for converter A and converter B at the same time. Note that this is a non blocking function. End of Scan flag and End of Calibration flag are both be set after the calibration process. As a result, the user should check these two flags by using the function HSADC_GetStatusFlags() to wait for the calibration process to complete.
- Parameters
-
| base | HSADC peripheral base address. |
| converterMask | Mask for converters to be operated. See the "_hsadc_converter_id". |
| calibrationModeMask | Mask for calibration mode to be operated. See the "_hsadc_calibration_mode". Shouldn't be zero. |
| uint32_t HSADC_GetCalibrationResultValue |
( |
HSADC_Type * |
base | ) |
|
This function returns the single ended calibration value and differential calibration value for converter A and converter B. The calibration value of each calibration mode for each converter can be received from this function's return value by using the mask and shift definition from HSADC_CALIBRATION_VALUE_A_SINGLE_ENDED_MASK to HSADC_CALIBRATION_VALUE_B_DIFFERENTIAL_SHIFT.
- Parameters
-
| base | HSADC peripheral base address. |
- Returns
- Calibration value for converter A and converter B.
| void HSADC_EnableCalibrationResultValue |
( |
HSADC_Type * |
base, |
|
|
uint16_t |
converterMask, |
|
|
bool |
enable |
|
) |
| |
This function enables or disables converter A and converter B to use the calibration values to obtain the final conversion result by calibration sum operation.
- Parameters
-
| base | HSADC peripheral base address. |
| converterMask | Mask for converters to be operated. See the "_hsadc_converter_id". |
| enable | Enable or disable the feature. |