Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 790 → Rev 791

/Spektrum-Diversity/Software/diversity.aws
1,0 → 0,0
<AVRWorkspace><IOSettings><CurrentRegisters/></IOSettings><part name="ATMEGA128"/><Files><File00000 Name="D:\Pendsa\Spektrum-Diversity\Software\diversity.c" Position="262 71 1328 776" LineCol="84 0" State="Maximized"/></Files></AVRWorkspace>
<AVRWorkspace><IOSettings><CurrentRegisters/></IOSettings><part name="ATMEGA128"/><Files><File00000 Name="D:\Pendsa\Spektrum-Diversity\Software\diversity.c" Position="262 71 1328 776" LineCol="211 4" State="Maximized"/></Files></AVRWorkspace>
/Spektrum-Diversity/Software/diversity.c
1,5 → 1,5
// ***************************************************************
// ** Spektrum Diversity v1.0 - use up to 4 satellite receivers **
// ** Spektrum Diversity v1.3 - use up to 4 satellite receivers **
// ***************************************************************
// ** Target: An Atmel ATtiny2313 (RC-Oscillator @ 8 MHz) **
// ** controls a 74HC151 Multiplexer **
7,11 → 7,9
// ** It monitors the data from 4 satellite receivers and **
// ** connects a valid one to the output via the multiplexer **
// ***************************************************************
// ** LED-Modes during startup (in chronological order) **
// ** LED-Modes during startup **
// ** ************************ **
// ** LED fast blink: Waiting for first datapulse **
// ** LED slow blink: Waiting 3 seconds while counting sat's **
// ** LED flashes: Indicates the number of active sat's **
// ** LED fast flash: Waiting for first datapulse **
// ** **
// ** LED-Modes during operation **
// ** ************************** **
18,11 → 16,11
// ** LED OFF: Everything is fine **
// ** LED ON: FAILURE - The first selected sat had lost sync **
// ** **
// ** LED-Modes after Self-Test **
// ** ************************* **
// ** LED-Modes after Self-Test and pressed button **
// ** ******************************************** **
// ** LED flashes at 1 Hz: Everything is fine **
// ** LED flashes some times: Times flashed -> damaged Channel# **
// ** LED off: check voltage(regulator) or firmware **
// ** LED off: check voltage(regulator), button or firmware **
// ***************************************************************
// ** (c) 2010-0xFFFF Stefan Pendsa **
// ** License: don't know - use it and have fun **
29,16 → 27,23
// ***************************************************************
 
#include <avr/io.h>
#include <avr/eeprom.h>
#include <avr/interrupt.h>
#include <util/delay.h>
 
 
#define LED_OFF PORTD |= 1 << PD0
#define LED_ON PORTD &= ~(1 << PD0)
 
volatile unsigned int TimerEvent;
 
unsigned char eedummy EEMEM; // Dummy-Variable for Address 0 in EEPROM
unsigned char eecheck EEMEM; // Check-Variable
unsigned char bind; // Bind-Pulse-Counter (in RAM)
unsigned char eebind EEMEM; // Bind-Pulse-Counter (in EEPROM)
 
 
 
