Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 677 → Rev 685

/C-OSD/trunk/default/Makefile
35,7 → 35,7
 
 
## Objects that must be built in order to link
OBJECTS = main.o usart1.o max7456_software_spi.o osd_helpers.o config.o spi.o buttons.o ppm.o osd_ncmode_default.o osd_ncmode_minimal.o osd_fcmode_default.o characters.o
OBJECTS = main.o usart1.o max7456_software_spi.o osd_helpers.o config.o spi.o buttons.o ppm.o osd_ncmode_default.o osd_ncmode_minimal.o osd_fcmode_default.o osd_fcmode_jopl.o characters.o
 
## Objects explicitly added by the user
LINKONLYOBJECTS =
76,6 → 76,9
 
osd_fcmode_default.o: ../osd_fcmode_default.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
 
osd_fcmode_jopl.o: ../osd_fcmode_jopl.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
characters.o: ../characters.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
104,4 → 107,4
 
 
## Other dependencies
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
/C-OSD/trunk/C-OSD.aps
1,0 → 0,0
<AVRStudio><MANAGEMENT><ProjectName>C-OSD</ProjectName><Created>24-Mar-2009 01:26:47</Created><LastEdit>02-Nov-2009 20:20:30</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>24-Mar-2009 01:26:47</Created><Version>4</Version><Build>4, 16, 0, 626</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>default\C-OSD.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>G:\Eigene Dateien\C-Projects\C-OSD\trunk\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR Simulator</CURRENT_TARGET><CURRENT_PART>ATmega162.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><modules><module></module></modules><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>main.c</SOURCEFILE><SOURCEFILE>max7456_software_spi.c</SOURCEFILE><SOURCEFILE>usart1.c</SOURCEFILE><SOURCEFILE>characters.c</SOURCEFILE><SOURCEFILE>osd_helpers.c</SOURCEFILE><SOURCEFILE>osd_ncmode_default.c</SOURCEFILE><SOURCEFILE>osd_fcmode_default.c</SOURCEFILE><SOURCEFILE>config.c</SOURCEFILE><SOURCEFILE>spi.c</SOURCEFILE><SOURCEFILE>buttons.c</SOURCEFILE><SOURCEFILE>ppm.c</SOURCEFILE><SOURCEFILE>osd_ncmode_minimal.c</SOURCEFILE><HEADERFILE>mk-data-structs.h</HEADERFILE><HEADERFILE>max7456_software_spi.h</HEADERFILE><HEADERFILE>usart1.h</HEADERFILE><HEADERFILE>main.h</HEADERFILE><HEADERFILE>osd_helpers.h</HEADERFILE><HEADERFILE>config.h</HEADERFILE><HEADERFILE>spi.h</HEADERFILE><HEADERFILE>buttons.h</HEADERFILE><HEADERFILE>ppm.h</HEADERFILE><HEADERFILE>osd_ncmode_default.h</HEADERFILE><HEADERFILE>osd_ncmode_minimal.h</HEADERFILE><HEADERFILE>osd_fcmode_default.h</HEADERFILE><HEADERFILE>characters.h</HEADERFILE><OTHERFILE>default\C-OSD.lss</OTHERFILE><OTHERFILE>default\C-OSD.map</OTHERFILE><OTHERFILE>default\Makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>default\Makefile</EXTERNALMAKEFILE><PART>atmega162</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>C-OSD.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>0</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -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:\WinAVR\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files><File00000><FileId>00000</FileId><FileName>main.c</FileName><Status>257</Status></File00000><File00001><FileId>00001</FileId><FileName>mk-data-structs.h</FileName><Status>1</Status></File00001><File00002><FileId>00002</FileId><FileName>max7456_software_spi.h</FileName><Status>1</Status></File00002><File00003><FileId>00003</FileId><FileName>max7456_software_spi.c</FileName><Status>1</Status></File00003><File00004><FileId>00004</FileId><FileName>usart1.c</FileName><Status>1</Status></File00004><File00005><FileId>00005</FileId><FileName>usart1.h</FileName><Status>1</Status></File00005><File00006><FileId>00006</FileId><FileName>characters.c</FileName><Status>1</Status></File00006><File00007><FileId>00007</FileId><FileName>main.h</FileName><Status>1</Status></File00007><File00008><FileId>00008</FileId><FileName>osd_helpers.c</FileName><Status>1</Status></File00008><File00009><FileId>00009</FileId><FileName>osd_helpers.h</FileName><Status>1</Status></File00009><File00010><FileId>00010</FileId><FileName>osd_ncmode_default.c</FileName><Status>1</Status></File00010><File00011><FileId>00011</FileId><FileName>osd_fcmode_default.c</FileName><Status>1</Status></File00011><File00012><FileId>00012</FileId><FileName>config.c</FileName><Status>1</Status></File00012><File00013><FileId>00013</FileId><FileName>config.h</FileName><Status>1</Status></File00013><File00014><FileId>00014</FileId><FileName>spi.c</FileName><Status>1</Status></File00014><File00015><FileId>00015</FileId><FileName>spi.h</FileName><Status>1</Status></File00015><File00016><FileId>00016</FileId><FileName>buttons.c</FileName><Status>1</Status></File00016><File00017><FileId>00017</FileId><FileName>buttons.h</FileName><Status>1</Status></File00017><File00018><FileId>00018</FileId><FileName>ppm.c</FileName><Status>1</Status></File00018><File00019><FileId>00019</FileId><FileName>ppm.h</FileName><Status>1</Status></File00019><File00020><FileId>00020</FileId><FileName>osd_ncmode_minimal.c</FileName><Status>1</Status></File00020><File00021><FileId>00021</FileId><FileName>osd_ncmode_default.h</FileName><Status>1</Status></File00021><File00022><FileId>00022</FileId><FileName>osd_ncmode_minimal.h</FileName><Status>1</Status></File00022><File00023><FileId>00023</FileId><FileName>osd_fcmode_default.h</FileName><Status>1</Status></File00023><File00024><FileId>00024</FileId><FileName>characters.h</FileName><Status>1</Status></File00024></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
<AVRStudio><MANAGEMENT><ProjectName>C-OSD</ProjectName><Created>24-Mar-2009 01:26:47</Created><LastEdit>09-Nov-2009 10:53:50</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>24-Mar-2009 01:26:47</Created><Version>4</Version><Build>4, 16, 0, 626</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>default\C-OSD.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>G:\Eigene Dateien\C-Projects\C-OSD\trunk\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR Simulator</CURRENT_TARGET><CURRENT_PART>ATmega162.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><modules><module></module></modules><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>main.c</SOURCEFILE><SOURCEFILE>max7456_software_spi.c</SOURCEFILE><SOURCEFILE>usart1.c</SOURCEFILE><SOURCEFILE>characters.c</SOURCEFILE><SOURCEFILE>osd_helpers.c</SOURCEFILE><SOURCEFILE>osd_ncmode_default.c</SOURCEFILE><SOURCEFILE>osd_fcmode_default.c</SOURCEFILE><SOURCEFILE>config.c</SOURCEFILE><SOURCEFILE>spi.c</SOURCEFILE><SOURCEFILE>buttons.c</SOURCEFILE><SOURCEFILE>ppm.c</SOURCEFILE><SOURCEFILE>osd_ncmode_minimal.c</SOURCEFILE><SOURCEFILE>osd_fcmode_jopl.c</SOURCEFILE><HEADERFILE>mk-data-structs.h</HEADERFILE><HEADERFILE>max7456_software_spi.h</HEADERFILE><HEADERFILE>usart1.h</HEADERFILE><HEADERFILE>main.h</HEADERFILE><HEADERFILE>osd_helpers.h</HEADERFILE><HEADERFILE>config.h</HEADERFILE><HEADERFILE>spi.h</HEADERFILE><HEADERFILE>buttons.h</HEADERFILE><HEADERFILE>ppm.h</HEADERFILE><HEADERFILE>osd_ncmode_default.h</HEADERFILE><HEADERFILE>osd_ncmode_minimal.h</HEADERFILE><HEADERFILE>osd_fcmode_default.h</HEADERFILE><HEADERFILE>characters.h</HEADERFILE><HEADERFILE>osd_fcmode_jopl.h</HEADERFILE><OTHERFILE>default\C-OSD.lss</OTHERFILE><OTHERFILE>default\C-OSD.map</OTHERFILE><OTHERFILE>default\Makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>default\Makefile</EXTERNALMAKEFILE><PART>atmega162</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>C-OSD.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -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:\WinAVR\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="1" orderaddress="1" ordergroup="1"/></IOView><Files><File00000><FileId>00000</FileId><FileName>main.c</FileName><Status>257</Status></File00000><File00001><FileId>00001</FileId><FileName>mk-data-structs.h</FileName><Status>1</Status></File00001><File00002><FileId>00002</FileId><FileName>max7456_software_spi.h</FileName><Status>1</Status></File00002><File00003><FileId>00003</FileId><FileName>max7456_software_spi.c</FileName><Status>1</Status></File00003><File00004><FileId>00004</FileId><FileName>usart1.c</FileName><Status>1</Status></File00004><File00005><FileId>00005</FileId><FileName>usart1.h</FileName><Status>1</Status></File00005><File00006><FileId>00006</FileId><FileName>characters.c</FileName><Status>1</Status></File00006><File00007><FileId>00007</FileId><FileName>main.h</FileName><Status>1</Status></File00007><File00008><FileId>00008</FileId><FileName>osd_helpers.c</FileName><Status>1</Status></File00008><File00009><FileId>00009</FileId><FileName>osd_helpers.h</FileName><Status>1</Status></File00009><File00010><FileId>00010</FileId><FileName>osd_ncmode_default.c</FileName><Status>1</Status></File00010><File00011><FileId>00011</FileId><FileName>osd_fcmode_default.c</FileName><Status>1</Status></File00011><File00012><FileId>00012</FileId><FileName>config.c</FileName><Status>1</Status></File00012><File00013><FileId>00013</FileId><FileName>config.h</FileName><Status>1</Status></File00013><File00014><FileId>00014</FileId><FileName>spi.c</FileName><Status>1</Status></File00014><File00015><FileId>00015</FileId><FileName>spi.h</FileName><Status>1</Status></File00015><File00016><FileId>00016</FileId><FileName>buttons.c</FileName><Status>1</Status></File00016><File00017><FileId>00017</FileId><FileName>buttons.h</FileName><Status>1</Status></File00017><File00018><FileId>00018</FileId><FileName>ppm.c</FileName><Status>1</Status></File00018><File00019><FileId>00019</FileId><FileName>ppm.h</FileName><Status>1</Status></File00019><File00020><FileId>00020</FileId><FileName>osd_ncmode_minimal.c</FileName><Status>1</Status></File00020><File00021><FileId>00021</FileId><FileName>osd_ncmode_default.h</FileName><Status>1</Status></File00021><File00022><FileId>00022</FileId><FileName>osd_ncmode_minimal.h</FileName><Status>1</Status></File00022><File00023><FileId>00023</FileId><FileName>osd_fcmode_default.h</FileName><Status>1</Status></File00023><File00024><FileId>00024</FileId><FileName>characters.h</FileName><Status>1</Status></File00024><File00025><FileId>00025</FileId><FileName>osd_fcmode_jopl.c</FileName><Status>1</Status></File00025><File00026><FileId>00026</FileId><FileName>default\Makefile</FileName><Status>1</Status></File00026></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
/C-OSD/trunk/CHANGE.LOG
18,6 → 18,10
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
****************************************************************************/
 
