cycle_counter.h File Reference

ARM functions for busy-wait delay loops. More...

#include <compiler.h>
Include dependency graph for cycle_counter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Convenience functions for busy-wait delay loops

#define cpu_ms_2_cy(ms, f_cpu)   (((uint64_t)(ms) * (f_cpu) + (uint64_t)(14e3 - 1ul)) / (uint64_t)14e3)
 Convert milli-seconds into CPU cycles. More...
 
#define cpu_us_2_cy(us, f_cpu)   (((uint64_t)(us) * (f_cpu) + (uint64_t)(14e6 - 1ul)) / (uint64_t)14e6)
 Convert micro-seconds into CPU cycles. More...
 
#define delay_cycles   portable_delay_cycles
 Delay program execution for a specified number of CPU cycles. More...
 
#define cpu_delay_ms(delay, f_cpu)   delay_cycles(cpu_ms_2_cy(delay, f_cpu))
 Delay program execution for a specified number of milliseconds. More...
 
#define cpu_delay_us(delay, f_cpu)   delay_cycles(cpu_us_2_cy(delay, f_cpu))
 Delay program execution for a specified number of microseconds. More...
 
void portable_delay_cycles (unsigned long n)
 Delay loop to delay n number of cycles. More...
 

Detailed Description

ARM functions for busy-wait delay loops.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

Definition in file cycle_counter.h.

Macro Definition Documentation

◆ cpu_delay_ms

#define cpu_delay_ms (   delay,
  f_cpu 
)    delay_cycles(cpu_ms_2_cy(delay, f_cpu))

Delay program execution for a specified number of milliseconds.

Parameters
delaynumber of milliseconds to wait
f_cpuCPU frequency in Hertz

Definition at line 107 of file cycle_counter.h.

◆ cpu_delay_us

#define cpu_delay_us (   delay,
  f_cpu 
)    delay_cycles(cpu_us_2_cy(delay, f_cpu))

Delay program execution for a specified number of microseconds.

Parameters
delaynumber of microseconds to wait
f_cpuCPU frequency in Hertz

Definition at line 108 of file cycle_counter.h.

◆ cpu_ms_2_cy

#define cpu_ms_2_cy (   ms,
  f_cpu 
)    (((uint64_t)(ms) * (f_cpu) + (uint64_t)(14e3 - 1ul)) / (uint64_t)14e3)

Convert milli-seconds into CPU cycles.

Parameters
msnumber of milliseconds
f_cpuCPU frequency in Hertz
Returns
the converted number of CPU cycles

Definition at line 98 of file cycle_counter.h.

◆ cpu_us_2_cy

#define cpu_us_2_cy (   us,
  f_cpu 
)    (((uint64_t)(us) * (f_cpu) + (uint64_t)(14e6 - 1ul)) / (uint64_t)14e6)

Convert micro-seconds into CPU cycles.

Parameters
msnumber of microseconds
f_cpuCPU frequency in Hertz
Returns
the converted number of CPU cycles

Definition at line 100 of file cycle_counter.h.

◆ delay_cycles

#define delay_cycles   portable_delay_cycles

Delay program execution for a specified number of CPU cycles.

Parameters
nnumber of CPU cycles to wait

Definition at line 105 of file cycle_counter.h.

Function Documentation

◆ portable_delay_cycles()

void portable_delay_cycles ( unsigned long  n)

Delay loop to delay n number of cycles.

Note
The function runs in internal RAM so that flash wait states will not affect the delay time.
Parameters
nNumber of cycles

Definition at line 42 of file cycle_counter.c.



inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:59