Subversion Repositories Projects

Rev

Rev 535 | Rev 542 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 535 Rev 541
Line 12... Line 12...
12
// ** License: don't know - use it and have fun          **
12
// ** License: don't know - use it and have fun          **
13
// ********************************************************
13
// ********************************************************
Line 14... Line 14...
14
 
14
 
15
 
-
 
Line 16... Line 15...
16
#include <avr/io.h>
15
 
17
#include <util/delay.h>
16
#include <avr/io.h>
18
 
17
 
19
#define TX_High PORTA |= 1 << PORTA0                                            // Set TX-Pin High
18
#define TX_High PORTA |= 1 << PORTA0                                            // Set TX-Pin High
Line 25... Line 24...
25
 
24
 
26
void Send(char sync, char data)
25
void Send(char sync, char data)
27
{
26
{
28
        if (sync == 0) SYNC_High; else SYNC_Low;                                // Send Sync
27
        if (sync == 0) SYNC_High; else SYNC_Low;                                // Send Sync
29
        if (data == 0) TX_High; else TX_Low;                                    // Send Data
28
        if (data == 0) TX_High; else TX_Low;                                    // Send Data
30
        _delay_ms(22);                                                                                  // Don't be too fast (Spektrum DX7 updates every 22ms)
29
        while ( PIND & (1<<PD5) );                                                              // Wait for DX7-Sync goes low
-
 
30
        while ( !(PIND & (1 << PD5)) );                                                 // Wait for DX7-Sync goes high
Line 31... Line 31...
31
}                                                                                                                       // (For DX7se set it to 11ms!!)
31
}
32
 
32
 
33
 
33
 
34
 
34
 
35
int main(void)
35
int main(void)
36
{
36
{
37
        char i,Parity;                                                                                  // Bit-Counter and Parity Bit
37
        char i,Parity;                                                                                  // Bit-Counter and Parity Bit
Line 38... Line 38...
38
        DDRA = 0b011;                                                                                   // PORT A INPUT: RESET; OUTPUT: Sync+Data
38
        DDRA = 0b011;                                                                                   // PORT A INPUT: RESET; OUTPUT: Sync+Data
39
        DDRD = 0b0000000;                                                                               // PORT D INPUT: Switches
39
        DDRD = 0b0000000;                                                                               // PORT D INPUT: Switches + DX7-Sync
40
        PORTA = 0b111;                                                                                  // Pull-Up for /RESET, High for Sync+Data
40
        PORTA = 0b111;                                                                                  // Pull-Up for /RESET, High for Sync+Data
41
        PORTD = 0b1111111;                                                                              // Pull-Up for Switches
41
        PORTD = 0b0011111;                                                                              // Pull-Up for Switches