35 #ifndef _UTIL_DELAY_H_ 36 #define _UTIL_DELAY_H_ 1 39 # ifndef __HAS_DELAY_CYCLES 40 # define __HAS_DELAY_CYCLES 1 85 #if !defined(__DOXYGEN__) 92 # warning "F_CPU not defined for <util/delay.h>" 108 # define F_CPU 1000000UL 112 # warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed" 115 #if __HAS_DELAY_CYCLES && defined(__OPTIMIZE__) && \ 116 !defined(__DELAY_BACKWARD_COMPATIBLE__) && \ 169 #if __HAS_DELAY_CYCLES && defined(__OPTIMIZE__) && \ 170 !defined(__DELAY_BACKWARD_COMPATIBLE__) && \ 173 extern void __builtin_avr_delay_cycles(
unsigned long);
174 __tmp = ((
F_CPU) / 1e3) * __ms;
176 #if defined(__DELAY_ROUND_DOWN__) 179 #elif defined(__DELAY_ROUND_CLOSEST__) 180 __ticks_dc = (
uint32_t)(fabs(__tmp)+0.5);
187 __builtin_avr_delay_cycles(__ticks_dc);
191 __tmp = ((
F_CPU) / 4e3) * __ms;
194 else if (__tmp > 65535)
258 #if __HAS_DELAY_CYCLES && defined(__OPTIMIZE__) && \ 259 !defined(__DELAY_BACKWARD_COMPATIBLE__) && \ 262 extern void __builtin_avr_delay_cycles(
unsigned long);
263 __tmp = ((
F_CPU) / 1e6) * __us;
265 #if defined(__DELAY_ROUND_DOWN__) 268 #elif defined(__DELAY_ROUND_CLOSEST__) 269 __ticks_dc = (
uint32_t)(fabs(__tmp)+0.5);
276 __builtin_avr_delay_cycles(__ticks_dc);
281 __tmp = ((
F_CPU) / 3e6) * __us;
282 __tmp2 = ((
F_CPU) / 4e6) * __us;
285 else if (__tmp2 > 65535)
290 else if (__tmp > 255)
void _delay_loop_2(uint16_t __count)
Definition: delay_basic.h:103
static __inline void __attribute__((__always_inline__)) __power_all_enable()
Definition: power.h:1188
unsigned char uint8_t
Definition: stdint.h:83
void _delay_ms(double __ms)
Definition: delay.h:166
unsigned long int uint32_t
Definition: stdint.h:103
void _delay_us(double __us)
Definition: delay.h:255
#define F_CPU
CPU frequency in Hz.
Definition: delay.h:108
void _delay_loop_1(uint8_t __count)
Definition: delay_basic.h:81
unsigned int uint16_t
Definition: stdint.h:93
double ceil(double __x) __ASM_ALIAS(ceilf)