MTB CAT1 Peripheral driver library

General Description

Functions

void Cy_SysClk_LpEcoConfigure (cy_en_clkbak_lpeco_loadcap_range_t capValue, cy_en_clkbak_lpeco_frequency_range_t freqValue, cy_en_clkbak_lpeco_max_amplitude_t ampValue, bool ampDetEn)
 Configures the low-power external crystal oscillator based on crystal characteristics. More...
 
cy_en_sysclk_status_t Cy_SysClk_LpEcoEnable (uint32_t timeoutus)
 Enables the low-power external crystal oscillator (LPECO). More...
 
void Cy_SysClk_LpEcoDisable (void)
 Disables the low-power external crystal oscillator (LPECO). More...
 
void Cy_SysClk_LpEcoSetFrequency (uint32_t freq)
 Stores the low-power external crystal oscillator (LPECO) frequency in a global variable within Sysclk driver. More...
 
uint32_t Cy_SysClk_LpEcoGetFrequency (void)
 Returns the frequency of the low-power external crystal oscillator (LPECO). More...
 
cy_en_sysclk_status_t Cy_SysClk_LpEcoPrescaleConfigure (bool enable, uint32_t int_div, uint32_t frac_div)
 Configures the low-power external crystal oscillator (LPECO) Prescaler and derives clk_lpeco_prescaler. More...
 
bool Cy_SysClk_LpEcoPrescaleIsEnabled (void)
 Reports whether or not LPECO Prescale is enabled. More...
 
bool Cy_SysClk_LpEcoAmplitudeOkay (void)
 Reports the current status of the low-power external crystal oscillator (LPECO) amplitude detection. More...
 
bool Cy_SysClk_LpEcoIsReady (void)
 Indicates whether or not the low-power external crystal oscillator (LPECO) has had enough time to start. More...
 

Function Documentation

◆ Cy_SysClk_LpEcoConfigure()

void Cy_SysClk_LpEcoConfigure ( cy_en_clkbak_lpeco_loadcap_range_t  capValue,
cy_en_clkbak_lpeco_frequency_range_t  freqValue,
cy_en_clkbak_lpeco_max_amplitude_t  ampValue,
bool  ampDetEn 
)

Configures the low-power external crystal oscillator based on crystal characteristics.

Parameters
capValuecy_en_clkbak_lpeco_loadcap_range_t
freqValuecy_en_clkbak_lpeco_frequency_range_t
ampValuecy_en_clkbak_lpeco_max_amplitude_t
ampDetEnEnable amplitude detection always (true) or only on init (false)
Note
This API is available for TVIIC devices.
Function Usage
/* Scenario: LPECO needs to be configured. The LPECO pins are configured
using the gpio driver (SRSS_LPECO_IN_PIN, SRSS_LPECO_OUT_PIN).
The LPECO crystal has the following characteristics:
Frequency: 8.00 MHz
Load capacitance: 18 pF */
/* Disable the LPECO before configuring */
/* Configure the LPECO with its characteristics */
true))
{
/* Insert error handling */
}
/* Enable the LPECO with a timeout of 3000 microseconds */
{
/* Insert error handling */
}

◆ Cy_SysClk_LpEcoEnable()

cy_en_sysclk_status_t Cy_SysClk_LpEcoEnable ( uint32_t  timeoutus)

Enables the low-power external crystal oscillator (LPECO).

This function should be called after Cy_SysClk_LpEcoConfigure.

Parameters
timeoutusAmount of time in microseconds to wait for the LPECO to stabilize. To avoid waiting for stabilization, set this parameter to 0.
Returns
Error / status code:
CY_SYSCLK_SUCCESS - ECO locked
CY_SYSCLK_TIMEOUT - ECO timed out and did not lock
CY_SYSCLK_INVALID_STATE - ECO already enabled
Note
Call SystemCoreClockUpdate after this function calling if it affects the CLK_HF0 or CLK_HF1 frequency.
This API is available for TVIIC devices.
Function Usage
/* Scenario: LPECO is successfully configured and needs to be enabled. The
LPECO pins are configured using the gpio driver
(SRSS_LPECO_IN_PIN, SRSS_LPECO_OUT_PIN). */
uint32_t lpecofreq = 0UL; /* Variable to store the LPECO frequency */
/* Enable the LPECO with a timeout of 5000 microseconds */
{
/* Now lpecofreq contains an actual LPECO frequency */
}
else
{
/* Insert error handling */
}
/* Set the path muxes and configure the downstream clocks. For example,
the LPECO can source the FLL through path 0 clock or it can source the
PLL through path 1 clock. */

