This set of functions is for initialization and basic usage.
Functions | |
cy_en_sar_status_t | Cy_SAR_Init (SAR_Type *base, const cy_stc_sar_config_t *config) |
Initialize all SAR configuration registers. More... | |
cy_en_sar_status_t | Cy_SAR_DeInit (SAR_Type *base, bool deInitRouting) |
Reset SAR registers back to power on reset defaults. More... | |
void | Cy_SAR_Enable (SAR_Type *base) |
Power up the SAR ADC subsystem block. More... | |
__STATIC_INLINE void | Cy_SAR_Disable (SAR_Type *base) |
Turn off the hardware block. More... | |
void | Cy_SAR_StartConvert (SAR_Type *base, cy_en_sar_start_convert_sel_t startSelect) |
Start a single scan (one shot) of all enabled channels or start scanning continuously. More... | |
void | Cy_SAR_StopConvert (SAR_Type *base) |
Stop continuous scanning of enabled channels. More... | |
cy_en_sar_status_t | Cy_SAR_IsEndConversion (SAR_Type *base, cy_en_sar_return_mode_t retMode) |
Immediately return the status of the conversion or does not return (blocking) until the conversion completes, depending on the retMode parameter. More... | |
int16_t | Cy_SAR_GetResult16 (const SAR_Type *base, uint32_t chan) |
Return the data available in the channel result data register as a signed 16-bit integer. More... | |
int32_t | Cy_SAR_GetResult32 (const SAR_Type *base, uint32_t chan) |
Return the data available in the channel result data register as a signed 32-bit integer. More... | |
__STATIC_INLINE uint32_t | Cy_SAR_GetChanResultUpdated (const SAR_Type *base) |
Return whether the RESULT register has been updated or not. More... | |
cy_en_sar_status_t Cy_SAR_Init | ( | SAR_Type * | base, |
const cy_stc_sar_config_t * | config | ||
) |
Initialize all SAR configuration registers.
If routing is to be configured, all switches will be cleared before being initialized.
base | Pointer to structure describing registers |
config | Pointer to structure containing configuration data. See cy_stc_sar_config_t and guidance in the Initialization and Enable section. |
cy_en_sar_status_t Cy_SAR_DeInit | ( | SAR_Type * | base, |
bool | deInitRouting | ||
) |
Reset SAR registers back to power on reset defaults.
The Cy_SAR_offset and Cy_SAR_countsPer10Volt arrays are NOT reset.
base | Pointer to structure describing registers |
deInitRouting | If true, all SARMUX switches are opened and switch control registers are reset to zero. If false, switch registers are untouched. |
void Cy_SAR_Enable | ( | SAR_Type * | base | ) |
Power up the SAR ADC subsystem block.
The hardware is ready to use after 2 us, which is included in this function.
base | Pointer to structure describing registers |
__STATIC_INLINE void Cy_SAR_Disable | ( | SAR_Type * | base | ) |
Turn off the hardware block.
base | Pointer to structure describing registers |
void Cy_SAR_StartConvert | ( | SAR_Type * | base, |
cy_en_sar_start_convert_sel_t | startSelect | ||
) |
Start a single scan (one shot) of all enabled channels or start scanning continuously.
When in continuous mode, all firmware and hardware triggers are ignored. To stop continuous scanning, call Cy_SAR_StopConvert.
base | Pointer to structure describing registers |
startSelect | A value of the enum cy_en_sar_start_convert_sel_t |
void Cy_SAR_StopConvert | ( | SAR_Type * | base | ) |
Stop continuous scanning of enabled channels.
If a conversion is currently executing, that conversion will complete, but no further conversions will occur until the next call to Cy_SAR_StartConvert or the next hardware trigger, if enabled.
base | Pointer to structure describing registers |
cy_en_sar_status_t Cy_SAR_IsEndConversion | ( | SAR_Type * | base, |
cy_en_sar_return_mode_t | retMode | ||
) |
Immediately return the status of the conversion or does not return (blocking) until the conversion completes, depending on the retMode parameter.
In blocking mode, there is a time out of about 10 seconds for a CPU speed of 100 MHz.
base | Pointer to structure describing registers |
retMode | A value of the enum cy_en_sar_return_mode_t |
int16_t Cy_SAR_GetResult16 | ( | const SAR_Type * | base, |
uint32_t | chan | ||
) |
Return the data available in the channel result data register as a signed 16-bit integer.
base | Pointer to structure describing registers |
chan | The channel to read the result from, between 0 and CY_SAR_MAX_NUM_CHANNELS - 1 |
int32_t Cy_SAR_GetResult32 | ( | const SAR_Type * | base, |
uint32_t | chan | ||
) |
Return the data available in the channel result data register as a signed 32-bit integer.
base | Pointer to structure describing registers |
chan | The channel to read the result from, between 0 and CY_SAR_MAX_NUM_CHANNELS - 1 |
__STATIC_INLINE uint32_t Cy_SAR_GetChanResultUpdated | ( | const SAR_Type * | base | ) |
Return whether the RESULT register has been updated or not.
If the bit is high, the corresponding channel RESULT register was updated, i.e. was sampled during the previous scan and, in case of Interleaved averaging, reached the averaging count. If the bit is low, the corresponding channel is not enabled or the averaging count is not yet reached for Interleaved averaging.
base | Pointer to structure describing registers |