PSOC E8XXGP Device Support Library

| PSOC E8XXGP Device Support Library

API Reference
AC (Autonomous Controller)
PDL API Reference » AUTONOMOUS ANALOG (Autonomous Analog Block)

## General Description

This driver provides API functions to configure the Autonomous Controller (AC) subsystem within the Autonomous Analog.

The AC controls the entire operation of the Autonomous Analog. This includes enabling/disabling analog blocks, configuring them using the dynamic part of the configuration, checking state/status and handling events by taking conditional actions, managing intermediate data and notifying the host MCU/peripheral using interrupts/triggers.

The diagram below shows the AC simplified internals.

For more information on the AC, refer to the device Architecture Technical Reference Manual (TRM).
For the exact location of the digital outputs pins, see the device datasheet.

# State Transition Table

The AC FSM is based on a sequencer that can operate in all power modes except Hibernate. The set of operating states for this sequencer is named the State Transition Table (STT). The total number of the states in the STT is 64. The STT of Autonomous Analog is defined by cy_stc_autanalog_stt_t and illustrated on the diagram below.

The AC part of the STT (STT AC) is configured with cy_stc_autanalog_stt_ac_t and described below. The STTs for other subsystems are described in the relevant chapter for each subsystem.

In each state of the STT, the AC interacts with other subsystems of the Autonomous Analog via a standard interface (see AC Interface chapter). This interaction includes receiving the subsystem status and issuing the appropriate action (if any), see AC Conditions and Actions chapter.

The AC can change the STT state sequentially or take branch conditionally, depending on events from the subsystems of the Autonomous Analog.

## AC Interface

The AC has a standard interface for each sub-system of the Autonomous Analog:

- Enable sub-system (used to enable/disable, gate resets/clocks, and power analog macros)
  e.g. cy_stc_autanalog_stt_ctb_t::enableOpamp0 for the CTB;
- Static Configuration Selection for channel selection (to sub-systems like the ADC and DAC)
  e.g. cy_stc_autanalog_stt_dac_t::channel for the DAC;
- Dynamic Configuration Selection for routing and/or gain (for sub-systems like the PTComp and CTB)
  e.g. cy_stc_autanalog_stt_ptcomp_t::dynCfgIdxComp0;
- Condition(s) (varies per sub-system) e.g. cy_en_autanalog_stt_ac_condition_t::CY_AUTANALOG_STT_AC_CONDITION_SAR_DONE;
- Action Trigger(s) (internal triggers for the clocked sub-systems like the ADC and DAC) e.g. cy_stc_autanalog_stt_sar_t::trigger;

The subsystems provide their interfaces for the AC in the cy_stc_autanalog_stt_t configuration structure. The complete STT configuration contains the total number of states used in the STT (cy_stc_autanalog_t::numSttEntries) and a pointer to the array of configured interfaces of that size (cy_stc_autanalog_t::stateTransitionTable).

## AC Conditions and Actions

The CONDITION events (cy_en_autanalog_stt_ac_condition_t) are statuses from the sub-systems of the Autonomous Analog for the AC that can be used to branch (cy_en_autanalog_stt_ac_action_t) the program execution (i.e. change the STT state) and/or triggering an appropriate action for the subsystem (e.g. cy_stc_autanalog_stt_dac_t::trigger).

# AC Loop/Interval Counters

The AC contains four Loop/Interval counters that are programmatically assigned to the STT states. These down counters are used by the AC to implement delays in a given STT state (interval) or loop constructions that may contain several STT states. The AC can support up to 4 loop counters, or up to 3 loop counters and 1 interval counter. The counters periods are programmed with cy_stc_autanalog_stt_ac_t::count. Every AC clock cycle (see AC Clock chapter), the counter value decrements. When the counter value reaches zero (terminal count), the counter asserts a CNT_DONE trigger that is read by the AC.

The current state of the Loop/Interval Counter represents cy_stc_autanalog_state_tc_t configuration structure.

## Loop Counters

The loop counters are used for repeating certain STT states for a finite number of times. The user requests a Loop Counter by programming a particular STT state with the BRANCH_IF_* action and CNT_DONE condition.