20091109-1100
+fc-only mode by Josef "jopl" Plasil (MK3Mag on FC and no NC)
*usart1 routine to filter out unwanted datasets (also big thanks to jopl)
 
20091102-2205
+nc/fc software version display in bootup
*changed checkbytes because of previously removed EEPROM data
/C-OSD/trunk/c-osd.aws
1,0 → 0,0
<AVRWorkspace><IOSettings><CurrentRegisters/></IOSettings><part name="ATMEGA162"/><Files><File00000 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\main.c" Position="430 100 1068 458" LineCol="383 0" State="Maximized"/><File00001 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\mk-data-structs.h" Position="452 122 1104 472" LineCol="53 0" State="Maximized"/><File00002 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\max7456_software_spi.h" Position="474 144 1126 494" LineCol="0 0" State="Maximized"/><File00003 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\max7456_software_spi.c" Position="496 166 1148 516" LineCol="0 0" State="Maximized"/><File00004 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\usart1.c" Position="518 188 1170 538" LineCol="0 0" State="Maximized"/><File00005 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\usart1.h" Position="540 210 1192 560" LineCol="0 0" State="Maximized"/><File00006 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\characters.c" Position="562 232 1214 582" LineCol="0 0" State="Maximized"/><File00007 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\main.h" Position="584 254 1236 604" LineCol="0 0" State="Maximized"/><File00008 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_helpers.c" Position="430 100 1082 450" LineCol="0 0" State="Maximized"/><File00009 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_helpers.h" Position="452 122 1104 472" LineCol="0 0" State="Maximized"/><File00010 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_ncmode_default.c" Position="474 144 1126 494" LineCol="194 0" State="Maximized"/><File00011 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_fcmode_default.c" Position="496 166 1148 516" LineCol="0 0" State="Maximized"/><File00012 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\config.c" Position="518 188 1170 538" LineCol="0 0" State="Maximized"/><File00013 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\config.h" Position="540 210 1192 560" LineCol="0 0" State="Maximized"/><File00014 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\spi.c" Position="562 232 1214 582" LineCol="0 0" State="Maximized"/><File00015 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\spi.h" Position="584 254 1236 604" LineCol="0 0" State="Maximized"/><File00016 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\buttons.c" Position="430 100 1082 450" LineCol="0 0" State="Maximized"/><File00017 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\buttons.h" Position="452 122 1104 472" LineCol="0 0" State="Maximized"/><File00018 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\ppm.c" Position="474 144 1126 494" LineCol="0 0" State="Maximized"/><File00019 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\ppm.h" Position="496 166 1148 516" LineCol="0 0" State="Maximized"/><File00020 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_ncmode_minimal.c" Position="518 188 1170 538" LineCol="0 0" State="Maximized"/><File00021 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_ncmode_default.h" Position="540 210 1192 560" LineCol="0 0" State="Maximized"/><File00022 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_ncmode_minimal.h" Position="562 232 1214 582" LineCol="0 0" State="Maximized"/><File00023 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_fcmode_default.h" Position="584 254 1236 604" LineCol="0 0" State="Maximized"/><File00024 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\characters.h" Position="426 77 1244 612" LineCol="7 10" State="Maximized"/></Files></AVRWorkspace>
<AVRWorkspace><IOSettings><CurrentRegisters/></IOSettings><part name="ATMEGA162"/><Files><File00000 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\main.c" Position="692 152 1490 624" LineCol="130 0" State="Maximized"/><File00001 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\mk-data-structs.h" Position="714 174 1504 616" LineCol="41 0" State="Maximized"/><File00002 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\max7456_software_spi.h" Position="736 196 1526 638" LineCol="0 0" State="Maximized"/><File00003 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\max7456_software_spi.c" Position="758 218 1548 660" LineCol="162 0" State="Maximized"/><File00004 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\usart1.c" Position="780 240 1570 682" LineCol="117 0" State="Maximized"/><File00005 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\usart1.h" Position="802 262 1592 704" LineCol="0 0" State="Maximized"/><File00006 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\characters.c" Position="824 284 1614 726" LineCol="41 0" State="Maximized"/><File00007 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\main.h" Position="688 129 1710 822" LineCol="41 16" State="Maximized"/><File00008 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_helpers.c" Position="868 328 1658 770" LineCol="0 0" State="Maximized"/><File00009 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_helpers.h" Position="890 350 1680 792" LineCol="69 0" State="Maximized"/><File00010 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_ncmode_default.c" Position="912 372 1702 814" LineCol="0 0" State="Maximized"/><File00011 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_fcmode_default.c" Position="692 152 1482 594" LineCol="104 0" State="Maximized"/><File00012 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\config.c" Position="714 174 1504 616" LineCol="201 0" State="Maximized"/><File00013 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\config.h" Position="736 196 1526 638" LineCol="0 0" State="Maximized"/><File00014 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\spi.c" Position="758 218 1548 660" LineCol="0 0" State="Maximized"/><File00015 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\spi.h" Position="780 240 1570 682" LineCol="0 0" State="Maximized"/><File00016 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\buttons.c" Position="802 262 1592 704" LineCol="0 0" State="Maximized"/><File00017 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\buttons.h" Position="824 284 1614 726" LineCol="0 0" State="Maximized"/><File00018 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\ppm.c" Position="846 306 1636 748" LineCol="0 0" State="Maximized"/><File00019 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\ppm.h" Position="868 328 1658 770" LineCol="0 0" State="Maximized"/><File00020 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_ncmode_minimal.c" Position="890 350 1680 792" LineCol="0 0" State="Maximized"/><File00021 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_ncmode_default.h" Position="912 372 1702 814" LineCol="0 0" State="Maximized"/><File00022 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_ncmode_minimal.h" Position="692 152 1482 594" LineCol="0 0" State="Maximized"/><File00023 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_fcmode_default.h" Position="714 174 1504 616" LineCol="7 0" State="Maximized"/><File00024 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\characters.h" Position="736 196 1526 638" LineCol="24 0" State="Maximized"/><File00025 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\osd_fcmode_jopl.c" Position="758 218 1548 660" LineCol="26 31" State="Maximized"/><File00026 Name="G:\Eigene Dateien\C-Projects\C-OSD\trunk\default\Makefile" Position="802 262 1596 708" LineCol="79 15" State="Maximized"/></Files></AVRWorkspace>
/C-OSD/trunk/config.c
197,7 → 197,7
usart1_request_mk_data(1, 'o', 100);
#endif
 
