cycle_counter.h
Go to the documentation of this file.
1 
33 /*
34  * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
35  */
36 #ifndef _cycle_counter_h_
37 #define _cycle_counter_h_
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 
44 #include <compiler.h>
45 
86 void portable_delay_cycles(unsigned long n);
87 
88 /* Cortex-M7 is faster than Cortex-M3/M4/M0+ */
89 #ifdef __CM7_REV
90 
91 # define cpu_ms_2_cy(ms, f_cpu) \
92  (((uint64_t)(ms) * (f_cpu) + (uint64_t)(5.932e3 - 1ul)) / (uint64_t)5.932e3)
93 # define cpu_us_2_cy(us, f_cpu) \
94  (((uint64_t)(us) * (f_cpu) + (uint64_t)(5.932e6 - 1ul)) / (uint64_t)5.932e6)
95 
96 #else
97 
98 # define cpu_ms_2_cy(ms, f_cpu) \
99  (((uint64_t)(ms) * (f_cpu) + (uint64_t)(14e3 - 1ul)) / (uint64_t)14e3)
100 # define cpu_us_2_cy(us, f_cpu) \
101  (((uint64_t)(us) * (f_cpu) + (uint64_t)(14e6 - 1ul)) / (uint64_t)14e6)
102 
103 #endif
104 
105 #define delay_cycles portable_delay_cycles
106 
107 #define cpu_delay_ms(delay, f_cpu) delay_cycles(cpu_ms_2_cy(delay, f_cpu))
108 #define cpu_delay_us(delay, f_cpu) delay_cycles(cpu_us_2_cy(delay, f_cpu))
109 
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif /* _cycle_counter_h_ */
Commonly used includes, types and macros.
void portable_delay_cycles(unsigned long n)
Delay loop to delay n number of cycles.
Definition: cycle_counter.c:42


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:04