CAT2 Peripheral Driver Library

Functions

cy_en_wdc_status_t Cy_WDC_Init (WCO_Type *base, cy_stc_wdc_config_t const *config)
 Initializes the WDC block. More...
 
void Cy_WDC_DeInit (WCO_Type *base)
 De-initializes the WDC block, returns register values to their default state. More...
 
__STATIC_INLINE void Cy_WDC_Enable (WCO_Type *base, uint32_t counters, uint16_t waitUs)
 Enables all specified counters. More...
 
__STATIC_INLINE void Cy_WDC_Disable (WCO_Type *base, uint32_t counters, uint16_t waitUs)
 Disables all specified counters. More...
 
__STATIC_INLINE uint32_t Cy_WDC_GetEnabledStatus (WCO_Type const *base, cy_en_wdc_ctr_t counter)
 Reports the enabled status of the specified counter. More...
 
__STATIC_INLINE void Cy_WDC_InterruptEnable (WCO_Type *base, cy_en_wdc_ctr_t counter)
 Enables interrupt generation for the specified counter. More...
 
__STATIC_INLINE void Cy_WDC_InterruptDisable (WCO_Type *base, cy_en_wdc_ctr_t counter)
 Disables interrupt generation for the specified counter. More...
 
__STATIC_INLINE bool Cy_WDC_GetInterruptSetting (WCO_Type const *base, cy_en_wdc_ctr_t counter)
 Reports interrupt setting for specified counter. More...
 
__STATIC_INLINE void Cy_WDC_SetClearOnMatch (WCO_Type *base, cy_en_wdc_ctr_t counter, uint32_t enable)
 Sets the Clear on match option for the specified counter. More...
 
__STATIC_INLINE uint32_t Cy_WDC_GetClearOnMatch (WCO_Type const *base, cy_en_wdc_ctr_t counter)
 Reports the Clear on match setting for the specified counter. More...
 
__STATIC_INLINE void Cy_WDC_SetCascade (WCO_Type *base, uint32_t cascade)
 Sets all the counter cascade options. More...
 
__STATIC_INLINE uint32_t Cy_WDC_GetCascade (WCO_Type const *base)
 Reports all the counter cascade option settings. More...
 
__STATIC_INLINE void Cy_WDC_SetMatch (WCO_Type *base, cy_en_wdc_ctr_t counter, uint32_t match, uint16_t waitUs)
 Sets the match comparison value for the specified counter (0 or 1). More...
 
__STATIC_INLINE uint32_t Cy_WDC_GetMatch (WCO_Type const *base, cy_en_wdc_ctr_t counter)
 Reports the match comparison value for the specified counter (0 or 1). More...
 
__STATIC_INLINE void Cy_WDC_SetToggleBit (WCO_Type *base, uint32_t bit)
 Sets a bit in Counter 2 to monitor for a toggle. More...
 
__STATIC_INLINE uint32_t Cy_WDC_GetToggleBit (WCO_Type const *base)
 Reports which bit in Counter 2 is monitored for a toggle. More...
 
__STATIC_INLINE uint32_t Cy_WDC_GetCount (WCO_Type const *base, cy_en_wdc_ctr_t counter)
 Reports the current counter value of the specified counter. More...
 
__STATIC_INLINE void Cy_WDC_ResetCounters (WCO_Type *base, uint32_t counters, uint16_t waitUs)
 Resets all specified counters. More...
 
__STATIC_INLINE uint32_t Cy_WDC_GetInterruptStatus (WCO_Type const *base)
 Reports the state of all WDC interrupts. More...
 
__STATIC_INLINE void Cy_WDC_ClearInterrupt (WCO_Type *base, uint32_t counters)
 Clears all specified WDC interrupts. More...
 
uint32_t Cy_WDC_GetCountCascaded (WCO_Type const *base)
 Reports the current value of combined C1-C0 cascaded counters. More...
 
__STATIC_INLINE cy_en_wdc_clock_t Cy_WDC_GetClockSource (WCO_Type const *base)
 Returns the clock source for WDC timers. More...
 
void Cy_WDC_SetClockSource (WCO_Type *base, cy_en_wdc_clock_t source)
 Sets the clock source for WDC timers. More...
 

Detailed Description

Function Documentation

◆ Cy_WDC_Init()

cy_en_wdc_status_t Cy_WDC_Init ( WCO_Type *  base,
cy_stc_wdc_config_t const *  config 
)

Initializes the WDC block.

