PSoC 6 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. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCapture (TCPWM_Type const *base, uint32_t cntNum)
 Returns the capture value. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCaptureBuf (TCPWM_Type const *base, uint32_t cntNum)
 Returns the buffered capture value. 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...
 

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
{
/* .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 */
};
/* Scenario: there is need to initialize
* the first (index = 0) quadrature decoder of the TCPWM0 block
* with the previously defined configuration settings
*/
#define MY_TCPWM_CNT_NUM (0UL)
#define MY_TCPWM_CNT_MASK (1UL << MY_TCPWM_CNT_NUM)
if (CY_TCPWM_SUCCESS != Cy_TCPWM_QuadDec_Init(TCPWM0, MY_TCPWM_CNT_NUM, &config))
{
/* Handle possible errors */
}
/* Enabled the initialized quadrature decoder */
Cy_TCPWM_QuadDec_Enable(TCPWM0, MY_TCPWM_CNT_NUM);
/* Then start the decoder */
Cy_TCPWM_TriggerStart(TCPWM0, MY_TCPWM_CNT_MASK);

◆ 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 previously defined configuration settings
*/
#define MY_TCPWM_CNT_NUM (0UL)
#define MY_TCPWM_CNT_MASK (1UL << MY_TCPWM_CNT_NUM)
if (CY_TCPWM_SUCCESS != Cy_TCPWM_QuadDec_Init(TCPWM0, MY_TCPWM_CNT_NUM, &config))
{
/* Handle possible errors */
}
/* Enabled the initialized quadrature decoder */
Cy_TCPWM_QuadDec_Enable(TCPWM0, MY_TCPWM_CNT_NUM);
/* Then start the decoder */
Cy_TCPWM_TriggerStart(TCPWM0, MY_TCPWM_CNT_MASK);

◆ 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.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
The status. See QuadDec Status
Function Usage
/* Scenario: there is a need to check if
* the first (index = 0) quadrature decoder of the TCPWM0 block is running
*/
#define MY_TCPWM_CNT_NUM (0UL)
Cy_TCPWM_QuadDec_GetStatus(TCPWM0, MY_TCPWM_CNT_NUM)))
{
/* The Counter is running */
}

◆ Cy_TCPWM_QuadDec_GetCapture()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCapture ( 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)
#define MY_TCPWM_CNT_MASK (1UL << MY_TCPWM_CNT_NUM)
/* The capture event can be triggered either by the Index HW input
* or by software:
*/
Cy_TCPWM_TriggerReloadOrIndex(TCPWM0, MY_TCPWM_CNT_MASK);
/* after some time or encoder moving */
Cy_TCPWM_TriggerReloadOrIndex(TCPWM0, MY_TCPWM_CNT_MASK);
/* Now we can get the latest captured value
* (captured during the second call of Cy_TCPWM_TriggerReloadOrIndex)
*/
uint32_t capture = Cy_TCPWM_QuadDec_GetCapture(TCPWM0, MY_TCPWM_CNT_NUM);
/* Also the previous captured value
* (captured during the first call of Cy_TCPWM_TriggerReloadOrIndex)
* is available by the next way
*/
uint32_t captureBuf = Cy_TCPWM_QuadDec_GetCaptureBuf(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_QuadDec_GetCaptureBuf()

__STATIC_INLINE uint32_t Cy_TCPWM_QuadDec_GetCaptureBuf ( 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)
#define MY_TCPWM_CNT_MASK (1UL << MY_TCPWM_CNT_NUM)
/* The capture event can be triggered either by the Index HW input
* or by software:
*/
Cy_TCPWM_TriggerReloadOrIndex(TCPWM0, MY_TCPWM_CNT_MASK);
/* after some time or encoder moving */
Cy_TCPWM_TriggerReloadOrIndex(TCPWM0, MY_TCPWM_CNT_MASK);
/* Now we can get the latest captured value
* (captured during the second call of Cy_TCPWM_TriggerReloadOrIndex)
*/
uint32_t capture = Cy_TCPWM_QuadDec_GetCapture(TCPWM0, MY_TCPWM_CNT_NUM);
/* Also the previous captured value
* (captured during the first call of Cy_TCPWM_TriggerReloadOrIndex)
* is available by the next way
*/
uint32_t captureBuf = Cy_TCPWM_QuadDec_GetCaptureBuf(TCPWM0, MY_TCPWM_CNT_NUM);

◆ 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_MASK (1UL << MY_TCPWM_CNT_NUM)
#define MY_TCPWM_CNT_VAL (0x8000UL) /* The "neutral" position for 16-bit decoder */
Cy_TCPWM_TriggerStopOrKill(TCPWM0, MY_TCPWM_CNT_MASK);
Cy_TCPWM_QuadDec_SetCounter(TCPWM0, MY_TCPWM_CNT_NUM, MY_TCPWM_CNT_VAL);
Cy_TCPWM_TriggerStart(TCPWM0, MY_TCPWM_CNT_MASK);

◆ 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);