36 #ifndef _cycle_counter_h_ 37 #define _cycle_counter_h_ 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) 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) 105 #define delay_cycles portable_delay_cycles 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)) Commonly used includes, types and macros.
void portable_delay_cycles(unsigned long n)
Delay loop to delay n number of cycles.