Parameters
baseThe base pointer to a structure that describes the registers.
configThe pointer to a structure that contains component configuration data.
Returns
cy_en_wdc_status_t Returns an error if any of the structure pointers is NULL.
Note
Do not call this function when the counters are running. First, disable counters using Cy_WDC_Disable.
This function waits four WDC clock source cycles in order to set the WDC clock source.

◆ Cy_WDC_DeInit()

void Cy_WDC_DeInit ( WCO_Type *  base)

De-initializes the WDC block, returns register values to their default state.

Parameters
baseThe base pointer to a structure that describes the registers.
Note
Do not call this function when the counters are running. First, disable counters using Cy_WDC_Disable.
Call this function only after calling the Cy_WDC_Init() function.
This function does not reset the WDC match value.
This function takes 10 WDC clock source cycles in order perform de-initialization.

◆ Cy_WDC_Enable()

__STATIC_INLINE void Cy_WDC_Enable ( WCO_Type *  base,
uint32_t  counters,
uint16_t  waitUs 
)

Enables all specified counters.

Parameters
baseThe base pointer to a structure that describes registers.
countersOR of all counters to enable. See the CY_WDC_COUNTER0_Msk, CY_WDC_COUNTER1_Msk, and CY_WDC_COUNTER2_Msk macros.
waitUsThe function waits for some delay in microseconds before returning, because the counter begins counting after three WDC clock-source cycles pass. The recommended waitUs parameter value is defined by CY_WDC_CLK_ILO_3CYCLES_US and CY_WDC_CLK_WCO_3CYCLES_US macros.
Note
Setting this parameter to a zero means No wait. In this case, it is the user's responsibility to check whether the selected counters were enabled immediately after the function call. This can be done by the Cy_WDC_GetEnabledStatus() API.

◆ Cy_WDC_Disable()

__STATIC_INLINE void Cy_WDC_Disable ( WCO_Type *  base,
uint32_t  counters,
uint16_t  waitUs 
)

Disables all specified counters.

Parameters
baseThe base pointer to a structure describing registers.
countersOR of all counters to disable. See the CY_WDC_COUNTER0_Msk, CY_WDC_COUNTER1_Msk, and CY_WDC_COUNTER2_Msk macros.
waitUsThe function waits for some delay in microseconds before returning, because the counter stops counting after three WDC clock source cycles pass. The recommended waitUs parameter value is defined by CY_WDC_CLK_ILO_3CYCLES_US and CY_WDC_CLK_WCO_3CYCLES_US macros.
Note
Setting this parameter to a zero means No wait. In this case, it is the user's responsibility to check whether the selected counters were disabled immediately after the function call. This can be done by the Cy_WDC_GetEnabledStatus() API.

◆ Cy_WDC_GetEnabledStatus()

__STATIC_INLINE uint32_t Cy_WDC_GetEnabledStatus ( WCO_Type const *  base,
cy_en_wdc_ctr_t  counter 
)

Reports the enabled status of the specified counter.

Parameters
baseThe base pointer to a structure that describes registers.
counterThe number of the WDT counter. See cy_en_wdc_ctr_t
Returns
The status of the WDC counter: 0 = disabled, 1 = enabled.

◆ Cy_WDC_InterruptEnable()

__STATIC_INLINE void Cy_WDC_InterruptEnable ( WCO_Type *  base,
cy_en_wdc_ctr_t  counter 
)

Enables interrupt generation for the specified counter.

Parameters
baseThe base pointer to a structure that describes registers.
counterThe number of the WDT counter. See cy_en_wdc_ctr_t
Note
Do not call this function while the counters are running. Disable the counter prior to calling this function using Cy_WDC_Disable.

◆ Cy_WDC_InterruptDisable()

__STATIC_INLINE void Cy_WDC_InterruptDisable ( WCO_Type *  base,
cy_en_wdc_ctr_t  counter 
)

Disables interrupt generation for the specified counter.

Parameters
baseThe base pointer to a structure that describes registers.
counterThe number of the WDT counter. See cy_en_wdc_ctr_t
Note
Do not call tis function while the counters are running. Disable the counter prior to calling this function using Cy_WDC_Disable.

◆ Cy_WDC_GetInterruptSetting()

__STATIC_INLINE bool Cy_WDC_GetInterruptSetting ( WCO_Type const *  base,
cy_en_wdc_ctr_t  counter 
)

Reports interrupt setting for specified counter.

