Rev 743 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 743 | Rev 769 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | // ******************************************************** |
1 | // ******************************************************** |
2 | // ** Spektrum DX7(se) Expander for 10 Channels at large ** |
2 | // ** Spektrum DX7(se) Expander for 12 Channels at large ** |
3 | // ******************************************************** |
3 | // ******************************************************** |
4 | // ** Target: Atmel ATtiny2313 with delivered standard ** |
4 | // ** Target: Atmel ATtiny2313 with delivered standard ** |
5 | // ** Fuses (internal RC-Oscillator @ 1 MHz) ** |
5 | // ** Fuses (internal RC-Oscillator @ 1 MHz) ** |
6 | // ******************************************************** |
6 | // ******************************************************** |
7 | // ** It sends data from 4 additionally switches over ** |
7 | // ** It sends data from 6 additionally switches over ** |
8 | // ** the tripole "FLAP" channel which the FlightControl ** |
8 | // ** the tripole "FLAP" channel which the FlightControl ** |
9 | // ** can decode "on the fly" :) ** |
9 | // ** can decode "on the fly" :) ** |
10 | // ******************************************************** |
10 | // ******************************************************** |
11 | // ** (c) 2009-0xFFFF Stefan Pendsa ** |
11 | // ** (c) 2009-0xFFFF Stefan Pendsa ** |
12 | // ** License: don't know - use it and have fun ** |
12 | // ** License: don't know - use it and have fun ** |
Line 33... | Line 33... | ||
33 | 33 | ||
34 | 34 | ||
35 | int main(void) |
35 | int main(void) |
36 | { |
- | |
37 | char i,Parity; // Bit-Counter and Parity Bit |
36 | { |
38 | unsigned int timer=0; // Timer for Battery-Remember-Beeping |
37 | char i,Parity; // Bit-Counter and Parity Bit |
39 | DDRA = 0b011; // PORT A INPUT: RESET; OUTPUT: Sync+Data |
38 | DDRA = 0b011; // PORT A INPUT: RESET; OUTPUT: Sync+Data |
40 | DDRB = 0b00000000; // PORT B INPUT: Jumper for Bypass |
39 | DDRB = 0b00000000; // PORT B INPUT: Jumper for Bypass |
41 | DDRD = 0b0000000; // PORT D INPUT: Switches + DX7-Sync |
40 | DDRD = 0b0000000; // PORT D INPUT: Switches + DX7-Sync |
42 | PORTA = 0b111; // Pull-Up for /RESET, High for Sync+Data |
41 | PORTA = 0b111; // Pull-Up for /RESET, High for Sync+Data |
Line 43... | Line 42... | ||
43 | PORTB = 0b01000000; // Pull-Up for Jumper |
42 | PORTB = 0b01000000; // Pull-Up for Jumper |
44 | PORTD = 0b0011111; // Pull-Up for Switches |
43 | PORTD = 0b1011111; // Pull-Up for Switches |
45 | 44 | ||
46 | while(1) // Main-Loop (Sending data all the time) |
45 | while(1) // Main-Loop (Sending data all the time) |
Line 56... | Line 55... | ||
56 | else // Normal Mode |
55 | else // Normal Mode |
57 | { |
56 | { |
58 | Parity = 0; // Reset Parity Bit |
57 | Parity = 0; // Reset Parity Bit |
59 | Send(1,0); // Send SYNC Pulse |
58 | Send(1,0); // Send SYNC Pulse |
Line -... | Line 59... | ||
- | 59 | ||
60 | 60 | i=0; |
|
61 | for (i=0;i<5;i++) // Encode the first five Port Pins |
61 | while (i<7) // Encode PD0-PD4 + PD6 |
62 | { |
62 | { |
63 | if (PIND & (1<<i)) // Check Pin #i |
63 | if (PIND & (1<<i)) // Check Pin #i |
64 | { |
64 | { |
65 | Send(0,0); // When High, Send Low (Switched to "0") |
65 | Send(0,0); // When High, Send Low (Switched to "0") |
66 | Parity = ~Parity; // and invert Parity Bit |
66 | Parity = ~Parity; // and invert Parity Bit |
- | 67 | } |
|
67 | } |
68 | else Send(0,1); // When Low, Send High (Switched to "1") |
- | 69 | i++; |
|
- | 70 | if (i == 5) i = 6; // Skip PD5 |
|
- | 71 | } |
|
- | 72 | ||
- | 73 | for (i=0;i<2;i++) // Encode PB0+PB1 (Hover Pitch) |
|
- | 74 | { |
|
68 | else |
75 | if ((PINB & (1<<i))) // Check Pin #i |
69 | { |
76 | { |
- | 77 | Send(0,0); // When High, Send Low (Switched to "0") |
|
70 | Send(0,1); // When Low, Send High (Switched to "1") |
78 | Parity = ~Parity; // and invert Parity Bit |
- | 79 | } |
|
71 | } |
80 | else Send(0,1); // When Low, Send High (Switched to "1") |
Line 72... | Line 81... | ||
72 | } |
81 | } |
73 | - | ||
74 | Send(0,Parity); // Send Parity Bit |
- | |
75 | - | ||
76 | timer++; // Timer increase for Battery-Remember-Beeping |
- | |
77 | if (timer == 6000) DDRB = 0b00000001; // 15 min 0.00 sec -> PB0 to GND |
- | |
78 | if (timer == 6001) DDRB = 0b00000000; // 15 min 0.15 sec -> PB0 input again |
- | |
79 | if (timer == 6002) DDRB = 0b00000010; // 15 min 0.30 sec -> PB1 to GND |
- | |
80 | if (timer == 6003) DDRB = 0b00000000; // 15 min 0.45 sec -> PB1 input again |
82 | |
81 | if (timer == 6004) timer = 0; // 15 min 0.60 sec -> Timer reset (half delays on DX7se) |
83 | Send(0,Parity); // Send Parity Bit |
82 | } |
84 | } |