MTB CAT1 Peripheral driver library

General Description

Functions

cy_en_tcpwm_status_t Cy_TCPWM_QuadDec_Init (TCPWM_Type *base, uint32_t cntNum, cy_stc_tcpwm_quaddec_config_t const *config)
 Initializes the counter in the TCPWM block for the QuadDec operation. More...
 
void Cy_TCPWM_QuadDec_DeInit (TCPWM_Type *base, uint32_t cntNum, cy_stc_tcpwm_quaddec_config_t const *config)
 De-initializes the counter in the TCPWM block, returns register values to default. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_Enable (TCPWM_Type *base, uint32_t cntNum)
 Enables the counter in the TCPWM block for the QuadDec operation. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_Disable (TCPWM_Type *base, uint32_t cntNum)
 Disables the counter in the TCPWM block. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetStatus (TCPWM_Type const *base, uint32_t cntNum)
 Returns the status of the QuadDec whether it is running or not. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCapture0Val (TCPWM_Type const *base, uint32_t cntNum)
 Returns the capture value. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCapture0BufVal (TCPWM_Type const *base, uint32_t cntNum)
 Returns the buffered capture value. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCompare0Val (TCPWM_Type *base, uint32_t cntNum, uint32_t compare0)
 Sets the compare value for Compare0 when the compare mode is enabled. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCompare0Val (TCPWM_Type const *base, uint32_t cntNum)
 Returns compare 0 value. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCompare0BufVal (TCPWM_Type *base, uint32_t cntNum, uint32_t compareBuf0)
 Sets the Buffered Compare 0 value when the compare mode is enabled. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCompare0BufVal (TCPWM_Type const *base, uint32_t cntNum)
 Returns Buffered Compare 0 Value. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_EnableCompare0Swap (TCPWM_Type *base, uint32_t cntNum, bool enable)
 Enables the comparison swap of compare 0 and compareBuf 0 when the comparison value is true. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCounter (TCPWM_Type *base, uint32_t cntNum, uint32_t count)
 Sets the value of the counter. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCounter (TCPWM_Type const *base, uint32_t cntNum)
 Returns the value in the counter. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCapture1Val (TCPWM_Type const *base, uint32_t cntNum)
 Returns capture 1 value when capture mode is enabled. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCapture1BufVal (TCPWM_Type const *base, uint32_t cntNum)
 Returns the buffered capture 1 value when capture mode is enabled. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCompare1Val (TCPWM_Type const *base, uint32_t cntNum)
 Returns compare 1 value. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCompare1BufVal (TCPWM_Type const *base, uint32_t cntNum)
 Returns the buffered compare 1 value. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCompare1Val (TCPWM_Type *base, uint32_t cntNum, uint32_t compare1)
 Sets the compare value for Compare 1 when the compare mode enabled. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCompare1BufVal (TCPWM_Type *base, uint32_t cntNum, uint32_t compareBuf1)
 Sets the buffered compare value for Compare 1 when the compare mode enabled. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_EnableCompare1Swap (TCPWM_Type *base, uint32_t cntNum, bool enable)
 Enables the comparison swap of compare 1 and compareBuf 1 when the comparison value is true. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_SetPeriod0 (TCPWM_Type *base, uint32_t cntNum, uint32_t period0)
 Sets the value of the period register. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetPeriod0 (TCPWM_Type const *base, uint32_t cntNum)
 Returns the value in the period 0 register. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_SetPeriod1 (TCPWM_Type *base, uint32_t cntNum, uint32_t period1)
 Sets the value of the period register. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetPeriod1 (TCPWM_Type const *base, uint32_t cntNum)
 Returns the value in the period 1 register. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_TriggerIndex1 (TCPWM_Type *base, uint32_t cntNum)
 Triggers a software index 1. More...
 
__STATIC_INLINE void Cy_TCPWM_QuadDec_EnableSwap (TCPWM_Type *base, uint32_t cntNum, bool enable)
 Enables/disables swapping mechanism between CC0 and buffered CC0, CC1 and buffered CC1, PERIOD and buffered PERIOD, DT and buffered DT. More...
 