_delay_ms(200);
_delay_ms(2000);
clear();
// update flags to paint display again because of clear
COSD_FLAGS_RUNTIME &= ~COSD_ICONS_WRITTEN;
/C-OSD/trunk/main.c
40,6 → 40,7
#include "osd_ncmode_default.h"
#include "osd_ncmode_minimal.h"
#include "osd_fcmode_default.h"
#include "osd_fcmode_jopl.h"
 
#if WRITECHARS != -1
#include "characters.h"
68,6 → 69,7
// 16bit should be enough, normal LiPos don't last that long
volatile uint16_t uptime = 0;
volatile uint16_t timer = 0;
volatile uint16_t flytime_fc = 0;
 
// remember last time data was received
volatile uint8_t seconds_since_last_data = 0;
132,6 → 134,7
* ##########################################################################*/
const char str_1[] PROGMEM = "default";
const char str_2[] PROGMEM = "minimal";
const char str_3[] PROGMEM = " jopl";
 
const displaymode_t ncdisplaymodes[] PROGMEM = {
{ osd_ncmode_default, (char *)str_1 },
140,6 → 143,7
 
const displaymode_t fcdisplaymodes[] PROGMEM = {
{ osd_fcmode_default, (char *)str_1 },
{ osd_fcmode_jopl, (char *)str_3 }
};
 
int (*osd_ncmode)(void) = (int(*)(void)) &osd_ncmode_default;
171,6 → 175,13
ISR(TIMER0_COMP_vect) {
if (!timer--) {
uptime++;
 
#if FCONLY
if (debugData.Analog[12]>10) {
flytime_fc++;
}
#endif
 
timer = 999;
seconds_since_last_data++;
}
319,10 → 330,10
 
#if ALLCHARSDEBUG | (WRITECHARS != -1)
clear();
write_all_chars();
LED1_ON
LED2_ON
LED3_ON
write_all_chars();
LED1_ON
LED2_ON
LED3_ON
LED4_ON
#else
 
/C-OSD/trunk/main.h
116,7 → 116,7
} displaymode_t;
 
const displaymode_t ncdisplaymodes[2];
const displaymode_t fcdisplaymodes[1];
const displaymode_t fcdisplaymodes[2];
 
int (*osd_ncmode)(void);
int (*osd_fcmode)(void);
137,6 → 137,7
// 16bit should be enough, normal LiPos don't last that long
volatile uint16_t uptime;
volatile uint16_t timer;
volatile uint16_t flytime_fc;
 
// remember last time data was received
volatile uint8_t seconds_since_last_data;
/C-OSD/trunk/osd_fcmode_jopl.c
0,0 → 1,176
/****************************************************************************
* Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-osd/ *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* This is an alternative FC-mode contributed by Josef "jopl" Plasil *
* who is using the FC with an MK3Mag and the OSD *
****************************************************************************/
 
#include "main.h"
#include "max7456_software_spi.h"
#include "osd_helpers.h"
#include "osd_fcmode_default.h"
 
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
 
// jopl Vario
static int16_t last_Altimeter = 0;
static int16_t Vario = 0;
 
int osd_fcmode_jopl() {
if (COSD_FLAGS_MODES & COSD_FLAG_HUD) {
// write icons at init or after menu/mode-switch
if (!(COSD_FLAGS_RUNTIME & COSD_ICONS_WRITTEN)) {
write_char_xy(10, top_line, 0xCA); // RC-transmitter
 
// jopl ... compass
write_char_xy(16, top_line, 0xD0); // degree symbol
// end jopl
 
write_char_xy(26, top_line, 0xCC); // small meters m height
write_char_xy(7, bottom_line, 0x9E); // small v
 
if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) {
write_char_xy(7, bottom_line - 1, 0x9F); // small A
write_char_xy(14, bottom_line - 1, 0xB5); // mah
if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) {
write_char_xy(21, bottom_line - 1, 0x9E); // small V
}
}
 
// jopl ... Times
write_char_xy(14, bottom_line, 0xD1); // on clock
write_char_xy(21, bottom_line, 0xD2); // fly clock
// end jopl
 
COSD_FLAGS_RUNTIME |= COSD_ICONS_WRITTEN;
}
 
write_ndigit_number_u(7, top_line, debugData.Analog[10], 3, 0);
if (debugData.Analog[10] <= RCLVL_WRN && last_RC_Quality > RCLVL_WRN) {
for (uint8_t x = 0; x < 4; x++)
write_char_att_xy(7 + x, top_line, BLINK);
} else if (debugData.Analog[10] > RCLVL_WRN && last_RC_Quality <= RCLVL_WRN) {
for (uint8_t x = 0; x < 4; x++)
write_char_att_xy(7 + x, top_line, 0);
}
 
// jopl ... compass
write_ndigit_number_u(13, top_line, debugData.Analog[8], 3, 0);
write_ascii_string_pgm(17, top_line, (const char *) (pgm_read_word(&(directions[heading_conv(debugData.Analog[8])]))));
// end jopl
 
// jopl Altimeter modification
if ((debugData.Analog[5] > 100) || (debugData.Analog[5] < -100)) {
// above 10m only write full meters
write_ndigit_number_s(22, top_line, debugData.Analog[5] / 10, 4, 0);
} else {
// up to 10m write meters.dm
write_ndigit_number_s_10th(22, top_line, debugData.Analog[5], 3, 0);
}
Vario = debugData.Analog[5] - last_Altimeter;
draw_variometer(27, top_line, Vario);
if (COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO) {
draw_big_variometer(27, 8, Vario);
}
last_Altimeter = debugData.Analog[5];
// end jopl
 
if (debugData.Analog[5] > max_Altimeter) max_Altimeter = debugData.Analog[5];
 
if (COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON) {
draw_artificial_horizon(top_line + 2, bottom_line - 1, debugData.Analog[0], debugData.Analog[1]);
}
 
// jopl ... compass heading
// seccond line
draw_compass(11, top_line + 1, debugData.Analog[8]);
// end jopl
 
// pre-bottom line
if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) {
//write_ndigit_number_s(3, bottom_line - 1, ampere, 4, 0);
write_ndigit_number_u_10th(3, bottom_line - 1, ampere / 10, 3, 0);
write_ndigit_number_s(10, bottom_line - 1, ampere_wasted / 10, 4, 0);
if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) {
write_ndigit_number_u_10th(17, bottom_line - 1, s_volt, 3, 0);
}
}
 
