-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiApp.c
executable file
·85 lines (42 loc) · 1.46 KB
/
iApp.c
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "MQ6812.h"
#include "iApp.h"
// delay_times(t_1ms, 800); // 用于 Normal mode, 不适用Slow mode
//void delay_times(uchar tBase, uint x); // 用于 Normal mode, 不适用Slow mode
//.....................|...........| x: 设定延迟时间变数
//.....................| tBase: 设定延迟单位: t_1ms/t_100us 等...
//#define t_1ms 0
//#define t_100us 1
//*********************************************************************
// 函数名 : delay_times(uchar tBase, uint x)
// 函数功能 : 延时函数
// 备注 : ==> t_1ms = 0;
// : ==> t_100us = 1;
// : ...
//*********************************************************************
void delay_times(uchar tBase, uint x)
{
uint i, cgcrT;
// uchar cgcrF[4]={ 2, 4, 8, 1 }; // HIRC => 8MHz
uchar cgcrF[4]={ 4, 8, 16, 2 }; // HIRC => 16MHz
// ...... ...... ...... delay for HIRC ...... ...... ......
if( SYSCR2.bit.b4 == 0 )
{
cgcrT = cgcrF[CGCR.byte]; //0:fc/4, 1:fc/2, 2:fc/1, 3:fc/8
switch(tBase){
__asm("NOP"); // switch 与第一个 case 之间置入一行 "NOP",避免编译出 "JP gg" 指令!
case 0: // t_1ms
cgcrT *= 110;
for(; x>0; x--)
for(i=0; i<cgcrT; i++){}
break;
case 1: // t_100us
cgcrT *= 11;
for(; x>0; x--)
for(i=0; i<cgcrT; i++){}
break;
}
}
// ...... ...... ...... delay for LIRC ...... ...... ......
else for(; x>0; x--){}
WDCDR.byte=0x4e; //clear wdt
}