Note
  When programming the AC to jump back to a particular state,
  it is recommended to use ACTION = BRANCH_IF_TRUE/BRANCH_IF_TRUE_CLR, CONDITION = TRUE.
  Avoid using ACTION = BRANCH_IF_FALSE/BRANCH_IF_FALSE_CLR, CONDITION = FALSE,
  as it could may cause unexpected issues.

## Interval Counter

The interval counters are used for waiting in a particular STT state for a finite amount of time. The user requests an Interval Counter by programming a particular STT state with the WAIT_FOR action and CNT_DONE condition.

# AC State

The current AC state represents the cy_stc_autanalog_state_ac_t configuration structure.

# Autonomous Analog State

The current Autonomous Analog state represents the cy_stc_autanalog_state_t configuration structure.

# High Speed and Low Power operation

The AC is available in both High Speed (HS) and Low Power (LP) modes. The operational mode of the AC determines the actual operation mode for the entire Autonomous Analog block (see cy_stc_autanalog_stt_ac_t::lpMode).

# AC Clock

In HS mode, the AC is clocked from CLK_HF9 directly (80MHz max) and functions only in chip Active mode.
In LP mode, the AC is clocked from CLK_LPOSC (4.096MHz nominal) and functions in chip Active and Deep Sleep modes.

# Power Management

In LP mode, the AC uses a dedicated logic for the Autonomous Analog digital logic duty cycling and minimizing both switching and leakage currents.

## Duty Cycling

The AC requests a duty cycling event based on the programming of the ACTION and CONDITION (cy_en_autanalog_stt_ac_action_t and cy_en_autanalog_stt_ac_condition_t). Whenever the AC state is programmed with WAIT_FOR action and *_WAKEUP condition, a sleep request is sent to the duty cycle FSM.

For configuration settings, see the cy_stc_autanalog_stt_t configuration structure and refer to State Transition Table chapter for more information.

## Wake-up Events and Wake-up Timer

The duty cycling FSM supports several different wake-up sources:

- Wake-up Timer;
- See the rest of *_WAKEUP conditions in cy_en_autanalog_stt_ac_condition_t;

The wake-up Timer can be clocked from the 32kHz low frequency clock (CLK_LF) or (at the expense of additional switching current) the 4.096MHz low power oscillator (CLK_LPOSC).

For configuration settings, see the cy_stc_autanalog_timer_t configuration structure.

# AC Configuration

The AC configuration includes:

- Wake-up timer (Wake-up Events and Wake-up Timer chapter);
- Enable the control a set of digital outputs (AC Digital Outputs chapter);
- The set of masks to control output triggers (External Triggers chapter);

For configuration settings, see the cy_stc_autanalog_ac_t configuration structure.

# AC Digital Outputs

Four GPIOs can be directly controlled by the AC (cy_stc_autanalog_stt_ac_t::gpioOut) in runtime. Before using this option, they must be enabled in the AC configuration (cy_stc_autanalog_ac_t::gpioOutEn) and unlocked for a given state in the State Transition Table (cy_stc_autanalog_stt_ac_t::unlockGpioOut). The digital waveforms are constructed based on the duration of a current state in the State Transition Table (State Transition Table) and the order of state execution.

For more details, refer to the AC Configuration and State Transition Table chapters.

# External Triggers

The trigger is the method to start the activity in a given chip block without MCU intervention. The AC supports four (hardware/firmware) input triggers and eight (cy_en_autanalog_ac_out_trigger_idx_t) output triggers.

## Input Triggers

The input trigger can be initiated by an event on external block (HW trigger) or from the API (FW trigger, cy_en_autanalog_fw_trigger_t).

## Firmware Triggers

The AC can use the FW triggers as the CONDITIONS (*_TR_AUTANALOG_IN*, cy_en_autanalog_stt_ac_condition_t) for the available ACTIONS (cy_en_autanalog_stt_ac_action_t).

For more details about the AC CONDITIONS and ACTIONS, refer to the AC Conditions and Actions chapter.

The FW trigger can be issued by means of the provided API, Cy_AutAnalog_FwTrigger.

## Output Triggers

