IAR for AVR delay函数

电子元件 4年前 (2022) aysz01
0

众所周知,在GCC AVR里有个delay.h的头文件,可以直接使用.

IAR for AVR里面只有__delay_cycles

所以,我自己写了个delay.h,包含三个可调用的函数

#ifndef __DELAY_H__
#define __DELAY_H__

#include

#ifndef F_CPU
#define F_CPU 16000000L
#endif

#define _delay_us(t) __delay_cycles(F_CPU / 1000000 * t)
#define _delay_ms(t) __delay_cycles(F_CPU / 1000 * t)
#define _delay_s(t) __delay_cycles(F_CPU * t)

#endif/* __DELAY_H__ */

版权声明:aysz01 发表于 2022-08-06 12:16:12。
转载请注明:IAR for AVR delay函数 | 鳌游电工

暂无评论

暂无评论...