draw_battery(2, bottom_line, min_voltage, debugData.Analog[9], max_voltage);
write_ndigit_number_u_10th(3, bottom_line, debugData.Analog[9], 3, 0);
if (debugData.Analog[9] <= min_voltage && last_UBat > min_voltage) {
for (uint8_t x = 2; x < 8; x++)
write_char_att_xy(x, bottom_line, BLINK);
} else if (debugData.Analog[9] > min_voltage && last_UBat < min_voltage) {
for (uint8_t x = 2; x < 8; x++)
write_char_att_xy(x, bottom_line, 0);
}
 
// jopl ... Times
write_time(8, bottom_line, uptime);
write_time(15, bottom_line, flytime_fc);
// Test ... show Gas value
// write_ndigit_number_s(22, bottom_line, debugData.Analog[5], 5, 0);
// end jopl
 
}
// remember last values
last_UBat = debugData.Analog[9];
last_RC_Quality = debugData.Analog[10];
 
/*
debugData.Analog[0]); // AngleNick
debugData.Analog[1]); // AngleRoll
debugData.Analog[2]); // AccNick
debugData.Analog[3]); // AccRoll
debugData.Analog[4]); // GyroGier
debugData.Analog[5]); // Height Value
debugData.Analog[6]); // AccZ
debugData.Analog[7]); // Throttle
debugData.Analog[8]); // Compass Value
debugData.Analog[9]); // Voltage
debugData.Analog[10]);// RC Signal
debugData.Analog[11]);// Gyro compass
debugData.Analog[12]);// Motor Front
debugData.Analog[13]);// Motor Rear
debugData.Analog[14]);// Motor Left
debugData.Analog[15]);// Motor Right
debugData.Analog[16]);//
debugData.Analog[17]);//
debugData.Analog[18]);//
debugData.Analog[19]);// MK3Mag CalState
debugData.Analog[20]);// Servo
debugData.Analog[21]);//
debugData.Analog[22]);//
debugData.Analog[23]);//
debugData.Analog[24]);//
debugData.Analog[25]);//
debugData.Analog[26]);//
debugData.Analog[27]);// Kalman_MaxDrift
debugData.Analog[28]);//
debugData.Analog[29]);//
debugData.Analog[30]);// GPS_Nick
debugData.Analog[31]);// GPS_Roll
*/
seconds_since_last_data = 0;
 