◆ Cy_SysClk_LpEcoDisable()

void Cy_SysClk_LpEcoDisable ( void  )

Disables the low-power external crystal oscillator (LPECO).

This function should not be called if the LPECO is sourcing clkHf[0] or clkHf[1].

Note
This API is available for TVIIC devices.
Function Usage
/* Scenario: LPECO sources path 2 clock, which sources HFCLK2. The LPECO
needs to be disabled and replaced with the IMO for HFCLK2. */
/* Update the path 2 clock to IMO */
/* Disable the LPECO */

◆ Cy_SysClk_LpEcoSetFrequency()

void Cy_SysClk_LpEcoSetFrequency ( uint32_t  freq)

Stores the low-power external crystal oscillator (LPECO) frequency in a global variable within Sysclk driver.

Parameters
freqOperating frequency of the crystal in Hz. Valid range: 3990000...8010000 (3.99..8.01 MHz).
Note
This API is available for TVIIC devices.

◆ Cy_SysClk_LpEcoGetFrequency()

uint32_t Cy_SysClk_LpEcoGetFrequency ( void  )

Returns the frequency of the low-power external crystal oscillator (LPECO).

Returns
The frequency of the LPECO in Hz.
Note
If the LPECO is not enabled or stable - a zero is returned.
This API is available for TVIIC devices.

◆ Cy_SysClk_LpEcoPrescaleConfigure()

cy_en_sysclk_status_t Cy_SysClk_LpEcoPrescaleConfigure ( bool  enable,
uint32_t  int_div,
uint32_t  frac_div 
)

Configures the low-power external crystal oscillator (LPECO) Prescaler and derives clk_lpeco_prescaler.

Parameters
enableLPECO Prescaler enable/disable.
int_div10-bit integer value. Subtract one from the desired divide value when using this parameter. For example , to divide by 1, int_div should be set to 0.
frac_div8-bit fraction value.
Returns
Error / status code:
CY_SYSCLK_SUCCESS - LPECO prescaler configuration completed successfully
CY_SYSCLK_BAD_PARAM - One or more invalid parameters
CY_SYSCLK_INVALID_STATE - LPECO already enabled
Note
This API is available for TVIIC devices.
Function Usage
/* Scenario: LPECO is successfully enabled and the LPECO prescaler needs
to be configured to run the RTC. The LPECO is running at
8.00 MHz and needs to be divided down to 32.768 kHz. */
/* divider value = 8000000 / 32768 = 244.140625 */
/* int_div = 244 - 1 = 243 */
/* frac_div = 256 * 0.140625 = 36 */
{
/* Insert error handling */
}

◆ Cy_SysClk_LpEcoPrescaleIsEnabled()

bool Cy_SysClk_LpEcoPrescaleIsEnabled ( void  )

Reports whether or not LPECO Prescale is enabled.

Returns
false = disabled
true = enabled
Note
This API is available for TVIIC devices.

◆ Cy_SysClk_LpEcoAmplitudeOkay()

bool Cy_SysClk_LpEcoAmplitudeOkay ( void  )

Reports the current status of the low-power external crystal oscillator (LPECO) amplitude detection.

Returns
false = Insufficient oscillation amplitude OR the amplitude detector is off
true = Sufficient oscillation amplitude is detected
Note
This API is available for TVIIC devices.
Function Usage
/* Scenario: Query the status of the LPECO amplitude detector and take
action based on the results. */
{
/* Oscillation amplitude is sufficient */
}
else
{
/* Oscillation amplitude is not sufficient OR amplitude detection is
disabled */
}

◆ Cy_SysClk_LpEcoIsReady()

bool Cy_SysClk_LpEcoIsReady ( void  )

Indicates whether or not the low-power external crystal oscillator (LPECO) has had enough time to start.

Returns
false = LPECO not stable
true = LPECO stable
Note
This API is available for TVIIC devices.
Function Usage
/* Scenario: Query the LPECO status to see if it has started and take
action based on the results. */
{
/* The LPECO has had enough time to start */
}
else
{
/* The LPECO has not started */
}