MTB CAT1 Peripheral driver library

General Description

Functions

void Cy_Profile_ClearConfiguration (void)
 Clears all counter configurations and sets all counters and overflow counters to 0. More...
 
__STATIC_INLINE void Cy_Profile_ClearCounters (void)
 Clears all hardware counters to 0. More...
 
cy_stc_profile_ctr_ptr_t Cy_Profile_ConfigureCounter (en_ep_mon_sel_t monitor, cy_en_profile_duration_t duration, cy_en_profile_ref_clk_t refClk, uint32_t weight)
 Configures and assigns a hardware profile counter to the list of used counters. More...
 
cy_en_profile_status_t Cy_Profile_FreeCounter (cy_stc_profile_ctr_ptr_t ctrAddr)
 Frees up a counter from a previously-assigned monitor source. More...
 
cy_en_profile_status_t Cy_Profile_EnableCounter (cy_stc_profile_ctr_ptr_t ctrAddr)
 Enables an assigned counter. More...
 
cy_en_profile_status_t Cy_Profile_DisableCounter (cy_stc_profile_ctr_ptr_t ctrAddr)
 Disables an assigned counter. More...
 

Function Documentation

◆ Cy_Profile_ClearConfiguration()

void Cy_Profile_ClearConfiguration ( void  )

Clears all counter configurations and sets all counters and overflow counters to 0.

Calls Cy_Profile_ClearCounters() to clear counter registers.

Function Usage
/* Scenario: A new profiling session with a different set of counter
configurations need to be allocated. */
/* List of handles for allocated counters */
cy_stc_profile_ctr_ptr_t cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};
uint8_t cntIdx;
/* Disable all the counters */
for(cntIdx = 0u; cntIdx < PROFILE_PRFL_CNT_NR; cntIdx++)
{
{
/* Insert error handling */
}
}
/* Clear all counter configurations */

◆ Cy_Profile_ClearCounters()

__STATIC_INLINE void Cy_Profile_ClearCounters ( void  )

Clears all hardware counters to 0.

Function Usage
/* Scenario: A new profiling window needs to be started with the counter
values reset to 0. */
/* Stop the profiling window */
/* Clear all counters before starting a new profiling window */
/* If applicable, clear the overflow bits in the data structure */
/* Start the profiling window */

◆ Cy_Profile_ConfigureCounter()

cy_stc_profile_ctr_ptr_t Cy_Profile_ConfigureCounter ( en_ep_mon_sel_t  monitor,
cy_en_profile_duration_t  duration,
cy_en_profile_ref_clk_t  refClk,
uint32_t  weight 
)

Configures and assigns a hardware profile counter to the list of used counters.

This function assigns an available profile counter to a slot in the internal software data structure and returns the handle for that slot location. The data structure is used to keep track of the counter status and to implement a 64-bit profile counter. If no counter slots are available, the function returns a NULL pointer.

Parameters
monitorThe monitor source number
durationEvents are monitored (0), or duration is monitored (1)
refClkCounter reference clock
weightWeighting factor for the counter value
Returns
A pointer to the counter data structure. NULL if no counter is available.
Function Usage
/* Scenario: SCB0 bus transfers need to be monitored during a fixed window.
The profile interrupt is configured using the sysint driver.
It's handler function is Cy_Profile_ISR(). */
/* List of handles for allocated counters */
cy_stc_profile_ctr_ptr_t cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};
/* Initialize the energy profiler */
/* Configure a profile counter to monitor the SCB0 bus transfer events */
cntHandle[0] = Cy_Profile_ConfigureCounter(SCB0_MONITOR_AHB, /* SCB0 bus transfer count */
CY_PROFILE_EVENT, /* Count number of SCB0 bus transfers */
CY_PROFILE_CLK_TIMER, /* Ignored for "event" counting */
20000UL); /* Weight of 20000 (example) */
if(cntHandle[0] == NULL)
{
/* Cannot allocate this counter. Check and try again. */
}
/* Enable the assigned counter */
(void)Cy_Profile_EnableCounter(cntHandle[0]);

◆ Cy_Profile_FreeCounter()

cy_en_profile_status_t Cy_Profile_FreeCounter ( cy_stc_profile_ctr_ptr_t  ctrAddr)

Frees up a counter from a previously-assigned monitor source.

Cy_Profile_ConfigureCounter() must have been called for this counter before calling this function.

Parameters
ctrAddrThe handle to the assigned counter (returned by calling Cy_Profile_ConfigureCounter()).
Returns
Status of the operation.
Note
The counter is not disabled by this function.
Function Usage
/* Scenario: A profile counter in position #0 was previously in use. It needs
to be reconfigured to monitor the CM0+ active cycles count. */
/* List of handles for allocated counters */
cy_stc_profile_ctr_ptr_t cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};
/* Free the profile counter in position #0 */
{
/* Insert error handling */
}
/* Configure a profile counter to monitor the CM0+ active cycle count events */
cntHandle[0] = Cy_Profile_ConfigureCounter(CPUSS_MONITOR_CM0, /* CM0+ active cycle count */
CY_PROFILE_EVENT, /* Count number of CM0+ active cycles */
CY_PROFILE_CLK_TIMER, /* Ignored for "event" counting */
40000UL); /* Weight of 40000 (example) */

◆ Cy_Profile_EnableCounter()

cy_en_profile_status_t Cy_Profile_EnableCounter ( cy_stc_profile_ctr_ptr_t  ctrAddr)

Enables an assigned counter.

Cy_Profile_ConfigureCounter() must have been called for this counter before calling this function.

Parameters
ctrAddrThe handle to the assigned counter, (returned by calling Cy_Profile_ConfigureCounter()).
Returns
Status of the operation.
Function Usage
/* Scenario: A profile counter needs to be configured and enabled to count
the number of HFCLK0 cycles in the profiling window. The energy
profiler is initialized and the profile interrupt is configured
and enabled. */
/* List of handles for allocated counters */
cy_stc_profile_ctr_ptr_t cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};
/* Configure a profile counter to count the number of HFCLK0 cycles in the profiling window */
cntHandle[0] = Cy_Profile_ConfigureCounter(PROFILE_ONE, /* Constant 1 (always count) */
CY_PROFILE_DURATION,/* Count number of clock cycles */
CY_PROFILE_CLK_HF, /* HFCLK0 */
1UL); /* Normalization weight of 1 */
{
/* Insert error handling */
}
/* Start the profiling window when ready. */

◆ Cy_Profile_DisableCounter()

cy_en_profile_status_t Cy_Profile_DisableCounter ( cy_stc_profile_ctr_ptr_t  ctrAddr)

Disables an assigned counter.

Cy_Profile_ConfigureCounter() must have been called for this counter before calling this function.

Parameters
ctrAddrThe handle to the assigned counter, (returned by calling Cy_Profile_ConfigureCounter()).
Returns
Status of the operation.
Function Usage
/* Scenario: A profile counter assigned to position #0 is no longer needed
and can be disabled. */
/* List of handles for allocated counters */
cy_stc_profile_ctr_ptr_t cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};
/* Disable the profile counter in position #0 */
{
/* Insert error handling */
}
/* Free the profile counter in position #0 */
{
/* Insert error handling */
}