ISR(TIMER1_OVF_vect) // Triggered every 8,192 msec
{
TimerEvent++;
63,7 → 68,7
 
 
 
void Binding(void) // Binding sequence for DX7
void Binding(void) // Binding sequence
{
unsigned char i = 0;
 
70,7 → 75,7
DDRB = 0b11110000; // Sat-Pins to output
_delay_ms(80); // Let them time to boot up
for (i=0;i<3;i++) // send three negative 100µs pulses to all sat's
for (i=0;i<bind;i++) // Send negative 100µs pulses to all sat's
{
PORTB = 0b00000000;
_delay_us(100);
78,8 → 83,20
_delay_us(100);
}
 
_delay_ms(1000);
DDRB = 0b00000000; // Sat-Pins to input after 1sec
for (i=0;i<bind;i++) // Flash the number of used pulses to the LED
{
LED_ON;
_delay_ms(100);
LED_OFF;
_delay_ms(250);
}
 
DDRB = 0b00000000; // Sat-Pins to input again
bind++; // Save increased bind-pulse-counter for next binding.
if (bind > 6) bind = 3; // 3 pulses are for DX7+AR6200, 4-6 pulses have been seen...
eeprom_write_byte(&eebind, bind); // around the world for other combinations. Hopefully it works for them.
_delay_ms(500);
}
 
 
113,6 → 130,8
 
DDRB = 0b00000000; // Port B Input again
 
while (PIND & (1<<PD6)); // Wait for Bind-Switch
 
while(1) // Never return
{
if (error == 0) // When no error occured -> LED flashes at 1 Hz
143,9 → 162,8
int main(void)
{
unsigned char i = 0;
unsigned char j = 0;
unsigned char active[4];
unsigned char sat = 4;
unsigned char sat = 99;
 
DDRB = 0b00000000; // Port B Input for satellites and feedback
DDRD = 0b0011001; // Port D Output for MUX and LED, Input for Switch & Test
154,6 → 172,16
 
for (i=0;i<4;i++) active[i] = 0; // Reset active-array
 
 
if (eeprom_read_byte(&eecheck) != 0x42) // Invalid Data in EEPROM -> initialize
{
eeprom_write_byte(&eecheck, 0x42);
bind = 3;
eeprom_write_byte(&eebind, bind);
}
else bind = eeprom_read_byte(&eebind); // Valid Data in EEPROM -> read bind-pulse-counter
 
 
if (!(PIND & (1<<PD5))) Testing(); // Initiate Self-Test when Test-Pad is low
if (!(PIND & (1<<PD6))) Binding(); // Initiate Binding when Bind-Button is pressed
 
164,7 → 192,7
sei(); // Global Interrupts enable
 
ResetTimer();
while((PINB & 0b11110000) == 0b11110000) // Wait for first signal (SYNC to frame)
while(sat == 99) // Wait for first signal
{
if (TimerEvent == 10) LED_ON; // Blink while waiting...
if (TimerEvent == 20)
172,54 → 200,21
LED_OFF;
TimerEvent = 0;
}
}
LED_OFF;
 
ResetTimer();
while(1) // Check active satellites for 5 seconds
{
if (TimerEvent == 20) LED_ON; // Blink (slower) while waiting...
if (TimerEvent == 40)
for (i=0;i<4;i++) // Select first active Satellite
{
LED_OFF;
TimerEvent = 0;
j++;
}
 
for (i=0;i<4;i++)
{
if (!(PINB & (1<<(i+4))))
{
active[i] = 1;
if (sat == 4) // Select first active satellite (only once)
{
sat = i;
SelectSat(i);
}
 
sat = i;
SelectSat(sat);
break;
}
}
if (j == 16) break; // 16 * 40 * 8ms = ~5sec
}
 
LED_OFF;
_delay_ms(1000);
 
for (i=0;i<4;i++) // Flash once for every active satellite
{
if (active[i] == 1)
{
LED_ON;
_delay_ms(100);
LED_OFF;
_delay_ms(400);
}
}
 
 
 
 
while(1) // Main-Loop
{
for (i=0;i<4;i++) active[i] = 0; // Reset active-array
233,7 → 228,6
ResetTimer();
while(TimerEvent < 1) // Check active satellites (for 1*8=8ms)
{
 
for (i=0;i<4;i++)
{
if (!(PINB & (1<<(i+4))))
245,7 → 239,6
 
if (active[sat] == 0) // Detect fail on active satellite
{
LED_ON; // Failure-LED ON
for (i=0;i<4;i++) // Select lowest active satellite
{
if (active[i] == 1)
255,6 → 248,7
break;
}
}
LED_ON; // Failure-LED ON
}
 
if (!(PIND & (1<<PD6))) LED_OFF; // Reset Failure-LED when Bind-Button is pressed
/Spektrum-Diversity/Software/Hex-Files/diversity.hex
1,70 → 1,72
:1000000012C02AC029C028C027C027C025C024C0CC
:1000100023C022C021C020C01FC01EC01DC01CC0E4
:100020001BC01AC019C011241FBECFEDCDBF10E0F8
:10003000A0E6B0E0ECE4F4E002C005900D92A0363A
:10004000B107D9F710E0A0E6B0E001C01D92A236DA
:10005000B107E1F7E3D0F8C1D3CF1F920F920FB6EB
:10003000A0E6B0E0ECE6F4E002C005900D92A03638
:10004000B107D9F710E0A0E6B0E001C01D92A336D9
:10005000B107E1F70AD108C2D3CF1F920F920FB6B2
:100060000F9211248F939F93809160009091610073
:10007000019690936100809360009F918F910F9003
:100080000FBE0F901F90189592B3880F880F880F9E
:100090009776982B92BB8AE18A95F1F708951DBC5B
:1000A0001CBC1092610010926000089580EF87BB25
:1000B00020E233E068EC70E048EC50E0CB010197BF
:1000C000F1F721503040C1F718BACA010197F1F792
:1000D00080EF88BBFA013197F1F718BAFA0131972E
:1000E000F1F788BBFA013197F1F718BAFA013197A5
:1000F000F1F788BBCA010197F1F780E197E228EC9C
:1001000030E0F9013197F1F70197D9F717BA08955F
:1001100080EF87BB80E588BB82B3877682BB9AE19C
:10012000892F8A95F1F726B382B38776886082BBE0
:100130009A95F1F7B39B02C022E005C0269526955B
:1001400026952095217082B38776806182BB8AE1F3
:100150008A95F1F7B39B23E082B38776886182BBEF
:100160008AE18A95F1F7B39924E080EA88BB82B3EB
:10017000877682BB8AE18A95F1F7B39921E082B351
:100180008776886082BB8AE18A95F1F7B39B22E08B
:1001900082B38776806182BB8AE18A95F1F7B39951
:1000B00080E293E028EC30E0F9013197F1F7019705
:1000C000D9F78091620090E028EC30E040EF09C061
:1000D00018BAF9013197F1F748BBF9013197F1F7F7
:1000E0009F5F9817A8F390E048EC50E013C09098F9
:1000F00028EE33E0FA013197F1F721503040D1F783
:10010000909A24EC39E0FA013197F1F72150304010
:10011000D1F79F5F981758F317BA8F5F80936200EB
:10012000873018F083E08093620020916200E199AB
:10013000FECF1CBA82E090E08EBB2DBB0FB6F894C8
:10014000E29AE19A0FBE88E893E128EC30E0F901E9
:100150003197F1F70197D9F7089580EF87BB80E5D4
:1001600088BB82B3877682BB9AE1892F8A95F1F7A3
:1001700026B382B38776886082BB9A95F1F7B39BEA
:1001800002C022E005C0269526952695209521706F
:1001900082B38776806182BB8AE18A95F1F7B39B4F
:1001A00023E082B38776886182BB8AE18A95F1F782
:1001B000B39B24E017BA48EC50E0222399F428ECD2
:1001C00030E0909888EE93E0F9013197F1F70197CC
:1001D000D9F7909A88E293E2F9013197F1F7019704
:1001E000D9F7EFCF30E0909888EE93E0FA0131979D
:1001F000F1F70197D9F7909A80EA9FE0FA013197D9
:10020000F1F70197D9F73F5F321768F380E197E282
:10021000FA013197F1F70197D9F7CFCFFF920F93FA
:100220001F93DF93CF9300D000D0CDB7DEB717BABE
:1002300089E181BB80EF88BB81E682BB19821A828B
:100240001B821C82859B64DF869B30DF88EE93E0F7
:1002500028EC30E0F9013197F1F70197D9F781E007
:100260008EBD80E889BF78941DBC1CBC0EC08091F7
:100270006000909161000A9709F490988091600065
:1002800090916100449729F4909A10926100109225
:10029000600086B3807F803F51F3909A1DBC1CBCE8
:1002A000109261001092600060E074E0DE0111962F
:1002B00001E01AE18091600090916100449709F497
:1002C00090988091600090916100889731F4909AA5
:1002D00010926100109260006F5F40E050E086B3C2
:1002E00090E04C5F5F4F042E02C0959587950A946D
:1002F000E2F74450504080FD14C0FD01E40FF51FAB
:100300000083743071F482B39A0173E0220F331FBB
:100310007A95E1F78776822B82BB812F8A95F1F758
:10032000742F4F5F5F4F44305105C9F6603109F0BB
:10033000C1CF909A80E197E228EC30E0F901319743
:10034000F1F70197D9F78E010F5F1F4FD80128EC05
:1003500030E0AE014B5F5F4F8C91813081F490981B
:1003600088EE93E0F9013197F1F70197D9F7909A68
:1003700080EA9FE0F9013197F1F70197D9F71196DB
:10038000A417B50749F7FF24F394DE0111966AE13B
:1003900019821A821B821C821DBC1CBC1092610037
:1003A0001092600006C080916000909161000497F7
:1003B00020F486B3807F803FB1F31DBC1CBC10923B
:1003C00061001092600013C0F80124E030E086B3B1
:1003D00090E0022E02C0959587950A94E2F780FF7F
:1003E000F0822F5F3F4F31962830310581F78091A1
:1003F000600090916100892B39F3FD01E70FF11D39
:1004000080818823E9F4909840E050E0FD01E40FFA
:10041000F51F8081813079F482B39A0193E0220F35
:10042000331F9A95E1F78776822B82BB862F8A95B8
:10043000F1F7742F05C04F5F5F4F4430510531F71E
:0C0440008699A6CF909AA4CFF894FFCF25
:1001B000B39924E080EA88BB82B3877682BB8AE168
:1001C0008A95F1F7B39921E082B38776886082BB84
:1001D0008AE18A95F1F7B39B22E082B3877680614A
:1001E00082BB8AE18A95F1F7B39923E082B38776DF
:1001F000886182BB8AE18A95F1F7B39B24E017BA44
:100200008699FECF48EC50E0222399F428EC30E0A8
:10021000909888EE93E0F9013197F1F70197D9F7BB
:10022000909A88E293E2F9013197F1F70197D9F7B3
:10023000EFCF30E0909888EE93E0FA013197F1F734
:100240000197D9F7909A80EA9FE0FA013197F1F788
:100250000197D9F73F5F321768F380E197E2FA011F
:100260003197F1F70197D9F7CFCF1F93DF93CF9352
:1002700000D000D0CDB7DEB717BA89E181BB80EFDF
:1002800088BB81E682BB19821A821B821C82E1999B
:10029000FECF81E090E0982F8EBBE09A8DB3823440
:1002A000E1F0E199FECF1CBA9EBB82E48DBB0FB694
:1002B000F894E29AE19A0FBE83E080936200E1999C
:1002C000FECF1CBA82E090E08EBB83E08DBB0FB600
:1002D000F894E29AE19A0FBE09C0E199FECF82E05C
:1002E00090E08EBBE09A8DB380936200859B35DFF2
:1002F000869BDCDE88EE93E028EC30E0F901319754
:10030000F1F70197D9F781E08EBD80E889BF789435
:100310001DBC1CBC1092610010926000DE011196A1
:1003200011E07AE180916000909161000A9709F4F0
:1003300090988091600090916100449729F4909A80
:10034000109261001092600040E050E0642F86B38C
:1003500090E04C5F5F4F042E02C0959587950A94FC
:10036000E2F74450504080FD14C0FD01E40FF51F3A
:10037000108382B39A0153E0220F331F5A95E1F79D
:100380008776822B82BB872F8A95F1F7633651F2ED
:1003900007C04F5F5F4F4430510509F4C3CFD6CF3C
:1003A000909A242FBE016F5F7F4FB1E0AAE11982BE
:1003B0001A821B821C821DBC1CBC10926100109210
:1003C000600006C08091600090916100049720F465
:1003D00086B3807F803FB1F31DBC1CBC10926100CE
:1003E0001092600010C086B390E0042E02C0959574
:1003F00087950A94E2F780FFB0834F5F5F4F319695
:100400004830510581F78091600090916100892BFF
:1004100021F4FB0144E050E0E6CFFB01E20FF11DC7
:1004200080818823E9F440E050E0FB01E40FF51FF0
:100430008081813079F482B39A0193E0220F331FD7
:100440009A95E1F78776822B82BB8A2F8A95F1F7FE
:10045000242F05C04F5F5F4F4430510531F790980E
:0C0460008699A5CF909AA3CFF894FFCF07
:00000001FF
/Spektrum-Diversity/Software/diversity.aps
1,0 → 0,0
<AVRStudio><MANAGEMENT><ProjectName>diversity</ProjectName><Created>23-Jul-2010 13:27:06</Created><LastEdit>29-Jul-2010 15:40:51</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>23-Jul-2010 13:27:06</Created><Version>4</Version><Build>4, 18, 0, 670</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>default\diversity.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>D:\Pendsa\Spektrum-Diversity\Software\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>JTAGICE mkII</CURRENT_TARGET><CURRENT_PART>ATmega128.xml</CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>diversity.c</SOURCEFILE><OTHERFILE>default\diversity.lss</OTHERFILE><OTHERFILE>default\diversity.map</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>NO</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE></EXTERNALMAKEFILE><PART>attiny2313</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>diversity.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>0</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\Programme\WinAVR-20081205\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\Programme\WinAVR-20081205\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><ProjectFiles><Files><Name>D:\Pendsa\Spektrum-Diversity\Software\diversity.c</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="1" orderaddress="1" ordergroup="1"/></IOView><Files><File00000><FileId>00000</FileId><FileName>diversity.c</FileName><Status>1</Status></File00000></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
<AVRStudio><MANAGEMENT><ProjectName>diversity</ProjectName><Created>23-Jul-2010 13:27:06</Created><LastEdit>09-Aug-2010 16:58:21</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>23-Jul-2010 13:27:06</Created><Version>4</Version><Build>4, 18, 0, 670</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>default\diversity.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>D:\Pendsa\Spektrum-Diversity\Software\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>JTAGICE mkII</CURRENT_TARGET><CURRENT_PART>ATmega128.xml</CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>diversity.c</SOURCEFILE><OTHERFILE>default\diversity.lss</OTHERFILE><OTHERFILE>default\diversity.map</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>NO</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE></EXTERNALMAKEFILE><PART>attiny2313</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>diversity.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>0</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\Programme\WinAVR-20081205\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\Programme\WinAVR-20081205\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><ProjectFiles><Files><Name>D:\Pendsa\Spektrum-Diversity\Software\diversity.c</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files><File00000><FileId>00000</FileId><FileName>diversity.c</FileName><Status>1</Status></File00000></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>