return 0;
}
 
#endif
/C-OSD/trunk/osd_fcmode_jopl.h
0,0 → 1,21
/****************************************************************************
* Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-osd/ *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
****************************************************************************/
 
int osd_fcmode_jopl(void);
/C-OSD/trunk/usart1.c
1,256 → 1,264
/****************************************************************************
* Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-osd/ *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
****************************************************************************/
 
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "main.h"
#include "usart1.h"
 
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
 
volatile uint8_t rxd_buffer_locked = 0;
volatile uint8_t rxd_buffer[RXD_BUFFER_LEN];
volatile uint8_t txd_buffer[TXD_BUFFER_LEN];
volatile uint8_t ReceivedBytes = 0;
volatile uint8_t *pRxData = 0;
volatile uint8_t RxDataLen = 0;
 
/* ##########################################################################
* USART stuff
* ##########################################################################*/
 
/**
* init usart1
*/
void usart1_init() {
UBRR1H = ((F_CPU / (16UL * baud)) - 1) >> 8;
UBRR1L = (F_CPU / (16UL * baud)) - 1;
 
// Enable receiver and transmitter; enable RX interrupt
UCSR1B = (1 << RXEN1) | (1 << TXEN1) | (1 << RXCIE1);
 
//asynchronous 8N1
UCSR1C = (1 << URSEL1) | (3 << UCSZ10);
}
 
