Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 768 → Rev 769

/Spektrum-Expander/DX7-Modulator/sexpander.c
1,10 → 1,10
// ********************************************************
// ** Spektrum DX7(se) Expander for 10 Channels at large **
// ** Spektrum DX7(se) Expander for 12 Channels at large **
// ********************************************************
// ** Target: Atmel ATtiny2313 with delivered standard **
// ** Fuses (internal RC-Oscillator @ 1 MHz) **
// ********************************************************
// ** It sends data from 4 additionally switches over **
// ** It sends data from 6 additionally switches over **
// ** the tripole "FLAP" channel which the FlightControl **
// ** can decode "on the fly" :) **
// ********************************************************
35,13 → 35,12
int main(void)
{
char i,Parity; // Bit-Counter and Parity Bit
unsigned int timer=0; // Timer for Battery-Remember-Beeping
DDRA = 0b011; // PORT A INPUT: RESET; OUTPUT: Sync+Data
DDRB = 0b00000000; // PORT B INPUT: Jumper for Bypass
DDRD = 0b0000000; // PORT D INPUT: Switches + DX7-Sync
PORTA = 0b111; // Pull-Up for /RESET, High for Sync+Data
PORTB = 0b01000000; // Pull-Up for Jumper
PORTD = 0b0011111; // Pull-Up for Switches
PORTD = 0b1011111; // Pull-Up for Switches
 
while(1) // Main-Loop (Sending data all the time)
{
58,7 → 57,8
Parity = 0; // Reset Parity Bit
Send(1,0); // Send SYNC Pulse
 
for (i=0;i<5;i++) // Encode the first five Port Pins
i=0;
while (i<7) // Encode PD0-PD4 + PD6
{
if (PIND & (1<<i)) // Check Pin #i
{
65,20 → 65,22
Send(0,0); // When High, Send Low (Switched to "0")
Parity = ~Parity; // and invert Parity Bit
}
else
else Send(0,1); // When Low, Send High (Switched to "1")
i++;
if (i == 5) i = 6; // Skip PD5
}
 
for (i=0;i<2;i++) // Encode PB0+PB1 (Hover Pitch)
{
if ((PINB & (1<<i))) // Check Pin #i
{
Send(0,1); // When Low, Send High (Switched to "1")
Send(0,0); // When High, Send Low (Switched to "0")
Parity = ~Parity; // and invert Parity Bit
}
else Send(0,1); // When Low, Send High (Switched to "1")
}
 
Send(0,Parity); // Send Parity Bit
 
timer++; // Timer increase for Battery-Remember-Beeping
if (timer == 6000) DDRB = 0b00000001; // 15 min 0.00 sec -> PB0 to GND
if (timer == 6001) DDRB = 0b00000000; // 15 min 0.15 sec -> PB0 input again
if (timer == 6002) DDRB = 0b00000010; // 15 min 0.30 sec -> PB1 to GND
if (timer == 6003) DDRB = 0b00000000; // 15 min 0.45 sec -> PB1 input again
if (timer == 6004) timer = 0; // 15 min 0.60 sec -> Timer reset (half delays on DX7se)
}
}
}