4 |
4: |
4: |
5 |
5: #include "lcd.h" |
5: #include "lcd.h" |
6 |
6: |
6: |
7 |
7: |
7: void AD_init(void) |
8 |
8: void rs232_init(void) |
8: { |
9 |
9: { |
9: ADON = 1; |
10 |
10: SPEN = 0; // Serial Port Enable Bit... 0 = disabled |
10: } |
11 |
11: TRISC6 = 0; |
11: |
12 |
12: TRISC7 = 1; |
12: void rs232_init(void) |
13 |
13: SYNC = 0; // SYNC switches between async(0) and sync(1) mode. |
13: { |
14 |
14: SPBRG = 25; |
14: SPEN = 0; // Serial Port Enable Bit... 0 = disabled |
15 |
15: TXSTA = 0x24; |
15: TRISC6 = 0; |
16 |
16: RCSTA = 0x90; |
16: TRISC7 = 1; |
17 |
17: SPEN = 1; |
17: SYNC = 0; // SYNC switches between async(0) and sync(1) mode. |
18 |
18: } |
18: SPBRG = 25; |
19 |
19: |
19: TXSTA = 0x24; |
20 |
20: void interrupt_init(void) |
20: RCSTA = 0x90; |
21 |
21: { |
21: SPEN = 1; |
22 |
22: // Assumes that all interrupts default is 0 |
22: } |
23 |
23: PEIE = 1; |
23: |
24 |
24: GIE = 1; |
24: void interrupt_init(void) |
25 |
25: RCIE = 1; |
25: { |
26 |
26: } |
26: // Assumes that all interrupts default is 0 |
27 |
27: |
27: PEIE = 1; |
28 |
28: void pic18_io_init(void) |
28: GIE = 1; |
29 |
29: { |
29: RCIE = 1; |
30 |
30: TRISA0 = 1; |
30: } |
31 |
31: TRISB1 = 1; |
31: |
32 |
32: TRISB2 = 1; |
32: void pic18_io_init(void) |
33 |
33: TRISB3 = 1; |
33: { |
34 |
34: TRISB4 = 1; |
34: TRISA0 = 1; |
35 |
35: } |
35: TRISB1 = 1; |
36 |
36: |
36: TRISB2 = 1; |
37 |
37: void interrupt_recieve_handler(void) |
37: TRISB3 = 1; |
38 |
38: { |
38: TRISB4 = 1; |
39 |
39: // Handle recieve inputs... |
39: } |
40 |
40: } |
40: |
41 |
41: |
41: void interrupt_recieve_handler(void) |
42 |
42: void interrupt interrupt_handler(void) |
42: { |
43 |
43: { |
43: // Handle recieve inputs... |
44 |
44: if(RCIF == 1) |
44: } |
45 |
45: { |
45: |
46 |
46: interrupt_recieve_handler(); |
46: void interrupt interrupt_handler(void) |
47 |
47: RCIF = 0; |
47: // Finds out what interrupt have been trigged, and starts the respective function. |
48 |
48: } |
48: { |
49 |
49: } |
49: if(RCIF == 1) |
50 |
50: |
50: { |
51 |
51: |
51: interrupt_recieve_handler(); |
52 |
52: void main() |
52: RCIF = 0; |
53 |
53: { |
53: } |
54 |
54: rs232_init(); |
54: } |
55 |
55: pic18_io_init(); |
55: |
56 |
56: } |
56: |
57 |
|
57: void main() |
58 |
|
58: { |
59 |
|
59: AD_init(); |
60 |
|
60: rs232_init(); |
61 |
|
61: pic18_io_init(); |
62 |
|
62: |
63 |
|
63: if(GODONE==0) |
64 |
|
64: { |
65 |
|
65: |
66 |
|
66: } |
67 |
|
67: } |