FastLED 3.9.3
Loading...
Searching...
No Matches
fastled_delay.h File Reference

Detailed Description

Utility functions and classes for managing delay cycles.

Definition in file fastled_delay.h.

#include "FastLED.h"
#include "types.h"
#include "force_inline.h"

Go to the source code of this file.

Classes

class  CMinWait< WAIT >
 Class to ensure that a minimum amount of time has kicked since the last time run - and delay if not enough time has passed yet. More...
 

Macros

Some timing related macros/definitions
#define F_CPU_MHZ   (F_CPU / 1000000L)
 CPU speed, in megahertz (MHz)
 
#define NS(_NS)   (((_NS * F_CPU_MHZ) + 999) / 1000)
 Convert from nanoseconds to number of clock cycles.
 
#define CLKS_TO_MICROS(_CLKS)   ((long)(_CLKS)) / (F_CPU / 1000000L)
 Convert from number of clock cycles to microseconds.
 
#define NO_TIME(A, B, C)   (NS(A) < 3 || NS(B) < 3 || NS(C) < 6)
 Macro for making sure there's enough time available.
 

Clock cycle counted delay loop

#define FL_NOP   __asm__ __volatile__ ("nop\n");
 Single no operation ("no-op") instruction for delay.
 
#define FL_NOP2   __asm__ __volatile__ ("nop\n\t nop\n");
 Double no operation ("no-op") instruction for delay.
 
template<cycle_t CYCLES>
void delaycycles ()
 Delay N clock cycles.
 
template<cycle_t CYCLES>
void delaycycles_min1 ()
 A variant of delaycycles that will always delay at least one cycle.
 
template<cycle_t CYCLES>
FASTLED_FORCE_INLINE void delaycycles ()
 Delay N clock cycles.
 

Macro Definition Documentation

◆ CLKS_TO_MICROS

#define CLKS_TO_MICROS ( _CLKS)    ((long)(_CLKS)) / (F_CPU / 1000000L)

Convert from number of clock cycles to microseconds.

Definition at line 209 of file fastled_delay.h.

◆ F_CPU_MHZ

#define F_CPU_MHZ   (F_CPU / 1000000L)

CPU speed, in megahertz (MHz)

Definition at line 202 of file fastled_delay.h.

◆ FL_NOP

#define FL_NOP   __asm__ __volatile__ ("nop\n");

Single no operation ("no-op") instruction for delay.

Definition at line 70 of file fastled_delay.h.

◆ FL_NOP2

#define FL_NOP2   __asm__ __volatile__ ("nop\n\t nop\n");

Double no operation ("no-op") instruction for delay.

Definition at line 72 of file fastled_delay.h.

◆ NO_TIME

#define NO_TIME ( A,
B,
C )   (NS(A) < 3 || NS(B) < 3 || NS(C) < 6)

Macro for making sure there's enough time available.

Definition at line 212 of file fastled_delay.h.

◆ NS

#define NS ( _NS)    (((_NS * F_CPU_MHZ) + 999) / 1000)

Convert from nanoseconds to number of clock cycles.

Definition at line 207 of file fastled_delay.h.

Function Documentation

◆ delaycycles() [1/2]

template<cycle_t CYCLES>
void delaycycles ( )
inline

Delay N clock cycles.

Template Parameters
CYCLESthe number of clock cycles to delay
Note
No delay is applied if CYCLES is less than or equal to zero.

Definition at line 134 of file fastled_delay.h.

◆ delaycycles() [2/2]

template<cycle_t CYCLES>
FASTLED_FORCE_INLINE void delaycycles ( )
inline

Delay N clock cycles.

Template Parameters
CYCLESthe number of clock cycles to delay
Note
No delay is applied if CYCLES is less than or equal to zero.

Definition at line 134 of file fastled_delay.h.

◆ delaycycles_min1()

template<cycle_t CYCLES>
void delaycycles_min1 ( )
inline

A variant of delaycycles that will always delay at least one cycle.

Definition at line 85 of file fastled_delay.h.