Atmel Software Framework

Busy-Wait Delay Routines

This module provides simple loop-based delay routines for those applications requiring a brief wait during execution.

Common API for UC3, XMEGA, and AVR MEGA.

Macros

#define delay_init(fcpu_hz)
 Initialize the delay driver. More...
 
#define delay_ms(delay)   ((delay) ? cpu_delay_ms(delay, F_CPU) : cpu_delay_us(1, F_CPU))
 Delay in milliseconds. More...
 
#define delay_s(delay)   ((delay) ? cpu_delay_ms(1000 * delay, F_CPU) : cpu_delay_us(1, F_CPU))
 Delay in seconds. More...
 
#define delay_us(delay)   ((delay) ? cpu_delay_us(delay, F_CPU) : cpu_delay_us(1, F_CPU))
 Delay in microseconds. More...
 
#define F_CPU   sysclk_get_cpu_hz()
 MCU Clock Frequency (Hertz) More...
 

#define delay_init (   fcpu_hz)

Initialize the delay driver.

Parameters
fcpu_hzCPU frequency in Hz
Deprecated:
This function is provided for compatibility with ASF applications that may not have been updated to configure the system clock via the common clock service; e.g. sysclk_init() and a configuration header file are used to configure clocks.

The functions in this module call sysclk_get_cpu_hz() function to obtain the system clock frequency.

Referenced by main(), and nm_bsp_init().

#define delay_s (   delay)    ((delay) ? cpu_delay_ms(1000 * delay, F_CPU) : cpu_delay_us(1, F_CPU))

Delay in seconds.

Parameters
delayDelay in seconds

Referenced by check_valid_firmware(), main(), and multi_language_show_card_size_info().

#define delay_us (   delay)    ((delay) ? cpu_delay_us(delay, F_CPU) : cpu_delay_us(1, F_CPU))

Delay in microseconds.

Parameters
delayDelay in microseconds

Referenced by main(), qt_hardware_reset(), qt_read_regs(), qt_write_regs(), ssd1306_hard_reset(), ssd1306_write_command(), and ssd1306_write_data().

#define F_CPU   sysclk_get_cpu_hz()

MCU Clock Frequency (Hertz)

Deprecated:
The F_CPU configuration constant is used for compatibility with the Busy-Wait Delay Routines routines. The common loop-based delay routines are designed to use the Clock Management modules while anticipating support for legacy applications assuming a statically defined clock frequency. Applications using a statically configured MCU clock frequency can define F_CPU (Hertz), in which case the common delay routines will use this value rather than calling sysclk_get_cpu_hz() to get the current MCU clock frequency.