Function Documentation

◆ Cy_TCPWM_QuadDec_Init()

cy_en_tcpwm_status_t Cy_TCPWM_QuadDec_Init ( TCPWM_Type base,
uint32_t  cntNum,
cy_stc_tcpwm_quaddec_config_t const *  config 
)

Initializes the counter in the TCPWM block for the QuadDec operation.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
configThe pointer to a configuration structure. See cy_stc_tcpwm_quaddec_config_t.
Returns
error / status code. See cy_en_tcpwm_status_t.
Function Usage
/* Scenario: there is need to initialize
* the first (index = 0) quadrature decoder of the TCPWM0 block
* with the below configuration settings
*/
cy_stc_tcpwm_quaddec_config_t tcpwm_v1_qd_config =
{
/* .resolution = */ CY_TCPWM_QUADDEC_X1, /* One count during one encoder cycle */
/* .interruptSources = */ CY_TCPWM_INT_ON_TC, /* Simple example without index input */
/* .indexInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
/* .indexInput = */ CY_TCPWM_INPUT_0, /* The index input is not used */
/* .stopInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
/* .stopInput = */ CY_TCPWM_INPUT_0, /* The stop input is not used, the block will be stopped by SW */
/* .phiAInput = */ CY_TCPWM_INPUT_TRIG_0, /* The phiA input is connected to the trigger multiplexer #0 of the Trigger Group #3 */
/* .phiBInput = */ CY_TCPWM_INPUT_TRIG_1, /* The phiB input is connected to the trigger multiplexer #1 of the Trigger Group #3 */
};
#define MY_TCPWM_CNT_NUM (0UL)
if (CY_TCPWM_SUCCESS != Cy_TCPWM_QuadDec_Init(TCPWM0, MY_TCPWM_CNT_NUM, &tcpwm_v1_qd_config))
{
/* Handle possible errors */
}
/* Enabled the initialized quadrature decoder */
Cy_TCPWM_QuadDec_Enable(TCPWM0, MY_TCPWM_CNT_NUM);
/* Then start the decoder */
Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* Scenario: there is need to initialize
* the first (index = 0) quadrature decoder of the TCPWM0 block
* with the below configuration settings
*/
cy_stc_tcpwm_quaddec_config_t tcpwm_v2_qd_config =
{
/* .resolution = */ CY_TCPWM_QUADDEC_X1, /* One count during one encoder cycle */
/* .interruptSources = */ CY_TCPWM_INT_ON_TC, /* Simple example without index input */
/* .indexInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
/* .indexInput = */ CY_TCPWM_INPUT_0, /* The index input is not used */
/* .stopInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
/* .stopInput = */ CY_TCPWM_INPUT_0, /* The stop input is not used, the block will be stopped by SW */
/* .phiAInput = */ CY_TCPWM_INPUT_TRIG(0), /* The phiA input is connected to the trigger multiplexer #0 of the Trigger Group #3 */
/* .phiBInput = */ CY_TCPWM_INPUT_TRIG(1), /* The phiB input is connected to the trigger multiplexer #1 of the Trigger Group #3 */
/* .phiAInputMode = */ CY_TCPWM_INPUT_LEVEL, /* Pass through (no edge detection) */
/* .phiBInputMode = */ CY_TCPWM_INPUT_LEVEL, /* Pass through (no edge detection) */
/* .quadmode = */ CY_TCPWM_QUADDEC_MODE_RANGE0, /* Quad mode */
/* .period0 = */ 0UL, /* Period 0 Value */
/* .captureOnIndex = */ CY_TCPWM_QUADDEC_CAPTURE_ON_INDEX, /* Capture On Index event */
/* .compare0 = */ 0Ul, /* Sets the value for Compare 0 */
/* .compareBuf0 = */ 0UL, /* Sets the value for the buffered Compare 0 */
/* .enableCompare0Swap = */ false, /* If enabled, the compare 0 values are swapped on the terminal count */
/* .compare1 = */ 0UL, /* Sets the value for Compare 1 */
/* .compareBuf1 = */ 0UL, /* Sets the value for the buffered Compare 0 */
/* .enableCompare1Swap = */ false, /* If enabled, the compare 0 values are swapped on the terminal count */
/* .capture0OrIndex1InputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* Configures how the capture0/index1 input behaves.*/
/* .capture0OrIndex1Input = */ CY_TCPWM_INPUT_0, /* Selects which input the capture0/index1 uses. The inputs are device-specific. */
/* .capture1InputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* Configures how the capture1 input behaves. */
/* .capture1Input = */ CY_TCPWM_INPUT_0, /* Selects which input the capture1 uses. The inputs are device-specific. */
/* .trigger0Event = */ CY_TCPWM_CNT_TRIGGER_ON_DISABLED, /* Disable output trigger0 event generation*/
/* .trigger1Event = */ CY_TCPWM_CNT_TRIGGER_ON_DISABLED, /* Disable output trigger1 event generation*/
};
#define MY_TCPWM_CNT_NUM (0UL)
if (CY_TCPWM_SUCCESS != Cy_TCPWM_QuadDec_Init(TCPWM0, MY_TCPWM_CNT_NUM, &tcpwm_v2_qd_config))
{
/* Handle possible errors */
}
/* Enabled the initialized quadrature decoder */
Cy_TCPWM_QuadDec_Enable(TCPWM0, MY_TCPWM_CNT_NUM);
/* Then start the decoder */
Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_DeInit()

