Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 779 → Rev 780

/Spektrum-Diversity/Software/diversity.c
1,38 → 1,39
// *************************************************************
// ** Spektrum Diversity - use up to 4 satellite receivers **
// *************************************************************
// ** Target: An Atmel ATtiny2313 (RC-Oscillator @ 8 MHz) **
// ** controls a 74HC151 Multiplexer **
// *************************************************************
// ** 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 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-Modes during operation **
// ** ************************** **
// ** LED OFF: Everything is fine **
// ** LED ON: FAILURE - The first selected sat had lost sync **
// ** **
// ** LED-Modes during Self-Test **
// ** ************************** **
// ** LED flashes at 1 Hz: Everything is fine **
// ** LED flashes some times: FAILURE **
// *************************************************************
// ** (c) 2010-0xFFFF Stefan Pendsa **
// ** License: don't know - use it and have fun **
// *************************************************************
// ***************************************************************
// ** Spektrum Diversity v1.0 - use up to 4 satellite receivers **
// ***************************************************************
// ** Target: An Atmel ATtiny2313 (RC-Oscillator @ 8 MHz) **
// ** controls a 74HC151 Multiplexer **
// ***************************************************************
// ** 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 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-Modes during operation **
// ** ************************** **
// ** LED OFF: Everything is fine **
// ** LED ON: FAILURE - The first selected sat had lost sync **
// ** **
// ** LED-Modes after Self-Test **
// ** ************************* **
// ** LED flashes at 1 Hz: Everything is fine **
// ** LED flashes some times: Times flashed -> damaged Channel# **
// ** LED off: check voltage(regulator) or firmware **
// ***************************************************************
// ** (c) 2010-0xFFFF Stefan Pendsa **
// ** License: don't know - use it and have fun **
// ***************************************************************
 
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
 
#define LED_OFF PORTD |= 1 << PORTD0
#define LED_ON PORTD &= ~(1 << PORTD0)
#define LED_OFF PORTD |= 1 << PD0
#define LED_ON PORTD &= ~(1 << PD0)
 
volatile unsigned int TimerEvent;
 
47,7 → 48,8
 
void SelectSat(unsigned char sat)
{
PORTD = (PORTD & 0b00000001) | (sat<<3); // Select the Input for 74HC151
PORTD = (PORTD & 0b1100111) | (sat << 3); // Select the input for 74HC151
_delay_us(10); // Wait for stable state
}
 
 
66,7 → 68,7
unsigned char i = 0;
 