/**
* disable the txd pin of usart1
*/
void usart1_DisableTXD(void) {
UCSR1B &= ~(1 << TXCIE1); // disable TX-Interrupt
UCSR1B &= ~(1 << TXEN1); // disable TX in USART
DDRB &= ~(1<<DDB3); // set TXD pin as input
PORTB &= ~(1 << PORTB3); // disable pullup on TXD pin
}
 
/**
* enable the txd pin of usart1
*/
void usart1_EnableTXD(void) {
DDRB |= (1<<DDB3); // set TXD pin as output
PORTB &= ~(1 << PORTB3); // disable pullup on TXD pin
UCSR1B |= (1 << TXEN1); // enable TX in USART
UCSR1B |= (1 << TXCIE1); // enable TX-Interrupt
}
 
/**
* send a single <character> through usart1
*/
void usart1_putc(unsigned char character) {
// wait until UDR ready
while (!(UCSR1A & (1 << UDRE1)));
UDR1 = character;
}
 
/**
* send a <string> throught usart1
*/
void usart1_puts(char *s) {
while (*s) {
usart1_putc(*s);
s++;
}
}
 
/**
* transmit interrupt handler
* unused
*/
ISR(SIG_USART1_DATA) {
}
 
/**
* receive data through usart1
* portions taken and adapted from
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Fbranches%2FV0.72p+Code+Redesign+killagreg%2Fuart0.c
*/
ISR(SIG_USART1_RECV) {
if (rxd_buffer_locked) return; // if rxd buffer is locked immediately return
LED1_ON
static uint16_t crc;
static uint8_t ptr_rxd_buffer = 0;
uint8_t crc1, crc2;
uint8_t c;
 
c = UDR1; // catch the received byte
 
// the rxd buffer is unlocked
if ((ptr_rxd_buffer == 0) && (c == '#')) // if rxd buffer is empty and syncronisation character is received
{
/*
// skip other datasets
if (ptr_rxd_buffer == 2 && rxd_buffer[ptr_rxd_buffer] != 'O') {
ptr_rxd_buffer = 0; // reset rxd buffer
rxd_buffer_locked = 0; // unlock rxd buffer
}*/
rxd_buffer[ptr_rxd_buffer++] = c; // copy 1st byte to buffer
crc = c; // init crc
} else if (ptr_rxd_buffer < RXD_BUFFER_LEN) // collect incomming bytes
{
if (c != '\r') // no termination character
{
rxd_buffer[ptr_rxd_buffer++] = c; // copy byte to rxd buffer
crc += c; // update crc
} else // termination character was received
{
// the last 2 bytes are no subject for checksum calculation
// they are the checksum itself
crc -= rxd_buffer[ptr_rxd_buffer - 2];
crc -= rxd_buffer[ptr_rxd_buffer - 1];
// calculate checksum from transmitted data
crc %= 4096;
crc1 = '=' + crc / 64;
crc2 = '=' + crc % 64;
// compare checksum to transmitted checksum bytes
if ((crc1 == rxd_buffer[ptr_rxd_buffer - 2]) && (crc2 == rxd_buffer[ptr_rxd_buffer - 1])) { // checksum valid
rxd_buffer[ptr_rxd_buffer] = '\r'; // set termination character
ReceivedBytes = ptr_rxd_buffer + 1; // store number of received bytes
rxd_buffer_locked = 1; // lock the rxd buffer
} else { // checksum invalid
rxd_buffer_locked = 0; // unlock rxd buffer
}
ptr_rxd_buffer = 0; // reset rxd buffer pointer
}
} else // rxd buffer overrun
{
ptr_rxd_buffer = 0; // reset rxd buffer
rxd_buffer_locked = 0; // unlock rxd buffer
}
LED1_OFF
}
 