The output trigger can be initiated in response to an event within the Autonomous Analog. The set of such events is defined in cy_en_autanalog_ac_out_trigger_mask_t. The required output triggers must be enabled in the AC configuration structure (cy_stc_autanalog_ac_t::mask). Also, you can modify them at runtime using the provided API. Cy_AutAnalog_GetOutputTriggerMask, Cy_AutAnalog_SetOutputTriggerMask.

# Sample use case: Interrupt and FW Trigger

The blinky LED example is based on the AC and State Transition Table.
The AC operates within the four states of the State Transition Table:

- State #0 is used to initialize the enabled subsystems of the Autonomous Analog;
- In state #1, the AC generates an interrupt;
- In State #2, the AC is used to wait for the FW trigger;
- State #3 is used for an unconditional return to State #1.
  The following Autonomous Analog configuration structures are automatically generated by the Device Configurator.

/* The AC configuration structure */
cy_stc_autanalog_ac_t CYBSP_AUTONOMOUS_CONTROLLER_cfg_ =
{
.gpioOutEn = CY_AUTANALOG_STT_AC_GPIO_OUT_DISABLED,
.mask =
{
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
},
.timer =
{
.enable = false,
.clkSrc = CY_AUTANALOG_TIMER_CLK_LP,
.period = 0U,
},
};
/* The configuration structure to set up the entire Autonomous Analog */
cy_stc_autanalog_cfg_t autonomous_analog_cfg_ =
{
.prb = NULL,
.ac = &CYBSP_AUTONOMOUS_CONTROLLER_cfg_,
.ctb =
{
NULL,
NULL,
},
.ptcomp =
{
NULL,
},
.dac =
{
NULL,
NULL,
},
.sar =
{
NULL,
},
};
/* The AC section in the State Transition Table state */
cy_stc_autanalog_stt_ac_t CYBSP_AUTONOMOUS_CONTROLLER_stt_[] =
{
/* State #0, wait for the enabled blocks to be ready */
{
.unlock = true,
.lpMode = true,
.condition = CY_AUTANALOG_STT_AC_CONDITION_BLOCK_READY,
.action = CY_AUTANALOG_STT_AC_ACTION_WAIT_FOR,
.branchState = 1U,
.trigInt = false,
.count = 0U,
.unlockGpioOut = false,
.gpioOut = CY_AUTANALOG_STT_AC_GPIO_OUT_DISABLED,
},
/* State #1, send interrupt */
{
.unlock = false,
.lpMode = false,
.condition = CY_AUTANALOG_STT_AC_CONDITION_FALSE,
.action = CY_AUTANALOG_STT_AC_ACTION_NEXT,
.branchState = 0U,
.trigInt = true,
.count = 0U,
.unlockGpioOut = false,
.gpioOut = CY_AUTANALOG_STT_AC_GPIO_OUT_DISABLED,
},
/* State #2, wait for input trigger #0 */
{
.unlock = false,
.lpMode = false,
.condition = CY_AUTANALOG_STT_AC_CONDITION_TR_AUTANALOG_IN0,
.action = CY_AUTANALOG_STT_AC_ACTION_WAIT_FOR,
.branchState = 0U,
.trigInt = false,
.count = 0U,
.unlockGpioOut = false,
.gpioOut = CY_AUTANALOG_STT_AC_GPIO_OUT_DISABLED,
},
/* State #3, go to State #1 unconditionally */
{
.unlock = false,
.lpMode = false,
.condition = CY_AUTANALOG_STT_AC_CONDITION_TRUE,
.action = CY_AUTANALOG_STT_AC_ACTION_BRANCH_IF_TRUE,
.branchState = 1U,
.trigInt = false,
.count = 0U,
.unlockGpioOut = false,
.gpioOut = CY_AUTANALOG_STT_AC_GPIO_OUT_DISABLED,
},
};
/* The configuration structure for the State Transition Table */
cy_stc_autanalog_stt_t autonomous_analog_stt_[] =
{
/* State #0 */
{
.ac = &CYBSP_AUTONOMOUS_CONTROLLER_stt_[0U],
.prb = NULL,
.ctb =
{
NULL,
NULL,
},
.ptcomp =
{
NULL,
},
.dac =
{
NULL,
NULL,
},
.sar =
{
NULL,
},
},
/* State #1 */
{
.ac = &CYBSP_AUTONOMOUS_CONTROLLER_stt_[1U],
.prb = NULL,
.ctb =
{
NULL,
NULL,
},
.ptcomp =
{
NULL,
},
.dac =
{
NULL,
NULL,
},
.sar =
{
NULL,
},
},
/* State #2 */
{
.ac = &CYBSP_AUTONOMOUS_CONTROLLER_stt_[2U],
.prb = NULL,
.ctb =
{
NULL,
NULL,
},
.ptcomp =
{
NULL,
},
.dac =
{
NULL,
NULL,
},
.sar =
{
NULL,
},
},
/* State #3 */
{
.ac = &CYBSP_AUTONOMOUS_CONTROLLER_stt_[3U],
.prb = NULL,
.ctb =
{
NULL,
NULL,
},
.ptcomp =
{
NULL,
},
.dac =
{
NULL,
NULL,
},
.sar =
{
NULL,
},
},
};
/* The configuration and State Transition Table to set up the entire Autonomous Analog */
cy_stc_autanalog_t autonomous_analog_init_ =
{
.configuration = &autonomous_analog_cfg_,
.numSttEntries = sizeof(autonomous_analog_stt_)/sizeof(autonomous_analog_stt_[0U]),
.stateTransitionTable = &autonomous_analog_stt_[0U],
};
cy_stc_autanalog_ac_t::gpioOutEn
cy_en_autanalog_stt_ac_gpio_out_t gpioOutEn
Control four GPIO outputs with the AC, see also cy_stc_autanalog_stt_ac_t::unlockGpioOut.
Definition: cy_autanalog_ac.h:993
cy_stc_autanalog_stt_ac_t::unlock
bool unlock
AC mode unlock:
Definition: cy_autanalog_ac.h:1081
cy_stc_autanalog_ac_t
The AC configuration structure.
Definition: cy_autanalog_ac.h:992
cy_stc_autanalog_stt_ac_t
The AC section in the State Transition Table state.
Definition: cy_autanalog_ac.h:1080
CY_AUTANALOG_STT_AC_CONDITION_TRUE
@ CY_AUTANALOG_STT_AC_CONDITION_TRUE
Unconditionally TRUE.
Definition: cy_autanalog_ac.h:360
CY_AUTANALOG_STT_AC_CONDITION_TR_AUTANALOG_IN0
@ CY_AUTANALOG_STT_AC_CONDITION_TR_AUTANALOG_IN0
External trigger 0 (or the FW trigger 0).
Definition: cy_autanalog_ac.h:609
CY_AUTANALOG_STT_AC_CONDITION_FALSE
@ CY_AUTANALOG_STT_AC_CONDITION_FALSE
Unconditionally FALSE.
Definition: cy_autanalog_ac.h:359
CY_AUTANALOG_STT_AC_CONDITION_BLOCK_READY
@ CY_AUTANALOG_STT_AC_CONDITION_BLOCK_READY
Enabled subsystems of the Autonomous Analog are initialized and ready for use.
Definition: cy_autanalog_ac.h:361
CY_AUTANALOG_STT_AC_GPIO_OUT_DISABLED
@ CY_AUTANALOG_STT_AC_GPIO_OUT_DISABLED
Control of the GPIO outs is disabled.
Definition: cy_autanalog_ac.h:295
CY_AUTANALOG_STT_AC_ACTION_WAIT_FOR
@ CY_AUTANALOG_STT_AC_ACTION_WAIT_FOR
Wait (indefinitely) for the associated CONDITION to be TRUE before moving to the next state,...
Definition: cy_autanalog_ac.h:313
CY_AUTANALOG_STT_AC_ACTION_NEXT
@ CY_AUTANALOG_STT_AC_ACTION_NEXT
Proceed to the next state in the STT.
Definition: cy_autanalog_ac.h:312
CY_AUTANALOG_STT_AC_ACTION_BRANCH_IF_TRUE
@ CY_AUTANALOG_STT_AC_ACTION_BRANCH_IF_TRUE
Check if CONDITION has occurred If it occurred, take the indicated branch cy_stc_autanalog_stt_ac_t::...
Definition: cy_autanalog_ac.h:316
CY_AUTANALOG_TIMER_CLK_LP
@ CY_AUTANALOG_TIMER_CLK_LP
The Timer clocked from CLK_LPOSC (nominally 4.096MHz)
Definition: cy_autanalog_ac.h:947
cy_stc_autanalog_cfg_t::prb
cy_stc_autanalog_prb_t * prb
The pointer to the PRB configuration.
Definition: cy_autanalog.h:398
cy_stc_autanalog_stt_t::ac
cy_stc_autanalog_stt_ac_t * ac
The pointer to the AC subsystem STT.
Definition: cy_autanalog.h:430
cy_stc_autanalog_t::configuration
cy_stc_autanalog_cfg_t * configuration
The pointer to the whole configuration structure.
Definition: cy_autanalog.h:458
cy_stc_autanalog_cfg_t
The configuration structure to set up the entire Autonomous Analog used with cy_stc_autanalog_t and C...
Definition: cy_autanalog.h:397
cy_stc_autanalog_stt_t
The configuration structure for one row of the State Transition Table, the array of these structures ...
Definition: cy_autanalog.h:429
cy_stc_autanalog_t
The configuration and STT data to set up the entire Autonomous Analog, used in Cy_AutAnalog_Init.
Definition: cy_autanalog.h:457