DDRB = 0b11110000; // Sat-Pins to output
_delay_ms(80); // Let them boot up
_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
{
91,23 → 93,23
 
PORTB = 0b01010000; // Test Pattern
SelectSat(0);
if (!(PINB & (1<<PB3))) error++;
if (!(PINB & (1<<PB3))) error = 1;
SelectSat(1);
if (PINB & (1<<PB3)) error++;
if (PINB & (1<<PB3)) error = 2;
SelectSat(2);
if (!(PINB & (1<<PB3))) error++;
if (!(PINB & (1<<PB3))) error = 3;
SelectSat(3);
if (PINB & (1<<PB3)) error++;
if (PINB & (1<<PB3)) error = 4;
 
PORTB = 0b10100000; // Another (inverted) Test Pattern
SelectSat(0);
if (PINB & (1<<PB3)) error++;
if (PINB & (1<<PB3)) error = 1;
SelectSat(1);
if (!(PINB & (1<<PB3))) error++;
if (!(PINB & (1<<PB3))) error = 2;
SelectSat(2);
if (PINB & (1<<PB3)) error++;
if (PINB & (1<<PB3)) error = 3;
SelectSat(3);
if (!(PINB & (1<<PB3))) error++;
if (!(PINB & (1<<PB3))) error = 4;
 
DDRB = 0b00000000; // Port B Input again
 
122,7 → 124,7
}
else
{
for (i=0;i<error;i++) // When error occured -> Flash once for every error
for (i=0;i<error;i++) // When error occured -> Flash-Out the Errorcode
{
LED_ON;
_delay_ms(100);
148,7 → 150,7
DDRB = 0b00000000; // Port B Input for satellites and feedback
DDRD = 0b0011001; // Port D Output for MUX and LED, Input for Switch & Test
PORTB = 0b11110000; // Port B Pullup's for (unused) satellites
PORTD = 0b1100001; // Port D Pullup's for Switch & Test, LED on
PORTD = 0b1100001; // Port D Pullup's for Switch & Test, LED off
 
for (i=0;i<4;i++) active[i] = 0; // Reset active-array
 
155,6 → 157,8
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
 
_delay_ms(100);
 
TCCR1B = ( 1 << CS10 ); // Timer1 Prescaler = 1 -> 8,192 msec
TIMSK = ( 1 << TOIE1 ); // Timer1 Overflow Interrupt Enable
sei(); // Global Interrupts enable
/Spektrum-Diversity/Software/Hex-Files/diversity.hex
1,64 → 1,70
:1000000012C02AC029C028C027C027C025C024C0CC
:1000100023C022C021C020C01FC01EC01DC01CC0E4
:100020001BC01AC019C011241FBECFEDCDBF10E0F8
:10003000A0E6B0E0EAEEF3E002C005900D92A03633
:10003000A0E6B0E0ECE4F4E002C005900D92A0363A
:10004000B107D9F710E0A0E6B0E001C01D92A236DA
:10005000B107E1F7C6D0C7C1D3CF1F920F920FB639
:10005000B107E1F7E3D0F8C1D3CF1F920F920FB6EB
:100060000F9211248F939F93809160009091610073
:10007000019690936100809360009F918F910F9003
:100080000FBE0F901F90189592B3880F880F880F9E
:100090009170982B92BB08951DBC1CBC10926100FE
:1000A00010926000089580EF87BB20E233E068EC97
:1000B00070E048EC50E0CB010197F1F7215030405F
:1000C000C1F718BACA010197F1F780EF88BBFA01AE
:1000D0003197F1F718BAFA013197F1F788BBFA01B5
:1000E0003197F1F718BAFA013197F1F788BBCA01D5
:1000F0000197F1F780E197E228EC30E0F9013197C0
:10010000F1F70197D9F717BA089580EF87BB80E51B
:1001100088BB82B3817082BB26B32695269526952F
:100120002095217082B38170886082BBB3992F5F64
:1001300082B38170806182BBB39B2F5F82B3817079
:10014000886182BBB3992F5F80EA88BB82B38170DC
:1001500082BBB3992F5F82B38170886082BBB39BEF
:100160002F5F82B38170806182BBB3992F5F82B3AE
:100170008170886182BBB39B2F5F17BA48EC50E057
:10018000222399F428EC30E0909888EE93E0F9016E
:100190003197F1F70197D9F7909A88E293E2F90144
:1001A0003197F1F70197D9F7EFCF30E0909888EECB
:1001B00093E0FA013197F1F70197D9F7909A80EA25
:1001C0009FE0FA013197F1F70197D9F73F5F3217B6
:1001D00068F380E197E2FA013197F1F70197D9F7D7
:1001E000CFCF0F931F93DF93CF9300D000D0CDB725
:1001F000DEB717BA89E181BB80EF88BB81E682BB9D
:1002000019821A821B821C82859B7FDF869B4BDFB3
:1002100081E08EBD80E889BF78941DBC1CBC0EC0F7
:1002200080916000909161000A9709F49098809104
:10023000600090916100449729F4909A10926100B7
:100240001092600086B3807F803F51F3909A1DBC6E
:100250001CBC109261001092600060E074E0DE014E
:10026000119611E08091600090916100449709F42B
:1002700090988091600090916100889731F4909AF5
:1002800010926100109260006F5F40E050E086B312
:1002900090E04C5F5F4F042E02C0959587950A94BD
:1002A000E2F74450504080FD11C0FD01E40FF51FFE
:1002B0001083743059F482B39A0173E0220F331F14
:1002C0007A95E1F78170822B82BB742F4F5F5F4F6D
:1002D00044305105E1F6603129F6909A80E197E2C9
:1002E00028EC30E0F9013197F1F70197D9F78E0149
:1002F0000F5F1F4FD80128EC30E0AE014B5F5F4F1E
:100300008C91813081F4909888EE93E0F9013197D7
:10031000F1F70197D9F7909A80EA9FE0F9013197B8
:10032000F1F70197D9F71196A417B50749F761E0DE
:10033000DE01119619821A821B821C821DBC1CBC14
:10034000109261001092600006C080916000909150
:100350006100049720F486B3807F803FB1F31DBC19
:100360001CBC109261001092600013C0F80124E0E0
:1003700030E086B390E0022E02C0959587950A94EE
:10038000E2F780FF60832F5F3F4F319628303105C1
:1003900081F78091600090916100892B39F3FD0114
:1003A000E70FF11D80818823D1F4909840E050E060
:1003B000FD01E40FF51F8081813061F482B39A0161
:1003C00093E0220F331F9A95E1F78170822B82BB55
:1003D000742F05C04F5F5F4F4430510549F7869930
:0A03E000A9CF909AA7CFF894FFCFA1
:100090009776982B92BB8AE18A95F1F708951DBC5B
:1000A0001CBC1092610010926000089580EF87BB25
:1000B00020E233E068EC70E048EC50E0CB010197BF
:1000C000F1F721503040C1F718BACA010197F1F792
:1000D00080EF88BBFA013197F1F718BAFA0131972E
:1000E000F1F788BBFA013197F1F718BAFA013197A5
:1000F000F1F788BBCA010197F1F780E197E228EC9C
:1001000030E0F9013197F1F70197D9F717BA08955F
:1001100080EF87BB80E588BB82B3877682BB9AE19C
:10012000892F8A95F1F726B382B38776886082BBE0
:100130009A95F1F7B39B02C022E005C0269526955B
:1001400026952095217082B38776806182BB8AE1F3
:100150008A95F1F7B39B23E082B38776886182BBEF
:100160008AE18A95F1F7B39924E080EA88BB82B3EB
:10017000877682BB8AE18A95F1F7B39921E082B351
:100180008776886082BB8AE18A95F1F7B39B22E08B
:1001900082B38776806182BB8AE18A95F1F7B39951
: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
:00000001FF
/Spektrum-Diversity/Software/diversity.aps
1,0 → 0,0
<AVRStudio><MANAGEMENT><ProjectName>diversity</ProjectName><Created>23-Jul-2010 13:27:06</Created><LastEdit>28-Jul-2010 17:47:08</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\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\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>
<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>
/Spektrum-Diversity/Software/diversity.aws
1,0 → 0,0
<AVRWorkspace><IOSettings><CurrentRegisters/></IOSettings><part name="ATmega128"/><Files><File00000 Name="D:\Pendsa\diversity\Software\diversity.c" Position="262 71 1328 776" LineCol="8 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="84 0" State="Maximized"/></Files></AVRWorkspace>