/**
* Decode the recevied Buffer
* portions taken and adapted from
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c
*/
void Decode64(void) {
uint8_t a, b, c, d;
uint8_t x, y, z;
uint8_t ptrIn = 3;
uint8_t ptrOut = 3;
uint8_t len = ReceivedBytes - 6;
 
while (len) {
a = rxd_buffer[ptrIn++] - '=';
b = rxd_buffer[ptrIn++] - '=';
c = rxd_buffer[ptrIn++] - '=';
d = rxd_buffer[ptrIn++] - '=';
 
x = (a << 2) | (b >> 4);
y = ((b & 0x0f) << 4) | (c >> 2);
z = ((c & 0x03) << 6) | d;
 
if (len--) rxd_buffer[ptrOut++] = x;
else break;
if (len--) rxd_buffer[ptrOut++] = y;
else break;
if (len--) rxd_buffer[ptrOut++] = z;
else break;
}
pRxData = &rxd_buffer[3];
RxDataLen = ptrOut - 3;
}
 
/**
* request Data through USART in special MK format by adding checksum and
* encode data in modified Base64
* portions taken and adapted from
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c
*/
void sendMKData(unsigned char cmd, unsigned char addr, unsigned char *snd, unsigned char len) {
unsigned int pt = 0;
unsigned char a, b, c;
unsigned char ptr = 0;
 
txd_buffer[pt++] = '#'; // Start-Byte
txd_buffer[pt++] = 'a' + addr; // Adress
txd_buffer[pt++] = cmd; // Command
while (len) {
if (len) {
a = snd[ptr++];
len--;
} else a = 0;
if (len) {
b = snd[ptr++];
len--;
} else b = 0;
if (len) {
c = snd[ptr++];
len--;
} else c = 0;
txd_buffer[pt++] = '=' + (a >> 2);
txd_buffer[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4));
txd_buffer[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6));
txd_buffer[pt++] = '=' + (c & 0x3f);
}
 
// add crc
unsigned int tmpCRC = 0, i;
for (i = 0; i < pt; i++) {
tmpCRC += txd_buffer[i];
}
tmpCRC %= 4096;
txd_buffer[i++] = '=' + tmpCRC / 64;
txd_buffer[i++] = '=' + tmpCRC % 64;
txd_buffer[i++] = '\r';
 
usart1_puts((char*) txd_buffer);
}
 
/**
* short script to directly send a request thorugh usart including en- and disabling it
* where <address> is the address of the receipient, <label> is which data set to request
* and <ms> represents the milliseconds delay between data
*/
void usart1_request_mk_data(uint8_t address, char label, uint8_t ms) {
// re-enable TXD pin
usart1_EnableTXD();
 
unsigned char mstenth = ms/10;
sendMKData(label, address, &mstenth, 1);
// wait until UDR ready
while (!(UCSR1A & (1 << UDRE1)));
// disable TXD pin again
usart1_DisableTXD();
}
 
#endif
/****************************************************************************
* Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-osd/ *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
****************************************************************************/
 
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "main.h"
#include "usart1.h"
 
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
 
volatile uint8_t rxd_buffer_locked = 0;
volatile uint8_t rxd_buffer[RXD_BUFFER_LEN];
volatile uint8_t txd_buffer[TXD_BUFFER_LEN];
volatile uint8_t ReceivedBytes = 0;
volatile uint8_t *pRxData = 0;
volatile uint8_t RxDataLen = 0;
 
/* ##########################################################################
* USART stuff
* ##########################################################################*/
 
/**
* init usart1
*/
void usart1_init() {
UBRR1H = ((F_CPU / (16UL * baud)) - 1) >> 8;
UBRR1L = (F_CPU / (16UL * baud)) - 1;
 
// Enable receiver and transmitter; enable RX interrupt
UCSR1B = (1 << RXEN1) | (1 << TXEN1) | (1 << RXCIE1);
 
//asynchronous 8N1
UCSR1C = (1 << URSEL1) | (3 << UCSZ10);
}
 
/**
* disable the txd pin of usart1
*/
void usart1_DisableTXD(void) {
UCSR1B &= ~(1 << TXCIE1); // disable TX-Interrupt
UCSR1B &= ~(1 << TXEN1); // disable TX in USART
DDRB &= ~(1 << DDB3); // set TXD pin as input
PORTB &= ~(1 << PORTB3); // disable pullup on TXD pin
}
 
/**
* enable the txd pin of usart1
*/
void usart1_EnableTXD(void) {
DDRB |= (1 << DDB3); // set TXD pin as output
PORTB &= ~(1 << PORTB3); // disable pullup on TXD pin
UCSR1B |= (1 << TXEN1); // enable TX in USART
UCSR1B |= (1 << TXCIE1); // enable TX-Interrupt
}
 
/**
* send a single <character> through usart1
*/
void usart1_putc(unsigned char character) {
// wait until UDR ready
while (!(UCSR1A & (1 << UDRE1)));
UDR1 = character;
}
 
/**
* send a <string> throught usart1
*/
void usart1_puts(char *s) {
while (*s) {
usart1_putc(*s);
s++;
}
}
 
/**
* transmit interrupt handler
* unused
*/
ISR(SIG_USART1_DATA) {
}
 
