Functions¶
-
group
group_sysanalog_functions
Functions
-
cy_en_sysanalog_status_t
Cy_SysAnalog_Init
(const cy_stc_sysanalog_config_t *config) Initialize the AREF block.
/* Scenario: The AREF is a system wide resource; it is used by multiple blocks (SAR, CTDAC, CTB, and CSDv2). * If one of these blocks require one of the AREF reference outputs, the AREF must be enabled. * The AREF block is not meant to be used stand-alone. */ /* The Cy_SysAnalog_Fast_Local configuration is provided by the driver * to cover a majority of use cases. It is the recommended configuration * for analog performance; it configures the block for * fast startup and sources all references with its local generators. */ cy_en_sysanalog_status_t status; status = Cy_SysAnalog_Init(&Cy_SysAnalog_Fast_Local); /* Turn on the hardware block. */ Cy_SysAnalog_Enable(); /* After the AREF is enabled, enable the consumer blocks (SAR, CTDAC, CTB, and CSDv2). */
- Return
CY_SYSANALOG_SUCCESS : initialization complete
CY_SYSANALOG_BAD_PARAM : input pointers are null, initialization incomplete
- Function Usage
- Parameters
config
: Pointer to structure containing configuration data. See cy_stc_sysanalog_config_t
-
__STATIC_INLINE void Cy_SysAnalog_DeInit (void)
Reset AREF configuration back to power on reset defaults.
/* Scenario: The AREF is no longer needed. Reset the AREF to power on reset settings. */ (void) Cy_SysAnalog_DeInit();
- Return
None
- Function Usage
-
__STATIC_INLINE uint32_t Cy_SysAnalog_GetIntrCauseExtended (const PASS_Type *base)
Return the PASS interrupt cause register value.
Depending on the device, there may be interrupts from these PASS blocks:
CTDAC (up to 4 instances)
CTB(m) (up to 4 instances)
SAR (up to 4 instances)
FIFO (up to 4 instances)
Compare this returned value with the enum values in cy_en_sysanalog_intr_cause_t to determine which block caused/triggered the interrupt.
/* Scenario: The device has multiple CTBs or CTDACs and * that user wants to know which instance caused the global interrupt. * This function is not useful or needed when the device has only * one CTB or CTDAC. */ uint32_t intrCause; intrCause = Cy_SysAnalog_GetIntrCauseExtended(PASS); if ((uint32_t) CY_SYSANALOG_INTR_CAUSE_CTB0 == (intrCause & (uint32_t) CY_SYSANALOG_INTR_CAUSE_CTB0)) { /* CTB0 caused the interrupt */ }
- Return
uint32_t Interrupt cause register value.
- Function Usage
-
__STATIC_INLINE void Cy_SysAnalog_SetDeepSleepMode (cy_en_sysanalog_deep_sleep_t deepSleep)
Set what parts of the AREF are enabled in Deep Sleep mode.
Disable AREF IP block
Enable IPTAT generator for fast wakeup from Deep Sleep mode. IPTAT outputs for CTBs are disabled.
Enable IPTAT generator and IPTAT outputs for CTB
Enable all generators and outputs: IPTAT, IZTAT, and VREF
note
The SRSS references are not available to the AREF in Deep Sleep mode. When operating in Deep Sleep mode, the local or external references must be selected.
/* Scenario: * The CTB opamps are using the current references from the AREF block. * The CTDAC is using the 1.2 V voltage reference from the AREF block. * The user wants the CTB and CTDAC to be enabled in Deep Sleep mode. * In order for the CTB and CTDAC to function in Deep Sleep mode, the references * from the AREF block must also be enabled for Deep Sleep operation. */ Cy_SysAnalog_SetDeepSleepMode(CY_SYSANALOG_DEEPSLEEP_IPTAT_IZTAT_VREF);
- Return
None
- Function Usage
- Parameters
deepSleep
: Select a value from cy_en_sysanalog_deep_sleep_t
-
__STATIC_INLINE cy_en_sysanalog_deep_sleep_t Cy_SysAnalog_GetDeepSleepMode (void)
Return Deep Sleep mode configuration as set by Cy_SysAnalog_SetDeepSleepMode.
/* Scenario: As a system wide resource, the AREF Deep Sleep mode configuration * affects all consumer blocks. The Deep Sleep mode settings should be queried * before it is modified as to not affect other blocks. */ cy_en_sysanalog_deep_sleep_t mode; mode = Cy_SysAnalog_GetDeepSleepMode(); /* Don't enable the voltage reference, VREF, in Deep Sleep unless * it is needed by other blocks (e.g. the CTDAC) as it will consume more power. */ if (CY_SYSANALOG_DEEPSLEEP_IPTAT_IZTAT_VREF != mode) { Cy_SysAnalog_SetDeepSleepMode(CY_SYSANALOG_DEEPSLEEP_IPTAT_2); }
- Return
A value from cy_en_sysanalog_deep_sleep_t
- Function Usage
-
__STATIC_INLINE void Cy_SysAnalog_Enable (void)
Enable the AREF hardware block.
/* Scenario: The AREF block has been initialized and needs to be enabled. */ Cy_SysAnalog_Enable(); /* After the AREF is enabled, enable the consumer blocks (SAR, CTDAC, CTB, and CSDv2). */
- Return
None
- Function Usage
-
__STATIC_INLINE void Cy_SysAnalog_Disable (void)
Disable the AREF hardware block.
/* Scenario: The AREF block is no longer needed. * That is, all the consumer blocks (SAR, CTDAC, CTB, and CSDv2) have been disabled. * Disable the AREF block to save power. */ Cy_SysAnalog_Disable();
- Return
None
- Function Usage
-
__STATIC_INLINE void Cy_SysAnalog_SetArefMode (cy_en_sysanalog_startup_t startup)
Set the AREF startup mode from power on reset or from Deep Sleep wakeup.
The AREF can startup in a normal or fast mode.
If fast startup is desired from Deep Sleep wakeup, the IPTAT generators must be enabled during Deep Sleep. This is a minimum Deep Sleep mode setting of CY_SYSANALOG_DEEPSLEEP_IPTAT_1 (see also Cy_SysAnalog_SetDeepSleepMode).
/* Scenario: The fast startup mode is desired. */ Cy_SysAnalog_SetArefMode(CY_SYSANALOG_STARTUP_FAST);
- Return
None
- Function Usage
- Parameters
startup
: Value from enum cy_en_sysanalog_startup_t
-
__STATIC_INLINE void Cy_SysAnalog_VrefSelect (cy_en_sysanalog_vref_source_t vref)
Set the source for the Vref.
The Vref can come from:
the locally generated 1.2 V reference
the SRSS, which provides a 0.8 V reference (not available to the AREF in Deep Sleep mode)
an external device pin
The locally generated reference has higher accuracy, more stability over temperature, and lower noise than the SRSS reference.
/* Select the local 1.2 V generator as the Vref source for optimal analog performance. */ Cy_SysAnalog_VrefSelect(CY_SYSANALOG_VREF_SOURCE_LOCAL_1_2V);
- Return
None
- Function Usage
- Parameters
vref
: Value from enum cy_en_sysanalog_vref_source_t
-
__STATIC_INLINE void Cy_SysAnalog_IztatSelect (cy_en_sysanalog_iztat_source_t iztat)
Set the source for the 1 uA IZTAT.
The IZTAT can come from:
the locally generated IZTAT
the SRSS (not available to the AREF in Deep Sleep mode)
The locally generated reference has higher accuracy, more stability over temperature, and lower noise than the SRSS reference.
/* Select the local generator as the IZTAT source for optimal analog performance. */ Cy_SysAnalog_IztatSelect(CY_SYSANALOG_IZTAT_SOURCE_LOCAL);
- Return
None
- Function Usage
- Parameters
iztat
: Value from enum cy_en_sysanalog_iztat_source_t
-
cy_en_sysanalog_status_t
Cy_SysAnalog_DeepSleepInit
(PASS_Type *base, const cy_stc_sysanalog_deep_sleep_config_t *config) Initialize PASS_ver2 Deep Sleep features such as Low Power Oscillator, Deep Sleep Clock, Timer.
- Return
CY_SYSANALOG_SUCCESS : initialization complete
CY_SYSANALOG_BAD_PARAM : input pointers are null, initialization incomplete
- Function Usage
/* Initializes Deep Sleep features */ const cy_stc_sysanalog_deep_sleep_config_t dsConfig = { /*.lpOscDsMode */ CY_SYSANALOG_LPOSC_ALWAYS_ON, /*.dsClkSource */ CY_SYSANALOG_DEEPSLEEP_SRC_LPOSC, /*.dsClkdivider */ CY_SYSANALOG_DEEPSLEEP_CLK_DIV_BY_4, /*.timerClock */ CY_SYSANALOG_TIMER_CLK_DEEPSLEEP, /*.timerPeriod */ 4000UL }; if (CY_SYSANALOG_SUCCESS == Cy_SysAnalog_DeepSleepInit(PASS, &dsConfig)) { /* Enable LpOsc and Timer blocks. */ Cy_SysAnalog_LpOscEnable(PASS); Cy_SysAnalog_TimerEnable(PASS); }
- Parameters
base
: Pointer to the PASS register structure.config
: Pointer to structure containing configuration data. See cy_stc_sysanalog_deep_sleep_config_t
-
cy_en_sysanalog_status_t