Parameters
baseThe base pointer to a structure that describes registers.
counterThe number of the WDT counter. See cy_en_wdc_ctr_t
Returns
The current setting of the counter. true - interrupt enabled false - interrupt disabled.

◆ Cy_WDC_SetClearOnMatch()

__STATIC_INLINE void Cy_WDC_SetClearOnMatch ( WCO_Type *  base,
cy_en_wdc_ctr_t  counter,
uint32_t  enable 
)

Sets the Clear on match option for the specified counter.

Parameters
baseThe base pointer to a structure that describes registers.
counterThe number of the WDT counter. See cy_en_wdc_ctr_t
Note
The match values are not supported by Counter 2.
Parameters
enableSet 0 to disable; 1 to enable.
Note
Do not call this function while the counters are running. Disable the counter prior to calling this function using Cy_WDC_Disable.

◆ Cy_WDC_GetClearOnMatch()

__STATIC_INLINE uint32_t Cy_WDC_GetClearOnMatch ( WCO_Type const *  base,
cy_en_wdc_ctr_t  counter 
)

Reports the Clear on match setting for the specified counter.

Parameters
baseThe base pointer to a structure that describes registers.
counterThe number of the WDT counter. See cy_en_wdc_ctr_t
Returns
The Clear on match status: 1 = enabled, 0 = disabled.
Note
The match value is not supported by Counter 2.

◆ Cy_WDC_SetCascade()

__STATIC_INLINE void Cy_WDC_SetCascade ( WCO_Type *  base,
uint32_t  cascade 
)

Sets all the counter cascade options.

Parameters
baseThe base pointer to a structure that describes registers.
cascadeSets or clears each of the cascade options Cascading Masks.
Note
Do not call this function when the counters are running. Disable counters to be cascaded prior to calling this function using Cy_WDC_Disable.
When cascading all three counters, enable the Clear on match option for counter 1.

◆ Cy_WDC_GetCascade()

__STATIC_INLINE uint32_t Cy_WDC_GetCascade ( WCO_Type const *  base)

Reports all the counter cascade option settings.

Parameters
baseThe base pointer to a structure that describes registers.
Returns
The current cascade option values Cascading Masks.

◆ Cy_WDC_SetMatch()

__STATIC_INLINE void Cy_WDC_SetMatch ( WCO_Type *  base,
cy_en_wdc_ctr_t  counter,
uint32_t  match,
uint16_t  waitUs 
)

Sets the match comparison value for the specified counter (0 or 1).

Parameters
baseThe base pointer to a structure that describes registers.
counterThe number of the WDT counter. See cy_en_wdc_ctr_t
matchThe value to match against the counter. The valid range is [0-65535] for c0ClearOnMatch (or c1ClearOnMatch) = 0 and [1-65535] for c0ClearOnMatch (or c1ClearOnMatch) = 1.
Note
The match value is not supported by Counter 2.
The match is done on the next increment after the counter value equals the match value.
Parameters
waitUsThe function waits for some delay in microseconds before returning, because the match affects after three WDC clock source cycles pass. The recommended waitUs parameter value is defined by CY_WDC_CLK_ILO_3CYCLES_US and CY_WDC_CLK_WCO_3CYCLES_US macros.
Note
Setting this parameter to a zero means No wait. Take this into account when changing the match values on the running counters.

◆ Cy_WDC_GetMatch()

__STATIC_INLINE uint32_t Cy_WDC_GetMatch ( WCO_Type const *  base,
cy_en_wdc_ctr_t  counter 
)

Reports the match comparison value for the specified counter (0 or 1).

Parameters
baseThe base pointer to a structure that describes registers.
counterThe number of the WDT counter. See cy_en_wdc_ctr_t
Note
The match values are not supported by Counter 2.
Returns
A 16-bit match value.

◆ Cy_WDC_SetToggleBit()

__STATIC_INLINE void Cy_WDC_SetToggleBit ( WCO_Type *  base,
uint32_t  bit 
)

Sets a bit in Counter 2 to monitor for a toggle.

Parameters
baseThe base pointer to a structure that describes registers.
bitThe Counter 2 bit is set to monitor for a toggle. The valid range [0-31].
Note
Do not call this function when the counter is running. Disable the counter prior to calling this function using Cy_WDC_Disable.

◆ Cy_WDC_GetToggleBit()

__STATIC_INLINE uint32_t Cy_WDC_GetToggleBit ( WCO_Type const *  base)