/*
* receive data through usart1
* portions taken and adapted from
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Fbranches%2FV0.72p+Code+Redesign+killagreg%2Fuart0.c
*/
ISR(SIG_USART1_RECV) {
uint8_t c;
// catch the received byte
c = UDR1;
if (rxd_buffer_locked) return; // if rxd buffer is locked immediately return
static uint16_t crc;
static uint8_t ptr_rxd_buffer = 0;
static uint8_t c1 = 0;
static uint8_t c2 = 0;
static uint8_t usart_rx_ok = 0;
uint8_t crc1, crc2;
// the rxd buffer is unlocked
if (usart_rx_ok == 0) {
if ((c2 == '#') && (c1 == 'b') && (c == 'D' || c == 'V' || c == 'O')) {
usart_rx_ok = 1;
rxd_buffer[ptr_rxd_buffer++] = c2;
crc = c2;
rxd_buffer[ptr_rxd_buffer++] = c1;
crc += c1;
rxd_buffer[ptr_rxd_buffer++] = c;
crc += c;
c2 = 0;
c1 = 0;
LED1_ON
LED2_OFF
} else {
c2 = c1;
c1 = c;
}
} else if (ptr_rxd_buffer < RXD_BUFFER_LEN) { // collect incomming bytes
if (c != '\r') { // no termination character
rxd_buffer[ptr_rxd_buffer++] = c; // copy byte to rxd buffer
crc += c; // update crc
} else { // termination character was received
// the last 2 bytes are no subject for checksum calculation
// they are the checksum itself
crc -= rxd_buffer[ptr_rxd_buffer - 2];
crc -= rxd_buffer[ptr_rxd_buffer - 1];
// calculate checksum from transmitted data
crc %= 4096;
crc1 = '=' + crc / 64;
crc2 = '=' + crc % 64;
// compare checksum to transmitted checksum bytes
if ((crc1 == rxd_buffer[ptr_rxd_buffer - 2]) && (crc2 == rxd_buffer[ptr_rxd_buffer - 1])) { // checksum valid
rxd_buffer[ptr_rxd_buffer] = '\r'; // set termination character
ReceivedBytes = ptr_rxd_buffer + 1; // store number of received bytes
rxd_buffer_locked = 1; // lock the rxd buffer
LED1_OFF
} else { // checksum invalid
rxd_buffer_locked = 0; // unlock rxd buffer
LED2_ON
}
ptr_rxd_buffer = 0; // reset rxd buffer pointer
usart_rx_ok = 0;
}
} else { // rxd buffer overrun
ptr_rxd_buffer = 0; // reset rxd buffer
rxd_buffer_locked = 0; // unlock rxd buffer
usart_rx_ok = 0;
LED2_ON
}
}
 
/**
* Decode the recevied Buffer
* portions taken and adapted from
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c
*/
void Decode64(void) {
uint8_t a, b, c, d;
uint8_t x, y, z;
uint8_t ptrIn = 3;
uint8_t ptrOut = 3;
uint8_t len = ReceivedBytes - 6;
 
while (len) {
a = rxd_buffer[ptrIn++] - '=';
b = rxd_buffer[ptrIn++] - '=';
c = rxd_buffer[ptrIn++] - '=';
d = rxd_buffer[ptrIn++] - '=';
 
x = (a << 2) | (b >> 4);
y = ((b & 0x0f) << 4) | (c >> 2);
z = ((c & 0x03) << 6) | d;
 
if (len--) rxd_buffer[ptrOut++] = x;
else break;
if (len--) rxd_buffer[ptrOut++] = y;
else break;
if (len--) rxd_buffer[ptrOut++] = z;
else break;
}
pRxData = &rxd_buffer[3];
RxDataLen = ptrOut - 3;
}
 
/**
* request Data through USART in special MK format by adding checksum and
* encode data in modified Base64
* portions taken and adapted from
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c
*/
void sendMKData(unsigned char cmd, unsigned char addr, unsigned char *snd, unsigned char len) {
unsigned int pt = 0;
unsigned char a, b, c;
unsigned char ptr = 0;
 
txd_buffer[pt++] = '#'; // Start-Byte
txd_buffer[pt++] = 'a' + addr; // Adress
txd_buffer[pt++] = cmd; // Command
while (len) {
if (len) {
a = snd[ptr++];
len--;
} else a = 0;
if (len) {
b = snd[ptr++];
len--;
} else b = 0;
if (len) {
c = snd[ptr++];
len--;
} else c = 0;
txd_buffer[pt++] = '=' + (a >> 2);
txd_buffer[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4));
txd_buffer[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6));
txd_buffer[pt++] = '=' + (c & 0x3f);
}
 
// add crc
unsigned int tmpCRC = 0, i;
for (i = 0; i < pt; i++) {
tmpCRC += txd_buffer[i];
}
tmpCRC %= 4096;
txd_buffer[i++] = '=' + tmpCRC / 64;
txd_buffer[i++] = '=' + tmpCRC % 64;
txd_buffer[i++] = '\r';
 
usart1_puts((char*) txd_buffer);
}
 
/**
* short script to directly send a request thorugh usart including en- and disabling it
* where <address> is the address of the receipient, <label> is which data set to request
* and <ms> represents the milliseconds delay between data
*/
void usart1_request_mk_data(uint8_t address, char label, uint8_t ms) {
// re-enable TXD pin
usart1_EnableTXD();
 
unsigned char mstenth = ms / 10;
sendMKData(label, address, &mstenth, 1);
// wait until UDR ready
while (!(UCSR1A & (1 << UDRE1)));
// disable TXD pin again
usart1_DisableTXD();
}
 
#endif
/C-OSD/trunk
Property changes:
Added: svn:ignore
+C-OSD-trunk