3237 |
kaklik |
1 |
#include "main.h" |
|
|
2 |
|
|
|
3 |
#define LED1 PIN_E0 // RMC |
|
|
4 |
#define LED2 PIN_E1 // 10s |
|
|
5 |
#define LED3 PIN_E2 // PPS |
|
|
6 |
#define LED4 PIN_A5 // Fix |
|
|
7 |
|
|
|
8 |
#define SYNC_OUTPUT PIN_A0 |
|
|
9 |
|
|
|
10 |
int1 sync; |
|
|
11 |
int8 sec; |
|
|
12 |
|
|
|
13 |
// Interrupt from B0 |
|
|
14 |
#int_EXT |
|
|
15 |
void EXT_isr(void) |
|
|
16 |
{ |
|
|
17 |
if (sync==1) |
|
|
18 |
{ |
|
|
19 |
output_high(SYNC_OUTPUT); |
|
|
20 |
output_toggle(LED2); |
|
|
21 |
delay_us(5); |
|
|
22 |
output_low(SYNC_OUTPUT); |
|
|
23 |
sync=0; |
|
|
24 |
} |
|
|
25 |
output_toggle(LED3); |
|
|
26 |
} |
|
|
27 |
|
|
|
28 |
|
|
|
29 |
void main() |
|
|
30 |
{ |
|
|
31 |
|
|
|
32 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
33 |
setup_adc(ADC_CLOCK_DIV_2); |
|
|
34 |
setup_spi(SPI_SS_DISABLED); |
|
|
35 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
36 |
setup_wdt(WDT_2304MS|WDT_DIV_16); |
|
|
37 |
setup_timer_1(T1_DISABLED); |
|
|
38 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
39 |
setup_ccp1(CCP_OFF); |
|
|
40 |
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard |
|
|
41 |
|
|
|
42 |
|
|
|
43 |
output_low(SYNC_OUTPUT); |
|
|
44 |
output_high(LED1); |
|
|
45 |
output_high(LED2); |
|
|
46 |
output_high(LED3); |
|
|
47 |
|
|
|
48 |
sync=0; |
|
|
49 |
|
|
|
50 |
enable_interrupts(INT_EXT); |
|
|
51 |
enable_interrupts(GLOBAL); |
|
|
52 |
|
|
|
53 |
while(true) |
|
|
54 |
{ |
|
|
55 |
while (getch()!='$'); |
|
|
56 |
if (getch()!='G') continue; |
|
|
57 |
if (getch()!='P') continue; |
|
|
58 |
if (getch()!='R') continue; |
|
|
59 |
if (getch()!='M') continue; |
|
|
60 |
if (getch()!='C') continue; |
|
|
61 |
if (getch()!=',') continue; |
|
|
62 |
getch(); |
|
|
63 |
getch(); |
|
|
64 |
getch(); |
|
|
65 |
getch(); |
|
|
66 |
getch(); |
|
|
67 |
output_toggle(LED1); |
|
|
68 |
sec=getch(); |
|
|
69 |
if ((sec=='9')) {sync=1; continue;} |
|
|
70 |
getch(); |
|
|
71 |
getch(); |
|
|
72 |
getch(); |
|
|
73 |
getch(); |
|
|
74 |
// getch(); GPS01A ma A na 18. znaku, ne na 19. |
|
|
75 |
if ('A'!=getch()) |
|
|
76 |
{ |
|
|
77 |
output_high(LED4); // Neni FIX |
|
|
78 |
if (sec=='0') {sync=1;} // Extra click hlasi chybu |
|
|
79 |
} |
|
|
80 |
else |
|
|
81 |
{ |
|
|
82 |
output_low(LED4); |
|
|
83 |
} |
|
|
84 |
} |
|
|
85 |
|
|
|
86 |
} |