This repository has been archived by the owner on Jan 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.h
149 lines (118 loc) · 4.75 KB
/
global.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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//$Id: global.h,v 1.28 2004-05-13 14:45:46 peter Exp $
#define DEBUG_SERIAL
//#define CLEAR_DOG() WDTCTL=(WDTCTL&0x00FF)+WDTPW+WDTCNTCL
#define CLEAR_DOG() WDTCTL=WDTPW|WDTHOLD
//#define DISPLAY
//òàéìåð
struct tm_in {
int sec;
int min;
int hour;
int day;
};
#define SECS_IN_MIN (time_in)60
#define MINS_IN_HR (time_in)60
#define HRS_IN_DAY (time_in)24
#define SECS_IN_HR (SECS_IN_MIN * MINS_IN_HR)
#define SECS_IN_DAY (SECS_IN_HR * HRS_IN_DAY)
void local_time(time_in t1,struct tm_in *t2);
void init_timer_a(void);
void tick_timer(void);
// ÀÖÏ
void init_adc(void); //èíèöèàëèçàöèÿ ÀÖÏ
void off_adc(void); //âûêëþ÷åíèå ÀÖÏ
#define ADC_FIFO_RCV_LEN 8 /* size of fifo ADC buffer */
#define SIZE_OF_ADC_DUMP 8
#define NUM_CHANEL 32
void set_dac(u16 d);
//èíäèêàòîð
void show_display(void);
void redraw_display_second(int force);
void redraw_display_minutes(int force);
void redraw_display_voltage(int force);
void redraw_display_celciy(int force);
//void cs_on_display(void);
//void cs_off_display(void);
//int power_good(void);
void work_with_display(void);
void work_with_serial(void);
unsigned int crc16(void*,unsigned int);
u16 send_serial_massiv(u8* data,u16 len);
u16 work_with_adc_put(void);
u8 put_packet_type3(u16 info);
u8 put_packet_type4(void);
u16 put_packet_type5(void);
u16 put_packet_type6(void);
u8 put_packet_type7(u16 info);
u8 put_packet_typeA(u16 info);
u8 put_packet_type19(u16 info);
u8 put_packet_type1A(void);
u8 write_asp_trn_fifo(u8 data_wr);
void init_uart(void);
void update_diplay(void);
void work_with_serial_rec(void);
void set_adc(int ch, char b);
void set_adc_temperature(void);
//ïîñëåäîâàòåëüíûé ïîðò
//#define SERIAL_FIFO_RCV_LEN 8 /* size of receive fifo serial buffer */
#define SERIAL_FIFO_TRN_LEN 64 /* size of transmit fifo serial buffer */
// ????????? #if NUM_MULTICHANNEL
#define ALL_JOB 0
#define DISPLAY_JOB 1
#define SERIAL_JOB 2
#define ADC_JOB 3
#define STAT_JOB 4
//çàõâàò íà÷àëà ðàáîòû â ïðåðûâàíèè
//åñëè â ïðåðûâàíèå âîøëè èç ðåæèìà ñïÿ÷êè, òî:
//ñóììèðóåì âðåìÿ ñïÿ÷êè, ïåðåçàðÿæàåì timer_hold
//èíà÷å ñóììèðóåì âðåìÿ ðàáîòû, ïåðåçàðÿæàåì timer_hold
//ýòî äîëæíî âûçûâàòüñÿ â íà÷àëå ïðåðûâàíèÿ
#define HOLD_TIME_IRQ() temp_hold=TAR-2; \
if (sleep) {timer_sum_sleep+=temp_hold-timer_hold;} \
else { \
switch(why_job){ \
default: \
timer_sum+=temp_hold-timer_hold;break; \
case DISPLAY_JOB: \
timer_sum_display+=temp_hold-timer_hold;break; \
case SERIAL_JOB: \
timer_sum_serial+=temp_hold-timer_hold;break; \
case ADC_JOB: \
timer_sum_adc+=temp_hold-timer_hold;break; \
case STAT_JOB: \
timer_sum_stat+=temp_hold-timer_hold;break; \
} \
}
//ñóììèðóåì âðåìÿ ðàáîòû îñíîâíîé ïðîãðàììû - ýòîò ìàêðîñ çàìåíÿåò ñîáîé óõîä â ñïÿ÷êó
#define SUM_TIME(what_job,to_sleep) _DINT(); \
temp_hold=TAR; \
switch(why_job){ \
default: \
timer_sum+=temp_hold-timer_hold;break; \
case DISPLAY_JOB: \
timer_sum_display+=temp_hold-timer_hold;break; \
case SERIAL_JOB: \
timer_sum_serial+=temp_hold-timer_hold;break; \
case ADC_JOB: \
timer_sum_adc+=temp_hold-timer_hold;break; \
case STAT_JOB: \
timer_sum_stat+=temp_hold-timer_hold;break; \
} \
sleep=to_sleep;why_job=what_job; \
timer_hold=TAR; \
if (sleep) \
timer_sum_sleep+=(timer_hold-temp_hold); \
else timer_sum+=(timer_hold-temp_hold)
//ñóììèðóåì âðåìÿ ðàáîòû â ïðåðûâàíèè è çàõâàò íà÷àëà ðàáîòû îñíîâíîé ïðîãðàììû
#define SUM_TIME_IRQ() timer_hold=TAR+2;timer_sum_int+=timer_hold-temp_hold;sleep=0
#define SUM_TIME_IRQ_NOSLEEP() timer_hold=TAR+3;timer_sum_int+=timer_hold-temp_hold
enum chanel_job{
NO_JOB,
LEVEL_UP, //íàêà÷èâàåì äàâëåíèå
LEVEL_DOWN
};
#define open_valve() {valve_hold=0;P2OUT&=~(BIT4+BIT5);}
#define set_hold() P2OUT&=~BIT5
#define close_valve() {valve_hold=4;P2OUT|=(BIT4+BIT5);}
#define on_pump() P4OUT|=BIT0
#define off_pump() P4OUT&=~BIT0