MTB CAT1 Peripheral driver library

General Description

This set of functions are for initializing, enabling, and disabling the CTDAC.

Functions

cy_en_ctdac_status_t Cy_CTDAC_Init (CTDAC_Type *base, const cy_stc_ctdac_config_t *config)
 Initialize all CTDAC configuration registers. More...
 
cy_en_ctdac_status_t Cy_CTDAC_DeInit (CTDAC_Type *base, bool deInitRouting)
 Reset CTDAC registers back to power on reset defaults. More...
 
cy_en_ctdac_status_t Cy_CTDAC_FastInit (CTDAC_Type *base, const cy_stc_ctdac_fast_config_t *config)
 Initialize the CTDAC to one of the common use modes. More...
 
__STATIC_INLINE void Cy_CTDAC_Enable (CTDAC_Type *base)
 Power up the CTDAC hardware block. More...
 
__STATIC_INLINE void Cy_CTDAC_Disable (CTDAC_Type *base)
 Turn off the hardware block. More...
 

Function Documentation

◆ Cy_CTDAC_Init()

cy_en_ctdac_status_t Cy_CTDAC_Init ( CTDAC_Type base,
const cy_stc_ctdac_config_t config 
)

Initialize all CTDAC configuration registers.

Parameters
basePointer to structure describing registers
configPointer to structure containing configuration data
Returns
Status of initialization, CY_CTDAC_SUCCESS or CY_CTDAC_BAD_PARAM
Function Usage
/* Scenario: Configure the CTDAC to use VDDA as the reference source with an unbuffered output.
* A 500 kHz peripheral clock is enabled and connected to the CTDAC for buffered writes. */
const cy_stc_ctdac_config_t config =
{
/* .refSource = */ CY_CTDAC_REFSOURCE_VDDA, /* Use VDDA as reference. */
/* .formatMode = */ CY_CTDAC_FORMAT_SIGNED, /* Set the register format to signed. */
/* .updateMode = */ CY_CTDAC_UPDATE_BUFFERED_WRITE, /* Set the update mode to buffered write. */
/* .deglitchMode = */ CY_CTDAC_DEGLITCHMODE_UNBUFFERED, /* Enable deglitching on the unbuffered output path. */
/* .outputMode = */ CY_CTDAC_OUTPUT_VALUE, /* Enable the output to drive the register value. */
/* .outputBuffer = */ CY_CTDAC_OUTPUT_UNBUFFERED, /* Output is unbuffered to pin. */
/* .deepSleep = */ CY_CTDAC_DEEPSLEEP_ENABLE, /* Enable the CTDAC to operate in Deep Sleep mode. */
/* .deglitchCycles = */ 34uL, /* Set the deglitch time to 700 ns. */
/* Deglitch time = (DEGLITCH_CNT + 1) / PERI_CLOCK_FREQ */
/* .value = */ 0uL, /* With signed format, set the initial output voltage to Vdda/2. */
/* .nextValue = */ 0uL,
/* .enableInterrupt = */ true, /* Enable interrupt. */
/* .configClock = */ true, /* Configure and connect the CTDAC clock. */
/* .dividerType = */ CY_SYSCLK_DIV_8_BIT, /* Use the 8-bit clock dividers for the CTDAC clock source. */
/* .dividerNum = */ 0uL, /* Select divider number 0. */
/* .dividerIntValue = */ 99uL, /* Set the CTDAC clock frequency to 500 kHz based on a 50 MHz PeriClk. */
/* CTDAC clock frequency = PERI_CLOCK_FREQ / (dividerIntValue + 1) */
/* .dividerFracValue= */ CY_CTDAC_DEINIT,
};
status = Cy_CTDAC_Init(CTDAC0, &config);
if (CY_CTDAC_SUCCESS == status)
{
/* Turn on the hardware block. */
Cy_CTDAC_Enable(CTDAC0);
}

◆ Cy_CTDAC_DeInit()

cy_en_ctdac_status_t Cy_CTDAC_DeInit ( CTDAC_Type base,
bool  deInitRouting 
)

Reset CTDAC registers back to power on reset defaults.

Note
Does not disable the clock.
Parameters
basePointer to structure describing registers
deInitRoutingIf true, all switches are reset to their default state. If false, switch registers are untouched.
Returns
Status of initialization, CY_CTDAC_SUCCESS, or CY_CTDAC_BAD_PARAM
Function Usage
/* Scenario: The CTDAC is no longer used or needs to be disabled. */
/* Disable and reset the CTDAC including switches. */
(void) Cy_CTDAC_DeInit(CTDAC0, true);

◆ Cy_CTDAC_FastInit()

cy_en_ctdac_status_t Cy_CTDAC_FastInit ( CTDAC_Type base,
const cy_stc_ctdac_fast_config_t config 
)

Initialize the CTDAC to one of the common use modes.

This function provides a quick and easy method of configuring the CTDAC when using the PDL driver for device configuration.

The other configuration options are set to:

A separate call to Cy_CTDAC_Enable is needed to turn on the hardware.

Parameters
basePointer to structure describing registers
configPointer to structure containing configuration data for quick initialization. Define your own or use one of the provided structures:
Returns
Status of initialization, CY_CTDAC_SUCCESS or CY_CTDAC_BAD_PARAM
Function Usage

The following code snippets configures VDDA as the reference source and routes the output directly to Pin 6 (unbuffered).

/* Scenario: Quickly configure the CTDAC using one of the common use cases
* provided by the driver. The Cy_CTDAC_Fast_VddaRef_UnbufferedOut configuration
* will use VDDA as the reference source and route the output directly to P9.6. */
if (CY_CTDAC_SUCCESS == status)
{
/* Turn on the hardware block. */
Cy_CTDAC_Enable(CTDAC0);
}
Function Usage

The following code snippet shows how the CTDAC and CTB blocks can quickly be configured to work together. The code configures the CTDAC to use a buffered output, a buffered reference source from the internal bandgap voltage, and closes all required analog routing switches.

ctdac_fast_init_funcusage.png
/* Scenario: Quickly configure the CTDAC and CTB blocks to work together.
* The CTDAC uses the internal AREF bandgap reference buffered with Opamp1
* and Opamp0 buffers the CTDAC output to P9.2. */
cy_en_ctdac_status_t ctdacStatus;
cy_en_ctb_status_t ctbStatus;
/* The AREF block must be initialized and enabled to provide a 1.2 V voltage reference
* for the CTDAC and the current references for the opamps. */
/* Buffer the reference and output of the CTDAC. */
/* Buffer the CTDAC output using Opamp0 to P9.2.
* Buffer the internal AREF bandgap voltage for the CTDAC reference using Opamp1. */
if ((CY_CTB_SUCCESS == ctbStatus) && (CY_CTDAC_SUCCESS == ctdacStatus))
{
/* Turn on the buffers before turning on the CTDAC. */
Cy_CTB_Enable(CTBM0);
Cy_CTDAC_Enable(CTDAC0);
}

◆ Cy_CTDAC_Enable()

__STATIC_INLINE void Cy_CTDAC_Enable ( CTDAC_Type base)

Power up the CTDAC hardware block.

Parameters
basePointer to structure describing registers
Returns
None

◆ Cy_CTDAC_Disable()

__STATIC_INLINE void Cy_CTDAC_Disable ( CTDAC_Type base)

Turn off the hardware block.

Parameters
basePointer to structure describing registers
Returns
None