void Cy_TCPWM_QuadDec_DeInit ( TCPWM_Type base,
uint32_t  cntNum,
cy_stc_tcpwm_quaddec_config_t const *  config 
)

De-initializes the counter in the TCPWM block, returns register values to default.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
configThe pointer to a configuration structure. See cy_stc_tcpwm_quaddec_config_t.
Function Usage
/* Scenario: there is need to deinitialize the previously initialized block */
#define MY_TCPWM_CNT_NUM (0UL)
/* Disable the counter prior to deinitializing */
Cy_TCPWM_QuadDec_Disable(TCPWM0, MY_TCPWM_CNT_NUM);
Cy_TCPWM_QuadDec_DeInit(TCPWM0, MY_TCPWM_CNT_NUM, &config);

◆ Cy_TCPWM_QuadDec_Enable()

__STATIC_INLINE void Cy_TCPWM_QuadDec_Enable ( TCPWM_Type base,
uint32_t  cntNum 
)

Enables the counter in the TCPWM block for the QuadDec operation.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Function Usage
/* Scenario: there is need to initialize
* the first (index = 0) quadrature decoder of the TCPWM0 block
* with the below configuration settings
*/
cy_stc_tcpwm_quaddec_config_t tcpwm_v1_qd_config =
{
/* .resolution = */ CY_TCPWM_QUADDEC_X1, /* One count during one encoder cycle */
/* .interruptSources = */ CY_TCPWM_INT_ON_TC, /* Simple example without index input */
/* .indexInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
/* .indexInput = */ CY_TCPWM_INPUT_0, /* The index input is not used */
/* .stopInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
/* .stopInput = */ CY_TCPWM_INPUT_0, /* The stop input is not used, the block will be stopped by SW */
/* .phiAInput = */ CY_TCPWM_INPUT_TRIG_0, /* The phiA input is connected to the trigger multiplexer #0 of the Trigger Group #3 */
/* .phiBInput = */ CY_TCPWM_INPUT_TRIG_1, /* The phiB input is connected to the trigger multiplexer #1 of the Trigger Group #3 */
};
#define MY_TCPWM_CNT_NUM (0UL)
if (CY_TCPWM_SUCCESS != Cy_TCPWM_QuadDec_Init(TCPWM0, MY_TCPWM_CNT_NUM, &tcpwm_v1_qd_config))
{
/* Handle possible errors */
}
/* Enabled the initialized quadrature decoder */
Cy_TCPWM_QuadDec_Enable(TCPWM0, MY_TCPWM_CNT_NUM);
/* Then start the decoder */
Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* Scenario: there is need to initialize
* the first (index = 0) quadrature decoder of the TCPWM0 block
* with the below configuration settings
*/
cy_stc_tcpwm_quaddec_config_t tcpwm_v2_qd_config =
{
/* .resolution = */ CY_TCPWM_QUADDEC_X1, /* One count during one encoder cycle */
/* .interruptSources = */ CY_TCPWM_INT_ON_TC, /* Simple example without index input */
/* .indexInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
/* .indexInput = */ CY_TCPWM_INPUT_0, /* The index input is not used */
/* .stopInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
/* .stopInput = */ CY_TCPWM_INPUT_0, /* The stop input is not used, the block will be stopped by SW */
/* .phiAInput = */ CY_TCPWM_INPUT_TRIG(0), /* The phiA input is connected to the trigger multiplexer #0 of the Trigger Group #3 */
/* .phiBInput = */ CY_TCPWM_INPUT_TRIG(1), /* The phiB input is connected to the trigger multiplexer #1 of the Trigger Group #3 */
/* .phiAInputMode = */ CY_TCPWM_INPUT_LEVEL, /* Pass through (no edge detection) */
/* .phiBInputMode = */ CY_TCPWM_INPUT_LEVEL, /* Pass through (no edge detection) */
/* .quadmode = */ CY_TCPWM_QUADDEC_MODE_RANGE0, /* Quad mode */
/* .period0 = */ 0UL, /* Period 0 Value */
/* .captureOnIndex = */ CY_TCPWM_QUADDEC_CAPTURE_ON_INDEX, /* Capture On Index event */
/* .compare0 = */ 0Ul, /* Sets the value for Compare 0 */
/* .compareBuf0 = */ 0UL, /* Sets the value for the buffered Compare 0 */
/* .enableCompare0Swap = */ false, /* If enabled, the compare 0 values are swapped on the terminal count */
/* .compare1 = */ 0UL, /* Sets the value for Compare 1 */
/* .compareBuf1 = */ 0UL, /* Sets the value for the buffered Compare 0 */
/* .enableCompare1Swap = */ false, /* If enabled, the compare 0 values are swapped on the terminal count */
/* .capture0OrIndex1InputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* Configures how the capture0/index1 input behaves.*/
/* .capture0OrIndex1Input = */ CY_TCPWM_INPUT_0, /* Selects which input the capture0/index1 uses. The inputs are device-specific. */
/* .capture1InputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* Configures how the capture1 input behaves. */
/* .capture1Input = */ CY_TCPWM_INPUT_0, /* Selects which input the capture1 uses. The inputs are device-specific. */
/* .trigger0Event = */ CY_TCPWM_CNT_TRIGGER_ON_DISABLED, /* Disable output trigger0 event generation*/
/* .trigger1Event = */ CY_TCPWM_CNT_TRIGGER_ON_DISABLED, /* Disable output trigger1 event generation*/
};
#define MY_TCPWM_CNT_NUM (0UL)
if (CY_TCPWM_SUCCESS != Cy_TCPWM_QuadDec_Init(TCPWM0, MY_TCPWM_CNT_NUM, &tcpwm_v2_qd_config))
{
/* Handle possible errors */
}
/* Enabled the initialized quadrature decoder */
Cy_TCPWM_QuadDec_Enable(TCPWM0, MY_TCPWM_CNT_NUM);
/* Then start the decoder */
Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_Disable()

