cy_sysanalog_8h

Header file for the system level analog reference driver.

Version

2.0

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
Copyright

Copyright 2017-2020 Cypress Semiconductor Corporation SPDX-License-Identifier: Apache-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defines

CY_SYSANALOG_DRV_VERSION_MAJOR

Driver major version.

CY_SYSANALOG_DRV_VERSION_MINOR

Driver minor version.

CY_SYSANALOG_ID

PASS driver identifier.

Enums

enum cy_en_sysanalog_status_t

cy_en_sysanalog_status_t: The AREF status/error code definitions.

Values:

enumerator CY_SYSANALOG_SUCCESS

Successful.

enumerator CY_SYSANALOG_BAD_PARAM

Invalid input parameters.

enumerator CY_SYSANALOG_UNSUPPORTED

Unsupported feature.

enum cy_en_sysanalog_startup_t

cy_en_sysanalog_startup_t: Aref startup mode from power on reset and from Deep Sleep wakeup.

To achieve the fast startup time (10 us) from Deep Sleep wakeup, the IPTAT generators must be enabled in Deep Sleep mode (see cy_en_sysanalog_deep_sleep_t).

The fast startup is the recommended mode.

Values:

enumerator CY_SYSANALOG_STARTUP_NORMAL

Normal startup.

enumerator CY_SYSANALOG_STARTUP_FAST

Fast startup (10 us) - recommended.

enum cy_en_sysanalog_vref_source_t

cy_en_sysanalog_vref_source_t: AREF voltage reference sources.

The voltage reference can come from three sources:

  • the locally generated 1.2 V reference

  • the SRSS which provides a 0.8 V reference (not available in Deep Sleep mode)

  • an external device pin

Values:

enumerator CY_SYSANALOG_VREF_SOURCE_SRSS

Use 0.8 V Vref from SRSS.

Low accuracy high noise source that is not intended for analog subsystems.

enumerator CY_SYSANALOG_VREF_SOURCE_LOCAL_1_2V

Use locally generated 1.2 V Vref.

enumerator CY_SYSANALOG_VREF_SOURCE_EXTERNAL

Use externally supplied Vref.

enum cy_en_sysanalog_iztat_source_t

cy_en_sysanalog_iztat_source_t: AREF IZTAT sources.

The AREF generates a 1 uA “Zero dependency To Absolute Temperature” (IZTAT) current reference that is independent of temperature variations. It can come from one of two sources:

  • Local reference (1 uA)

  • Reference from the SRSS (250 nA that is gained by 4. Not available in Deep Sleep mode)

Values:

enumerator CY_SYSANALOG_IZTAT_SOURCE_SRSS

Use 250 nA IZTAT from SRSS and gain by 4 to output 1 uA.

enumerator CY_SYSANALOG_IZTAT_SOURCE_LOCAL

Use locally generated 1 uA IZTAT.

enum cy_en_sysanalog_deep_sleep_t

cy_en_sysanalog_deep_sleep_t: AREF Deep Sleep mode.

Configure what part of the AREF block is 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

Values:

enumerator CY_SYSANALOG_DEEPSLEEP_DISABLE

Disable AREF IP block.

enumerator CY_SYSANALOG_DEEPSLEEP_IPTAT_1

Enable IPTAT generator for fast wakeup from Deep Sleep mode IPTAT outputs for CTBs are disabled.

enumerator CY_SYSANALOG_DEEPSLEEP_IPTAT_2

Enable IPTAT generator and IPTAT outputs for CTB.

enumerator CY_SYSANALOG_DEEPSLEEP_IPTAT_IZTAT_VREF

Enable all generators and outputs: IPTAT, IZTAT, and VREF.

enum cy_en_sysanalog_intr_cause_t

cy_en_sysanalog_intr_cause_t: Interrupt cause sources.

Depending on the device, there may be interrupts from these PASS blocks:

  1. CTDAC (up to 4 instances)

  2. CTB(m) (up to 4 instances)

  3. SAR (up to 4 instances)

  4. FIFO (up to 4 instances)

A device could potentially have more than one instance of CTB or CTDAC blocks. To find out which instance caused the interrupt, call Cy_SysAnalog_GetIntrCauseExtended and compare the returned result with one of these enum values.

Values:

enumerator CY_SYSANALOG_INTR_CAUSE_CTB0

Interrupt cause mask for CTB0.

enumerator CY_SYSANALOG_INTR_CAUSE_CTB1

Interrupt cause mask for CTB1.

enumerator CY_SYSANALOG_INTR_CAUSE_CTB2

Interrupt cause mask for CTB2.

enumerator CY_SYSANALOG_INTR_CAUSE_CTB3

Interrupt cause mask for CTB3.

enumerator CY_SYSANALOG_INTR_CAUSE_CTDAC0

Interrupt cause mask for CTDAC0.

enumerator CY_SYSANALOG_INTR_CAUSE_CTDAC1

Interrupt cause mask for CTDAC1.

