ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
adi_cyclecount.h
1 /*
2  *******************************************************************************
3  * @brief: Framework to preform cycle count measurements
4  *
5  * @details this is a framework for monitoring the cycle counts
6  * for ISRs and APIs. The framework uses systick.
7 
8 *******************************************************************************
9 
10  Copyright(c) 2016-2017 Analog Devices, Inc. All Rights Reserved.
11 
12  This software is proprietary and confidential. By using this software you agree
13  to the terms of the associated Analog Devices License Agreement.
14 
15  ******************************************************************************/
16 
17 #ifndef ADI_CYCLECOUNT_H
18 #define ADI_CYCLECOUNT_H
19 
20 #include <stdbool.h>
21 #include <stdint.h>
22 #include <adi_cycle_counting_config.h>
23 
24 
36 typedef uint64_t adi_cyclecount_t;
37 
38 
45 #define ADI_CYCLECOUNT_SYSTICKS (0xFFFFFFu)
46 
52 #define ADI_CYCLECOUNT_INITIAL_STACK_INDEX (-1)
53 
57 typedef enum {
58 
64 
65 
74 #define ADI_CYCLECOUNT_ISR_EXT_3 1u
75 #define ADI_CYCLECOUNT_ISR_UART 2u
76 #define ADI_CYCLECOUNT_ISR_DMA_UART_TX 3u
77 #define ADI_CYCLECOUNT_ISR_DMA_UART_RX 4u
78 #define ADI_CYCLECOUNT_ISR_TMR_COMMON 5u
79 #define ADI_CYCLECOUNT_ISR_RTC 6u
80 #define ADI_CYCLECOUNT_ISR_SPI 7u
81 #define ADI_CYCLECOUNT_ISR_CRC 8u
82 #define ADI_CYCLECOUNT_ISR_SPORT 9u
83 #define ADI_CYCLECOUNT_ID_COUNT 10u
92 typedef struct
93 {
102  uint32_t sample_count;
105 
111 #if defined(ADI_CYCLECOUNT_ENABLED) && (ADI_CYCLECOUNT_ENABLED == 1u)
112 
113  #define ADI_CYCLECOUNT_INITIALIZE() adi_cyclecount_init()
114  #define ADI_CYCLECOUNT_STORE(id) adi_cyclecount_store(id)
115  #define ADI_CYCLECOUNT_REPORT() adi_cyclecount_report()
117 #else
118 
119  #define ADI_CYCLECOUNT_INITIALIZE() do{}while(0)
120  #define ADI_CYCLECOUNT_STORE(id) do{}while(0)
121  #define ADI_CYCLECOUNT_REPORT() do{}while(0)
122 #endif
123 
124 
125 /* Forward API declarations */
129 extern ADI_CYCLECOUNT_RESULT adi_cyclecount_store(uint32_t id);
130 extern void adi_cyclecount_init(void);
131 extern void adi_cyclecount_report(void);
132 extern ADI_CYCLECOUNT_RESULT adi_cyclecount_addEntity(const char *EntityName, uint32_t *pid);
133 
134 extern void SysTick_Handler(void);
135 
138 #endif /* ADI_CYCLECOUNT_H */
139 
ADI_CYCLECOUNT_RESULT adi_cyclecount_store(uint32_t id)
Store Cycle Count.
adi_cyclecount_t average_cycles_unadjusted
void adi_cyclecount_report(void)
Generate a cycle count report.
uint64_t adi_cyclecount_t
void SysTick_Handler(void)
adi_cyclecount_t average_cycles_adjusted
adi_cyclecount_t adi_cyclecount_get(void)
Read the current number of cycle counts.
ADI_CYCLECOUNT_RESULT adi_cyclecount_start(void)
API to be called to start a new cycle counting context.
ADI_CYCLECOUNT_RESULT
adi_cyclecount_t max_cycles_adjusted
ADI_CYCLECOUNT_RESULT adi_cyclecount_addEntity(const char *EntityName, uint32_t *pid)
Add an ISR/API to the cycle counting list.
adi_cyclecount_t max_cycles_unadjusted
ADI_CYCLECOUNT_RESULT adi_cyclecount_stop(void)
Cycle Count Stop.
void adi_cyclecount_init(void)
API to be called to initialize the cycle counting framework.
adi_cyclecount_t min_cycles_adjusted
adi_cyclecount_t min_cycles_unadjusted