-
Notifications
You must be signed in to change notification settings - Fork 0
/
delayIAR.h
53 lines (42 loc) · 1.65 KB
/
delayIAR.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Õèäåð çàäåðæåê äëÿ IAR. Èñïîëüçóåò __delay_cycles äëÿ ôîðìèðîâàíèÿ çàäåðæåê
îò íàíîñåêóíä äî ñåêóíä.  ïàðàìåòðå CPU_CLK_Hz óêàçàòü òàêòîâóþ ÷àñòîòó â ãåðöàõ.
*/
#ifndef DELAY_H
#define DELAY_H
#include <inavr.h>
#define CPU_CLK_kHz (unsigned long)(CPU_CLK_Hz/1000)
#define delay_ns(x) __delay_cycles(x*CPU_CLK_kHz*0.000001)
#define delay_us(x) __delay_cycles(x*(CPU_CLK_Hz/1000000))
#define delay_ms(x) __delay_cycles(x*(CPU_CLK_Hz/1000))
#define delay_s(x) __delay_cycles(x*CPU_CLK_Hz)
#define delay_600ns __no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();
#define delay_500ns __no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();
#define delay_400ns __no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();\
__no_operation();
#define delay_250ns __no_operation();\
__no_operation();\
__no_operation();\
__no_operation();
#endif