enumerator CY_SYSANALOG_INTR_CAUSE_CTDAC2

Interrupt cause mask for CTDAC2.

enumerator CY_SYSANALOG_INTR_CAUSE_CTDAC3

Interrupt cause mask for CTDAC3.

enumerator CY_SYSANALOG_INTR_CAUSE_SAR0

Interrupt cause mask for SAR0.

Available only for PASS_ver2.

enumerator CY_SYSANALOG_INTR_CAUSE_SAR1

Interrupt cause mask for SAR1.

Available only for PASS_ver2.

enumerator CY_SYSANALOG_INTR_CAUSE_SAR2

Interrupt cause mask for SAR2.

Available only for PASS_ver2.

enumerator CY_SYSANALOG_INTR_CAUSE_SAR3

Interrupt cause mask for SAR3.

Available only for PASS_ver2.

enumerator CY_SYSANALOG_INTR_CAUSE_FIFO0

Interrupt cause mask for FIFO0.

Available only for PASS_ver2.

enumerator CY_SYSANALOG_INTR_CAUSE_FIFO1

Interrupt cause mask for FIFO1.

Available only for PASS_ver2.

enumerator CY_SYSANALOG_INTR_CAUSE_FIFO2

Interrupt cause mask for FIFO2.

Available only for PASS_ver2.

enumerator CY_SYSANALOG_INTR_CAUSE_FIFO3

Interrupt cause mask for FIFO3.

Available only for PASS_ver2.

enum cy_en_sysanalog_deep_sleep_clock_sel_t

cy_en_sysanalog_deep_sleep_clock_sel_t: Deep Sleep Clock selection.

Specifies Deep Sleep Clock source:

  • DSCLK is set to LPOSC

  • DSCLK is set to CLK_MF

Values:

enumerator CY_SYSANALOG_DEEPSLEEP_SRC_LPOSC

DSCLK is set to LPOSC.

enumerator CY_SYSANALOG_DEEPSLEEP_SRC_CLK_MF

DSCLK is set to CLK_MF.

enum cy_en_sysanalog_deep_sleep_clock_div_t

cy_en_sysanalog_deep_sleep_clock_div_t: Deep Sleep clock divider.

Specifies Deep Sleep Clock divider.

  • Transparent mode, feed through selected clock source w/o dividing

  • Divide selected clock source by 2

  • Divide selected clock source by 4

  • Divide selected clock source by 8

  • Divide selected clock source by 16

Values:

enumerator CY_SYSANALOG_DEEPSLEEP_CLK_NO_DIV

Transparent mode, feed through selected clock source w/o dividing.

enumerator CY_SYSANALOG_DEEPSLEEP_CLK_DIV_BY_2

Divide selected clock source by 2.

enumerator CY_SYSANALOG_DEEPSLEEP_CLK_DIV_BY_4

Divide selected clock source by 4.

enumerator CY_SYSANALOG_DEEPSLEEP_CLK_DIV_BY_8

Divide selected clock source by 8.

enumerator CY_SYSANALOG_DEEPSLEEP_CLK_DIV_BY_16

Divide selected clock source by 16.

enum cy_en_sysanalog_lposc_deep_sleep_mode_t

cy_en_sysanalog_lposc_deep_sleep_mode_t: Low Power Oscillator (LPOSC) modes.

Configures Low Power Oscillator mode in Deep Sleep.

  • LPOSC enabled by TIMER trigger

  • LPOSC always on in Deep Sleep

Values:

enumerator CY_SYSANALOG_LPOSC_DUTY_CYCLED

LPOSC enabled by TIMER trigger.

enumerator CY_SYSANALOG_LPOSC_ALWAYS_ON

LPOSC always on in Deep Sleep.

enum cy_en_sysanalog_timer_clock_t

cy_en_sysanalog_timer_clock_t: Timer clock.

Values:

enumerator CY_SYSANALOG_TIMER_CLK_PERI

Timer clocked from CLK_PERI.

enumerator CY_SYSANALOG_TIMER_CLK_DEEPSLEEP

Timer clocked from CLK_DPSLP.

enumerator CY_SYSANALOG_TIMER_CLK_LF

Timer clocked from CLK_LF.

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

Function Usage

Parameters

__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:

  1. CTDAC (up to 4 instances)

  2. CTB(m) (up to 4 instances)

  3. SAR (up to 4 instances)

  4. 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

__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

__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

__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

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

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

__STATIC_INLINE void Cy_SysAnalog_LpOscEnable (PASS_Type *base)

Enables Low Power Oscillator in configured by Cy_SysAnalog_DeepSleepInit mode.

Return

None

Function Usage

    /* Enable Low Power Oscillator and configure it to be always enabled in Deep Sleep. */
    Cy_SysAnalog_LpOscEnable(PASS);

Parameters
  • base: Pointer to the PASS register structure.

__STATIC_INLINE void Cy_SysAnalog_LpOscDisable (PASS_Type *base)

Disables the Low Power Oscillator.

Return