__STATIC_INLINE void Cy_TCPWM_QuadDec_Disable ( TCPWM_Type base,
uint32_t  cntNum 
)

Disables the counter in the TCPWM block.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Function Usage
/* Scenario: there is need to deinitialize the previously initialized block */
#define MY_TCPWM_CNT_NUM (0UL)
/* Disable the counter prior to deinitializing */
Cy_TCPWM_QuadDec_Disable(TCPWM0, MY_TCPWM_CNT_NUM);
Cy_TCPWM_QuadDec_DeInit(TCPWM0, MY_TCPWM_CNT_NUM, &config);

◆ Cy_TCPWM_QuadDec_GetStatus()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetStatus ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the status of the QuadDec whether it is running or not.

In case the QuadDec is running, status will also provide information on counting up/down.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
The status. See QuadDec Status
Note
The status value is not the same as in TCPWM status register.
Function Usage
/* Scenario: there is a need to check if
* the first (index = 0) quadrature decoder of the TCPWM0 block is running or not.
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t status = Cy_TCPWM_QuadDec_GetStatus(TCPWM0, MY_TCPWM_CNT_NUM);
{
/* Up Counting */
}
{
/* Down Counting */
}
else
{
/* QuadDec is not running */
}

◆ Cy_TCPWM_QuadDec_GetCapture0Val()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCapture0Val ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the capture value.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
The capture value.
Function Usage
/* Scenario: there is a need to get the capture values of
* the first (index = 0) quadrature decoder of the TCPWM0 block.
*/
#define MY_TCPWM_CNT_NUM (0UL)
/* The capture event can be triggered either by the Index HW input
* or by software:
*/
Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* after some time or encoder moving */
Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* Now we can get the latest captured value
* (captured during the second call of Cy_TCPWM_TriggerReloadOrIndex_Single)
*/
uint32_t capture = Cy_TCPWM_QuadDec_GetCapture0Val(TCPWM0, MY_TCPWM_CNT_NUM);
/* Also the previous captured value
* (captured during the first call of Cy_TCPWM_TriggerReloadOrIndex_Single)
* is available by the next way
*/
uint32_t captureBuf = Cy_TCPWM_QuadDec_GetCapture0BufVal(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_GetCapture0BufVal()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCapture0BufVal ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the buffered capture value.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
The buffered capture value.
Function Usage
/* Scenario: there is a need to get the capture values of
* the first (index = 0) quadrature decoder of the TCPWM0 block.
*/
#define MY_TCPWM_CNT_NUM (0UL)
/* The capture event can be triggered either by the Index HW input
* or by software:
*/
Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* after some time or encoder moving */
Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* Now we can get the latest captured value
* (captured during the second call of Cy_TCPWM_TriggerReloadOrIndex_Single)
*/
uint32_t capture = Cy_TCPWM_QuadDec_GetCapture0Val(TCPWM0, MY_TCPWM_CNT_NUM);
/* Also the previous captured value
* (captured during the first call of Cy_TCPWM_TriggerReloadOrIndex_Single)
* is available by the next way
*/
uint32_t captureBuf = Cy_TCPWM_QuadDec_GetCapture0BufVal(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_SetCompare0Val()

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCompare0Val ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  compare0 
)

Sets the compare value for Compare0 when the compare mode is enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
compare0The Compare 0 value.
Function Usage
/* Scenario: there is a need to set compare 0 value
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t compare0 = 0uL;
Cy_TCPWM_QuadDec_SetCompare0Val(TCPWM0, MY_TCPWM_CNT_NUM, 255U);
compare0 = Cy_TCPWM_QuadDec_GetCompare0Val(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_GetCompare0Val()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCompare0Val ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns compare 0 value.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Compare 0 value.
Function Usage
/* Scenario: there is a need to set compare 0 value
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t compare0 = 0uL;
Cy_TCPWM_QuadDec_SetCompare0Val(TCPWM0, MY_TCPWM_CNT_NUM, 255U);
compare0 = Cy_TCPWM_QuadDec_GetCompare0Val(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_SetCompare0BufVal()

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCompare0BufVal ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  compareBuf0 
)

Sets the Buffered Compare 0 value when the compare mode is enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
compareBuf0The Buffered Compare 0 value.
Function Usage
/* Scenario: there is a need to set buffered compare 0 value
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t compare0buff = 0uL;
Cy_TCPWM_QuadDec_SetCompare0BufVal(TCPWM0, MY_TCPWM_CNT_NUM, 255U);
compare0buff = Cy_TCPWM_QuadDec_GetCompare0BufVal(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_GetCompare0BufVal()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCompare0BufVal ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns Buffered Compare 0 Value.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Buffered Compare 0 Value.
Function Usage
/* Scenario: there is a need to set buffered compare 0 value
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t compare0buff = 0uL;
Cy_TCPWM_QuadDec_SetCompare0BufVal(TCPWM0, MY_TCPWM_CNT_NUM, 255U);
compare0buff = Cy_TCPWM_QuadDec_GetCompare0BufVal(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_EnableCompare0Swap()

__STATIC_INLINE void Cy_TCPWM_QuadDec_EnableCompare0Swap ( TCPWM_Type base,
uint32_t  cntNum,
bool  enable 
)

Enables the comparison swap of compare 0 and compareBuf 0 when the comparison value is true.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
enabletrue = swap enabled, false = swap disabled
Function Usage
/* Scenario: there is a need to swap compare 0 and compare 0 buffer values
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
Cy_TCPWM_QuadDec_EnableCompare0Swap(TCPWM0, MY_TCPWM_CNT_NUM, true);

◆ Cy_TCPWM_QuadDec_SetCounter()

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCounter ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  count 
)

Sets the value of the counter.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
countThe value to write into the counter.
Function Usage
/* Scenario: there is a need to set the counter value for
* the first (index = 0) counter of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
#define MY_TCPWM_CNT_VAL (0x8000UL) /* The "neutral" position for 16-bit decoder */
Cy_TCPWM_TriggerStopOrKill_Single(TCPWM0, MY_TCPWM_CNT_NUM);
Cy_TCPWM_QuadDec_SetCounter(TCPWM0, MY_TCPWM_CNT_NUM, MY_TCPWM_CNT_VAL);
Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_GetCounter()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCounter ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the value in the counter.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
The current counter value.
Function Usage
/* Scenario: there is a need to get the current counter value
* (i.e. essentially the current position of the quadrature encoder)
* of the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t count = Cy_TCPWM_QuadDec_GetCounter(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_GetCapture1Val()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCapture1Val ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns capture 1 value when capture mode is enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Capture 1 value.

◆ Cy_TCPWM_QuadDec_GetCapture1BufVal()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCapture1BufVal ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the buffered capture 1 value when capture mode is enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Buffered capture 1 value.

◆ Cy_TCPWM_QuadDec_GetCompare1Val()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCompare1Val ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns compare 1 value.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Compare 1 value.
Function Usage
/* Scenario: there is a need to set compare 1 value
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t compare1 = 0uL;
Cy_TCPWM_QuadDec_SetCompare1Val(TCPWM0, MY_TCPWM_CNT_NUM, 255U);
compare1 = Cy_TCPWM_QuadDec_GetCompare1Val(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_GetCompare1BufVal()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCompare1BufVal ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the buffered compare 1 value.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Buffered compare 1 value.
Function Usage
/* Scenario: there is a need to set compare 1 buffer value
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t compare1buff = 0uL;
Cy_TCPWM_QuadDec_SetCompare1BufVal(TCPWM0, MY_TCPWM_CNT_NUM, 255U);
compare1buff = Cy_TCPWM_QuadDec_GetCompare1BufVal(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_SetCompare1Val()

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCompare1Val ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  compare1 
)

Sets the compare value for Compare 1 when the compare mode enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
compare1The Compare 1 value.
Function Usage
/* Scenario: there is a need to set compare 1 value
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t compare1 = 0uL;
Cy_TCPWM_QuadDec_SetCompare1Val(TCPWM0, MY_TCPWM_CNT_NUM, 255U);
compare1 = Cy_TCPWM_QuadDec_GetCompare1Val(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_SetCompare1BufVal()

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCompare1BufVal ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  compareBuf1 
)

Sets the buffered compare value for Compare 1 when the compare mode enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
compareBuf1The buffered Compare 1 value.
Function Usage
/* Scenario: there is a need to set compare 1 buffer value
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t compare1buff = 0uL;
Cy_TCPWM_QuadDec_SetCompare1BufVal(TCPWM0, MY_TCPWM_CNT_NUM, 255U);
compare1buff = Cy_TCPWM_QuadDec_GetCompare1BufVal(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_EnableCompare1Swap()

__STATIC_INLINE void Cy_TCPWM_QuadDec_EnableCompare1Swap ( TCPWM_Type base,
uint32_t  cntNum,
bool  enable 
)

Enables the comparison swap of compare 1 and compareBuf 1 when the comparison value is true.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
enabletrue = swap enabled; false = swap disabled
Function Usage
/* Scenario: there is a need to swap compare 1 and compare 1 buffer values
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
Cy_TCPWM_QuadDec_EnableCompare1Swap(TCPWM0, MY_TCPWM_CNT_NUM, true);

◆ Cy_TCPWM_QuadDec_SetPeriod0()

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetPeriod0 ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  period0 
)

Sets the value of the period register.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
period0The value to write into a period.
Function Usage
/* Scenario: there is a need to set period 0 value
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t period0 = 0uL;
Cy_TCPWM_QuadDec_SetPeriod0(TCPWM0, MY_TCPWM_CNT_NUM, 255U);
period0 = Cy_TCPWM_QuadDec_GetPeriod0(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_GetPeriod0()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetPeriod0 ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the value in the period 0 register.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
The current period value.
Function Usage
/* Scenario: there is a need to set period 0 value
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t period0 = 0uL;
Cy_TCPWM_QuadDec_SetPeriod0(TCPWM0, MY_TCPWM_CNT_NUM, 255U);
period0 = Cy_TCPWM_QuadDec_GetPeriod0(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_SetPeriod1()

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetPeriod1 ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  period1 
)

Sets the value of the period register.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
period1The value to write into a period 1.
Function Usage
/* Scenario: there is a need to set period 1 value
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t period1 = 0uL;
Cy_TCPWM_QuadDec_SetPeriod1(TCPWM0, MY_TCPWM_CNT_NUM, 255U);
period1 = Cy_TCPWM_QuadDec_GetPeriod1(TCPWM0, MY_TCPWM_CNT_NUM);
Note
supported only in TCPWM_ver2

◆ Cy_TCPWM_QuadDec_GetPeriod1()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetPeriod1 ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the value in the period 1 register.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
The current period 1 value.
Function Usage
/* Scenario: there is a need to set period 1 value
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t period1 = 0uL;
Cy_TCPWM_QuadDec_SetPeriod1(TCPWM0, MY_TCPWM_CNT_NUM, 255U);
period1 = Cy_TCPWM_QuadDec_GetPeriod1(TCPWM0, MY_TCPWM_CNT_NUM);
Note
supported only in TCPWM_ver2

◆ Cy_TCPWM_QuadDec_TriggerIndex1()

__STATIC_INLINE void Cy_TCPWM_QuadDec_TriggerIndex1 ( TCPWM_Type base,
uint32_t  cntNum 
)

Triggers a software index 1.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Function Usage
/* Scenario: there is a need to trigger Index1 event
* for the first (index = 0) quadrature decoder of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
Cy_TCPWM_QuadDec_TriggerIndex1(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_EnableSwap()

__STATIC_INLINE void Cy_TCPWM_QuadDec_EnableSwap ( TCPWM_Type base,
uint32_t  cntNum,
bool  enable 
)

Enables/disables swapping mechanism between CC0 and buffered CC0, CC1 and buffered CC1, PERIOD and buffered PERIOD, DT and buffered DT.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
enabletrue = swap enabled; false = swap disabled