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