2002 |
kakl |
1 |
#include "main.h" |
|
|
2 |
|
|
|
3 |
|
|
|
4 |
#define LED PIN_B2 |
|
|
5 |
#define TRAFO1 PIN_B1 |
|
|
6 |
#define TRAFO2 PIN_A2 |
|
|
7 |
#define ALERT PIN_B5 |
|
|
8 |
#define OPTRON PIN_A0 |
|
|
9 |
|
|
|
10 |
|
|
|
11 |
void main() |
|
|
12 |
{ |
|
|
13 |
output_high(ALERT); |
|
|
14 |
|
|
|
15 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
16 |
setup_adc(ADC_CLOCK_DIV_2); |
|
|
17 |
setup_spi(SPI_SS_DISABLED); |
|
|
18 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
19 |
// setup_wdt(WDT_1152MS|WDT_DIV_16); |
|
|
20 |
setup_wdt(WDT_288MS); |
|
|
21 |
setup_timer_1(T1_DISABLED); |
|
|
22 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
23 |
setup_ccp1(CCP_OFF); |
|
|
24 |
setup_comparator(NC_NC_NC_NC); |
|
|
25 |
setup_vref(FALSE); |
|
|
26 |
setup_oscillator(OSC_1MHZ|OSC_TIMER1); |
|
|
27 |
|
|
|
28 |
restart_wdt(); |
|
|
29 |
|
|
|
30 |
while(true) |
|
|
31 |
{ |
|
|
32 |
int8 n; |
|
|
33 |
|
|
|
34 |
for(n=0;n<165;n++) // 20ms |
|
|
35 |
{ |
|
|
36 |
output_low(TRAFO1); |
|
|
37 |
output_high(TRAFO2); |
|
|
38 |
delay_us(28); // 121us |
|
|
39 |
output_high(TRAFO1); |
|
|
40 |
output_low(TRAFO2); |
|
|
41 |
} |
|
|
42 |
restart_wdt(); |
|
|
43 |
output_high(TRAFO1); |
|
|
44 |
output_high(TRAFO2); |
|
|
45 |
output_toggle(LED); |
|
|
46 |
delay_ms(100); |
|
|
47 |
restart_wdt(); |
|
|
48 |
|
|
|
49 |
int16 i; |
|
|
50 |
|
4630 |
kakl |
51 |
for(i=0;i<1300;i++) |
2002 |
kakl |
52 |
{ |
|
|
53 |
delay_ms(1); |
|
|
54 |
restart_wdt(); |
|
|
55 |
if(input(OPTRON)==0) |
|
|
56 |
{ |
|
|
57 |
output_low(ALERT); |
|
|
58 |
while(TRUE) restart_wdt(); |
|
|
59 |
} |
|
|
60 |
} |
|
|
61 |
} |
|
|
62 |
} |
|
|
63 |
|