Reports which bit in Counter 2 is monitored for a toggle.

Parameters
baseThe base pointer to a structure that describes registers.
Returns
The bit that is monitored (range 0 to 31).

◆ Cy_WDC_GetCount()

__STATIC_INLINE uint32_t Cy_WDC_GetCount ( WCO_Type const *  base,
cy_en_wdc_ctr_t  counter 
)

Reports the current counter value of the specified counter.

Parameters
baseThe base pointer to a structure that describes registers.
counterThe number of the WDT counter. See cy_en_wdc_ctr_t
Returns
A live counter value. Counters 0 and 1 are 16-bit counters and Counter 2 is a 32-bit counter.

◆ Cy_WDC_ResetCounters()

__STATIC_INLINE void Cy_WDC_ResetCounters ( WCO_Type *  base,
uint32_t  counters,
uint16_t  waitUs 
)

Resets all specified counters.

Parameters
baseThe base pointer to a structure that describes registers.
countersOR of all counters to reset. See the CY_WDC_COUNTER0_Msk, CY_WDC_COUNTER1_Msk, and CY_WDC_COUNTER2_Msk macros.
waitUsThe function waits for some delay in microseconds before returning, because a reset occurs after three WDC clock source cycle passes. The recommended waitUs parameter value is defined by CY_WDC_CLK_ILO_3CYCLES_US and CY_WDC_CLK_WCO_3CYCLES_US macros.
Note
Setting this parameter to a zero means No wait. In this case, it is the user's responsibility to check whether the selected counters were reset immediately after the function call. This can be done by the Cy_WDC_GetCount() API.

◆ Cy_WDC_GetInterruptStatus()

__STATIC_INLINE uint32_t Cy_WDC_GetInterruptStatus ( WCO_Type const *  base)

Reports the state of all WDC interrupts.

Parameters
baseThe base pointer to a structure that describes registers.
Returns
The OR'd state of the interrupts. See the CY_WDC_COUNTER0_Msk, CY_WDC_COUNTER1_Msk, and CY_WDC_COUNTER2_Msk macros.

◆ Cy_WDC_ClearInterrupt()

__STATIC_INLINE void Cy_WDC_ClearInterrupt ( WCO_Type *  base,
uint32_t  counters 
)

Clears all specified WDC interrupts.

All the WDT interrupts must be cleared by the firmware; otherwise interrupts are generated continuously.

Parameters
baseThe base pointer to a structure describes registers.
countersOR of all interrupt sources to clear. See the CY_WDC_COUNTER0_Msk, CY_WDC_COUNTER1_Msk, and CY_WDC_COUNTER2_Msk macros.

◆ Cy_WDC_GetCountCascaded()

uint32_t Cy_WDC_GetCountCascaded ( WCO_Type const *  base)

Reports the current value of combined C1-C0 cascaded counters.

Parameters
baseThe base pointer to a structure that describes the registers.
Note
Enable both counters, and cascade C0 to C1 before calling this function. C2 is not reported. Instead, to get a 64-bit C2-C1-C0 cascaded value, call this function followed by Cy_WDC_GetCount(base, CY_WDC_COUNTER2), and then combine the results.
This function does not return the correct result when it is called after the Cy_WDC_Enable() or Cy_WDC_ResetCounters() function with a delay less than three WDC clock source cycles. The recommended waitUs parameter value is defined by CY_WDC_CLK_ILO_3CYCLES_US and CY_WDC_CLK_WCO_3CYCLES_US macros.
Returns
The value of combined C1-C0 cascaded counters.

◆ Cy_WDC_GetClockSource()

__STATIC_INLINE cy_en_wdc_clock_t Cy_WDC_GetClockSource ( WCO_Type const *  base)

Returns the clock source for WDC timers.

Parameters
baseThe base pointer to a structure describes registers.
Returns
The WDC timers clock source. See cy_en_wdc_clock_t

◆ Cy_WDC_SetClockSource()

void Cy_WDC_SetClockSource ( WCO_Type *  base,
cy_en_wdc_clock_t  source 
)

Sets the clock source for WDC timers.

Parameters
baseThe base pointer to a structure describes registers.
sourceWDC timers clock source. See cy_en_wdc_clock_t
Warning
WDC reset is required if counters source was switched while any of the counters were running. Call the Cy_WDC_ResetCounters() function after WDC source switching. It is highly recommended to disable WDC before clock source switching. Changing the WDC clock source may change the functionality that uses WDC as the clock source.