The content of the application is presented below:

/*******************************************************************************
* Header Files
*******************************************************************************/
#include "cybsp.h"
/*******************************************************************************
* Macros
*******************************************************************************/
#define LED_BLINK_DELAY (100000U)
/*******************************************************************************
* Global Variables
*******************************************************************************/
volatile bool autonomous_analog_ac_int_flag = false;
/*******************************************************************************
* Interrupt handler: autonomous_analog_ac_int_hook
*******************************************************************************/
void autonomous_analog_ac_int_hook(void)
{
/* Read the interrupt status register */
uint32_t autonomous_analog_ac_int_status = Cy_AutAnalog_GetInterruptStatus();
/* Clear already handled interrupt */
Cy_AutAnalog_ClearInterrupt(autonomous_analog_ac_int_status);
/* Check the source of the interrupt */
if ((autonomous_analog_ac_int_status & (uint32_t) CY_AUTANALOG_INT_AC) == (uint32_t) CY_AUTANALOG_INT_AC)
{
/* Set the interrupt flag */
autonomous_analog_ac_int_flag = true;
}
}
Cy_AutAnalog_ClearInterrupt
__STATIC_INLINE void Cy_AutAnalog_ClearInterrupt(uint32_t interrupt)
Clears the interrupts for the Autonomous Analog.
Definition: cy_autanalog.h:740
Cy_AutAnalog_GetInterruptStatus
__STATIC_INLINE uint32_t Cy_AutAnalog_GetInterruptStatus(void)
Returns the status of combined Autonomous Analog interrupt requests.
Definition: cy_autanalog.h:722
CY_AUTANALOG_INT_AC
#define CY_AUTANALOG_INT_AC
AC interrupt.
Definition: cy_autanalog.h:215