None

Function Usage

    /* Scenario: The Low Power Oscillator is no longer needed. */
    Cy_SysAnalog_LpOscDisable(PASS);

Parameters
  • base: Pointer to the PASS register structure.

__STATIC_INLINE void Cy_SysAnalog_TimerEnable (PASS_Type *base)

Enable the analog subsystem timer in configured by Cy_SysAnalog_DeepSleepInit mode.

Return

None

Function Usage

    /* Scenario: Enable the Timer for Deep Sleep operation. */
    Cy_SysAnalog_TimerEnable(PASS);

    /* Scenario: The Timer is no longer needed. */
    Cy_SysAnalog_TimerDisable(PASS);

Parameters
  • base: Pointer to the PASS register structure.

__STATIC_INLINE void Cy_SysAnalog_TimerDisable (PASS_Type *base)

Disable the analog subsystem timer.

Return

None

Function Usage

    /* Scenario: Enable the Timer for Deep Sleep operation. */
    Cy_SysAnalog_TimerEnable(PASS);

    /* Scenario: The Timer is no longer needed. */
    Cy_SysAnalog_TimerDisable(PASS);

Parameters
  • base: Pointer to the PASS register structure.

__STATIC_INLINE void Cy_SysAnalog_TimerSetPeriod (PASS_Type *base, uint32_t periodVal)

Sets the analog subsystem timer period.

Return

None

Function Usage

    uint32_t period;
    /* Scenario: Get the Timer period value. */
    period = Cy_SysAnalog_TimerGetPeriod(PASS);

    /* Scenario: Set the new Timer period value. */
    Cy_SysAnalog_TimerDisable(PASS);
    Cy_SysAnalog_TimerSetPeriod(PASS, period);
    Cy_SysAnalog_TimerEnable(PASS);

Parameters
  • base: Pointer to the PASS register structure.

  • periodVal: the period value. Actual timer period equals periodVal + 1.

__STATIC_INLINE uint32_t Cy_SysAnalog_TimerGetPeriod (const PASS_Type *base)

Returns the analog subsystem timer period.

Return

the Timer period value.

Function Usage

    uint32_t period;
    /* Scenario: Get the Timer period value. */
    period = Cy_SysAnalog_TimerGetPeriod(PASS);

    /* Scenario: Set the new Timer period value. */
    Cy_SysAnalog_TimerDisable(PASS);
    Cy_SysAnalog_TimerSetPeriod(PASS, period);
    Cy_SysAnalog_TimerEnable(PASS);

Parameters
  • base: Pointer to the PASS register structure.

Variables

const cy_stc_sysanalog_config_t Cy_SysAnalog_Fast_Local

Configure the AREF to use the local Vref and local IZTAT.

Can be used with Cy_SysAnalog_Init. Other configuration options are set to:

  • .startup = CY_PASS_AREF_MODE_FAST

  • .deepSleep = CY_PASS_AREF_DEEPSLEEP_DISABLE

const cy_stc_sysanalog_config_t Cy_SysAnalog_Fast_SRSS

Configure the AREF to use the SRSS Vref and SRSS IZTAT.

Can be used with Cy_SysAnalog_Init. Other configuration options are set to:

  • .startup = CY_PASS_AREF_MODE_FAST

  • .deepSleep = CY_PASS_AREF_DEEPSLEEP_DISABLE

const cy_stc_sysanalog_config_t Cy_SysAnalog_Fast_External

Configure the AREF to use the external Vref and local IZTAT.

Can be used with Cy_SysAnalog_Init. Other configuration options are set to:

  • .startup = CY_PASS_AREF_MODE_FAST

  • .deepSleep = CY_PASS_AREF_DEEPSLEEP_DISABLE

struct cy_stc_sysanalog_config_t
#include <cy_sysanalog.h>

Structure to configure the entire AREF block.

Public Members

cy_en_sysanalog_startup_t startup

AREF normal or fast start.

cy_en_sysanalog_iztat_source_t iztat

AREF 1uA IZTAT source: Local or SRSS.

cy_en_sysanalog_vref_source_t vref

AREF Vref: Local, SRSS, or external pin.

cy_en_sysanalog_deep_sleep_t deepSleep

AREF Deep Sleep mode.

struct cy_stc_sysanalog_deep_sleep_config_t
#include <cy_sysanalog.h>

Structure to configure PASS_ver2 Deep Sleep features such as Low Power Oscillator, Deep Sleep Clock, Timer.

Public Members

cy_en_sysanalog_lposc_deep_sleep_mode_t lpOscDsMode

Low Power Oscillator Deep Sleep mode.

cy_en_sysanalog_deep_sleep_clock_sel_t dsClkSource

Deep Sleep Clock source select.

cy_en_sysanalog_deep_sleep_clock_div_t dsClkdivider

Deep Sleep Clock divider.

cy_en_sysanalog_timer_clock_t timerClock

Timer Clock source select.

uint32_t timerPeriod

Timer period.

Range 1..65536