The content of main.c is shown below:

cy_rslt_t result = CY_RSLT_SUCCESS;
/* Initialize the device and board peripherals */
result = cybsp_init();
if (CY_RSLT_SUCCESS != result)
{
CY_ASSERT(0);
}
/* Enable global interrupts */
__enable_irq();
/* Initialize configuration structure for a single interrupt channel */
const cy_stc_sysint_t AUTANALOG_AC_IRQ_cfg =
{
.intrSrc = pass_interrupt_lppass_IRQn,
.intrPriority = 3u
};
/* Initialize the referenced interrupt */
cy_en_sysint_status_t sysIntStatus = Cy_SysInt_Init(&AUTANALOG_AC_IRQ_cfg, &autonomous_analog_ac_int_hook);
if (CY_SYSINT_SUCCESS != sysIntStatus)
{
CY_ASSERT(0);
}
/* Clear pending interrupt */
NVIC_ClearPendingIRQ(pass_interrupt_lppass_IRQn);
/* Enable the interrupt */
NVIC_EnableIRQ(pass_interrupt_lppass_IRQn);
/* Initialize the Autonomous Analog */
uint32_t autonomous_analog_init_status = Cy_AutAnalog_Init(&autonomous_analog_init_);
if (CY_AUTANALOG_SUCCESS == autonomous_analog_init_status)
{
/* Set the interrupt mask for the Autonomous Analog */
Cy_AutAnalog_SetInterruptMask(CY_AUTANALOG_INT_AC);
/* Enables the AC for operation */
Cy_AutAnalog_StartAutonomousControl();
}
else
{
CY_ASSERT(0);
}
uint32_t led_blink_delay = 0u;
for(;;)
{
if (autonomous_analog_ac_int_flag)
{
autonomous_analog_ac_int_flag = false;
/* Send the firmware trigger #0 */
Cy_AutAnalog_FwTrigger(CY_AUTANALOG_FW_TRIGGER0);
if (++led_blink_delay == LED_BLINK_DELAY)
{
led_blink_delay = 0u;
/* Toggle the user LED */
Cy_GPIO_Inv(CYBSP_USER_LED_PORT, CYBSP_USER_LED_PIN);
}
}
}
CY_AUTANALOG_FW_TRIGGER0
@ CY_AUTANALOG_FW_TRIGGER0
FW trigger 0.
Definition: cy_autanalog_ac.h:790
Cy_AutAnalog_StartAutonomousControl
void Cy_AutAnalog_StartAutonomousControl(void)
Enables the AC for operation.
Definition: cy_autanalog_ac.c:115
Cy_AutAnalog_FwTrigger
void Cy_AutAnalog_FwTrigger(cy_en_autanalog_fw_trigger_t triggNum)
Sends a firmware trigger to the AC.
Definition: cy_autanalog_ac.c:217
CY_AUTANALOG_SUCCESS
@ CY_AUTANALOG_SUCCESS
Initialization completed successfully.
Definition: cy_autanalog_common.h:110
Cy_AutAnalog_Init
uint32_t Cy_AutAnalog_Init(const cy_stc_autanalog_t *cfgAndStates)
Initializes the entire Autonomous Analog with the configuration and states provided.
Definition: cy_autanalog.c:157
Cy_AutAnalog_SetInterruptMask
__STATIC_INLINE void Cy_AutAnalog_SetInterruptMask(uint32_t mask)
Configures which bits of the interrupt request register will trigger an interrupt event in the Autono...
Definition: cy_autanalog.h:786
Cy_GPIO_Inv
__STATIC_FORCEINLINE void Cy_GPIO_Inv(GPIO_PRT_Type *base, uint32_t pinNum)
Set a pin output logic state to the inverse of the current output logic state.
Definition: cy_gpio.h:1251
cy_rslt_t
uint32_t cy_rslt_t
Provides the result of an operation as a structured bitfield.
Definition: cy_result.h:459
CY_RSLT_SUCCESS
#define CY_RSLT_SUCCESS
cy_rslt_t return value indicating success
Definition: cy_result.h:486
cy_stc_sysint_t::intrSrc
IRQn_Type intrSrc
Interrupt source.
Definition: cy_sysint.h:229
cy_stc_sysint_t
Initialization configuration structure for a single interrupt channel.
Definition: cy_sysint.h:227
cy_en_sysint_status_t
cy_en_sysint_status_t
SysInt Driver error codes.
Definition: cy_sysint.h:198
CY_SYSINT_SUCCESS
@ CY_SYSINT_SUCCESS
Returned successful.
Definition: cy_sysint.h:199
Cy_SysInt_Init
cy_en_sysint_status_t Cy_SysInt_Init(const cy_stc_sysint_t *config, cy_israddress userIsr)
Initializes the referenced interrupt by setting the priority and the interrupt vector.
Definition: cy_sysint_v2.c:80

## API Reference
| Macros
| Functions
| Data Structures
| Enumerated Types