sorted the boards into seperate directories with corresponding software altogether
This commit is contained in:
parent
64a0c81d81
commit
0fdd3778ed
|
@ -0,0 +1,9 @@
|
||||||
|
*.lst
|
||||||
|
*.eep
|
||||||
|
*.hex
|
||||||
|
*.lss
|
||||||
|
*.map
|
||||||
|
*.sym
|
||||||
|
|
||||||
|
*.s#?
|
||||||
|
*.b#?
|
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,581 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE eagle SYSTEM "eagle.dtd">
|
||||||
|
<eagle version="6.4">
|
||||||
|
<drawing>
|
||||||
|
<settings>
|
||||||
|
<setting alwaysvectorfont="no"/>
|
||||||
|
<setting verticaltext="up"/>
|
||||||
|
</settings>
|
||||||
|
<grid distance="1.27" unitdist="mm" unit="mm" style="lines" multiple="1" display="no" altdistance="0.025" altunitdist="inch" altunit="inch"/>
|
||||||
|
<layers>
|
||||||
|
<layer number="1" name="Top" color="4" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="2" name="Route2" color="1" fill="3" visible="no" active="no"/>
|
||||||
|
<layer number="3" name="Route3" color="4" fill="3" visible="no" active="no"/>
|
||||||
|
<layer number="4" name="Route4" color="1" fill="4" visible="no" active="no"/>
|
||||||
|
<layer number="5" name="Route5" color="4" fill="4" visible="no" active="no"/>
|
||||||
|
<layer number="6" name="Route6" color="1" fill="8" visible="no" active="no"/>
|
||||||
|
<layer number="7" name="Route7" color="4" fill="8" visible="no" active="no"/>
|
||||||
|
<layer number="8" name="Route8" color="1" fill="2" visible="no" active="no"/>
|
||||||
|
<layer number="9" name="Route9" color="4" fill="2" visible="no" active="no"/>
|
||||||
|
<layer number="10" name="Route10" color="1" fill="7" visible="no" active="no"/>
|
||||||
|
<layer number="11" name="Route11" color="4" fill="7" visible="no" active="no"/>
|
||||||
|
<layer number="12" name="Route12" color="1" fill="5" visible="no" active="no"/>
|
||||||
|
<layer number="13" name="Route13" color="4" fill="5" visible="no" active="no"/>
|
||||||
|
<layer number="14" name="Route14" color="1" fill="6" visible="no" active="no"/>
|
||||||
|
<layer number="15" name="Route15" color="4" fill="6" visible="no" active="no"/>
|
||||||
|
<layer number="16" name="Bottom" color="1" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="17" name="Pads" color="2" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="18" name="Vias" color="2" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="19" name="Unrouted" color="6" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="20" name="Dimension" color="15" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="21" name="tPlace" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="22" name="bPlace" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="23" name="tOrigins" color="15" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="24" name="bOrigins" color="15" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="25" name="tNames" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="26" name="bNames" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="27" name="tValues" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="28" name="bValues" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="29" name="tStop" color="7" fill="3" visible="no" active="yes"/>
|
||||||
|
<layer number="30" name="bStop" color="7" fill="6" visible="no" active="yes"/>
|
||||||
|
<layer number="31" name="tCream" color="7" fill="4" visible="no" active="yes"/>
|
||||||
|
<layer number="32" name="bCream" color="7" fill="5" visible="no" active="yes"/>
|
||||||
|
<layer number="33" name="tFinish" color="6" fill="3" visible="no" active="yes"/>
|
||||||
|
<layer number="34" name="bFinish" color="6" fill="6" visible="no" active="yes"/>
|
||||||
|
<layer number="35" name="tGlue" color="7" fill="4" visible="no" active="yes"/>
|
||||||
|
<layer number="36" name="bGlue" color="7" fill="5" visible="no" active="yes"/>
|
||||||
|
<layer number="37" name="tTest" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="38" name="bTest" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="39" name="tKeepout" color="4" fill="11" visible="yes" active="yes"/>
|
||||||
|
<layer number="40" name="bKeepout" color="1" fill="11" visible="yes" active="yes"/>
|
||||||
|
<layer number="41" name="tRestrict" color="4" fill="10" visible="yes" active="yes"/>
|
||||||
|
<layer number="42" name="bRestrict" color="1" fill="10" visible="yes" active="yes"/>
|
||||||
|
<layer number="43" name="vRestrict" color="2" fill="10" visible="yes" active="yes"/>
|
||||||
|
<layer number="44" name="Drills" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="45" name="Holes" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="46" name="Milling" color="3" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="47" name="Measures" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="48" name="Document" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="49" name="Reference" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="50" name="dxf" color="7" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="51" name="tDocu" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="52" name="bDocu" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="91" name="Nets" color="2" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="92" name="Busses" color="1" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="93" name="Pins" color="2" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="94" name="Symbols" color="4" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="95" name="Names" color="7" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="96" name="Values" color="7" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="97" name="Info" color="7" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="98" name="Guide" color="6" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="250" name="Descript" color="3" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="251" name="SMDround" color="12" fill="11" visible="no" active="no"/>
|
||||||
|
</layers>
|
||||||
|
<board>
|
||||||
|
<plain>
|
||||||
|
<wire x1="0" y1="0" x2="146.03" y2="0" width="0" layer="20"/>
|
||||||
|
<wire x1="146.03" y1="0" x2="146.03" y2="26.34" width="0" layer="20"/>
|
||||||
|
<wire x1="146.03" y1="26.34" x2="0" y2="26.34" width="0" layer="20"/>
|
||||||
|
<wire x1="0" y1="26.34" x2="0" y2="0" width="0" layer="20"/>
|
||||||
|
<text x="76.2" y="-7.62" size="1.778" layer="16" rot="MR0">db_bp_led_panel</text>
|
||||||
|
</plain>
|
||||||
|
<libraries>
|
||||||
|
<library name="con-harting-ml">
|
||||||
|
<description><b>Harting & 3M Connectors</b><p>
|
||||||
|
Low profile connectors, straight<p>
|
||||||
|
<author>Created by librarian@cadsoft.de</author></description>
|
||||||
|
<packages>
|
||||||
|
<package name="ML14">
|
||||||
|
<description><b>HARTING</b></description>
|
||||||
|
<wire x1="-11.43" y1="3.175" x2="11.43" y2="3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="11.43" y1="-3.175" x2="11.43" y2="3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-11.43" y1="3.175" x2="-11.43" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-12.7" y1="4.445" x2="-11.43" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="12.7" y1="-4.445" x2="8.001" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="12.7" y1="-4.445" x2="12.7" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-12.7" y1="4.445" x2="-12.7" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="11.43" y1="-3.175" x2="7.112" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-2.413" x2="-2.032" y2="-2.413" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-3.175" x2="-2.032" y2="-2.413" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-3.175" x2="-11.43" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-3.175" x2="-2.032" y2="-3.429" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-2.413" x2="2.032" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-3.175" x2="2.032" y2="-3.429" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="11.43" y1="4.445" x2="11.43" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="11.43" y1="4.699" x2="10.16" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="10.16" y1="4.445" x2="10.16" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="11.43" y1="4.445" x2="12.7" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="0.635" y1="4.699" x2="-0.635" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="0.635" y1="4.699" x2="0.635" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="0.635" y1="4.445" x2="10.16" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-0.635" y1="4.699" x2="-0.635" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-10.16" y1="4.699" x2="-11.43" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-11.43" y1="4.699" x2="-11.43" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-10.16" y1="4.699" x2="-10.16" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-10.16" y1="4.445" x2="-0.635" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="4.699" y1="-4.445" x2="2.032" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-4.445" x2="-2.032" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="5.588" y1="-3.175" x2="5.588" y2="-3.429" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="5.588" y1="-3.175" x2="2.032" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.112" y1="-3.175" x2="7.112" y2="-3.429" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.112" y1="-3.175" x2="5.588" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="4.699" y1="-4.445" x2="5.08" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.62" y1="-3.937" x2="8.001" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.62" y1="-3.937" x2="7.112" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="5.588" y1="-3.429" x2="2.032" y2="-3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-3.429" x2="2.032" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.112" y1="-3.429" x2="11.684" y2="-3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="11.684" y1="-3.429" x2="11.684" y2="3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="11.684" y1="3.429" x2="-11.684" y2="3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="-11.684" y1="3.429" x2="-11.684" y2="-3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="-11.684" y1="-3.429" x2="-2.032" y2="-3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-3.429" x2="-2.032" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="5.588" y1="-3.429" x2="5.588" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="5.588" y1="-3.937" x2="5.08" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.112" y1="-3.429" x2="7.112" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.112" y1="-3.937" x2="5.588" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-4.445" x2="-6.858" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-6.858" y1="-4.318" x2="-6.858" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-6.858" y1="-4.318" x2="-8.382" y2="-4.318" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-8.382" y1="-4.445" x2="-8.382" y2="-4.318" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-8.382" y1="-4.445" x2="-12.7" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<pad name="1" x="-7.62" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="2" x="-7.62" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="3" x="-5.08" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="4" x="-5.08" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="5" x="-2.54" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="6" x="-2.54" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="7" x="0" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="8" x="0" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="9" x="2.54" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="10" x="2.54" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="11" x="5.08" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="12" x="5.08" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="13" x="7.62" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="14" x="7.62" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<text x="-12.7" y="5.08" size="1.778" layer="25" ratio="10">>NAME</text>
|
||||||
|
<text x="0" y="5.08" size="1.778" layer="27" ratio="10">>VALUE</text>
|
||||||
|
<text x="-1.016" y="-4.064" size="1.27" layer="21" ratio="10">14</text>
|
||||||
|
<text x="-10.16" y="-1.905" size="1.27" layer="21" ratio="10">1</text>
|
||||||
|
<text x="-10.16" y="0.635" size="1.27" layer="21" ratio="10">2</text>
|
||||||
|
<rectangle x1="7.366" y1="1.016" x2="7.874" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="4.826" y1="1.016" x2="5.334" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="4.826" y1="-1.524" x2="5.334" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="7.366" y1="-1.524" x2="7.874" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="-5.334" y1="1.016" x2="-4.826" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="-7.874" y1="1.016" x2="-7.366" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="-2.794" y1="1.016" x2="-2.286" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="2.286" y1="1.016" x2="2.794" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="-0.254" y1="1.016" x2="0.254" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="-5.334" y1="-1.524" x2="-4.826" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="-7.874" y1="-1.524" x2="-7.366" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="-2.794" y1="-1.524" x2="-2.286" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="2.286" y1="-1.524" x2="2.794" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="-0.254" y1="-1.524" x2="0.254" y2="-1.016" layer="51"/>
|
||||||
|
</package>
|
||||||
|
</packages>
|
||||||
|
</library>
|
||||||
|
<library name="led">
|
||||||
|
<description><b>LEDs</b><p>
|
||||||
|
<author>Created by librarian@cadsoft.de</author><br>
|
||||||
|
Extended by Federico Battaglin <author>&lt;federico.rd@fdpinternational.com&gt;</author> with DUOLED</description>
|
||||||
|
<packages>
|
||||||
|
<package name="LED5MM">
|
||||||
|
<description><B>LED</B><p>
|
||||||
|
5 mm, round</description>
|
||||||
|
<wire x1="2.54" y1="-1.905" x2="2.54" y2="1.905" width="0.2032" layer="21"/>
|
||||||
|
<wire x1="2.54" y1="-1.905" x2="2.54" y2="1.905" width="0.254" layer="21" curve="-286.260205"/>
|
||||||
|
<wire x1="-1.143" y1="0" x2="0" y2="1.143" width="0.1524" layer="51" curve="-90"/>
|
||||||
|
<wire x1="0" y1="-1.143" x2="1.143" y2="0" width="0.1524" layer="51" curve="90"/>
|
||||||
|
<wire x1="-1.651" y1="0" x2="0" y2="1.651" width="0.1524" layer="51" curve="-90"/>
|
||||||
|
<wire x1="0" y1="-1.651" x2="1.651" y2="0" width="0.1524" layer="51" curve="90"/>
|
||||||
|
<wire x1="-2.159" y1="0" x2="0" y2="2.159" width="0.1524" layer="51" curve="-90"/>
|
||||||
|
<wire x1="0" y1="-2.159" x2="2.159" y2="0" width="0.1524" layer="51" curve="90"/>
|
||||||
|
<circle x="0" y="0" radius="2.54" width="0.1524" layer="21"/>
|
||||||
|
<pad name="A" x="-1.27" y="0" drill="0.8128" shape="octagon"/>
|
||||||
|
<pad name="K" x="1.27" y="0" drill="0.8128" shape="octagon"/>
|
||||||
|
<text x="3.175" y="0.5334" size="1.27" layer="25" ratio="10">>NAME</text>
|
||||||
|
<text x="3.2004" y="-1.8034" size="1.27" layer="27" ratio="10">>VALUE</text>
|
||||||
|
</package>
|
||||||
|
</packages>
|
||||||
|
</library>
|
||||||
|
</libraries>
|
||||||
|
<attributes>
|
||||||
|
</attributes>
|
||||||
|
<variantdefs>
|
||||||
|
</variantdefs>
|
||||||
|
<classes>
|
||||||
|
<class number="0" name="default" width="0" drill="0">
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
<designrules name="default *">
|
||||||
|
<description language="de"><b>EAGLE Design Rules</b>
|
||||||
|
<p>
|
||||||
|
Die Standard-Design-Rules sind so gewählt, dass sie für
|
||||||
|
die meisten Anwendungen passen. Sollte ihre Platine
|
||||||
|
besondere Anforderungen haben, treffen Sie die erforderlichen
|
||||||
|
Einstellungen hier und speichern die Design Rules unter
|
||||||
|
einem neuen Namen ab.</description>
|
||||||
|
<description language="en"><b>EAGLE Design Rules</b>
|
||||||
|
<p>
|
||||||
|
The default Design Rules have been set to cover
|
||||||
|
a wide range of applications. Your particular design
|
||||||
|
may have different requirements, so please make the
|
||||||
|
necessary adjustments and save your customized
|
||||||
|
design rules under a new name.</description>
|
||||||
|
<param name="layerSetup" value="(1*16)"/>
|
||||||
|
<param name="mtCopper" value="0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm"/>
|
||||||
|
<param name="mtIsolate" value="1.5mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm"/>
|
||||||
|
<param name="mdWireWire" value="8mil"/>
|
||||||
|
<param name="mdWirePad" value="8mil"/>
|
||||||
|
<param name="mdWireVia" value="8mil"/>
|
||||||
|
<param name="mdPadPad" value="8mil"/>
|
||||||
|
<param name="mdPadVia" value="8mil"/>
|
||||||
|
<param name="mdViaVia" value="8mil"/>
|
||||||
|
<param name="mdSmdPad" value="8mil"/>
|
||||||
|
<param name="mdSmdVia" value="8mil"/>
|
||||||
|
<param name="mdSmdSmd" value="8mil"/>
|
||||||
|
<param name="mdViaViaSameLayer" value="8mil"/>
|
||||||
|
<param name="mnLayersViaInSmd" value="2"/>
|
||||||
|
<param name="mdCopperDimension" value="0mil"/>
|
||||||
|
<param name="mdDrill" value="8mil"/>
|
||||||
|
<param name="mdSmdStop" value="0mil"/>
|
||||||
|
<param name="msWidth" value="10mil"/>
|
||||||
|
<param name="msDrill" value="24mil"/>
|
||||||
|
<param name="msMicroVia" value="9.99mm"/>
|
||||||
|
<param name="msBlindViaRatio" value="0.5"/>
|
||||||
|
<param name="rvPadTop" value="0.25"/>
|
||||||
|
<param name="rvPadInner" value="0.25"/>
|
||||||
|
<param name="rvPadBottom" value="0.25"/>
|
||||||
|
<param name="rvViaOuter" value="0.25"/>
|
||||||
|
<param name="rvViaInner" value="0.25"/>
|
||||||
|
<param name="rvMicroViaOuter" value="0.25"/>
|
||||||
|
<param name="rvMicroViaInner" value="0.25"/>
|
||||||
|
<param name="rlMinPadTop" value="10mil"/>
|
||||||
|
<param name="rlMaxPadTop" value="20mil"/>
|
||||||
|
<param name="rlMinPadInner" value="10mil"/>
|
||||||
|
<param name="rlMaxPadInner" value="20mil"/>
|
||||||
|
<param name="rlMinPadBottom" value="10mil"/>
|
||||||
|
<param name="rlMaxPadBottom" value="20mil"/>
|
||||||
|
<param name="rlMinViaOuter" value="8mil"/>
|
||||||
|
<param name="rlMaxViaOuter" value="20mil"/>
|
||||||
|
<param name="rlMinViaInner" value="8mil"/>
|
||||||
|
<param name="rlMaxViaInner" value="20mil"/>
|
||||||
|
<param name="rlMinMicroViaOuter" value="4mil"/>
|
||||||
|
<param name="rlMaxMicroViaOuter" value="20mil"/>
|
||||||
|
<param name="rlMinMicroViaInner" value="4mil"/>
|
||||||
|
<param name="rlMaxMicroViaInner" value="20mil"/>
|
||||||
|
<param name="psTop" value="-1"/>
|
||||||
|
<param name="psBottom" value="-1"/>
|
||||||
|
<param name="psFirst" value="-1"/>
|
||||||
|
<param name="psElongationLong" value="100"/>
|
||||||
|
<param name="psElongationOffset" value="100"/>
|
||||||
|
<param name="mvStopFrame" value="1"/>
|
||||||
|
<param name="mvCreamFrame" value="0"/>
|
||||||
|
<param name="mlMinStopFrame" value="4mil"/>
|
||||||
|
<param name="mlMaxStopFrame" value="4mil"/>
|
||||||
|
<param name="mlMinCreamFrame" value="0mil"/>
|
||||||
|
<param name="mlMaxCreamFrame" value="0mil"/>
|
||||||
|
<param name="mlViaStopLimit" value="0mil"/>
|
||||||
|
<param name="srRoundness" value="0"/>
|
||||||
|
<param name="srMinRoundness" value="0mil"/>
|
||||||
|
<param name="srMaxRoundness" value="0mil"/>
|
||||||
|
<param name="slThermalIsolate" value="10mil"/>
|
||||||
|
<param name="slThermalsForVias" value="0"/>
|
||||||
|
<param name="dpMaxLengthDifference" value="10mm"/>
|
||||||
|
<param name="dpGapFactor" value="2.5"/>
|
||||||
|
<param name="checkGrid" value="0"/>
|
||||||
|
<param name="checkAngle" value="0"/>
|
||||||
|
<param name="checkFont" value="1"/>
|
||||||
|
<param name="checkRestrict" value="1"/>
|
||||||
|
<param name="useDiameter" value="13"/>
|
||||||
|
<param name="maxErrors" value="50"/>
|
||||||
|
</designrules>
|
||||||
|
<autorouter>
|
||||||
|
<pass name="Default">
|
||||||
|
<param name="RoutingGrid" value="50mil"/>
|
||||||
|
<param name="tpViaShape" value="round"/>
|
||||||
|
<param name="PrefDir.1" value="|"/>
|
||||||
|
<param name="PrefDir.2" value="0"/>
|
||||||
|
<param name="PrefDir.3" value="0"/>
|
||||||
|
<param name="PrefDir.4" value="0"/>
|
||||||
|
<param name="PrefDir.5" value="0"/>
|
||||||
|
<param name="PrefDir.6" value="0"/>
|
||||||
|
<param name="PrefDir.7" value="0"/>
|
||||||
|
<param name="PrefDir.8" value="0"/>
|
||||||
|
<param name="PrefDir.9" value="0"/>
|
||||||
|
<param name="PrefDir.10" value="0"/>
|
||||||
|
<param name="PrefDir.11" value="0"/>
|
||||||
|
<param name="PrefDir.12" value="0"/>
|
||||||
|
<param name="PrefDir.13" value="0"/>
|
||||||
|
<param name="PrefDir.14" value="0"/>
|
||||||
|
<param name="PrefDir.15" value="0"/>
|
||||||
|
<param name="PrefDir.16" value="-"/>
|
||||||
|
<param name="cfVia" value="8"/>
|
||||||
|
<param name="cfNonPref" value="5"/>
|
||||||
|
<param name="cfChangeDir" value="2"/>
|
||||||
|
<param name="cfOrthStep" value="2"/>
|
||||||
|
<param name="cfDiagStep" value="3"/>
|
||||||
|
<param name="cfExtdStep" value="0"/>
|
||||||
|
<param name="cfBonusStep" value="1"/>
|
||||||
|
<param name="cfMalusStep" value="1"/>
|
||||||
|
<param name="cfPadImpact" value="4"/>
|
||||||
|
<param name="cfSmdImpact" value="4"/>
|
||||||
|
<param name="cfBusImpact" value="0"/>
|
||||||
|
<param name="cfHugging" value="3"/>
|
||||||
|
<param name="cfAvoid" value="4"/>
|
||||||
|
<param name="cfPolygon" value="10"/>
|
||||||
|
<param name="cfBase.1" value="0"/>
|
||||||
|
<param name="cfBase.2" value="1"/>
|
||||||
|
<param name="cfBase.3" value="1"/>
|
||||||
|
<param name="cfBase.4" value="1"/>
|
||||||
|
<param name="cfBase.5" value="1"/>
|
||||||
|
<param name="cfBase.6" value="1"/>
|
||||||
|
<param name="cfBase.7" value="1"/>
|
||||||
|
<param name="cfBase.8" value="1"/>
|
||||||
|
<param name="cfBase.9" value="1"/>
|
||||||
|
<param name="cfBase.10" value="1"/>
|
||||||
|
<param name="cfBase.11" value="1"/>
|
||||||
|
<param name="cfBase.12" value="1"/>
|
||||||
|
<param name="cfBase.13" value="1"/>
|
||||||
|
<param name="cfBase.14" value="1"/>
|
||||||
|
<param name="cfBase.15" value="1"/>
|
||||||
|
<param name="cfBase.16" value="0"/>
|
||||||
|
<param name="mnVias" value="20"/>
|
||||||
|
<param name="mnSegments" value="9999"/>
|
||||||
|
<param name="mnExtdSteps" value="9999"/>
|
||||||
|
<param name="mnRipupLevel" value="10"/>
|
||||||
|
<param name="mnRipupSteps" value="100"/>
|
||||||
|
<param name="mnRipupTotal" value="100"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Follow-me" refer="Default" active="yes">
|
||||||
|
</pass>
|
||||||
|
<pass name="Busses" refer="Default" active="yes">
|
||||||
|
<param name="cfNonPref" value="4"/>
|
||||||
|
<param name="cfBusImpact" value="4"/>
|
||||||
|
<param name="cfHugging" value="0"/>
|
||||||
|
<param name="mnVias" value="0"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Route" refer="Default" active="yes">
|
||||||
|
</pass>
|
||||||
|
<pass name="Optimize1" refer="Default" active="yes">
|
||||||
|
<param name="cfVia" value="99"/>
|
||||||
|
<param name="cfExtdStep" value="10"/>
|
||||||
|
<param name="cfHugging" value="1"/>
|
||||||
|
<param name="mnExtdSteps" value="1"/>
|
||||||
|
<param name="mnRipupLevel" value="0"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Optimize2" refer="Optimize1" active="yes">
|
||||||
|
<param name="cfNonPref" value="0"/>
|
||||||
|
<param name="cfChangeDir" value="6"/>
|
||||||
|
<param name="cfExtdStep" value="0"/>
|
||||||
|
<param name="cfBonusStep" value="2"/>
|
||||||
|
<param name="cfMalusStep" value="2"/>
|
||||||
|
<param name="cfPadImpact" value="2"/>
|
||||||
|
<param name="cfSmdImpact" value="2"/>
|
||||||
|
<param name="cfHugging" value="0"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Optimize3" refer="Optimize2" active="yes">
|
||||||
|
<param name="cfChangeDir" value="8"/>
|
||||||
|
<param name="cfPadImpact" value="0"/>
|
||||||
|
<param name="cfSmdImpact" value="0"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Optimize4" refer="Optimize3" active="yes">
|
||||||
|
<param name="cfChangeDir" value="25"/>
|
||||||
|
</pass>
|
||||||
|
</autorouter>
|
||||||
|
<elements>
|
||||||
|
<element name="SV1" library="con-harting-ml" package="ML14" value="" x="72.39" y="10.16" rot="MR0">
|
||||||
|
<attribute name="OC_NEWARK" value="unknown" x="45.72" y="5.08" size="1.778" layer="28" rot="MR0" display="off"/>
|
||||||
|
<attribute name="MPN" value="" x="45.72" y="5.08" size="1.778" layer="28" rot="MR0" display="off"/>
|
||||||
|
<attribute name="MF" value="" x="45.72" y="5.08" size="1.778" layer="28" rot="MR0" display="off"/>
|
||||||
|
<attribute name="OC_FARNELL" value="unknown" x="45.72" y="5.08" size="1.778" layer="28" rot="MR0" display="off"/>
|
||||||
|
</element>
|
||||||
|
<element name="LED1" library="led" package="LED5MM" value="" x="6.35" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED2" library="led" package="LED5MM" value="" x="15.24" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED3" library="led" package="LED5MM" value="" x="24.13" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED4" library="led" package="LED5MM" value="" x="33.02" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED5" library="led" package="LED5MM" value="" x="41.91" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED6" library="led" package="LED5MM" value="" x="50.8" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED7" library="led" package="LED5MM" value="" x="59.69" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED8" library="led" package="LED5MM" value="" x="68.58" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED9" library="led" package="LED5MM" value="" x="139.7" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED10" library="led" package="LED5MM" value="" x="130.81" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED11" library="led" package="LED5MM" value="" x="121.92" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED12" library="led" package="LED5MM" value="" x="113.03" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED13" library="led" package="LED5MM" value="" x="104.14" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED14" library="led" package="LED5MM" value="" x="95.25" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED15" library="led" package="LED5MM" value="" x="86.36" y="21.59" rot="R90"/>
|
||||||
|
<element name="LED16" library="led" package="LED5MM" value="" x="77.47" y="21.59" rot="R90"/>
|
||||||
|
</elements>
|
||||||
|
<signals>
|
||||||
|
<signal name="DIG3">
|
||||||
|
<contactref element="SV1" pad="2"/>
|
||||||
|
<contactref element="LED1" pad="K"/>
|
||||||
|
<contactref element="LED2" pad="K"/>
|
||||||
|
<contactref element="LED3" pad="K"/>
|
||||||
|
<contactref element="LED4" pad="K"/>
|
||||||
|
<contactref element="LED5" pad="K"/>
|
||||||
|
<contactref element="LED6" pad="K"/>
|
||||||
|
<contactref element="LED7" pad="K"/>
|
||||||
|
<contactref element="LED8" pad="K"/>
|
||||||
|
<wire x1="6.35" y1="22.86" x2="15.24" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="15.24" y1="22.86" x2="24.13" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="24.13" y1="22.86" x2="33.02" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="33.02" y1="22.86" x2="41.91" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="41.91" y1="22.86" x2="50.8" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="50.8" y1="22.86" x2="59.69" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="59.69" y1="22.86" x2="68.58" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="135.89" y1="21.59" x2="138.43" y2="21.59" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="138.43" y1="21.59" x2="140.97" y2="21.59" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="140.97" y1="21.59" x2="142.24" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="142.24" y1="22.86" x2="142.24" y2="24.13" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="142.24" y1="24.13" x2="140.97" y2="25.4" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="140.97" y1="25.4" x2="71.12" y2="25.4" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="71.12" y1="25.4" x2="68.58" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="80.01" y1="11.43" x2="119.38" y2="11.43" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="119.38" y1="11.43" x2="129.54" y2="21.59" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="129.54" y1="21.59" x2="135.89" y2="21.59" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="DIG4">
|
||||||
|
<contactref element="SV1" pad="4"/>
|
||||||
|
<contactref element="LED9" pad="K"/>
|
||||||
|
<contactref element="LED10" pad="K"/>
|
||||||
|
<contactref element="LED11" pad="K"/>
|
||||||
|
<contactref element="LED12" pad="K"/>
|
||||||
|
<contactref element="LED13" pad="K"/>
|
||||||
|
<contactref element="LED14" pad="K"/>
|
||||||
|
<contactref element="LED15" pad="K"/>
|
||||||
|
<contactref element="LED16" pad="K"/>
|
||||||
|
<wire x1="125.73" y1="20.32" x2="125.73" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="125.73" y1="22.86" x2="130.81" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="130.81" y1="22.86" x2="139.7" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="121.92" y1="22.86" x2="125.73" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="121.92" y1="22.86" x2="113.03" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="113.03" y1="22.86" x2="104.14" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="104.14" y1="22.86" x2="95.25" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="95.25" y1="22.86" x2="86.36" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="86.36" y1="22.86" x2="77.47" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="77.47" y1="11.43" x2="78.74" y2="12.7" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="78.74" y1="12.7" x2="118.11" y2="12.7" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="118.11" y1="12.7" x2="125.73" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$2">
|
||||||
|
<contactref element="LED1" pad="A"/>
|
||||||
|
<contactref element="SV1" pad="1"/>
|
||||||
|
<contactref element="LED9" pad="A"/>
|
||||||
|
<wire x1="80.01" y1="8.89" x2="80.01" y2="2.54" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="80.01" y1="2.54" x2="78.74" y2="1.27" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="78.74" y1="1.27" x2="10.16" y2="1.27" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="10.16" y1="1.27" x2="7.62" y2="1.27" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="7.62" y1="1.27" x2="6.35" y2="2.54" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="6.35" y1="2.54" x2="6.35" y2="20.32" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="80.01" y1="8.89" x2="128.27" y2="8.89" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="128.27" y1="8.89" x2="139.7" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$4">
|
||||||
|
<contactref element="LED2" pad="A"/>
|
||||||
|
<contactref element="SV1" pad="3"/>
|
||||||
|
<contactref element="LED10" pad="A"/>
|
||||||
|
<wire x1="15.24" y1="20.32" x2="15.24" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="15.24" y1="3.81" x2="16.51" y2="2.54" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="16.51" y1="2.54" x2="19.05" y2="2.54" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="19.05" y1="2.54" x2="76.2" y2="2.54" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="76.2" y1="2.54" x2="77.47" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="77.47" y1="3.81" x2="77.47" y2="8.89" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="77.47" y1="8.89" x2="78.74" y2="10.16" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="78.74" y1="10.16" x2="120.65" y2="10.16" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="120.65" y1="10.16" x2="130.81" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$5">
|
||||||
|
<contactref element="LED3" pad="A"/>
|
||||||
|
<contactref element="SV1" pad="5"/>
|
||||||
|
<contactref element="LED11" pad="A"/>
|
||||||
|
<wire x1="24.13" y1="20.32" x2="24.13" y2="5.08" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="24.13" y1="5.08" x2="25.4" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="25.4" y1="3.81" x2="27.94" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="27.94" y1="3.81" x2="73.66" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="73.66" y1="3.81" x2="74.93" y2="5.08" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="74.93" y1="5.08" x2="74.93" y2="8.89" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="74.93" y1="8.89" x2="76.2" y2="10.16" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="76.2" y1="10.16" x2="76.2" y2="12.7" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="76.2" y1="12.7" x2="77.47" y2="13.97" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="77.47" y1="13.97" x2="115.57" y2="13.97" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="115.57" y1="13.97" x2="121.92" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$6">
|
||||||
|
<contactref element="LED4" pad="A"/>
|
||||||
|
<contactref element="SV1" pad="7"/>
|
||||||
|
<contactref element="LED12" pad="A"/>
|
||||||
|
<wire x1="33.02" y1="20.32" x2="33.02" y2="6.35" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="33.02" y1="6.35" x2="34.29" y2="5.08" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="34.29" y1="5.08" x2="71.12" y2="5.08" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="71.12" y1="5.08" x2="72.39" y2="6.35" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="72.39" y1="6.35" x2="72.39" y2="8.89" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="72.39" y1="8.89" x2="73.66" y2="10.16" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="73.66" y1="10.16" x2="73.66" y2="12.7" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="73.66" y1="12.7" x2="76.2" y2="15.24" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="76.2" y1="15.24" x2="107.95" y2="15.24" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="107.95" y1="15.24" x2="113.03" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$7">
|
||||||
|
<contactref element="LED5" pad="A"/>
|
||||||
|
<contactref element="SV1" pad="9"/>
|
||||||
|
<contactref element="LED13" pad="A"/>
|
||||||
|
<wire x1="41.91" y1="20.32" x2="41.91" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="41.91" y1="7.62" x2="43.18" y2="6.35" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="43.18" y1="6.35" x2="68.58" y2="6.35" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="68.58" y1="6.35" x2="69.85" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="69.85" y1="7.62" x2="69.85" y2="8.89" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="69.85" y1="8.89" x2="71.12" y2="10.16" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="71.12" y1="10.16" x2="71.12" y2="12.7" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="71.12" y1="12.7" x2="74.93" y2="16.51" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="74.93" y1="16.51" x2="100.33" y2="16.51" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="100.33" y1="16.51" x2="104.14" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$9">
|
||||||
|
<contactref element="LED7" pad="A"/>
|
||||||
|
<contactref element="SV1" pad="13"/>
|
||||||
|
<contactref element="LED15" pad="A"/>
|
||||||
|
<wire x1="59.69" y1="20.32" x2="59.69" y2="11.43" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="59.69" y1="11.43" x2="62.23" y2="8.89" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="62.23" y1="8.89" x2="64.77" y2="8.89" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="86.36" y1="20.32" x2="85.09" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="85.09" y1="20.32" x2="83.82" y2="21.59" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="83.82" y1="21.59" x2="60.96" y2="21.59" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="60.96" y1="21.59" x2="59.69" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$10">
|
||||||
|
<contactref element="LED8" pad="A"/>
|
||||||
|
<contactref element="SV1" pad="14"/>
|
||||||
|
<contactref element="LED16" pad="A"/>
|
||||||
|
<wire x1="68.58" y1="20.32" x2="71.12" y2="20.32" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="71.12" y1="20.32" x2="77.47" y2="20.32" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="64.77" y1="11.43" x2="71.12" y2="20.32" width="0.6096" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$15">
|
||||||
|
<contactref element="LED14" pad="A"/>
|
||||||
|
<contactref element="LED6" pad="A"/>
|
||||||
|
<contactref element="SV1" pad="11"/>
|
||||||
|
<wire x1="50.8" y1="20.32" x2="50.8" y2="10.16" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="50.8" y1="10.16" x2="53.34" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="53.34" y1="7.62" x2="66.04" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="66.04" y1="7.62" x2="67.31" y2="8.89" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="67.31" y1="8.89" x2="68.58" y2="10.16" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="68.58" y1="10.16" x2="68.58" y2="12.7" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="68.58" y1="12.7" x2="73.66" y2="17.78" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="73.66" y1="17.78" x2="92.71" y2="17.78" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="92.71" y1="17.78" x2="95.25" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="GND">
|
||||||
|
<polygon width="0.4064" layer="16">
|
||||||
|
<vertex x="0" y="26.67"/>
|
||||||
|
<vertex x="146.05" y="26.67"/>
|
||||||
|
<vertex x="146.05" y="0"/>
|
||||||
|
<vertex x="0" y="0"/>
|
||||||
|
</polygon>
|
||||||
|
</signal>
|
||||||
|
</signals>
|
||||||
|
</board>
|
||||||
|
</drawing>
|
||||||
|
</eagle>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,730 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE eagle SYSTEM "eagle.dtd">
|
||||||
|
<eagle version="6.4">
|
||||||
|
<drawing>
|
||||||
|
<settings>
|
||||||
|
<setting alwaysvectorfont="no"/>
|
||||||
|
<setting verticaltext="up"/>
|
||||||
|
</settings>
|
||||||
|
<grid distance="0.025" unitdist="inch" unit="inch" style="lines" multiple="1" display="no" altdistance="0.025" altunitdist="inch" altunit="inch"/>
|
||||||
|
<layers>
|
||||||
|
<layer number="1" name="Top" color="4" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="2" name="Route2" color="1" fill="3" visible="no" active="no"/>
|
||||||
|
<layer number="3" name="Route3" color="4" fill="3" visible="no" active="no"/>
|
||||||
|
<layer number="4" name="Route4" color="1" fill="4" visible="no" active="no"/>
|
||||||
|
<layer number="5" name="Route5" color="4" fill="4" visible="no" active="no"/>
|
||||||
|
<layer number="6" name="Route6" color="1" fill="8" visible="no" active="no"/>
|
||||||
|
<layer number="7" name="Route7" color="4" fill="8" visible="no" active="no"/>
|
||||||
|
<layer number="8" name="Route8" color="1" fill="2" visible="no" active="no"/>
|
||||||
|
<layer number="9" name="Route9" color="4" fill="2" visible="no" active="no"/>
|
||||||
|
<layer number="10" name="Route10" color="1" fill="7" visible="no" active="no"/>
|
||||||
|
<layer number="11" name="Route11" color="4" fill="7" visible="no" active="no"/>
|
||||||
|
<layer number="12" name="Route12" color="1" fill="5" visible="no" active="no"/>
|
||||||
|
<layer number="13" name="Route13" color="4" fill="5" visible="no" active="no"/>
|
||||||
|
<layer number="14" name="Route14" color="1" fill="6" visible="no" active="no"/>
|
||||||
|
<layer number="15" name="Route15" color="4" fill="6" visible="no" active="no"/>
|
||||||
|
<layer number="16" name="Bottom" color="1" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="17" name="Pads" color="2" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="18" name="Vias" color="2" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="19" name="Unrouted" color="6" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="20" name="Dimension" color="15" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="21" name="tPlace" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="22" name="bPlace" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="23" name="tOrigins" color="15" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="24" name="bOrigins" color="15" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="25" name="tNames" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="26" name="bNames" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="27" name="tValues" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="28" name="bValues" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="29" name="tStop" color="7" fill="3" visible="no" active="yes"/>
|
||||||
|
<layer number="30" name="bStop" color="7" fill="6" visible="no" active="yes"/>
|
||||||
|
<layer number="31" name="tCream" color="7" fill="4" visible="no" active="yes"/>
|
||||||
|
<layer number="32" name="bCream" color="7" fill="5" visible="no" active="yes"/>
|
||||||
|
<layer number="33" name="tFinish" color="6" fill="3" visible="no" active="yes"/>
|
||||||
|
<layer number="34" name="bFinish" color="6" fill="6" visible="no" active="yes"/>
|
||||||
|
<layer number="35" name="tGlue" color="7" fill="4" visible="no" active="yes"/>
|
||||||
|
<layer number="36" name="bGlue" color="7" fill="5" visible="no" active="yes"/>
|
||||||
|
<layer number="37" name="tTest" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="38" name="bTest" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="39" name="tKeepout" color="4" fill="11" visible="no" active="yes"/>
|
||||||
|
<layer number="40" name="bKeepout" color="1" fill="11" visible="no" active="yes"/>
|
||||||
|
<layer number="41" name="tRestrict" color="4" fill="10" visible="no" active="yes"/>
|
||||||
|
<layer number="42" name="bRestrict" color="1" fill="10" visible="no" active="yes"/>
|
||||||
|
<layer number="43" name="vRestrict" color="2" fill="10" visible="no" active="yes"/>
|
||||||
|
<layer number="44" name="Drills" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="45" name="Holes" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="46" name="Milling" color="3" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="47" name="Measures" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="48" name="Document" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="49" name="Reference" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="50" name="dxf" color="7" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="51" name="tDocu" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="52" name="bDocu" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="91" name="Nets" color="2" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="92" name="Busses" color="1" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="93" name="Pins" color="2" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="94" name="Symbols" color="4" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="95" name="Names" color="7" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="96" name="Values" color="7" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="97" name="Info" color="7" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="98" name="Guide" color="6" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="250" name="Descript" color="3" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="251" name="SMDround" color="12" fill="11" visible="no" active="no"/>
|
||||||
|
</layers>
|
||||||
|
<board>
|
||||||
|
<plain>
|
||||||
|
<wire x1="0" y1="0" x2="149.84" y2="0" width="0" layer="20"/>
|
||||||
|
<wire x1="149.84" y1="0" x2="149.84" y2="75.87" width="0" layer="20"/>
|
||||||
|
<wire x1="149.84" y1="75.87" x2="0" y2="75.87" width="0" layer="20"/>
|
||||||
|
<wire x1="0" y1="75.87" x2="0" y2="0" width="0" layer="20"/>
|
||||||
|
<text x="143.51" y="25.4" size="1.778" layer="16" font="fixed" rot="MR90">db_bp_sevenseg_panel rev. 1</text>
|
||||||
|
<text x="143.51" y="66.04" size="1.778" layer="1" font="fixed" rot="R270">db_bp_sevenseg_panel rev. 1</text>
|
||||||
|
<hole x="146.05" y="71.755" drill="3.2"/>
|
||||||
|
<hole x="146.05" y="3.81" drill="3.2"/>
|
||||||
|
<hole x="3.81" y="3.81" drill="3.2"/>
|
||||||
|
<hole x="3.81" y="71.755" drill="3.2"/>
|
||||||
|
</plain>
|
||||||
|
<libraries>
|
||||||
|
<library name="7seg">
|
||||||
|
<packages>
|
||||||
|
<package name="6970">
|
||||||
|
<wire x1="0.175" y1="69.785" x2="48.085" y2="69.785" width="0.2498" layer="21"/>
|
||||||
|
<wire x1="48.085" y1="0.065" x2="0.175" y2="0.065" width="0.2498" layer="21"/>
|
||||||
|
<wire x1="0.175" y1="69.785" x2="0.175" y2="0.065" width="0.2498" layer="21"/>
|
||||||
|
<wire x1="48.085" y1="0.065" x2="48.085" y2="69.785" width="0.2498" layer="21"/>
|
||||||
|
<wire x1="31.3247" y1="14.9964" x2="30.3499" y2="14.0216" width="1.1994" layer="51"/>
|
||||||
|
<circle x="38.0765" y="11.3698" radius="2.2035" width="0" layer="21"/>
|
||||||
|
<pad name="1" x="19.05" y="5.08" drill="0.7" diameter="1.4224" shape="long" rot="R90"/>
|
||||||
|
<pad name="2" x="21.59" y="5.08" drill="0.7" diameter="1.4224" shape="long" rot="R90"/>
|
||||||
|
<pad name="3" x="24.13" y="5.08" drill="0.7" diameter="1.4224" shape="long" rot="R90"/>
|
||||||
|
<pad name="4" x="26.67" y="5.08" drill="0.7" diameter="1.4224" shape="long" rot="R90"/>
|
||||||
|
<pad name="5" x="29.21" y="5.08" drill="0.7" diameter="1.4224" shape="long" rot="R90"/>
|
||||||
|
<pad name="6" x="19.05" y="64.77" drill="0.7" diameter="1.4224" shape="long" rot="R90"/>
|
||||||
|
<pad name="7" x="21.59" y="64.77" drill="0.7" diameter="1.4224" shape="long" rot="R90"/>
|
||||||
|
<pad name="8" x="24.13" y="64.77" drill="0.7" diameter="1.4224" shape="long" rot="R90"/>
|
||||||
|
<pad name="9" x="26.67" y="64.77" drill="0.7" diameter="1.4224" shape="long" rot="R90"/>
|
||||||
|
<pad name="10" x="29.21" y="64.77" drill="0.7" diameter="1.4224" shape="long" rot="R90"/>
|
||||||
|
<text x="1.5748" y="71.0692" size="2.0828" layer="25" ratio="10">>NAME</text>
|
||||||
|
<text x="33.7058" y="71.501" size="2.0828" layer="27" ratio="10">>VALUE</text>
|
||||||
|
<polygon width="1.1994" layer="21" spacing="3.749">
|
||||||
|
<vertex x="19.9234" y="52.2972"/>
|
||||||
|
<vertex x="20.44" y="55.2492"/>
|
||||||
|
<vertex x="34.9786" y="55.2492"/>
|
||||||
|
<vertex x="34.6096" y="52.2972"/>
|
||||||
|
</polygon>
|
||||||
|
<polygon width="1.1994" layer="21" spacing="3.749">
|
||||||
|
<vertex x="33.7432" y="37.4058"/>
|
||||||
|
<vertex x="36.8613" y="55.1146"/>
|
||||||
|
<vertex x="37.7741" y="55.1388" curve="-104.725326"/>
|
||||||
|
<vertex x="39.6377" y="52.6036"/>
|
||||||
|
<vertex x="36.5284" y="35.766"/>
|
||||||
|
<vertex x="35.1262" y="35.766"/>
|
||||||
|
</polygon>
|
||||||
|
<polygon width="1.1994" layer="21" spacing="3.749">
|
||||||
|
<vertex x="15.4216" y="37.5372"/>
|
||||||
|
<vertex x="18.5212" y="55.2492"/>
|
||||||
|
<vertex x="17.7094" y="55.2492" curve="77.708388"/>
|
||||||
|
<vertex x="15.0526" y="53.109"/>
|
||||||
|
<vertex x="12.0268" y="35.766"/>
|
||||||
|
<vertex x="13.7242" y="35.766"/>
|
||||||
|
</polygon>
|
||||||
|
<polygon width="1.1994" layer="21" spacing="3.749">
|
||||||
|
<vertex x="15.1264" y="34.3638"/>
|
||||||
|
<vertex x="16.9714" y="36.2088"/>
|
||||||
|
<vertex x="32.1004" y="36.2088"/>
|
||||||
|
<vertex x="33.2074" y="34.659"/>
|
||||||
|
<vertex x="31.879" y="33.2568"/>
|
||||||
|
<vertex x="16.2334" y="33.2568"/>
|
||||||
|
</polygon>
|
||||||
|
<polygon width="1.1994" layer="21" spacing="3.749">
|
||||||
|
<vertex x="28.558" y="17.0946"/>
|
||||||
|
<vertex x="28.0414" y="14.1426"/>
|
||||||
|
<vertex x="13.5028" y="14.1426"/>
|
||||||
|
<vertex x="13.8718" y="17.0946"/>
|
||||||
|
</polygon>
|
||||||
|
<polygon width="1.1994" layer="21" spacing="3.749">
|
||||||
|
<vertex x="14.5168" y="32.1336"/>
|
||||||
|
<vertex x="11.6201" y="14.2772"/>
|
||||||
|
<vertex x="10.7073" y="14.253" curve="-104.725326"/>
|
||||||
|
<vertex x="8.8437" y="16.7882"/>
|
||||||
|
<vertex x="11.7316" y="33.7734"/>
|
||||||
|
<vertex x="13.1338" y="33.7734"/>
|
||||||
|
</polygon>
|
||||||
|
<polygon width="1.1994" layer="21" spacing="3.749">
|
||||||
|
<vertex x="32.9122" y="31.4118"/>
|
||||||
|
<vertex x="29.9602" y="14.1426"/>
|
||||||
|
<vertex x="30.772" y="14.1426" curve="77.708388"/>
|
||||||
|
<vertex x="33.4288" y="16.2828"/>
|
||||||
|
<vertex x="36.2332" y="33.0354"/>
|
||||||
|
<vertex x="34.5358" y="33.0354"/>
|
||||||
|
</polygon>
|
||||||
|
</package>
|
||||||
|
</packages>
|
||||||
|
</library>
|
||||||
|
<library name="con-harting-ml">
|
||||||
|
<description><b>Harting & 3M Connectors</b><p>
|
||||||
|
Low profile connectors, straight<p>
|
||||||
|
<author>Created by librarian@cadsoft.de</author></description>
|
||||||
|
<packages>
|
||||||
|
<package name="ML14">
|
||||||
|
<description><b>HARTING</b></description>
|
||||||
|
<wire x1="-11.43" y1="3.175" x2="11.43" y2="3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="11.43" y1="-3.175" x2="11.43" y2="3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-11.43" y1="3.175" x2="-11.43" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-12.7" y1="4.445" x2="-11.43" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="12.7" y1="-4.445" x2="8.001" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="12.7" y1="-4.445" x2="12.7" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-12.7" y1="4.445" x2="-12.7" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="11.43" y1="-3.175" x2="7.112" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-2.413" x2="-2.032" y2="-2.413" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-3.175" x2="-2.032" y2="-2.413" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-3.175" x2="-11.43" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-3.175" x2="-2.032" y2="-3.429" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-2.413" x2="2.032" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-3.175" x2="2.032" y2="-3.429" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="11.43" y1="4.445" x2="11.43" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="11.43" y1="4.699" x2="10.16" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="10.16" y1="4.445" x2="10.16" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="11.43" y1="4.445" x2="12.7" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="0.635" y1="4.699" x2="-0.635" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="0.635" y1="4.699" x2="0.635" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="0.635" y1="4.445" x2="10.16" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-0.635" y1="4.699" x2="-0.635" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-10.16" y1="4.699" x2="-11.43" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-11.43" y1="4.699" x2="-11.43" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-10.16" y1="4.699" x2="-10.16" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-10.16" y1="4.445" x2="-0.635" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="4.699" y1="-4.445" x2="2.032" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-4.445" x2="-2.032" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="5.588" y1="-3.175" x2="5.588" y2="-3.429" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="5.588" y1="-3.175" x2="2.032" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.112" y1="-3.175" x2="7.112" y2="-3.429" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.112" y1="-3.175" x2="5.588" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="4.699" y1="-4.445" x2="5.08" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.62" y1="-3.937" x2="8.001" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.62" y1="-3.937" x2="7.112" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="5.588" y1="-3.429" x2="2.032" y2="-3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-3.429" x2="2.032" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.112" y1="-3.429" x2="11.684" y2="-3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="11.684" y1="-3.429" x2="11.684" y2="3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="11.684" y1="3.429" x2="-11.684" y2="3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="-11.684" y1="3.429" x2="-11.684" y2="-3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="-11.684" y1="-3.429" x2="-2.032" y2="-3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-3.429" x2="-2.032" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="5.588" y1="-3.429" x2="5.588" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="5.588" y1="-3.937" x2="5.08" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.112" y1="-3.429" x2="7.112" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.112" y1="-3.937" x2="5.588" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-4.445" x2="-6.858" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-6.858" y1="-4.318" x2="-6.858" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-6.858" y1="-4.318" x2="-8.382" y2="-4.318" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-8.382" y1="-4.445" x2="-8.382" y2="-4.318" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-8.382" y1="-4.445" x2="-12.7" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<pad name="1" x="-7.62" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="2" x="-7.62" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="3" x="-5.08" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="4" x="-5.08" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="5" x="-2.54" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="6" x="-2.54" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="7" x="0" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="8" x="0" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="9" x="2.54" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="10" x="2.54" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="11" x="5.08" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="12" x="5.08" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="13" x="7.62" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="14" x="7.62" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<text x="-12.7" y="5.08" size="1.778" layer="25" ratio="10">>NAME</text>
|
||||||
|
<text x="0" y="5.08" size="1.778" layer="27" ratio="10">>VALUE</text>
|
||||||
|
<text x="-1.016" y="-4.064" size="1.27" layer="21" ratio="10">14</text>
|
||||||
|
<text x="-10.16" y="-1.905" size="1.27" layer="21" ratio="10">1</text>
|
||||||
|
<text x="-10.16" y="0.635" size="1.27" layer="21" ratio="10">2</text>
|
||||||
|
<rectangle x1="7.366" y1="1.016" x2="7.874" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="4.826" y1="1.016" x2="5.334" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="4.826" y1="-1.524" x2="5.334" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="7.366" y1="-1.524" x2="7.874" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="-5.334" y1="1.016" x2="-4.826" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="-7.874" y1="1.016" x2="-7.366" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="-2.794" y1="1.016" x2="-2.286" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="2.286" y1="1.016" x2="2.794" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="-0.254" y1="1.016" x2="0.254" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="-5.334" y1="-1.524" x2="-4.826" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="-7.874" y1="-1.524" x2="-7.366" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="-2.794" y1="-1.524" x2="-2.286" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="2.286" y1="-1.524" x2="2.794" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="-0.254" y1="-1.524" x2="0.254" y2="-1.016" layer="51"/>
|
||||||
|
</package>
|
||||||
|
</packages>
|
||||||
|
</library>
|
||||||
|
</libraries>
|
||||||
|
<attributes>
|
||||||
|
</attributes>
|
||||||
|
<variantdefs>
|
||||||
|
</variantdefs>
|
||||||
|
<classes>
|
||||||
|
<class number="0" name="default" width="0" drill="0">
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
<designrules name="default *">
|
||||||
|
<description language="de"><b>EAGLE Design Rules</b>
|
||||||
|
<p>
|
||||||
|
Die Standard-Design-Rules sind so gewählt, dass sie für
|
||||||
|
die meisten Anwendungen passen. Sollte ihre Platine
|
||||||
|
besondere Anforderungen haben, treffen Sie die erforderlichen
|
||||||
|
Einstellungen hier und speichern die Design Rules unter
|
||||||
|
einem neuen Namen ab.</description>
|
||||||
|
<description language="en"><b>EAGLE Design Rules</b>
|
||||||
|
<p>
|
||||||
|
The default Design Rules have been set to cover
|
||||||
|
a wide range of applications. Your particular design
|
||||||
|
may have different requirements, so please make the
|
||||||
|
necessary adjustments and save your customized
|
||||||
|
design rules under a new name.</description>
|
||||||
|
<param name="layerSetup" value="(1*16)"/>
|
||||||
|
<param name="mtCopper" value="0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm"/>
|
||||||
|
<param name="mtIsolate" value="1.5mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm"/>
|
||||||
|
<param name="mdWireWire" value="8mil"/>
|
||||||
|
<param name="mdWirePad" value="8mil"/>
|
||||||
|
<param name="mdWireVia" value="8mil"/>
|
||||||
|
<param name="mdPadPad" value="8mil"/>
|
||||||
|
<param name="mdPadVia" value="8mil"/>
|
||||||
|
<param name="mdViaVia" value="8mil"/>
|
||||||
|
<param name="mdSmdPad" value="8mil"/>
|
||||||
|
<param name="mdSmdVia" value="8mil"/>
|
||||||
|
<param name="mdSmdSmd" value="8mil"/>
|
||||||
|
<param name="mdViaViaSameLayer" value="8mil"/>
|
||||||
|
<param name="mnLayersViaInSmd" value="2"/>
|
||||||
|
<param name="mdCopperDimension" value="0mil"/>
|
||||||
|
<param name="mdDrill" value="8mil"/>
|
||||||
|
<param name="mdSmdStop" value="0mil"/>
|
||||||
|
<param name="msWidth" value="10mil"/>
|
||||||
|
<param name="msDrill" value="24mil"/>
|
||||||
|
<param name="msMicroVia" value="9.99mm"/>
|
||||||
|
<param name="msBlindViaRatio" value="0.5"/>
|
||||||
|
<param name="rvPadTop" value="0.25"/>
|
||||||
|
<param name="rvPadInner" value="0.25"/>
|
||||||
|
<param name="rvPadBottom" value="0.25"/>
|
||||||
|
<param name="rvViaOuter" value="0.25"/>
|
||||||
|
<param name="rvViaInner" value="0.25"/>
|
||||||
|
<param name="rvMicroViaOuter" value="0.25"/>
|
||||||
|
<param name="rvMicroViaInner" value="0.25"/>
|
||||||
|
<param name="rlMinPadTop" value="10mil"/>
|
||||||
|
<param name="rlMaxPadTop" value="20mil"/>
|
||||||
|
<param name="rlMinPadInner" value="10mil"/>
|
||||||
|
<param name="rlMaxPadInner" value="20mil"/>
|
||||||
|
<param name="rlMinPadBottom" value="10mil"/>
|
||||||
|
<param name="rlMaxPadBottom" value="20mil"/>
|
||||||
|
<param name="rlMinViaOuter" value="8mil"/>
|
||||||
|
<param name="rlMaxViaOuter" value="20mil"/>
|
||||||
|
<param name="rlMinViaInner" value="8mil"/>
|
||||||
|
<param name="rlMaxViaInner" value="20mil"/>
|
||||||
|
<param name="rlMinMicroViaOuter" value="4mil"/>
|
||||||
|
<param name="rlMaxMicroViaOuter" value="20mil"/>
|
||||||
|
<param name="rlMinMicroViaInner" value="4mil"/>
|
||||||
|
<param name="rlMaxMicroViaInner" value="20mil"/>
|
||||||
|
<param name="psTop" value="-1"/>
|
||||||
|
<param name="psBottom" value="-1"/>
|
||||||
|
<param name="psFirst" value="-1"/>
|
||||||
|
<param name="psElongationLong" value="100"/>
|
||||||
|
<param name="psElongationOffset" value="100"/>
|
||||||
|
<param name="mvStopFrame" value="1"/>
|
||||||
|
<param name="mvCreamFrame" value="0"/>
|
||||||
|
<param name="mlMinStopFrame" value="4mil"/>
|
||||||
|
<param name="mlMaxStopFrame" value="4mil"/>
|
||||||
|
<param name="mlMinCreamFrame" value="0mil"/>
|
||||||
|
<param name="mlMaxCreamFrame" value="0mil"/>
|
||||||
|
<param name="mlViaStopLimit" value="0mil"/>
|
||||||
|
<param name="srRoundness" value="0"/>
|
||||||
|
<param name="srMinRoundness" value="0mil"/>
|
||||||
|
<param name="srMaxRoundness" value="0mil"/>
|
||||||
|
<param name="slThermalIsolate" value="10mil"/>
|
||||||
|
<param name="slThermalsForVias" value="0"/>
|
||||||
|
<param name="dpMaxLengthDifference" value="10mm"/>
|
||||||
|
<param name="dpGapFactor" value="2.5"/>
|
||||||
|
<param name="checkGrid" value="0"/>
|
||||||
|
<param name="checkAngle" value="0"/>
|
||||||
|
<param name="checkFont" value="1"/>
|
||||||
|
<param name="checkRestrict" value="1"/>
|
||||||
|
<param name="useDiameter" value="13"/>
|
||||||
|
<param name="maxErrors" value="50"/>
|
||||||
|
</designrules>
|
||||||
|
<autorouter>
|
||||||
|
<pass name="Default">
|
||||||
|
<param name="RoutingGrid" value="50mil"/>
|
||||||
|
<param name="tpViaShape" value="round"/>
|
||||||
|
<param name="PrefDir.1" value="|"/>
|
||||||
|
<param name="PrefDir.2" value="0"/>
|
||||||
|
<param name="PrefDir.3" value="0"/>
|
||||||
|
<param name="PrefDir.4" value="0"/>
|
||||||
|
<param name="PrefDir.5" value="0"/>
|
||||||
|
<param name="PrefDir.6" value="0"/>
|
||||||
|
<param name="PrefDir.7" value="0"/>
|
||||||
|
<param name="PrefDir.8" value="0"/>
|
||||||
|
<param name="PrefDir.9" value="0"/>
|
||||||
|
<param name="PrefDir.10" value="0"/>
|
||||||
|
<param name="PrefDir.11" value="0"/>
|
||||||
|
<param name="PrefDir.12" value="0"/>
|
||||||
|
<param name="PrefDir.13" value="0"/>
|
||||||
|
<param name="PrefDir.14" value="0"/>
|
||||||
|
<param name="PrefDir.15" value="0"/>
|
||||||
|
<param name="PrefDir.16" value="-"/>
|
||||||
|
<param name="cfVia" value="8"/>
|
||||||
|
<param name="cfNonPref" value="5"/>
|
||||||
|
<param name="cfChangeDir" value="2"/>
|
||||||
|
<param name="cfOrthStep" value="2"/>
|
||||||
|
<param name="cfDiagStep" value="3"/>
|
||||||
|
<param name="cfExtdStep" value="0"/>
|
||||||
|
<param name="cfBonusStep" value="1"/>
|
||||||
|
<param name="cfMalusStep" value="1"/>
|
||||||
|
<param name="cfPadImpact" value="4"/>
|
||||||
|
<param name="cfSmdImpact" value="4"/>
|
||||||
|
<param name="cfBusImpact" value="0"/>
|
||||||
|
<param name="cfHugging" value="3"/>
|
||||||
|
<param name="cfAvoid" value="4"/>
|
||||||
|
<param name="cfPolygon" value="10"/>
|
||||||
|
<param name="cfBase.1" value="0"/>
|
||||||
|
<param name="cfBase.2" value="1"/>
|
||||||
|
<param name="cfBase.3" value="1"/>
|
||||||
|
<param name="cfBase.4" value="1"/>
|
||||||
|
<param name="cfBase.5" value="1"/>
|
||||||
|
<param name="cfBase.6" value="1"/>
|
||||||
|
<param name="cfBase.7" value="1"/>
|
||||||
|
<param name="cfBase.8" value="1"/>
|
||||||
|
<param name="cfBase.9" value="1"/>
|
||||||
|
<param name="cfBase.10" value="1"/>
|
||||||
|
<param name="cfBase.11" value="1"/>
|
||||||
|
<param name="cfBase.12" value="1"/>
|
||||||
|
<param name="cfBase.13" value="1"/>
|
||||||
|
<param name="cfBase.14" value="1"/>
|
||||||
|
<param name="cfBase.15" value="1"/>
|
||||||
|
<param name="cfBase.16" value="0"/>
|
||||||
|
<param name="mnVias" value="20"/>
|
||||||
|
<param name="mnSegments" value="9999"/>
|
||||||
|
<param name="mnExtdSteps" value="9999"/>
|
||||||
|
<param name="mnRipupLevel" value="10"/>
|
||||||
|
<param name="mnRipupSteps" value="100"/>
|
||||||
|
<param name="mnRipupTotal" value="100"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Follow-me" refer="Default" active="yes">
|
||||||
|
</pass>
|
||||||
|
<pass name="Busses" refer="Default" active="yes">
|
||||||
|
<param name="cfNonPref" value="4"/>
|
||||||
|
<param name="cfBusImpact" value="4"/>
|
||||||
|
<param name="cfHugging" value="0"/>
|
||||||
|
<param name="mnVias" value="0"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Route" refer="Default" active="yes">
|
||||||
|
</pass>
|
||||||
|
<pass name="Optimize1" refer="Default" active="yes">
|
||||||
|
<param name="cfVia" value="99"/>
|
||||||
|
<param name="cfExtdStep" value="10"/>
|
||||||
|
<param name="cfHugging" value="1"/>
|
||||||
|
<param name="mnExtdSteps" value="1"/>
|
||||||
|
<param name="mnRipupLevel" value="0"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Optimize2" refer="Optimize1" active="yes">
|
||||||
|
<param name="cfNonPref" value="0"/>
|
||||||
|
<param name="cfChangeDir" value="6"/>
|
||||||
|
<param name="cfExtdStep" value="0"/>
|
||||||
|
<param name="cfBonusStep" value="2"/>
|
||||||
|
<param name="cfMalusStep" value="2"/>
|
||||||
|
<param name="cfPadImpact" value="2"/>
|
||||||
|
<param name="cfSmdImpact" value="2"/>
|
||||||
|
<param name="cfHugging" value="0"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Optimize3" refer="Optimize2" active="yes">
|
||||||
|
<param name="cfChangeDir" value="8"/>
|
||||||
|
<param name="cfPadImpact" value="0"/>
|
||||||
|
<param name="cfSmdImpact" value="0"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Optimize4" refer="Optimize3" active="yes">
|
||||||
|
<param name="cfChangeDir" value="25"/>
|
||||||
|
</pass>
|
||||||
|
</autorouter>
|
||||||
|
<elements>
|
||||||
|
<element name="LED1" library="7seg" package="6970" value="7-SEG_" x="2.54" y="2.54"/>
|
||||||
|
<element name="LED2" library="7seg" package="6970" value="7-SEG_" x="50.8" y="2.54"/>
|
||||||
|
<element name="LED3" library="7seg" package="6970" value="7-SEG_" x="99.06" y="2.54"/>
|
||||||
|
<element name="SV1" library="con-harting-ml" package="ML14" value="" x="123.19" y="36.83" rot="MR180">
|
||||||
|
<attribute name="OC_NEWARK" value="unknown" x="199.39" y="118.11" size="1.778" layer="28" rot="MR180" display="off"/>
|
||||||
|
<attribute name="MPN" value="" x="199.39" y="118.11" size="1.778" layer="28" rot="MR180" display="off"/>
|
||||||
|
<attribute name="MF" value="" x="199.39" y="118.11" size="1.778" layer="28" rot="MR180" display="off"/>
|
||||||
|
<attribute name="OC_FARNELL" value="unknown" x="199.39" y="118.11" size="1.778" layer="28" rot="MR180" display="off"/>
|
||||||
|
</element>
|
||||||
|
</elements>
|
||||||
|
<signals>
|
||||||
|
<signal name="SEGA">
|
||||||
|
<contactref element="LED1" pad="7"/>
|
||||||
|
<contactref element="LED3" pad="7"/>
|
||||||
|
<contactref element="LED2" pad="7"/>
|
||||||
|
<contactref element="SV1" pad="1"/>
|
||||||
|
<wire x1="120.65" y1="67.31" x2="120.65" y2="68.58" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="120.65" y1="68.58" x2="119.38" y2="69.85" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="119.38" y1="69.85" x2="85.09" y2="69.85" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="85.09" y1="69.85" x2="83.82" y2="68.58" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="83.82" y1="68.58" x2="83.82" y2="64.77" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="83.82" y1="64.77" x2="82.55" y2="63.5" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="82.55" y1="63.5" x2="73.66" y2="63.5" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="73.66" y1="63.5" x2="72.39" y2="64.77" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="72.39" y1="64.77" x2="72.39" y2="67.31" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="72.39" y1="67.31" x2="72.39" y2="68.58" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="72.39" y1="68.58" x2="71.12" y2="69.85" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="71.12" y1="69.85" x2="36.83" y2="69.85" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="36.83" y1="69.85" x2="35.56" y2="68.58" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="35.56" y1="68.58" x2="35.56" y2="64.77" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="35.56" y1="64.77" x2="34.29" y2="63.5" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="34.29" y1="63.5" x2="25.4" y2="63.5" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="25.4" y1="63.5" x2="24.13" y2="64.77" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="24.13" y1="64.77" x2="24.13" y2="67.31" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="120.65" y1="67.31" x2="120.65" y2="44.45" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="120.65" y1="44.45" x2="119.38" y2="43.18" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="115.57" y1="38.1" x2="116.84" y2="36.83" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="116.84" y1="36.83" x2="118.745" y2="36.83" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="118.745" y1="36.83" x2="119.38" y2="37.465" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="119.38" y1="37.465" x2="119.38" y2="43.18" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="SEGB">
|
||||||
|
<contactref element="LED3" pad="6"/>
|
||||||
|
<contactref element="LED2" pad="6"/>
|
||||||
|
<contactref element="LED1" pad="6"/>
|
||||||
|
<contactref element="SV1" pad="3"/>
|
||||||
|
<wire x1="118.11" y1="67.31" x2="116.84" y2="67.31" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="116.84" y1="67.31" x2="115.57" y2="68.58" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="115.57" y1="68.58" x2="86.36" y2="68.58" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="86.36" y1="68.58" x2="85.09" y2="67.31" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="85.09" y1="67.31" x2="85.09" y2="63.5" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="85.09" y1="63.5" x2="83.82" y2="62.23" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="83.82" y1="62.23" x2="71.12" y2="62.23" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="71.12" y1="62.23" x2="69.85" y2="63.5" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="69.85" y1="63.5" x2="69.85" y2="67.31" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="69.85" y1="67.31" x2="68.58" y2="67.31" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="68.58" y1="67.31" x2="67.31" y2="68.58" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="67.31" y1="68.58" x2="38.1" y2="68.58" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="38.1" y1="68.58" x2="36.83" y2="67.31" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="36.83" y1="67.31" x2="36.83" y2="63.5" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="36.83" y1="63.5" x2="35.56" y2="62.23" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="35.56" y1="62.23" x2="22.86" y2="62.23" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="22.86" y1="62.23" x2="21.59" y2="63.5" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="21.59" y1="63.5" x2="21.59" y2="67.31" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="118.11" y1="67.31" x2="118.11" y2="38.1" width="0.6096" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="SEGC">
|
||||||
|
<contactref element="LED1" pad="4"/>
|
||||||
|
<contactref element="LED2" pad="4"/>
|
||||||
|
<contactref element="LED3" pad="4"/>
|
||||||
|
<contactref element="SV1" pad="5"/>
|
||||||
|
<wire x1="125.73" y1="7.62" x2="125.73" y2="5.08" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="125.73" y1="5.08" x2="124.46" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="124.46" y1="3.81" x2="83.82" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="83.82" y1="3.81" x2="82.55" y2="5.08" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="82.55" y1="5.08" x2="82.55" y2="8.89" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="82.55" y1="8.89" x2="81.28" y2="10.16" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="81.28" y1="10.16" x2="78.74" y2="10.16" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="78.74" y1="10.16" x2="77.47" y2="8.89" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="77.47" y1="8.89" x2="77.47" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="77.47" y1="7.62" x2="77.47" y2="5.08" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="77.47" y1="5.08" x2="76.2" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="76.2" y1="3.81" x2="35.56" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="35.56" y1="3.81" x2="34.29" y2="5.08" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="34.29" y1="5.08" x2="34.29" y2="8.89" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="34.29" y1="8.89" x2="33.02" y2="10.16" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="33.02" y1="10.16" x2="30.48" y2="10.16" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="30.48" y1="10.16" x2="29.21" y2="8.89" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="29.21" y1="8.89" x2="29.21" y2="7.62" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="125.73" y1="7.62" x2="125.73" y2="27.94" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="125.73" y1="27.94" x2="127" y2="29.21" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="127" y1="29.21" x2="127" y2="40.64" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="127" y1="40.64" x2="126.365" y2="41.275" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="126.365" y1="41.275" x2="121.285" y2="41.275" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="121.285" y1="41.275" x2="120.65" y2="40.64" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="120.65" y1="40.64" x2="120.65" y2="38.1" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="SEGD">
|
||||||
|
<contactref element="LED3" pad="2"/>
|
||||||
|
<contactref element="LED2" pad="2"/>
|
||||||
|
<contactref element="LED1" pad="2"/>
|
||||||
|
<contactref element="SV1" pad="7"/>
|
||||||
|
<wire x1="120.65" y1="7.62" x2="120.65" y2="6.35" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="120.65" y1="6.35" x2="119.38" y2="5.08" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="119.38" y1="5.08" x2="85.09" y2="5.08" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="85.09" y1="5.08" x2="83.82" y2="6.35" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="83.82" y1="6.35" x2="83.82" y2="10.16" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="83.82" y1="10.16" x2="82.55" y2="11.43" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="82.55" y1="11.43" x2="73.66" y2="11.43" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="73.66" y1="11.43" x2="72.39" y2="10.16" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="72.39" y1="10.16" x2="72.39" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="72.39" y1="7.62" x2="72.39" y2="6.35" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="72.39" y1="6.35" x2="71.12" y2="5.08" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="71.12" y1="5.08" x2="36.83" y2="5.08" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="36.83" y1="5.08" x2="35.56" y2="6.35" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="35.56" y1="6.35" x2="35.56" y2="10.16" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="35.56" y1="10.16" x2="34.29" y2="11.43" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="34.29" y1="11.43" x2="25.4" y2="11.43" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="25.4" y1="11.43" x2="24.13" y2="10.16" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="24.13" y1="10.16" x2="24.13" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="120.65" y1="7.62" x2="120.65" y2="9.525" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="120.65" y1="9.525" x2="123.19" y2="12.065" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="123.19" y1="12.065" x2="123.19" y2="32.385" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="123.19" y1="32.385" x2="121.92" y2="33.655" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="121.92" y1="33.655" x2="121.92" y2="36.195" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="121.92" y1="36.195" x2="123.19" y2="37.465" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="123.19" y1="37.465" x2="123.19" y2="38.1" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="SEGE">
|
||||||
|
<contactref element="LED1" pad="1"/>
|
||||||
|
<contactref element="LED3" pad="1"/>
|
||||||
|
<contactref element="LED2" pad="1"/>
|
||||||
|
<contactref element="SV1" pad="9"/>
|
||||||
|
<wire x1="118.11" y1="7.62" x2="116.84" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="116.84" y1="7.62" x2="115.57" y2="6.35" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="115.57" y1="6.35" x2="86.36" y2="6.35" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="86.36" y1="6.35" x2="85.09" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="85.09" y1="7.62" x2="85.09" y2="11.43" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="85.09" y1="11.43" x2="83.82" y2="12.7" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="83.82" y1="12.7" x2="71.12" y2="12.7" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="71.12" y1="12.7" x2="69.85" y2="11.43" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="69.85" y1="11.43" x2="69.85" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="69.85" y1="7.62" x2="68.58" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="68.58" y1="7.62" x2="67.31" y2="6.35" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="67.31" y1="6.35" x2="38.1" y2="6.35" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="38.1" y1="6.35" x2="36.83" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="36.83" y1="7.62" x2="36.83" y2="11.43" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="36.83" y1="11.43" x2="35.56" y2="12.7" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="35.56" y1="12.7" x2="22.86" y2="12.7" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="22.86" y1="12.7" x2="21.59" y2="11.43" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="21.59" y1="11.43" x2="21.59" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="118.11" y1="7.62" x2="118.11" y2="31.115" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="118.11" y1="31.115" x2="119.38" y2="32.385" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="119.38" y1="32.385" x2="119.38" y2="36.195" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="119.38" y1="36.195" x2="120.015" y2="36.83" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="120.015" y1="36.83" x2="121.285" y2="36.83" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="121.285" y1="36.83" x2="121.92" y2="37.465" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="121.92" y1="37.465" x2="121.92" y2="39.37" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="121.92" y1="39.37" x2="122.555" y2="40.005" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="122.555" y1="40.005" x2="125.095" y2="40.005" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="125.095" y1="40.005" x2="125.73" y2="39.37" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="125.73" y1="39.37" x2="125.73" y2="38.1" width="0.6096" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="SEGF">
|
||||||
|
<contactref element="LED1" pad="9"/>
|
||||||
|
<contactref element="LED3" pad="9"/>
|
||||||
|
<contactref element="LED2" pad="9"/>
|
||||||
|
<contactref element="SV1" pad="11"/>
|
||||||
|
<wire x1="125.73" y1="67.31" x2="125.73" y2="69.85" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="125.73" y1="69.85" x2="124.46" y2="71.12" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="124.46" y1="71.12" x2="83.82" y2="71.12" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="83.82" y1="71.12" x2="82.55" y2="69.85" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="82.55" y1="69.85" x2="82.55" y2="66.04" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="82.55" y1="66.04" x2="81.28" y2="64.77" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="81.28" y1="64.77" x2="78.74" y2="64.77" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="78.74" y1="64.77" x2="77.47" y2="66.04" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="77.47" y1="66.04" x2="77.47" y2="67.31" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="77.47" y1="67.31" x2="77.47" y2="69.85" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="77.47" y1="69.85" x2="76.2" y2="71.12" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="76.2" y1="71.12" x2="35.56" y2="71.12" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="35.56" y1="71.12" x2="34.29" y2="69.85" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="34.29" y1="69.85" x2="34.29" y2="66.04" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="34.29" y1="66.04" x2="33.02" y2="64.77" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="33.02" y1="64.77" x2="30.48" y2="64.77" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="30.48" y1="64.77" x2="29.21" y2="66.04" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="29.21" y1="66.04" x2="29.21" y2="67.31" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="125.73" y1="67.31" x2="125.73" y2="49.53" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="125.73" y1="49.53" x2="128.27" y2="46.99" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="128.27" y1="46.99" x2="128.27" y2="38.1" width="0.6096" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="SEGG">
|
||||||
|
<contactref element="LED1" pad="10"/>
|
||||||
|
<contactref element="LED2" pad="10"/>
|
||||||
|
<contactref element="LED3" pad="10"/>
|
||||||
|
<contactref element="SV1" pad="13"/>
|
||||||
|
<wire x1="128.27" y1="67.31" x2="128.27" y2="71.12" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="128.27" y1="71.12" x2="127" y2="72.39" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="127" y1="72.39" x2="80.01" y2="72.39" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="80.01" y1="72.39" x2="33.02" y2="72.39" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="33.02" y1="72.39" x2="31.75" y2="71.12" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="31.75" y1="71.12" x2="31.75" y2="67.31" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="80.01" y1="67.31" x2="80.01" y2="72.39" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="128.27" y1="67.31" x2="128.27" y2="49.53" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="128.27" y1="49.53" x2="130.81" y2="46.99" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="130.81" y1="46.99" x2="130.81" y2="38.1" width="0.6096" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="SEGDP">
|
||||||
|
<contactref element="LED1" pad="5"/>
|
||||||
|
<contactref element="LED3" pad="5"/>
|
||||||
|
<contactref element="LED2" pad="5"/>
|
||||||
|
<contactref element="SV1" pad="14"/>
|
||||||
|
<wire x1="128.27" y1="7.62" x2="128.27" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="128.27" y1="3.81" x2="127" y2="2.54" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="127" y1="2.54" x2="80.01" y2="2.54" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="80.01" y1="2.54" x2="33.02" y2="2.54" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="33.02" y1="2.54" x2="31.75" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="31.75" y1="3.81" x2="31.75" y2="7.62" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="80.01" y1="7.62" x2="80.01" y2="2.54" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="128.27" y1="7.62" x2="128.27" y2="20.32" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="128.27" y1="20.32" x2="130.81" y2="22.86" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="130.81" y1="22.86" x2="130.81" y2="35.56" width="0.6096" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="DIG3">
|
||||||
|
<contactref element="SV1" pad="2"/>
|
||||||
|
<contactref element="LED1" pad="3"/>
|
||||||
|
<contactref element="LED1" pad="8"/>
|
||||||
|
<wire x1="115.57" y1="35.56" x2="113.665" y2="35.56" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="113.665" y1="35.56" x2="112.395" y2="36.83" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="112.395" y1="36.83" x2="17.78" y2="36.83" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="26.67" y1="7.62" x2="26.67" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="26.67" y1="3.81" x2="25.4" y2="2.54" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="25.4" y1="2.54" x2="19.05" y2="2.54" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="19.05" y1="2.54" x2="17.78" y2="3.81" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="17.78" y1="3.81" x2="17.78" y2="36.83" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="17.78" y1="36.83" x2="17.78" y2="70.485" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="17.78" y1="70.485" x2="19.05" y2="71.755" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="19.05" y1="71.755" x2="25.4" y2="71.755" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="25.4" y1="71.755" x2="26.67" y2="70.485" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="26.67" y1="67.31" x2="26.67" y2="70.485" width="0.6096" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="DIG4">
|
||||||
|
<contactref element="SV1" pad="4"/>
|
||||||
|
<contactref element="LED2" pad="8"/>
|
||||||
|
<contactref element="LED2" pad="3"/>
|
||||||
|
<wire x1="118.11" y1="35.56" x2="118.11" y2="34.925" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="118.11" y1="34.925" x2="116.205" y2="33.02" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="116.205" y1="33.02" x2="76.2" y2="33.02" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="76.2" y1="33.02" x2="75.8825" y2="32.7025" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="75.8825" y1="32.7025" x2="74.93" y2="31.75" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="74.93" y1="31.75" x2="74.93" y2="17.145" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="74.93" y1="7.62" x2="74.93" y2="17.145" width="0.4064" layer="1"/>
|
||||||
|
<via x="74.93" y="17.145" extent="1-16" drill="0.6" diameter="2.54" shape="octagon"/>
|
||||||
|
<via x="74.93" y="34.29" extent="1-16" drill="0.6" diameter="2.54" shape="octagon"/>
|
||||||
|
<wire x1="74.93" y1="34.29" x2="74.93" y2="33.655" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="74.93" y1="33.655" x2="75.8825" y2="32.7025" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="74.93" y1="34.29" x2="74.93" y2="67.31" width="0.4064" layer="1"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="DIG5">
|
||||||
|
<contactref element="SV1" pad="6"/>
|
||||||
|
<contactref element="LED3" pad="8"/>
|
||||||
|
<contactref element="LED3" pad="3"/>
|
||||||
|
<via x="120.65" y="17.145" extent="1-16" drill="0.6" diameter="2.54" shape="octagon"/>
|
||||||
|
<wire x1="120.65" y1="29.845" x2="120.65" y2="17.145" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="120.65" y1="17.145" x2="123.19" y2="17.145" width="0.4064" layer="1"/>
|
||||||
|
<wire x1="123.19" y1="17.145" x2="123.19" y2="7.62" width="0.4064" layer="1"/>
|
||||||
|
<wire x1="123.19" y1="67.31" x2="123.19" y2="47.625" width="0.4064" layer="1"/>
|
||||||
|
<via x="120.65" y="29.845" extent="1-16" drill="0.6" diameter="2.54" shape="octagon"/>
|
||||||
|
<wire x1="123.19" y1="47.625" x2="135.89" y2="47.625" width="0.4064" layer="1"/>
|
||||||
|
<wire x1="135.89" y1="47.625" x2="135.89" y2="29.845" width="0.4064" layer="1"/>
|
||||||
|
<wire x1="135.89" y1="29.845" x2="120.65" y2="29.845" width="0.4064" layer="1"/>
|
||||||
|
<wire x1="120.65" y1="29.845" x2="120.65" y2="35.56" width="0.6096" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="GND">
|
||||||
|
<polygon width="0.8128" layer="16" spacing="2.54" isolate="0.8128">
|
||||||
|
<vertex x="0" y="75.565"/>
|
||||||
|
<vertex x="149.86" y="75.565"/>
|
||||||
|
<vertex x="149.86" y="0"/>
|
||||||
|
<vertex x="0" y="0"/>
|
||||||
|
</polygon>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$1">
|
||||||
|
</signal>
|
||||||
|
</signals>
|
||||||
|
</board>
|
||||||
|
</drawing>
|
||||||
|
</eagle>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,276 @@
|
||||||
|
# On command line:
|
||||||
|
#
|
||||||
|
# make all = Make software.
|
||||||
|
#
|
||||||
|
# make clean = Clean out built project files.
|
||||||
|
#
|
||||||
|
# make program = Download the hex file to the device, using avrdude. Please
|
||||||
|
# customize the avrdude settings below first!
|
||||||
|
#
|
||||||
|
# To rebuild project do "make clean" then "make all".
|
||||||
|
#
|
||||||
|
|
||||||
|
MCU = atmega32
|
||||||
|
F_CPU = 8000000
|
||||||
|
|
||||||
|
# Output format. (can be srec, ihex, binary)
|
||||||
|
FORMAT = ihex
|
||||||
|
|
||||||
|
# Target file name (without extension).
|
||||||
|
TARGET = main
|
||||||
|
|
||||||
|
SRC = src/$(TARGET).c src/utils.c src/uart.c
|
||||||
|
|
||||||
|
|
||||||
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
|
OPT = s
|
||||||
|
|
||||||
|
|
||||||
|
# List any extra directories to look for include files here.
|
||||||
|
# Each directory must be seperated by a space.
|
||||||
|
EXTRAINCDIRS = src/
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flag to set the C Standard level.
|
||||||
|
# c89 - "ANSI" C
|
||||||
|
# gnu89 - c89 plus GCC extensions
|
||||||
|
# c99 - ISO C99 standard (not yet fully implemented)
|
||||||
|
# gnu99 - c99 plus GCC extensions
|
||||||
|
CSTANDARD = -std=gnu99
|
||||||
|
|
||||||
|
# Place -D or -U options here
|
||||||
|
CDEFS =
|
||||||
|
|
||||||
|
# Place -I options here
|
||||||
|
CINCS =
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flags.
|
||||||
|
# -O*: optimization level
|
||||||
|
# -f...: tuning, see GCC manual and avr-libc documentation
|
||||||
|
# -Wall...: warning level
|
||||||
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
|
# -adhlns...: create assembler listing
|
||||||
|
CFLAGS += $(CDEFS) $(CINCS)
|
||||||
|
CFLAGS += -O$(OPT)
|
||||||
|
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
|
||||||
|
CFLAGS += -Wall -Wstrict-prototypes
|
||||||
|
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
|
||||||
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
CFLAGS += $(CSTANDARD)
|
||||||
|
CFLAGS += -DF_CPU=$(F_CPU) #-DDEBUG
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# External memory options
|
||||||
|
|
||||||
|
|
||||||
|
# Linker flags.
|
||||||
|
# -Wl,...: tell GCC to pass this to linker.
|
||||||
|
# -Map: create map file
|
||||||
|
# --cref: add cross reference to map file
|
||||||
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
|
|
||||||
|
|
||||||
|
# Programming support using avrdude. Settings and variables.
|
||||||
|
AVRDUDE_PROGRAMMER = usbasp
|
||||||
|
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
|
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
||||||
|
|
||||||
|
AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Define programs and commands.
|
||||||
|
SHELL = sh
|
||||||
|
CC = avr-gcc
|
||||||
|
OBJCOPY = avr-objcopy
|
||||||
|
OBJDUMP = avr-objdump
|
||||||
|
SIZE = avr-size
|
||||||
|
NM = avr-nm
|
||||||
|
AVRDUDE = avrdude
|
||||||
|
REMOVE = rm -f
|
||||||
|
COPY = cp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Define Messages
|
||||||
|
# English
|
||||||
|
MSG_ERRORS_NONE = Errors: none
|
||||||
|
MSG_BEGIN = -------- begin --------
|
||||||
|
MSG_END = -------- end --------
|
||||||
|
MSG_SIZE_BEFORE = Size before:
|
||||||
|
MSG_SIZE_AFTER = Size after:
|
||||||
|
MSG_COFF = Converting to AVR COFF:
|
||||||
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
MSG_FLASH = Creating load file for Flash:
|
||||||
|
MSG_EEPROM = Creating load file for EEPROM:
|
||||||
|
MSG_EXTENDED_LISTING = Creating Extended Listing:
|
||||||
|
MSG_SYMBOL_TABLE = Creating Symbol Table:
|
||||||
|
MSG_LINKING = Linking:
|
||||||
|
MSG_COMPILING = Compiling:
|
||||||
|
MSG_ASSEMBLING = Assembling:
|
||||||
|
MSG_CLEANING = Cleaning project:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Define all object files.
|
||||||
|
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
|
||||||
|
|
||||||
|
# Define all listing files.
|
||||||
|
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flags to generate dependency files.
|
||||||
|
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
|
||||||
|
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
|
||||||
|
|
||||||
|
# Combine all necessary flags and optional flags.
|
||||||
|
# Add target processor to flags.
|
||||||
|
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Default target.
|
||||||
|
all: begin gccversion sizebefore build sizeafter finished end
|
||||||
|
|
||||||
|
build: elf hex eep lss sym
|
||||||
|
|
||||||
|
elf: $(TARGET).elf
|
||||||
|
hex: $(TARGET).hex
|
||||||
|
eep: $(TARGET).eep
|
||||||
|
lss: $(TARGET).lss
|
||||||
|
sym: $(TARGET).sym
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Eye candy.
|
||||||
|
# AVR Studio 3.x does not check make's exit code but relies on
|
||||||
|
# the following magic strings to be generated by the compile job.
|
||||||
|
begin:
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_BEGIN)
|
||||||
|
|
||||||
|
finished:
|
||||||
|
@echo $(MSG_ERRORS_NONE)
|
||||||
|
|
||||||
|
end:
|
||||||
|
@echo $(MSG_END)
|
||||||
|
@echo
|
||||||
|
|
||||||
|
|
||||||
|
# Display size of file.
|
||||||
|
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
|
||||||
|
ELFSIZE = $(SIZE) -A $(TARGET).elf
|
||||||
|
sizebefore:
|
||||||
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
sizeafter:
|
||||||
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Display compiler version information.
|
||||||
|
gccversion :
|
||||||
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Program the device.
|
||||||
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
||||||
|
# Create final output files (.hex, .eep) from ELF output file.
|
||||||
|
%.hex: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_FLASH) $@
|
||||||
|
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||||
|
|
||||||
|
%.eep: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_EEPROM) $@
|
||||||
|
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||||
|
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
||||||
|
|
||||||
|
# Create extended listing file from ELF output file.
|
||||||
|
%.lss: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_EXTENDED_LISTING) $@
|
||||||
|
$(OBJDUMP) -h -S $< > $@
|
||||||
|
|
||||||
|
# Create a symbol table from ELF output file.
|
||||||
|
%.sym: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_SYMBOL_TABLE) $@
|
||||||
|
$(NM) -n $< > $@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Link: create ELF output file from object files.
|
||||||
|
.SECONDARY : $(TARGET).elf
|
||||||
|
.PRECIOUS : $(OBJ)
|
||||||
|
%.elf: $(OBJ)
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_LINKING) $@
|
||||||
|
$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create object files from C source files.
|
||||||
|
%.o : %.c
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_COMPILING) $<
|
||||||
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create assembler files from C source files.
|
||||||
|
%.s : %.c
|
||||||
|
$(CC) -S $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
# Assemble: create object files from assembler source files.
|
||||||
|
%.o : %.S
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_ASSEMBLING) $<
|
||||||
|
$(CC) -c $(ALL_ASFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Target: clean project.
|
||||||
|
clean: begin clean_list finished end
|
||||||
|
|
||||||
|
clean_list :
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_CLEANING)
|
||||||
|
$(REMOVE) $(TARGET).hex
|
||||||
|
$(REMOVE) $(TARGET).eep
|
||||||
|
$(REMOVE) $(TARGET).obj
|
||||||
|
$(REMOVE) $(TARGET).cof
|
||||||
|
$(REMOVE) $(TARGET).elf
|
||||||
|
$(REMOVE) $(TARGET).map
|
||||||
|
$(REMOVE) $(TARGET).obj
|
||||||
|
$(REMOVE) $(TARGET).a90
|
||||||
|
$(REMOVE) $(TARGET).sym
|
||||||
|
$(REMOVE) $(TARGET).lnk
|
||||||
|
$(REMOVE) $(TARGET).lss
|
||||||
|
$(REMOVE) $(OBJ)
|
||||||
|
$(REMOVE) $(LST)
|
||||||
|
$(REMOVE) $(SRC:.c=.s)
|
||||||
|
$(REMOVE) $(SRC:.c=.d)
|
||||||
|
$(REMOVE) .dep/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Include the dependency files.
|
||||||
|
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
||||||
|
|
||||||
|
|
||||||
|
# Listing of phony targets.
|
||||||
|
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
||||||
|
build elf hex eep lss sym coff extcoff \
|
||||||
|
clean clean_list program
|
||||||
|
|
|
@ -0,0 +1,318 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "utils.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
#define BUFSIZE 40
|
||||||
|
#define CURRENT_MAX 30000 // 30 Ampere is max
|
||||||
|
|
||||||
|
volatile uint16_t syscounter = 0;
|
||||||
|
volatile uint8_t digitbuffer[6] = { 0,0,0,0,0,0 };
|
||||||
|
volatile uint8_t leddigitbuffer[4] = { 0,0,0,0 };
|
||||||
|
uint8_t digit = 0;
|
||||||
|
uint8_t leddigit = 0;
|
||||||
|
|
||||||
|
// values send over uart from powerboard
|
||||||
|
uint16_t voltage = 0;
|
||||||
|
int16_t current_in = 0;
|
||||||
|
int16_t current_out = 0;
|
||||||
|
uint8_t dumpsw = 0; //TODO: make bitfield
|
||||||
|
uint8_t loadsw = 0; //TODO: make bitfield
|
||||||
|
uint8_t gensw = 0; //TODO: make bitfield
|
||||||
|
|
||||||
|
uint16_t power_gen = 0;
|
||||||
|
uint16_t power_load = 0;
|
||||||
|
|
||||||
|
unsigned char data_count = 0;
|
||||||
|
unsigned char data_in[BUFSIZE];
|
||||||
|
char command_in[BUFSIZE];
|
||||||
|
|
||||||
|
const uint8_t segment_translate[10] = {
|
||||||
|
63, 6, 91, 79, 102, 109, 125, 7, 127, 111
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t smallbar_translate[9] = {
|
||||||
|
0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t bigbar_translate[15][2] = {
|
||||||
|
{ 0x00, 0xc0},
|
||||||
|
{ 0x00, 0x60},
|
||||||
|
{ 0x00, 0x30},
|
||||||
|
{ 0x00, 0x18},
|
||||||
|
{ 0x00, 0x0c},
|
||||||
|
{ 0x00, 0x06},
|
||||||
|
{ 0x00, 0x03},
|
||||||
|
{ 0x01, 0x01},
|
||||||
|
{ 0x03, 0x00},
|
||||||
|
{ 0x06, 0x00},
|
||||||
|
{ 0x0c, 0x00},
|
||||||
|
{ 0x18, 0x00},
|
||||||
|
{ 0x30, 0x00},
|
||||||
|
{ 0x60, 0x00},
|
||||||
|
{ 0xc0, 0x00}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void timer_init(void) {
|
||||||
|
// clock is 8MHz
|
||||||
|
TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10) ; // CTC Mode for Timer 1 (16Bit) with prescale of 64
|
||||||
|
OCR1A = 250; // 500Hz
|
||||||
|
TIMSK = _BV(OCIE1A);
|
||||||
|
sei(); // enable interrupts
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ports_init(void) {
|
||||||
|
// make column / digit driver pins to output
|
||||||
|
LEDDIG_DDR |= _BV(LEDS_MID1) | _BV(LEDS_MID2) | _BV(LEDS_LOAD) | _BV(LEDS_GEN);
|
||||||
|
SEVENSEGDIG_DDR |= _BV(DIG0) | _BV(DIG1) | _BV(DIG2) | _BV(DIG3) | _BV(DIG4) | _BV(DIG5);
|
||||||
|
|
||||||
|
// make data ports to output
|
||||||
|
LED_DDR = 0xff;
|
||||||
|
SEVENSEG_DDR = 0xff;
|
||||||
|
|
||||||
|
SEVENSEGDIG_PORT = 0;
|
||||||
|
SEVENSEG_PORT = 0;
|
||||||
|
|
||||||
|
LEDDIG_PORT = 0;
|
||||||
|
LED_PORT = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_sevenseg(uint8_t display, uint16_t value) {
|
||||||
|
uint8_t d[3];
|
||||||
|
d[2] = (value % 1000 / 100 );
|
||||||
|
d[1] = (value % 100 / 10 );
|
||||||
|
d[0] = (value % 10);
|
||||||
|
|
||||||
|
if(display == 0) {
|
||||||
|
digitbuffer[0] = segment_translate[d[0]];
|
||||||
|
if(d[1] == 0 && d[2] == 0)
|
||||||
|
digitbuffer[1] = 0x00;
|
||||||
|
else
|
||||||
|
digitbuffer[1] = segment_translate[d[1]];
|
||||||
|
if(d[2] == 0)
|
||||||
|
digitbuffer[2] = 0x00;
|
||||||
|
else
|
||||||
|
digitbuffer[2] = segment_translate[d[2]];
|
||||||
|
} else {
|
||||||
|
digitbuffer[3] = segment_translate[d[0]];
|
||||||
|
if(d[1] == 0 && d[2] == 0)
|
||||||
|
digitbuffer[4] = 0x00;
|
||||||
|
else
|
||||||
|
digitbuffer[4] = segment_translate[d[1]];
|
||||||
|
if(d[2] == 0)
|
||||||
|
digitbuffer[5] = 0x00;
|
||||||
|
else
|
||||||
|
digitbuffer[5] = segment_translate[d[2]];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_bar(uint8_t display, uint16_t value, uint16_t max) {
|
||||||
|
uint16_t x = 0;
|
||||||
|
float temp = max;
|
||||||
|
|
||||||
|
x = (uint16_t)( (value / temp) * 8.0);
|
||||||
|
|
||||||
|
x%=8;
|
||||||
|
|
||||||
|
switch(display) {
|
||||||
|
case LEDS_LOAD:
|
||||||
|
leddigitbuffer[2] = smallbar_translate[x];
|
||||||
|
break;
|
||||||
|
case LEDS_GEN:
|
||||||
|
leddigitbuffer[3] = smallbar_translate[x];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
static void print_bar_bottom(uint16_t in, uint16_t out, uint16_t max) {
|
||||||
|
uint16_t x;
|
||||||
|
float temp = max;
|
||||||
|
|
||||||
|
if(out == in) {
|
||||||
|
leddigitbuffer[0] = bigbar_translate[7][0];
|
||||||
|
leddigitbuffer[1] = bigbar_translate[7][1];
|
||||||
|
return;
|
||||||
|
} else if( out > in ) {
|
||||||
|
x = (uint16_t)( ((out - in) / temp) * 8.0);
|
||||||
|
x = x+8;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
x = (uint16_t)( ((in - out) / temp) * 8.0);
|
||||||
|
x = 7-x;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(x > 14) x = 14;
|
||||||
|
if(x < 0) x = 0;
|
||||||
|
|
||||||
|
leddigitbuffer[0] = bigbar_translate[x][0];
|
||||||
|
leddigitbuffer[1] = bigbar_translate[x][1];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void process_command() {
|
||||||
|
if(strstr(command_in,"A") != NULL) {
|
||||||
|
// we have an A and B (from check in work_uart()
|
||||||
|
// so our message should be complete and consist of:
|
||||||
|
// A$voltage,$current_in,$current_out,$power_in,$power_out,loadsw,dumpsw,gensw\n
|
||||||
|
|
||||||
|
//A12.5,65464,00000,00000,00000,1,0,1B
|
||||||
|
|
||||||
|
char *token;
|
||||||
|
uint8_t tokencounter = 0;
|
||||||
|
|
||||||
|
char *start = strrchr(command_in, 'A');
|
||||||
|
|
||||||
|
// remove first (B is ignored by atoi)
|
||||||
|
start++;
|
||||||
|
|
||||||
|
token = strtok(start, ",");
|
||||||
|
|
||||||
|
while( token ) {
|
||||||
|
switch(tokencounter) {
|
||||||
|
case 0:
|
||||||
|
voltage = atoi(token);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
current_in = atoi(token);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
current_out = atoi(token);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
power_gen = atoi(token);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
power_load = atoi(token);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if(atoi(token) == 1) loadsw = 1;
|
||||||
|
else loadsw = 0;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
if(atoi(token) == 1) dumpsw = 1;
|
||||||
|
else dumpsw = 0;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
if(atoi(token) == 1) gensw = 1;
|
||||||
|
else gensw = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
tokencounter++;
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void work_uart(){
|
||||||
|
unsigned int c = uart_getc();
|
||||||
|
|
||||||
|
if ( !(c & UART_NO_DATA) ) {
|
||||||
|
data_in[data_count] = c;
|
||||||
|
|
||||||
|
if (data_in[data_count] == 'B') {
|
||||||
|
data_count = 0;
|
||||||
|
|
||||||
|
memcpy(command_in, data_in, BUFSIZE);
|
||||||
|
memset(data_in, 0, BUFSIZE);
|
||||||
|
|
||||||
|
process_command();
|
||||||
|
} else {
|
||||||
|
data_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void demo_display(void) {
|
||||||
|
|
||||||
|
for(uint8_t i = 0; i< 16;i++) {
|
||||||
|
leddigitbuffer[0] = bigbar_translate[i][0];
|
||||||
|
leddigitbuffer[1] = bigbar_translate[i][1];
|
||||||
|
wait(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint8_t i = 0; i< 9;i++) {
|
||||||
|
leddigitbuffer[2] = smallbar_translate[i];
|
||||||
|
wait(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint8_t i = 0; i< 9;i++) {
|
||||||
|
leddigitbuffer[3] = smallbar_translate[i];
|
||||||
|
wait(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint8_t j = 0; j< 3;j++) {
|
||||||
|
for(uint8_t i = 0; i< 6; i++) {
|
||||||
|
digitbuffer[i] = 0xff;
|
||||||
|
}
|
||||||
|
wait(20);
|
||||||
|
for(uint8_t i = 0; i< 6; i++) {
|
||||||
|
digitbuffer[i] = 0x00;
|
||||||
|
}
|
||||||
|
wait(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint8_t i = 0; i< 3;i++) {
|
||||||
|
leddigitbuffer[i] = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
ports_init();
|
||||||
|
timer_init();
|
||||||
|
uart_init(UART_BAUD_SELECT(19200,F_CPU));
|
||||||
|
memset(data_in, 0, BUFSIZE);
|
||||||
|
|
||||||
|
|
||||||
|
demo_display();
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
|
||||||
|
work_uart();
|
||||||
|
|
||||||
|
if(syscounter >= 100) {
|
||||||
|
uart_putc('a'); // send a to receive values
|
||||||
|
|
||||||
|
print_sevenseg(0, power_gen);
|
||||||
|
print_sevenseg(1, power_load);
|
||||||
|
|
||||||
|
print_bar(LEDS_GEN, current_in, CURRENT_MAX);
|
||||||
|
print_bar(LEDS_LOAD, current_out, CURRENT_MAX);
|
||||||
|
|
||||||
|
print_bar_bottom(current_in, current_out, 10000);
|
||||||
|
|
||||||
|
syscounter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// system timer
|
||||||
|
SIGNAL(TIMER1_COMPA_vect) {
|
||||||
|
syscounter++;
|
||||||
|
|
||||||
|
// output to sevensegment and leds
|
||||||
|
// make this here to reduce display flicker
|
||||||
|
digit++;
|
||||||
|
if(digit >5) digit = 0;
|
||||||
|
leddigit++;
|
||||||
|
if(leddigit >3) leddigit = 0;
|
||||||
|
|
||||||
|
SEVENSEG_PORT = digitbuffer[digit];
|
||||||
|
SEVENSEGDIG_PORT = _BV(digit+DIG0);
|
||||||
|
|
||||||
|
LED_PORT = leddigitbuffer[leddigit];
|
||||||
|
LEDDIG_PORT = _BV(leddigit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef _main_h
|
||||||
|
#define _main_h
|
||||||
|
|
||||||
|
#define SEVENSEG_PORT PORTA
|
||||||
|
#define SEVENSEG_DDR DDRA
|
||||||
|
|
||||||
|
#define LED_PORT PORTC
|
||||||
|
#define LED_DDR DDRC
|
||||||
|
|
||||||
|
#define DIG0 PD2
|
||||||
|
#define DIG1 PD3
|
||||||
|
#define DIG2 PD4
|
||||||
|
#define DIG3 PD5
|
||||||
|
#define DIG4 PD6
|
||||||
|
#define DIG5 PD7
|
||||||
|
#define LEDS_MID1 PB0
|
||||||
|
#define LEDS_MID2 PB1
|
||||||
|
#define LEDS_LOAD PB2
|
||||||
|
#define LEDS_GEN PB3
|
||||||
|
|
||||||
|
#define SEVENSEGDIG_PORT PORTD
|
||||||
|
#define SEVENSEGDIG_DDR DDRD
|
||||||
|
|
||||||
|
#define LEDDIG_PORT PORTB
|
||||||
|
#define LEDDIG_DDR DDRB
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,479 @@
|
||||||
|
/*************************************************************************
|
||||||
|
Title: Interrupt UART library with receive/transmit circular buffers
|
||||||
|
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
|
||||||
|
File: $Id: uart.c,v 1.10 2013/06/02 07:27:04 peter Exp $
|
||||||
|
Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher
|
||||||
|
Hardware: any AVR with built-in UART,
|
||||||
|
License: GNU General Public License
|
||||||
|
|
||||||
|
DESCRIPTION:
|
||||||
|
An interrupt is generated when the UART has finished transmitting or
|
||||||
|
receiving a byte. The interrupt handling routines use circular buffers
|
||||||
|
for buffering received and transmitted data.
|
||||||
|
|
||||||
|
The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE variables define
|
||||||
|
the buffer size in bytes. Note that these variables must be a
|
||||||
|
power of 2.
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
Refere to the header file uart.h for a description of the routines.
|
||||||
|
See also example test_uart.c.
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
Based on Atmel Application Note AVR306
|
||||||
|
|
||||||
|
LICENSE:
|
||||||
|
Copyright (C) 2006 Peter Fleury
|
||||||
|
|
||||||
|
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, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
*************************************************************************/
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* constants and macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* size of RX/TX buffers */
|
||||||
|
#define UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1)
|
||||||
|
#define UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1)
|
||||||
|
|
||||||
|
#if ( UART_RX_BUFFER_SIZE & UART_RX_BUFFER_MASK )
|
||||||
|
#error RX buffer size is not a power of 2
|
||||||
|
#endif
|
||||||
|
#if ( UART_TX_BUFFER_SIZE & UART_TX_BUFFER_MASK )
|
||||||
|
#error TX buffer size is not a power of 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__AVR_AT90S2313__) \
|
||||||
|
|| defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \
|
||||||
|
|| defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \
|
||||||
|
|| defined(__AVR_ATmega103__)
|
||||||
|
/* old AVR classic or ATmega103 with one UART */
|
||||||
|
#define AT90_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS USR
|
||||||
|
#define UART0_CONTROL UCR
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__)
|
||||||
|
/* old AVR classic with one UART */
|
||||||
|
#define AT90_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \
|
||||||
|
|| defined(__AVR_ATmega323__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RXC_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__)
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega163__)
|
||||||
|
/* ATmega163 with one UART */
|
||||||
|
#define ATMEGA_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega162__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RXC_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RXC_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega161__)
|
||||||
|
/* ATmega with UART */
|
||||||
|
#error "AVR ATmega161 currently not supported by this libaray !"
|
||||||
|
#elif defined(__AVR_ATmega169__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \
|
||||||
|
|| defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATtiny2313__)
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega329__) || \
|
||||||
|
defined(__AVR_ATmega649__) || \
|
||||||
|
defined(__AVR_ATmega325__) || \
|
||||||
|
defined(__AVR_ATmega645__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega644__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#else
|
||||||
|
#error "no UART definition for MCU available"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* module global variables
|
||||||
|
*/
|
||||||
|
static volatile unsigned char UART_TxBuf[UART_TX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART_RxBuf[UART_RX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART_TxHead;
|
||||||
|
static volatile unsigned char UART_TxTail;
|
||||||
|
static volatile unsigned char UART_RxHead;
|
||||||
|
static volatile unsigned char UART_RxTail;
|
||||||
|
static volatile unsigned char UART_LastRxError;
|
||||||
|
|
||||||
|
#if defined( ATMEGA_USART1 )
|
||||||
|
static volatile unsigned char UART1_TxBuf[UART_TX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART1_RxBuf[UART_RX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART1_TxHead;
|
||||||
|
static volatile unsigned char UART1_TxTail;
|
||||||
|
static volatile unsigned char UART1_RxHead;
|
||||||
|
static volatile unsigned char UART1_RxTail;
|
||||||
|
static volatile unsigned char UART1_LastRxError;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ISR (UART0_RECEIVE_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART Receive Complete interrupt
|
||||||
|
Purpose: called when the UART has received a character
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
unsigned char data;
|
||||||
|
unsigned char usr;
|
||||||
|
unsigned char lastRxError;
|
||||||
|
|
||||||
|
|
||||||
|
/* read UART status register and UART data register */
|
||||||
|
usr = UART0_STATUS;
|
||||||
|
data = UART0_DATA;
|
||||||
|
|
||||||
|
/* */
|
||||||
|
#if defined( AT90_UART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#elif defined( ATMEGA_USART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#elif defined( ATMEGA_USART0 )
|
||||||
|
lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) );
|
||||||
|
#elif defined ( ATMEGA_UART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* calculate buffer index */
|
||||||
|
tmphead = ( UART_RxHead + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
|
||||||
|
if ( tmphead == UART_RxTail ) {
|
||||||
|
/* error: receive buffer overflow */
|
||||||
|
lastRxError = UART_BUFFER_OVERFLOW >> 8;
|
||||||
|
}else{
|
||||||
|
/* store new index */
|
||||||
|
UART_RxHead = tmphead;
|
||||||
|
/* store received data in buffer */
|
||||||
|
UART_RxBuf[tmphead] = data;
|
||||||
|
}
|
||||||
|
UART_LastRxError |= lastRxError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ISR (UART0_TRANSMIT_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART Data Register Empty interrupt
|
||||||
|
Purpose: called when the UART is ready to transmit the next byte
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART_TxHead != UART_TxTail) {
|
||||||
|
/* calculate and store new buffer index */
|
||||||
|
tmptail = (UART_TxTail + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
UART_TxTail = tmptail;
|
||||||
|
/* get one byte from buffer and write it to UART */
|
||||||
|
UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */
|
||||||
|
}else{
|
||||||
|
/* tx buffer empty, disable UDRE interrupt */
|
||||||
|
UART0_CONTROL &= ~_BV(UART0_UDRIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_init()
|
||||||
|
Purpose: initialize UART and set baudrate
|
||||||
|
Input: baudrate using macro UART_BAUD_SELECT()
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_init(unsigned int baudrate)
|
||||||
|
{
|
||||||
|
UART_TxHead = 0;
|
||||||
|
UART_TxTail = 0;
|
||||||
|
UART_RxHead = 0;
|
||||||
|
UART_RxTail = 0;
|
||||||
|
|
||||||
|
#if defined( AT90_UART )
|
||||||
|
/* set baud rate */
|
||||||
|
UBRR = (unsigned char)baudrate;
|
||||||
|
|
||||||
|
/* enable UART receiver and transmmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN);
|
||||||
|
|
||||||
|
#elif defined (ATMEGA_USART)
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRRH = (unsigned char)(baudrate>>8);
|
||||||
|
UBRRL = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|(1<<RXEN)|(1<<TXEN);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL
|
||||||
|
UCSRC = (1<<URSEL)|(3<<UCSZ0);
|
||||||
|
#else
|
||||||
|
UCSRC = (3<<UCSZ0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined (ATMEGA_USART0 )
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X0); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRR0H = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR0L = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE0)|(1<<RXEN0)|(1<<TXEN0);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL0
|
||||||
|
UCSR0C = (1<<URSEL0)|(3<<UCSZ00);
|
||||||
|
#else
|
||||||
|
UCSR0C = (3<<UCSZ00);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( ATMEGA_UART )
|
||||||
|
/* set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRRHI = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable UART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|(1<<RXEN)|(1<<TXEN);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}/* uart_init */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_getc()
|
||||||
|
Purpose: return byte from ringbuffer
|
||||||
|
Returns: lower byte: received byte from ringbuffer
|
||||||
|
higher byte: last receive error
|
||||||
|
**************************************************************************/
|
||||||
|
unsigned int uart_getc(void)
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
unsigned char data;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART_RxHead == UART_RxTail ) {
|
||||||
|
return UART_NO_DATA; /* no data available */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate /store buffer index */
|
||||||
|
tmptail = (UART_RxTail + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
UART_RxTail = tmptail;
|
||||||
|
|
||||||
|
/* get data from receive buffer */
|
||||||
|
data = UART_RxBuf[tmptail];
|
||||||
|
|
||||||
|
data = (UART_LastRxError << 8) + data;
|
||||||
|
UART_LastRxError = 0;
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}/* uart_getc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_putc()
|
||||||
|
Purpose: write byte to ringbuffer for transmitting via UART
|
||||||
|
Input: byte to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_putc(unsigned char data)
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
|
||||||
|
|
||||||
|
tmphead = (UART_TxHead + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
|
||||||
|
while ( tmphead == UART_TxTail ){
|
||||||
|
;/* wait for free space in buffer */
|
||||||
|
}
|
||||||
|
|
||||||
|
UART_TxBuf[tmphead] = data;
|
||||||
|
UART_TxHead = tmphead;
|
||||||
|
|
||||||
|
/* enable UDRE interrupt */
|
||||||
|
UART0_CONTROL |= _BV(UART0_UDRIE);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}/* uart_putc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_puts()
|
||||||
|
Purpose: transmit string to UART
|
||||||
|
Input: string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_puts(const char *s )
|
||||||
|
{
|
||||||
|
while (*s)
|
||||||
|
uart_putc(*s++);
|
||||||
|
|
||||||
|
}/* uart_puts */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_puts_p()
|
||||||
|
Purpose: transmit string from program memory to UART
|
||||||
|
Input: program memory string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_puts_p(const char *progmem_s )
|
||||||
|
{
|
||||||
|
register char c;
|
||||||
|
|
||||||
|
while ( (c = pgm_read_byte(progmem_s++)) )
|
||||||
|
uart_putc(c);
|
||||||
|
|
||||||
|
}/* uart_puts_p */
|
||||||
|
|
|
@ -0,0 +1,180 @@
|
||||||
|
#ifndef UART_H
|
||||||
|
#define UART_H
|
||||||
|
/************************************************************************
|
||||||
|
Title: Interrupt UART library with receive/transmit circular buffers
|
||||||
|
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
|
||||||
|
File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $
|
||||||
|
Software: AVR-GCC 4.1, AVR Libc 1.4
|
||||||
|
Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz
|
||||||
|
License: GNU General Public License
|
||||||
|
Usage: see Doxygen manual
|
||||||
|
|
||||||
|
LICENSE:
|
||||||
|
Copyright (C) 2006 Peter Fleury
|
||||||
|
|
||||||
|
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, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup pfleury_uart UART Library
|
||||||
|
* @code #include <uart.h> @endcode
|
||||||
|
*
|
||||||
|
* @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers.
|
||||||
|
*
|
||||||
|
* This library can be used to transmit and receive data through the built in UART.
|
||||||
|
*
|
||||||
|
* An interrupt is generated when the UART has finished transmitting or
|
||||||
|
* receiving a byte. The interrupt handling routines use circular buffers
|
||||||
|
* for buffering received and transmitted data.
|
||||||
|
*
|
||||||
|
* The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE constants define
|
||||||
|
* the size of the circular buffers in bytes. Note that these constants must be a power of 2.
|
||||||
|
* You may need to adapt this constants to your target and your application by adding
|
||||||
|
* CDEFS += -DUART_RX_BUFFER_SIZE=nn -DUART_RX_BUFFER_SIZE=nn to your Makefile.
|
||||||
|
*
|
||||||
|
* @note Based on Atmel Application Note AVR306
|
||||||
|
* @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**@{*/
|
||||||
|
|
||||||
|
|
||||||
|
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304
|
||||||
|
#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** constants and macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @brief UART Baudrate Expression
|
||||||
|
* @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
||||||
|
* @param baudrate baudrate in bps, e.g. 1200, 2400, 9600
|
||||||
|
*/
|
||||||
|
#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL)
|
||||||
|
|
||||||
|
/** @brief UART Baudrate Expression for ATmega double speed mode
|
||||||
|
* @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
||||||
|
* @param baudrate baudrate in bps, e.g. 1200, 2400, 9600
|
||||||
|
*/
|
||||||
|
#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000)
|
||||||
|
|
||||||
|
|
||||||
|
/** Size of the circular receive buffer, must be power of 2 */
|
||||||
|
#ifndef UART_RX_BUFFER_SIZE
|
||||||
|
#define UART_RX_BUFFER_SIZE 32
|
||||||
|
#endif
|
||||||
|
/** Size of the circular transmit buffer, must be power of 2 */
|
||||||
|
#ifndef UART_TX_BUFFER_SIZE
|
||||||
|
#define UART_TX_BUFFER_SIZE 32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* test if the size of the circular buffers fits into SRAM */
|
||||||
|
#if ( (UART_RX_BUFFER_SIZE+UART_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) )
|
||||||
|
#error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** high byte error return code of uart_getc()
|
||||||
|
*/
|
||||||
|
#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */
|
||||||
|
#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */
|
||||||
|
#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */
|
||||||
|
#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */
|
||||||
|
#define UART_NO_DATA 0x0100 /* no receive data available */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** function prototypes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Initialize UART and set baudrate
|
||||||
|
@param baudrate Specify baudrate using macro UART_BAUD_SELECT()
|
||||||
|
@return none
|
||||||
|
*/
|
||||||
|
extern void uart_init(unsigned int baudrate);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get received byte from ringbuffer
|
||||||
|
*
|
||||||
|
* Returns in the lower byte the received character and in the
|
||||||
|
* higher byte the last receive error.
|
||||||
|
* UART_NO_DATA is returned when no data is available.
|
||||||
|
*
|
||||||
|
* @param void
|
||||||
|
* @return lower byte: received byte from ringbuffer
|
||||||
|
* @return higher byte: last receive status
|
||||||
|
* - \b 0 successfully received data from UART
|
||||||
|
* - \b UART_NO_DATA
|
||||||
|
* <br>no receive data available
|
||||||
|
* - \b UART_BUFFER_OVERFLOW
|
||||||
|
* <br>Receive ringbuffer overflow.
|
||||||
|
* We are not reading the receive buffer fast enough,
|
||||||
|
* one or more received character have been dropped
|
||||||
|
* - \b UART_OVERRUN_ERROR
|
||||||
|
* <br>Overrun condition by UART.
|
||||||
|
* A character already present in the UART UDR register was
|
||||||
|
* not read by the interrupt handler before the next character arrived,
|
||||||
|
* one or more received characters have been dropped.
|
||||||
|
* - \b UART_FRAME_ERROR
|
||||||
|
* <br>Framing Error by UART
|
||||||
|
*/
|
||||||
|
extern unsigned int uart_getc(void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put byte to ringbuffer for transmitting via UART
|
||||||
|
* @param data byte to be transmitted
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
extern void uart_putc(unsigned char data);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put string to ringbuffer for transmitting via UART
|
||||||
|
*
|
||||||
|
* The string is buffered by the uart library in a circular buffer
|
||||||
|
* and one character at a time is transmitted to the UART using interrupts.
|
||||||
|
* Blocks if it can not write the whole string into the circular buffer.
|
||||||
|
*
|
||||||
|
* @param s string to be transmitted
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
extern void uart_puts(const char *s );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put string from program memory to ringbuffer for transmitting via UART.
|
||||||
|
*
|
||||||
|
* The string is buffered by the uart library in a circular buffer
|
||||||
|
* and one character at a time is transmitted to the UART using interrupts.
|
||||||
|
* Blocks if it can not write the whole string into the circular buffer.
|
||||||
|
*
|
||||||
|
* @param s program memory string to be transmitted
|
||||||
|
* @return none
|
||||||
|
* @see uart_puts_P
|
||||||
|
*/
|
||||||
|
extern void uart_puts_p(const char *s );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Macro to automatically put a string constant into program memory
|
||||||
|
*/
|
||||||
|
#define uart_puts_P(__s) uart_puts_p(PSTR(__s))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // UART_H
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
void wait(uint8_t count) {
|
||||||
|
uint8_t i;
|
||||||
|
if(count == 0) count = 100;
|
||||||
|
for(i=0;i<count;i++) {
|
||||||
|
_delay_ms(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_voltage(uint16_t x) {
|
||||||
|
uart_putc(48 + (x / 10000));
|
||||||
|
uart_putc(48 + (x % 10000 /1000));
|
||||||
|
uart_putc('.');
|
||||||
|
uart_putc(48 + (x % 1000 / 100 ));
|
||||||
|
//uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
//uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_int16(int16_t x) {
|
||||||
|
if(x <0) uart_putc('-');
|
||||||
|
uart_putc(48 + (x / 10000));
|
||||||
|
uart_putc(48 + (x % 10000 /1000));
|
||||||
|
uart_putc(48 + (x % 1000 / 100 ));
|
||||||
|
uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_uint16(uint16_t x) {
|
||||||
|
uart_putc(48 + (x / 10000));
|
||||||
|
uart_putc(48 + (x % 10000 /1000));
|
||||||
|
uart_putc(48 + (x % 1000 / 100 ));
|
||||||
|
uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef _utils_h
|
||||||
|
#define _utils_h
|
||||||
|
|
||||||
|
extern void wait(uint8_t count);
|
||||||
|
extern void uart_print_voltage(uint16_t);
|
||||||
|
extern void uart_print_int16(int16_t);
|
||||||
|
extern void uart_print_uint16(uint16_t);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,942 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE eagle SYSTEM "eagle.dtd">
|
||||||
|
<eagle version="6.4">
|
||||||
|
<drawing>
|
||||||
|
<settings>
|
||||||
|
<setting alwaysvectorfont="no"/>
|
||||||
|
<setting verticaltext="up"/>
|
||||||
|
</settings>
|
||||||
|
<grid distance="0.025" unitdist="inch" unit="inch" style="lines" multiple="1" display="no" altdistance="0.025" altunitdist="inch" altunit="inch"/>
|
||||||
|
<layers>
|
||||||
|
<layer number="1" name="Top" color="4" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="2" name="Route2" color="1" fill="3" visible="no" active="no"/>
|
||||||
|
<layer number="3" name="Route3" color="4" fill="3" visible="no" active="no"/>
|
||||||
|
<layer number="4" name="Route4" color="1" fill="4" visible="no" active="no"/>
|
||||||
|
<layer number="5" name="Route5" color="4" fill="4" visible="no" active="no"/>
|
||||||
|
<layer number="6" name="Route6" color="1" fill="8" visible="no" active="no"/>
|
||||||
|
<layer number="7" name="Route7" color="4" fill="8" visible="no" active="no"/>
|
||||||
|
<layer number="8" name="Route8" color="1" fill="2" visible="no" active="no"/>
|
||||||
|
<layer number="9" name="Route9" color="4" fill="2" visible="no" active="no"/>
|
||||||
|
<layer number="10" name="Route10" color="1" fill="7" visible="no" active="no"/>
|
||||||
|
<layer number="11" name="Route11" color="4" fill="7" visible="no" active="no"/>
|
||||||
|
<layer number="12" name="Route12" color="1" fill="5" visible="no" active="no"/>
|
||||||
|
<layer number="13" name="Route13" color="4" fill="5" visible="no" active="no"/>
|
||||||
|
<layer number="14" name="Route14" color="1" fill="6" visible="no" active="no"/>
|
||||||
|
<layer number="15" name="Route15" color="4" fill="6" visible="no" active="no"/>
|
||||||
|
<layer number="16" name="Bottom" color="1" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="17" name="Pads" color="2" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="18" name="Vias" color="2" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="19" name="Unrouted" color="6" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="20" name="Dimension" color="15" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="21" name="tPlace" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="22" name="bPlace" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="23" name="tOrigins" color="15" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="24" name="bOrigins" color="15" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="25" name="tNames" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="26" name="bNames" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="27" name="tValues" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="28" name="bValues" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="29" name="tStop" color="7" fill="3" visible="no" active="yes"/>
|
||||||
|
<layer number="30" name="bStop" color="7" fill="6" visible="no" active="yes"/>
|
||||||
|
<layer number="31" name="tCream" color="7" fill="4" visible="no" active="yes"/>
|
||||||
|
<layer number="32" name="bCream" color="7" fill="5" visible="no" active="yes"/>
|
||||||
|
<layer number="33" name="tFinish" color="6" fill="3" visible="no" active="yes"/>
|
||||||
|
<layer number="34" name="bFinish" color="6" fill="6" visible="no" active="yes"/>
|
||||||
|
<layer number="35" name="tGlue" color="7" fill="4" visible="no" active="yes"/>
|
||||||
|
<layer number="36" name="bGlue" color="7" fill="5" visible="no" active="yes"/>
|
||||||
|
<layer number="37" name="tTest" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="38" name="bTest" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="39" name="tKeepout" color="4" fill="11" visible="no" active="yes"/>
|
||||||
|
<layer number="40" name="bKeepout" color="1" fill="11" visible="no" active="yes"/>
|
||||||
|
<layer number="41" name="tRestrict" color="4" fill="10" visible="no" active="yes"/>
|
||||||
|
<layer number="42" name="bRestrict" color="1" fill="10" visible="no" active="yes"/>
|
||||||
|
<layer number="43" name="vRestrict" color="2" fill="10" visible="no" active="yes"/>
|
||||||
|
<layer number="44" name="Drills" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="45" name="Holes" color="7" fill="1" visible="yes" active="yes"/>
|
||||||
|
<layer number="46" name="Milling" color="3" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="47" name="Measures" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="48" name="Document" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="49" name="Reference" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="50" name="dxf" color="7" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="51" name="tDocu" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="52" name="bDocu" color="7" fill="1" visible="no" active="yes"/>
|
||||||
|
<layer number="91" name="Nets" color="2" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="92" name="Busses" color="1" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="93" name="Pins" color="2" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="94" name="Symbols" color="4" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="95" name="Names" color="7" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="96" name="Values" color="7" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="97" name="Info" color="7" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="98" name="Guide" color="6" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="250" name="Descript" color="3" fill="1" visible="no" active="no"/>
|
||||||
|
<layer number="251" name="SMDround" color="12" fill="11" visible="no" active="no"/>
|
||||||
|
</layers>
|
||||||
|
<board>
|
||||||
|
<plain>
|
||||||
|
<wire x1="17.145" y1="0" x2="69.83" y2="0" width="0" layer="20"/>
|
||||||
|
<wire x1="69.83" y1="0" x2="69.83" y2="71.425" width="0" layer="20"/>
|
||||||
|
<wire x1="69.83" y1="71.425" x2="17.145" y2="71.425" width="0" layer="20"/>
|
||||||
|
<wire x1="17.145" y1="71.425" x2="17.145" y2="0" width="0" layer="20"/>
|
||||||
|
<text x="67.31" y="62.23" size="1.778" layer="16" font="vector" rot="MR0">db_servo rev 05/14</text>
|
||||||
|
<text x="64.77" y="58.42" size="1.778" layer="16" font="vector" rot="MR0">Lucas Pleß</text>
|
||||||
|
<hole x="20.32" y="3.175" drill="0.8"/>
|
||||||
|
<hole x="20.32" y="68.58" drill="0.8"/>
|
||||||
|
<hole x="66.675" y="68.58" drill="0.8"/>
|
||||||
|
<hole x="66.675" y="3.175" drill="0.8"/>
|
||||||
|
</plain>
|
||||||
|
<libraries>
|
||||||
|
<library name="rcl">
|
||||||
|
<packages>
|
||||||
|
<package name="0207/10">
|
||||||
|
<description><b>RESISTOR</b><p>
|
||||||
|
type 0207, grid 10 mm</description>
|
||||||
|
<wire x1="5.08" y1="0" x2="4.064" y2="0" width="0.6096" layer="51"/>
|
||||||
|
<wire x1="-5.08" y1="0" x2="-4.064" y2="0" width="0.6096" layer="51"/>
|
||||||
|
<wire x1="-3.175" y1="0.889" x2="-2.921" y2="1.143" width="0.1524" layer="21" curve="-90"/>
|
||||||
|
<wire x1="-3.175" y1="-0.889" x2="-2.921" y2="-1.143" width="0.1524" layer="21" curve="90"/>
|
||||||
|
<wire x1="2.921" y1="-1.143" x2="3.175" y2="-0.889" width="0.1524" layer="21" curve="90"/>
|
||||||
|
<wire x1="2.921" y1="1.143" x2="3.175" y2="0.889" width="0.1524" layer="21" curve="-90"/>
|
||||||
|
<wire x1="-3.175" y1="-0.889" x2="-3.175" y2="0.889" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.921" y1="1.143" x2="-2.54" y2="1.143" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.413" y1="1.016" x2="-2.54" y2="1.143" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.921" y1="-1.143" x2="-2.54" y2="-1.143" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.413" y1="-1.016" x2="-2.54" y2="-1.143" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.413" y1="1.016" x2="2.54" y2="1.143" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.413" y1="1.016" x2="-2.413" y2="1.016" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.413" y1="-1.016" x2="2.54" y2="-1.143" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.413" y1="-1.016" x2="-2.413" y2="-1.016" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.921" y1="1.143" x2="2.54" y2="1.143" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.921" y1="-1.143" x2="2.54" y2="-1.143" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="3.175" y1="-0.889" x2="3.175" y2="0.889" width="0.1524" layer="21"/>
|
||||||
|
<pad name="1" x="-5.08" y="0" drill="0.8128" shape="octagon"/>
|
||||||
|
<pad name="2" x="5.08" y="0" drill="0.8128" shape="octagon"/>
|
||||||
|
<text x="-3.048" y="1.524" size="1.27" layer="25" ratio="10">>NAME</text>
|
||||||
|
<text x="-2.2606" y="-0.635" size="1.27" layer="27" ratio="10">>VALUE</text>
|
||||||
|
<rectangle x1="3.175" y1="-0.3048" x2="4.0386" y2="0.3048" layer="21"/>
|
||||||
|
<rectangle x1="-4.0386" y1="-0.3048" x2="-3.175" y2="0.3048" layer="21"/>
|
||||||
|
</package>
|
||||||
|
<package name="C0603">
|
||||||
|
<description><b>CAPACITOR</b></description>
|
||||||
|
<wire x1="-1.473" y1="0.983" x2="1.473" y2="0.983" width="0.0508" layer="39"/>
|
||||||
|
<wire x1="1.473" y1="0.983" x2="1.473" y2="-0.983" width="0.0508" layer="39"/>
|
||||||
|
<wire x1="1.473" y1="-0.983" x2="-1.473" y2="-0.983" width="0.0508" layer="39"/>
|
||||||
|
<wire x1="-1.473" y1="-0.983" x2="-1.473" y2="0.983" width="0.0508" layer="39"/>
|
||||||
|
<wire x1="-0.356" y1="0.432" x2="0.356" y2="0.432" width="0.1016" layer="51"/>
|
||||||
|
<wire x1="-0.356" y1="-0.419" x2="0.356" y2="-0.419" width="0.1016" layer="51"/>
|
||||||
|
<smd name="1" x="-0.85" y="0" dx="1.1" dy="1" layer="1"/>
|
||||||
|
<smd name="2" x="0.85" y="0" dx="1.1" dy="1" layer="1"/>
|
||||||
|
<text x="-0.635" y="0.635" size="1.27" layer="25">>NAME</text>
|
||||||
|
<text x="-0.635" y="-1.905" size="1.27" layer="27">>VALUE</text>
|
||||||
|
<rectangle x1="-0.8382" y1="-0.4699" x2="-0.3381" y2="0.4801" layer="51"/>
|
||||||
|
<rectangle x1="0.3302" y1="-0.4699" x2="0.8303" y2="0.4801" layer="51"/>
|
||||||
|
<rectangle x1="-0.1999" y1="-0.3" x2="0.1999" y2="0.3" layer="35"/>
|
||||||
|
</package>
|
||||||
|
<package name="E2-4">
|
||||||
|
<description><b>ELECTROLYTIC CAPACITOR</b><p>
|
||||||
|
grid 2 mm, diameter 4 mm</description>
|
||||||
|
<wire x1="-1.524" y1="0" x2="-0.762" y2="0" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="-0.762" y1="0" x2="-0.762" y2="-1.016" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="-0.762" y1="-1.016" x2="-0.254" y2="-1.016" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="-0.254" y1="-1.016" x2="-0.254" y2="1.016" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="-0.254" y1="1.016" x2="-0.762" y2="1.016" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="-0.762" y1="1.016" x2="-0.762" y2="0" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="0.635" y1="0" x2="1.524" y2="0" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="-0.762" y1="1.524" x2="-0.254" y2="1.524" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-0.508" y1="1.27" x2="-0.508" y2="1.778" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="0.381" y1="1.524" x2="0.889" y2="1.524" width="0.1524" layer="21"/>
|
||||||
|
<circle x="0" y="0" radius="2.159" width="0.1524" layer="21"/>
|
||||||
|
<pad name="-" x="1.016" y="0" drill="0.8128" diameter="1.27" shape="octagon"/>
|
||||||
|
<pad name="+" x="-1.016" y="0" drill="0.8128" diameter="1.27"/>
|
||||||
|
<text x="2.159" y="0.889" size="1.27" layer="25" ratio="10">>NAME</text>
|
||||||
|
<text x="2.159" y="-2.159" size="1.27" layer="27" ratio="10">>VALUE</text>
|
||||||
|
<rectangle x1="0.254" y1="-1.016" x2="0.762" y2="1.016" layer="51"/>
|
||||||
|
</package>
|
||||||
|
<package name="E3,5-8">
|
||||||
|
<description><b>ELECTROLYTIC CAPACITOR</b><p>
|
||||||
|
grid 3.5 mm, diameter 8 mm</description>
|
||||||
|
<wire x1="-3.429" y1="1.143" x2="-2.667" y2="1.143" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-3.048" y1="0.762" x2="-3.048" y2="1.524" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-1.651" y1="0" x2="-0.762" y2="0" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="-0.762" y1="0" x2="-0.762" y2="-1.27" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="-0.762" y1="-1.27" x2="-0.254" y2="-1.27" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="-0.254" y1="-1.27" x2="-0.254" y2="1.27" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="-0.254" y1="1.27" x2="-0.762" y2="1.27" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="-0.762" y1="1.27" x2="-0.762" y2="0" width="0.1524" layer="51"/>
|
||||||
|
<wire x1="0.635" y1="0" x2="1.651" y2="0" width="0.1524" layer="51"/>
|
||||||
|
<circle x="0" y="0" radius="4.064" width="0.1524" layer="21"/>
|
||||||
|
<pad name="-" x="1.778" y="0" drill="0.8128" diameter="1.6002" shape="octagon"/>
|
||||||
|
<pad name="+" x="-1.778" y="0" drill="0.8128" diameter="1.6002"/>
|
||||||
|
<text x="3.302" y="2.794" size="1.27" layer="25" ratio="10">>NAME</text>
|
||||||
|
<text x="-2.286" y="-3.048" size="1.27" layer="27" ratio="10">>VALUE</text>
|
||||||
|
<rectangle x1="0.254" y1="-1.27" x2="0.762" y2="1.27" layer="51"/>
|
||||||
|
</package>
|
||||||
|
</packages>
|
||||||
|
</library>
|
||||||
|
<library name="con-harting-ml">
|
||||||
|
<packages>
|
||||||
|
<package name="ML10">
|
||||||
|
<description><b>HARTING</b></description>
|
||||||
|
<wire x1="-8.89" y1="3.175" x2="8.89" y2="3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="8.89" y1="-3.175" x2="8.89" y2="3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-8.89" y1="3.175" x2="-8.89" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-10.16" y1="4.445" x2="-8.89" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="10.16" y1="-4.445" x2="5.461" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="10.16" y1="-4.445" x2="10.16" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-10.16" y1="4.445" x2="-10.16" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="8.89" y1="-3.175" x2="4.572" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-2.413" x2="-2.032" y2="-2.413" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-3.175" x2="-2.032" y2="-2.413" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-3.175" x2="-8.89" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-3.175" x2="-2.032" y2="-3.429" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-2.413" x2="2.032" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-3.175" x2="2.032" y2="-3.429" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="8.89" y1="4.445" x2="8.89" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="8.89" y1="4.699" x2="7.62" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="7.62" y1="4.445" x2="7.62" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="8.89" y1="4.445" x2="10.16" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="0.635" y1="4.699" x2="-0.635" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="0.635" y1="4.699" x2="0.635" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="0.635" y1="4.445" x2="7.62" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-0.635" y1="4.699" x2="-0.635" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-7.62" y1="4.699" x2="-8.89" y2="4.699" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-8.89" y1="4.699" x2="-8.89" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-7.62" y1="4.699" x2="-7.62" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-7.62" y1="4.445" x2="-0.635" y2="4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.159" y1="-4.445" x2="2.032" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-4.445" x2="-2.032" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="3.048" y1="-3.175" x2="3.048" y2="-3.429" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="3.048" y1="-3.175" x2="2.032" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="4.572" y1="-3.175" x2="4.572" y2="-3.429" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="4.572" y1="-3.175" x2="3.048" y2="-3.175" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="2.159" y1="-4.445" x2="2.54" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="5.08" y1="-3.937" x2="5.461" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="5.08" y1="-3.937" x2="4.572" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="3.048" y1="-3.429" x2="2.032" y2="-3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="2.032" y1="-3.429" x2="2.032" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="4.572" y1="-3.429" x2="9.144" y2="-3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="9.144" y1="-3.429" x2="9.144" y2="3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="9.144" y1="3.429" x2="-9.144" y2="3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="-9.144" y1="3.429" x2="-9.144" y2="-3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="-9.144" y1="-3.429" x2="-2.032" y2="-3.429" width="0.0508" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-3.429" x2="-2.032" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="3.048" y1="-3.429" x2="3.048" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="3.048" y1="-3.937" x2="2.54" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="4.572" y1="-3.429" x2="4.572" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="4.572" y1="-3.937" x2="3.048" y2="-3.937" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-2.032" y1="-4.445" x2="-4.445" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-4.445" y1="-4.318" x2="-4.445" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-4.445" y1="-4.318" x2="-5.715" y2="-4.318" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-5.715" y1="-4.445" x2="-5.715" y2="-4.318" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-5.715" y1="-4.445" x2="-10.16" y2="-4.445" width="0.1524" layer="21"/>
|
||||||
|
<pad name="1" x="-5.08" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="2" x="-5.08" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="3" x="-2.54" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="4" x="-2.54" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="5" x="0" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="6" x="0" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="7" x="2.54" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="8" x="2.54" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="9" x="5.08" y="-1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<pad name="10" x="5.08" y="1.27" drill="0.9144" shape="octagon"/>
|
||||||
|
<text x="-1.016" y="-4.064" size="1.27" layer="21" ratio="10">10</text>
|
||||||
|
<text x="-10.16" y="5.08" size="1.778" layer="25" ratio="10">>NAME</text>
|
||||||
|
<text x="0" y="5.08" size="1.778" layer="27" ratio="10">>VALUE</text>
|
||||||
|
<text x="-7.62" y="-1.905" size="1.27" layer="21" ratio="10">1</text>
|
||||||
|
<text x="-7.62" y="0.635" size="1.27" layer="21" ratio="10">2</text>
|
||||||
|
<rectangle x1="-2.794" y1="1.016" x2="-2.286" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="-5.334" y1="1.016" x2="-4.826" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="-0.254" y1="1.016" x2="0.254" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="4.826" y1="1.016" x2="5.334" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="2.286" y1="1.016" x2="2.794" y2="1.524" layer="51"/>
|
||||||
|
<rectangle x1="-2.794" y1="-1.524" x2="-2.286" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="-5.334" y1="-1.524" x2="-4.826" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="-0.254" y1="-1.524" x2="0.254" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="4.826" y1="-1.524" x2="5.334" y2="-1.016" layer="51"/>
|
||||||
|
<rectangle x1="2.286" y1="-1.524" x2="2.794" y2="-1.016" layer="51"/>
|
||||||
|
</package>
|
||||||
|
</packages>
|
||||||
|
</library>
|
||||||
|
<library name="con-tycoelectronics">
|
||||||
|
<description><b>Tyco Electronics Connector</b><p>
|
||||||
|
http://catalog.tycoelectronics.com<br>
|
||||||
|
<author>Created by librarian@cadsoft.de</author></description>
|
||||||
|
<packages>
|
||||||
|
<package name="RJ45-NO-SHIELD">
|
||||||
|
<description><b>RJ45 Low Profile</b> No Shield<p>
|
||||||
|
For all RJ45 N and Z Series Models<br>
|
||||||
|
Source: www.tycoelectronics.com .. ENG_DS_1654001_1099_RJ_L_0507.pdf</description>
|
||||||
|
<wire x1="-7.527" y1="10.819" x2="7.527" y2="10.819" width="0.2032" layer="21"/>
|
||||||
|
<wire x1="8.4455" y1="-5.5118" x2="-8.4455" y2="-5.5118" width="0.01" layer="20"/>
|
||||||
|
<wire x1="7.527" y1="-7.782" x2="-7.527" y2="-7.782" width="0.2032" layer="21"/>
|
||||||
|
<wire x1="-7.527" y1="-7.782" x2="-7.527" y2="10.819" width="0.2032" layer="21"/>
|
||||||
|
<wire x1="7.527" y1="10.819" x2="7.527" y2="-7.782" width="0.2032" layer="21"/>
|
||||||
|
<pad name="4" x="-0.635" y="8.89" drill="0.9" diameter="1.4"/>
|
||||||
|
<pad name="3" x="-1.905" y="6.35" drill="0.9" diameter="1.4"/>
|
||||||
|
<pad name="2" x="-3.175" y="8.89" drill="0.9" diameter="1.4"/>
|
||||||
|
<pad name="5" x="0.635" y="6.35" drill="0.9" diameter="1.4"/>
|
||||||
|
<pad name="1" x="-4.445" y="6.35" drill="0.9" diameter="1.4"/>
|
||||||
|
<pad name="6" x="1.905" y="8.89" drill="0.9" diameter="1.4"/>
|
||||||
|
<pad name="7" x="3.175" y="6.35" drill="0.9" diameter="1.4"/>
|
||||||
|
<pad name="8" x="4.445" y="8.89" drill="0.9" diameter="1.4"/>
|
||||||
|
<text x="-9.525" y="-0.635" size="1.778" layer="25" rot="R90">>NAME</text>
|
||||||
|
<text x="-5.715" y="2.54" size="1.778" layer="27">>VALUE</text>
|
||||||
|
<rectangle x1="7.6" y1="-5.485" x2="8.875" y2="-4.342" layer="21"/>
|
||||||
|
<rectangle x1="-8.875" y1="-5.485" x2="-7.625" y2="-4.342" layer="21"/>
|
||||||
|
<hole x="-5.715" y="0" drill="3.2512"/>
|
||||||
|
<hole x="5.715" y="0" drill="3.2512"/>
|
||||||
|
</package>
|
||||||
|
</packages>
|
||||||
|
</library>
|
||||||
|
<library name="maxim">
|
||||||
|
<description><b>Maxim Components</b><p>
|
||||||
|
|
||||||
|
<author>Created by librarian@cadsoft.de</author></description>
|
||||||
|
<packages>
|
||||||
|
<package name="DIL16">
|
||||||
|
<description><b>Dual In Line Package</b></description>
|
||||||
|
<wire x1="10.16" y1="2.921" x2="-10.16" y2="2.921" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-10.16" y1="-2.921" x2="10.16" y2="-2.921" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="10.16" y1="2.921" x2="10.16" y2="-2.921" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-10.16" y1="2.921" x2="-10.16" y2="1.016" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-10.16" y1="-2.921" x2="-10.16" y2="-1.016" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-10.16" y1="1.016" x2="-10.16" y2="-1.016" width="0.1524" layer="21" curve="-180"/>
|
||||||
|
<pad name="1" x="-8.89" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="2" x="-6.35" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="7" x="6.35" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="8" x="8.89" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="3" x="-3.81" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="4" x="-1.27" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="6" x="3.81" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="5" x="1.27" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="9" x="8.89" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="10" x="6.35" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="11" x="3.81" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="12" x="1.27" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="13" x="-1.27" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="14" x="-3.81" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="15" x="-6.35" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="16" x="-8.89" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<text x="-10.541" y="-2.921" size="1.27" layer="25" ratio="10" rot="R90">>NAME</text>
|
||||||
|
<text x="-7.493" y="-0.635" size="1.27" layer="27" ratio="10">>VALUE</text>
|
||||||
|
</package>
|
||||||
|
</packages>
|
||||||
|
</library>
|
||||||
|
<library name="linear">
|
||||||
|
<packages>
|
||||||
|
<package name="TO220V">
|
||||||
|
<description><b>TO 200 vertical</b></description>
|
||||||
|
<wire x1="5.08" y1="-1.143" x2="4.953" y2="-4.064" width="0.127" layer="21"/>
|
||||||
|
<wire x1="4.699" y1="-4.318" x2="4.953" y2="-4.064" width="0.127" layer="21"/>
|
||||||
|
<wire x1="4.699" y1="-4.318" x2="-4.699" y2="-4.318" width="0.127" layer="21"/>
|
||||||
|
<wire x1="-4.953" y1="-4.064" x2="-4.699" y2="-4.318" width="0.127" layer="21"/>
|
||||||
|
<wire x1="-4.953" y1="-4.064" x2="-5.08" y2="-1.143" width="0.127" layer="21"/>
|
||||||
|
<circle x="-4.4958" y="-3.7084" radius="0.254" width="0.127" layer="21"/>
|
||||||
|
<pad name="1" x="-2.54" y="-2.54" drill="1.016" shape="long" rot="R90"/>
|
||||||
|
<pad name="2" x="0" y="-2.54" drill="1.016" shape="long" rot="R90"/>
|
||||||
|
<pad name="3" x="2.54" y="-2.54" drill="1.016" shape="long" rot="R90"/>
|
||||||
|
<text x="-5.08" y="-6.0452" size="1.27" layer="25" ratio="10">>NAME</text>
|
||||||
|
<text x="-5.08" y="-7.62" size="1.27" layer="27" ratio="10">>VALUE</text>
|
||||||
|
<text x="-3.175" y="-3.175" size="1.27" layer="51" ratio="10">1</text>
|
||||||
|
<text x="-0.635" y="-3.175" size="1.27" layer="51" ratio="10">2</text>
|
||||||
|
<text x="1.905" y="-3.175" size="1.27" layer="51" ratio="10">3</text>
|
||||||
|
<rectangle x1="-5.334" y1="-0.762" x2="5.334" y2="0" layer="21"/>
|
||||||
|
<rectangle x1="-5.334" y1="-1.27" x2="-3.429" y2="-0.762" layer="21"/>
|
||||||
|
<rectangle x1="-1.651" y1="-1.27" x2="-0.889" y2="-0.762" layer="21"/>
|
||||||
|
<rectangle x1="-3.429" y1="-1.27" x2="-1.651" y2="-0.762" layer="51"/>
|
||||||
|
<rectangle x1="0.889" y1="-1.27" x2="1.651" y2="-0.762" layer="21"/>
|
||||||
|
<rectangle x1="3.429" y1="-1.27" x2="5.334" y2="-0.762" layer="21"/>
|
||||||
|
<rectangle x1="-0.889" y1="-1.27" x2="0.889" y2="-0.762" layer="51"/>
|
||||||
|
<rectangle x1="1.651" y1="-1.27" x2="3.429" y2="-0.762" layer="51"/>
|
||||||
|
</package>
|
||||||
|
</packages>
|
||||||
|
</library>
|
||||||
|
<library name="pinhead">
|
||||||
|
<description><b>Pin Header Connectors</b><p>
|
||||||
|
<author>Created by librarian@cadsoft.de</author></description>
|
||||||
|
<packages>
|
||||||
|
<package name="1X03">
|
||||||
|
<description><b>PIN HEADER</b></description>
|
||||||
|
<wire x1="-3.175" y1="1.27" x2="-1.905" y2="1.27" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-1.905" y1="1.27" x2="-1.27" y2="0.635" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-1.27" y1="0.635" x2="-1.27" y2="-0.635" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-1.27" y1="-0.635" x2="-1.905" y2="-1.27" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-1.27" y1="0.635" x2="-0.635" y2="1.27" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-0.635" y1="1.27" x2="0.635" y2="1.27" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="0.635" y1="1.27" x2="1.27" y2="0.635" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="1.27" y1="0.635" x2="1.27" y2="-0.635" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="1.27" y1="-0.635" x2="0.635" y2="-1.27" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="0.635" y1="-1.27" x2="-0.635" y2="-1.27" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-0.635" y1="-1.27" x2="-1.27" y2="-0.635" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-3.81" y1="0.635" x2="-3.81" y2="-0.635" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-3.175" y1="1.27" x2="-3.81" y2="0.635" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-3.81" y1="-0.635" x2="-3.175" y2="-1.27" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-1.905" y1="-1.27" x2="-3.175" y2="-1.27" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="1.27" y1="0.635" x2="1.905" y2="1.27" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="1.905" y1="1.27" x2="3.175" y2="1.27" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="3.175" y1="1.27" x2="3.81" y2="0.635" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="3.81" y1="0.635" x2="3.81" y2="-0.635" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="3.81" y1="-0.635" x2="3.175" y2="-1.27" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="3.175" y1="-1.27" x2="1.905" y2="-1.27" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="1.905" y1="-1.27" x2="1.27" y2="-0.635" width="0.1524" layer="21"/>
|
||||||
|
<pad name="1" x="-2.54" y="0" drill="1.016" shape="long" rot="R90"/>
|
||||||
|
<pad name="2" x="0" y="0" drill="1.016" shape="long" rot="R90"/>
|
||||||
|
<pad name="3" x="2.54" y="0" drill="1.016" shape="long" rot="R90"/>
|
||||||
|
<text x="-3.8862" y="1.8288" size="1.27" layer="25" ratio="10">>NAME</text>
|
||||||
|
<text x="-3.81" y="-3.175" size="1.27" layer="27">>VALUE</text>
|
||||||
|
<rectangle x1="-0.254" y1="-0.254" x2="0.254" y2="0.254" layer="51"/>
|
||||||
|
<rectangle x1="-2.794" y1="-0.254" x2="-2.286" y2="0.254" layer="51"/>
|
||||||
|
<rectangle x1="2.286" y1="-0.254" x2="2.794" y2="0.254" layer="51"/>
|
||||||
|
</package>
|
||||||
|
</packages>
|
||||||
|
</library>
|
||||||
|
<library name="atmel">
|
||||||
|
<description><b>AVR Devices</b><p>
|
||||||
|
Configurable logic, microcontrollers, nonvolatile memories<p>
|
||||||
|
Based on the following sources:<p>
|
||||||
|
<ul>
|
||||||
|
<li>www.atmel.com
|
||||||
|
<li>CD-ROM : Configurable Logic Microcontroller Nonvolatile Memory
|
||||||
|
<li>CadSoft download site, www.cadsoft.de or www.cadsoftusa.com , file at90smcu_v400.zip
|
||||||
|
<li>avr.lbr
|
||||||
|
</ul>
|
||||||
|
<author>Revised by librarian@cadsoft.de</author></description>
|
||||||
|
<packages>
|
||||||
|
<package name="DIL20">
|
||||||
|
<description><B>Dual In Line</B></description>
|
||||||
|
<wire x1="-13.208" y1="-0.635" x2="-13.208" y2="-2.794" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-13.208" y1="-0.635" x2="-13.208" y2="0.635" width="0.1524" layer="21" curve="180"/>
|
||||||
|
<wire x1="13.208" y1="-2.794" x2="13.208" y2="2.794" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="13.208" y1="-2.794" x2="-13.208" y2="-2.794" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-13.208" y1="2.794" x2="-13.208" y2="0.635" width="0.1524" layer="21"/>
|
||||||
|
<wire x1="-13.208" y1="2.794" x2="13.208" y2="2.794" width="0.1524" layer="21"/>
|
||||||
|
<pad name="1" x="-11.43" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="2" x="-8.89" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="3" x="-6.35" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="4" x="-3.81" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="5" x="-1.27" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="6" x="1.27" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="7" x="3.81" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="8" x="6.35" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="9" x="8.89" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="10" x="11.43" y="-3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="11" x="11.43" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="12" x="8.89" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="13" x="6.35" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="14" x="3.81" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="15" x="1.27" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="16" x="-1.27" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="17" x="-3.81" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="18" x="-6.35" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="19" x="-8.89" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<pad name="20" x="-11.43" y="3.81" drill="0.8128" shape="long" rot="R90"/>
|
||||||
|
<text x="-13.5128" y="-2.54" size="1.778" layer="25" ratio="10" rot="R90">>NAME</text>
|
||||||
|
<text x="-10.16" y="-0.762" size="1.778" layer="27" ratio="10">>VALUE</text>
|
||||||
|
</package>
|
||||||
|
</packages>
|
||||||
|
</library>
|
||||||
|
</libraries>
|
||||||
|
<attributes>
|
||||||
|
</attributes>
|
||||||
|
<variantdefs>
|
||||||
|
</variantdefs>
|
||||||
|
<classes>
|
||||||
|
<class number="0" name="default" width="0" drill="0">
|
||||||
|
</class>
|
||||||
|
</classes>
|
||||||
|
<designrules name="default *">
|
||||||
|
<description language="de"><b>EAGLE Design Rules</b>
|
||||||
|
<p>
|
||||||
|
Die Standard-Design-Rules sind so gewählt, dass sie für
|
||||||
|
die meisten Anwendungen passen. Sollte ihre Platine
|
||||||
|
besondere Anforderungen haben, treffen Sie die erforderlichen
|
||||||
|
Einstellungen hier und speichern die Design Rules unter
|
||||||
|
einem neuen Namen ab.</description>
|
||||||
|
<description language="en"><b>EAGLE Design Rules</b>
|
||||||
|
<p>
|
||||||
|
The default Design Rules have been set to cover
|
||||||
|
a wide range of applications. Your particular design
|
||||||
|
may have different requirements, so please make the
|
||||||
|
necessary adjustments and save your customized
|
||||||
|
design rules under a new name.</description>
|
||||||
|
<param name="layerSetup" value="(1*16)"/>
|
||||||
|
<param name="mtCopper" value="0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm 0.035mm"/>
|
||||||
|
<param name="mtIsolate" value="1.5mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm 0.15mm 0.2mm"/>
|
||||||
|
<param name="mdWireWire" value="8mil"/>
|
||||||
|
<param name="mdWirePad" value="8mil"/>
|
||||||
|
<param name="mdWireVia" value="8mil"/>
|
||||||
|
<param name="mdPadPad" value="8mil"/>
|
||||||
|
<param name="mdPadVia" value="8mil"/>
|
||||||
|
<param name="mdViaVia" value="8mil"/>
|
||||||
|
<param name="mdSmdPad" value="8mil"/>
|
||||||
|
<param name="mdSmdVia" value="8mil"/>
|
||||||
|
<param name="mdSmdSmd" value="8mil"/>
|
||||||
|
<param name="mdViaViaSameLayer" value="8mil"/>
|
||||||
|
<param name="mnLayersViaInSmd" value="2"/>
|
||||||
|
<param name="mdCopperDimension" value="0mil"/>
|
||||||
|
<param name="mdDrill" value="8mil"/>
|
||||||
|
<param name="mdSmdStop" value="0mil"/>
|
||||||
|
<param name="msWidth" value="10mil"/>
|
||||||
|
<param name="msDrill" value="24mil"/>
|
||||||
|
<param name="msMicroVia" value="9.99mm"/>
|
||||||
|
<param name="msBlindViaRatio" value="0.5"/>
|
||||||
|
<param name="rvPadTop" value="0.25"/>
|
||||||
|
<param name="rvPadInner" value="0.25"/>
|
||||||
|
<param name="rvPadBottom" value="0.25"/>
|
||||||
|
<param name="rvViaOuter" value="0.25"/>
|
||||||
|
<param name="rvViaInner" value="0.25"/>
|
||||||
|
<param name="rvMicroViaOuter" value="0.25"/>
|
||||||
|
<param name="rvMicroViaInner" value="0.25"/>
|
||||||
|
<param name="rlMinPadTop" value="10mil"/>
|
||||||
|
<param name="rlMaxPadTop" value="20mil"/>
|
||||||
|
<param name="rlMinPadInner" value="10mil"/>
|
||||||
|
<param name="rlMaxPadInner" value="20mil"/>
|
||||||
|
<param name="rlMinPadBottom" value="10mil"/>
|
||||||
|
<param name="rlMaxPadBottom" value="20mil"/>
|
||||||
|
<param name="rlMinViaOuter" value="8mil"/>
|
||||||
|
<param name="rlMaxViaOuter" value="20mil"/>
|
||||||
|
<param name="rlMinViaInner" value="8mil"/>
|
||||||
|
<param name="rlMaxViaInner" value="20mil"/>
|
||||||
|
<param name="rlMinMicroViaOuter" value="4mil"/>
|
||||||
|
<param name="rlMaxMicroViaOuter" value="20mil"/>
|
||||||
|
<param name="rlMinMicroViaInner" value="4mil"/>
|
||||||
|
<param name="rlMaxMicroViaInner" value="20mil"/>
|
||||||
|
<param name="psTop" value="-1"/>
|
||||||
|
<param name="psBottom" value="-1"/>
|
||||||
|
<param name="psFirst" value="-1"/>
|
||||||
|
<param name="psElongationLong" value="100"/>
|
||||||
|
<param name="psElongationOffset" value="100"/>
|
||||||
|
<param name="mvStopFrame" value="1"/>
|
||||||
|
<param name="mvCreamFrame" value="0"/>
|
||||||
|
<param name="mlMinStopFrame" value="4mil"/>
|
||||||
|
<param name="mlMaxStopFrame" value="4mil"/>
|
||||||
|
<param name="mlMinCreamFrame" value="0mil"/>
|
||||||
|
<param name="mlMaxCreamFrame" value="0mil"/>
|
||||||
|
<param name="mlViaStopLimit" value="0mil"/>
|
||||||
|
<param name="srRoundness" value="0"/>
|
||||||
|
<param name="srMinRoundness" value="0mil"/>
|
||||||
|
<param name="srMaxRoundness" value="0mil"/>
|
||||||
|
<param name="slThermalIsolate" value="10mil"/>
|
||||||
|
<param name="slThermalsForVias" value="0"/>
|
||||||
|
<param name="dpMaxLengthDifference" value="10mm"/>
|
||||||
|
<param name="dpGapFactor" value="2.5"/>
|
||||||
|
<param name="checkGrid" value="0"/>
|
||||||
|
<param name="checkAngle" value="0"/>
|
||||||
|
<param name="checkFont" value="1"/>
|
||||||
|
<param name="checkRestrict" value="1"/>
|
||||||
|
<param name="useDiameter" value="13"/>
|
||||||
|
<param name="maxErrors" value="50"/>
|
||||||
|
</designrules>
|
||||||
|
<autorouter>
|
||||||
|
<pass name="Default">
|
||||||
|
<param name="RoutingGrid" value="50mil"/>
|
||||||
|
<param name="tpViaShape" value="round"/>
|
||||||
|
<param name="PrefDir.1" value="0"/>
|
||||||
|
<param name="PrefDir.2" value="0"/>
|
||||||
|
<param name="PrefDir.3" value="0"/>
|
||||||
|
<param name="PrefDir.4" value="0"/>
|
||||||
|
<param name="PrefDir.5" value="0"/>
|
||||||
|
<param name="PrefDir.6" value="0"/>
|
||||||
|
<param name="PrefDir.7" value="0"/>
|
||||||
|
<param name="PrefDir.8" value="0"/>
|
||||||
|
<param name="PrefDir.9" value="0"/>
|
||||||
|
<param name="PrefDir.10" value="0"/>
|
||||||
|
<param name="PrefDir.11" value="0"/>
|
||||||
|
<param name="PrefDir.12" value="0"/>
|
||||||
|
<param name="PrefDir.13" value="0"/>
|
||||||
|
<param name="PrefDir.14" value="0"/>
|
||||||
|
<param name="PrefDir.15" value="0"/>
|
||||||
|
<param name="PrefDir.16" value="*"/>
|
||||||
|
<param name="cfVia" value="8"/>
|
||||||
|
<param name="cfNonPref" value="5"/>
|
||||||
|
<param name="cfChangeDir" value="2"/>
|
||||||
|
<param name="cfOrthStep" value="2"/>
|
||||||
|
<param name="cfDiagStep" value="3"/>
|
||||||
|
<param name="cfExtdStep" value="0"/>
|
||||||
|
<param name="cfBonusStep" value="1"/>
|
||||||
|
<param name="cfMalusStep" value="1"/>
|
||||||
|
<param name="cfPadImpact" value="4"/>
|
||||||
|
<param name="cfSmdImpact" value="4"/>
|
||||||
|
<param name="cfBusImpact" value="0"/>
|
||||||
|
<param name="cfHugging" value="3"/>
|
||||||
|
<param name="cfAvoid" value="4"/>
|
||||||
|
<param name="cfPolygon" value="10"/>
|
||||||
|
<param name="cfBase.1" value="0"/>
|
||||||
|
<param name="cfBase.2" value="1"/>
|
||||||
|
<param name="cfBase.3" value="1"/>
|
||||||
|
<param name="cfBase.4" value="1"/>
|
||||||
|
<param name="cfBase.5" value="1"/>
|
||||||
|
<param name="cfBase.6" value="1"/>
|
||||||
|
<param name="cfBase.7" value="1"/>
|
||||||
|
<param name="cfBase.8" value="1"/>
|
||||||
|
<param name="cfBase.9" value="1"/>
|
||||||
|
<param name="cfBase.10" value="1"/>
|
||||||
|
<param name="cfBase.11" value="1"/>
|
||||||
|
<param name="cfBase.12" value="1"/>
|
||||||
|
<param name="cfBase.13" value="1"/>
|
||||||
|
<param name="cfBase.14" value="1"/>
|
||||||
|
<param name="cfBase.15" value="1"/>
|
||||||
|
<param name="cfBase.16" value="0"/>
|
||||||
|
<param name="mnVias" value="20"/>
|
||||||
|
<param name="mnSegments" value="9999"/>
|
||||||
|
<param name="mnExtdSteps" value="9999"/>
|
||||||
|
<param name="mnRipupLevel" value="10"/>
|
||||||
|
<param name="mnRipupSteps" value="100"/>
|
||||||
|
<param name="mnRipupTotal" value="100"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Follow-me" refer="Default" active="yes">
|
||||||
|
</pass>
|
||||||
|
<pass name="Busses" refer="Default" active="yes">
|
||||||
|
<param name="cfNonPref" value="4"/>
|
||||||
|
<param name="cfBusImpact" value="4"/>
|
||||||
|
<param name="cfHugging" value="0"/>
|
||||||
|
<param name="mnVias" value="0"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Route" refer="Default" active="yes">
|
||||||
|
</pass>
|
||||||
|
<pass name="Optimize1" refer="Default" active="yes">
|
||||||
|
<param name="cfVia" value="99"/>
|
||||||
|
<param name="cfExtdStep" value="10"/>
|
||||||
|
<param name="cfHugging" value="1"/>
|
||||||
|
<param name="mnExtdSteps" value="1"/>
|
||||||
|
<param name="mnRipupLevel" value="0"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Optimize2" refer="Optimize1" active="yes">
|
||||||
|
<param name="cfNonPref" value="0"/>
|
||||||
|
<param name="cfChangeDir" value="6"/>
|
||||||
|
<param name="cfExtdStep" value="0"/>
|
||||||
|
<param name="cfBonusStep" value="2"/>
|
||||||
|
<param name="cfMalusStep" value="2"/>
|
||||||
|
<param name="cfPadImpact" value="2"/>
|
||||||
|
<param name="cfSmdImpact" value="2"/>
|
||||||
|
<param name="cfHugging" value="0"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Optimize3" refer="Optimize2" active="yes">
|
||||||
|
<param name="cfChangeDir" value="8"/>
|
||||||
|
<param name="cfPadImpact" value="0"/>
|
||||||
|
<param name="cfSmdImpact" value="0"/>
|
||||||
|
</pass>
|
||||||
|
<pass name="Optimize4" refer="Optimize3" active="yes">
|
||||||
|
<param name="cfChangeDir" value="25"/>
|
||||||
|
</pass>
|
||||||
|
</autorouter>
|
||||||
|
<elements>
|
||||||
|
<element name="R1" library="rcl" package="0207/10" value="10k" x="54.61" y="52.07" rot="R180"/>
|
||||||
|
<element name="C6" library="rcl" package="C0603" value="100n" x="33.02" y="65.405" rot="MR270"/>
|
||||||
|
<element name="X1" library="con-tycoelectronics" package="RJ45-NO-SHIELD" value="RJ45-8X" x="24.13" y="43.815" rot="R270">
|
||||||
|
<attribute name="OC_NEWARK" value="16R6101" x="15.24" y="-33.655" size="1.778" layer="27" rot="R270" display="off"/>
|
||||||
|
<attribute name="MPN" value="RJ45-8X" x="15.24" y="-33.655" size="1.778" layer="27" rot="R270" display="off"/>
|
||||||
|
<attribute name="MF" value="" x="15.24" y="-33.655" size="1.778" layer="27" rot="R270" display="off"/>
|
||||||
|
<attribute name="OC_FARNELL" value="unknown" x="15.24" y="-33.655" size="1.778" layer="27" rot="R270" display="off"/>
|
||||||
|
</element>
|
||||||
|
<element name="IC5" library="maxim" package="DIL16" value="MAX232" x="34.925" y="19.05" rot="R270">
|
||||||
|
<attribute name="OC_NEWARK" value="68K4544" x="-17.145" y="-55.88" size="1.778" layer="27" rot="R270" display="off"/>
|
||||||
|
<attribute name="MPN" value="MAX232ACPE+" x="-17.145" y="-55.88" size="1.778" layer="27" rot="R270" display="off"/>
|
||||||
|
<attribute name="MF" value="MAXIM" x="-17.145" y="-55.88" size="1.778" layer="27" rot="R270" display="off"/>
|
||||||
|
<attribute name="OC_FARNELL" value="9723773" x="-17.145" y="-55.88" size="1.778" layer="27" rot="R270" display="off"/>
|
||||||
|
</element>
|
||||||
|
<element name="C2" library="rcl" package="E2-4" value="" x="26.035" y="27.94" rot="R270"/>
|
||||||
|
<element name="C12" library="rcl" package="E2-4" value="" x="26.035" y="17.78" rot="R270"/>
|
||||||
|
<element name="C13" library="rcl" package="E2-4" value="" x="26.035" y="12.7" rot="R90"/>
|
||||||
|
<element name="C14" library="rcl" package="E2-4" value="" x="26.035" y="22.86" rot="R270"/>
|
||||||
|
<element name="C15" library="rcl" package="E2-4" value="" x="43.815" y="27.305" rot="R270"/>
|
||||||
|
<element name="C16" library="rcl" package="C0603" value="" x="41.275" y="30.48" rot="MR180"/>
|
||||||
|
<element name="IC3" library="linear" package="TO220V" value="7805V" x="20.955" y="60.96" rot="R90"/>
|
||||||
|
<element name="C1" library="rcl" package="E3,5-8" value="470µ/25V" x="30.48" y="55.88" rot="R270"/>
|
||||||
|
<element name="C3" library="rcl" package="E3,5-8" value="470µ/25V" x="30.48" y="66.675" rot="R270"/>
|
||||||
|
<element name="ISP1" library="con-harting-ml" package="ML10" value="" x="43.18" y="43.18" rot="R90">
|
||||||
|
<attribute name="OC_NEWARK" value="unknown" x="81.28" y="120.65" size="1.778" layer="27" rot="R90" display="off"/>
|
||||||
|
<attribute name="MPN" value="" x="81.28" y="120.65" size="1.778" layer="27" rot="R90" display="off"/>
|
||||||
|
<attribute name="MF" value="" x="81.28" y="120.65" size="1.778" layer="27" rot="R90" display="off"/>
|
||||||
|
<attribute name="OC_FARNELL" value="unknown" x="81.28" y="120.65" size="1.778" layer="27" rot="R90" display="off"/>
|
||||||
|
</element>
|
||||||
|
<element name="JP1" library="pinhead" package="1X03" value="" x="47.625" y="21.59" rot="R180"/>
|
||||||
|
<element name="C11" library="rcl" package="C0603" value="100n" x="46.355" y="19.05" rot="MR0"/>
|
||||||
|
<element name="IC1" library="atmel" package="DIL20" value="AT90S2313P" x="59.055" y="34.925" rot="R90">
|
||||||
|
<attribute name="OC_NEWARK" value="unknown" x="59.055" y="34.925" size="1.778" layer="27" rot="R90" display="off"/>
|
||||||
|
<attribute name="MPN" value="" x="59.055" y="34.925" size="1.778" layer="27" rot="R90" display="off"/>
|
||||||
|
<attribute name="MF" value="" x="59.055" y="34.925" size="1.778" layer="27" rot="R90" display="off"/>
|
||||||
|
<attribute name="OC_FARNELL" value="unknown" x="59.055" y="34.925" size="1.778" layer="27" rot="R90" display="off"/>
|
||||||
|
</element>
|
||||||
|
</elements>
|
||||||
|
<signals>
|
||||||
|
<signal name="+5V">
|
||||||
|
<contactref element="R1" pad="2"/>
|
||||||
|
<contactref element="C16" pad="1"/>
|
||||||
|
<contactref element="IC5" pad="16"/>
|
||||||
|
<contactref element="C15" pad="+"/>
|
||||||
|
<contactref element="C14" pad="-"/>
|
||||||
|
<contactref element="ISP1" pad="2"/>
|
||||||
|
<contactref element="IC3" pad="3"/>
|
||||||
|
<contactref element="C3" pad="+"/>
|
||||||
|
<wire x1="38.735" y1="27.94" x2="36.195" y2="27.94" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="36.195" y1="27.94" x2="34.925" y2="26.67" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="34.925" y1="26.67" x2="34.925" y2="25.4" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="34.925" y1="25.4" x2="33.655" y2="24.13" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="33.655" y1="24.13" x2="28.321" y2="24.13" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="28.321" y1="24.13" x2="26.035" y2="21.844" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="35.56" y1="67.31" x2="35.56" y2="59.055" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="35.56" y1="59.055" x2="39.37" y2="55.245" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="39.37" y1="55.245" x2="39.37" y2="52.07" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="39.37" y1="52.07" x2="39.37" y2="38.1" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="39.37" y1="34.29" x2="39.37" y2="38.1" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="41.91" y1="38.1" x2="39.37" y2="38.1" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="38.735" y1="27.94" x2="38.735" y2="30.48" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="40.425" y1="30.48" x2="38.735" y2="30.48" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="38.735" y1="30.48" x2="38.735" y2="33.655" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="38.735" y1="33.655" x2="39.37" y2="34.29" width="0.6096" layer="16"/>
|
||||||
|
<contactref element="C11" pad="1"/>
|
||||||
|
<contactref element="JP1" pad="2"/>
|
||||||
|
<contactref element="C6" pad="1"/>
|
||||||
|
<contactref element="IC1" pad="20"/>
|
||||||
|
<wire x1="30.48" y1="68.453" x2="33.02" y2="68.453" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="33.02" y1="68.453" x2="34.417" y2="68.453" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="34.417" y1="68.453" x2="35.56" y2="67.31" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="23.495" y1="63.5" x2="23.495" y2="67.31" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="23.495" y1="67.31" x2="24.765" y2="68.58" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="24.765" y1="68.58" x2="30.353" y2="68.58" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="30.353" y1="68.58" x2="30.48" y2="68.453" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="33.02" y1="66.255" x2="33.02" y2="68.453" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="47.205" y1="19.05" x2="47.205" y2="19.265" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="47.205" y1="19.265" x2="47.625" y2="19.685" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="47.625" y1="19.685" x2="47.625" y2="21.59" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="47.625" y1="33.02" x2="46.355" y2="34.29" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="46.355" y1="34.29" x2="39.37" y2="34.29" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="47.625" y1="33.02" x2="47.625" y2="24.765" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="47.625" y1="24.765" x2="47.625" y2="21.59" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="55.245" y1="23.495" x2="52.705" y2="23.495" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="52.705" y1="23.495" x2="51.435" y2="24.765" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="51.435" y1="24.765" x2="47.625" y2="24.765" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="49.53" y1="52.07" x2="39.37" y2="52.07" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="38.735" y1="27.94" x2="41.91" y2="27.94" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="43.815" y1="28.321" x2="42.291" y2="28.321" width="0.6096" layer="16"/>
|
||||||
|
<wire x1="42.291" y1="28.321" x2="41.91" y2="27.94" width="0.6096" layer="16" curve="90"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="GND">
|
||||||
|
<contactref element="X1" pad="2"/>
|
||||||
|
<contactref element="X1" pad="1"/>
|
||||||
|
<contactref element="IC5" pad="15"/>
|
||||||
|
<contactref element="C13" pad="+"/>
|
||||||
|
<contactref element="C15" pad="-"/>
|
||||||
|
<contactref element="C16" pad="2"/>
|
||||||
|
<contactref element="C1" pad="-"/>
|
||||||
|
<contactref element="IC3" pad="2"/>
|
||||||
|
<contactref element="C3" pad="-"/>
|
||||||
|
<contactref element="ISP1" pad="10"/>
|
||||||
|
<contactref element="ISP1" pad="8"/>
|
||||||
|
<contactref element="ISP1" pad="6"/>
|
||||||
|
<contactref element="ISP1" pad="4"/>
|
||||||
|
<wire x1="41.91" y1="40.64" x2="41.91" y2="43.18" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="41.91" y1="43.18" x2="41.91" y2="45.72" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="41.91" y1="45.72" x2="41.91" y2="48.26" width="0.4064" layer="16"/>
|
||||||
|
<polygon width="0.4064" layer="16" isolate="0.4064">
|
||||||
|
<vertex x="17.145" y="0"/>
|
||||||
|
<vertex x="17.145" y="71.755"/>
|
||||||
|
<vertex x="69.85" y="71.755"/>
|
||||||
|
<vertex x="69.85" y="0"/>
|
||||||
|
</polygon>
|
||||||
|
<wire x1="29.845" y1="41.91" x2="31.115" y2="41.91" width="0.3048" layer="16"/>
|
||||||
|
<wire x1="31.115" y1="41.91" x2="32.385" y2="40.64" width="0.3048" layer="16"/>
|
||||||
|
<wire x1="32.385" y1="40.64" x2="33.655" y2="40.64" width="0.3048" layer="16"/>
|
||||||
|
<contactref element="C11" pad="2"/>
|
||||||
|
<contactref element="JP1" pad="3"/>
|
||||||
|
<contactref element="IC1" pad="10"/>
|
||||||
|
<contactref element="C6" pad="2"/>
|
||||||
|
<contactref element="IC1" pad="10"/>
|
||||||
|
<wire x1="42.125" y1="30.48" x2="43.18" y2="30.48" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="38.735" y1="25.4" x2="37.465" y2="25.4" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="37.465" y1="25.4" x2="33.655" y2="21.59" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="33.655" y1="21.59" x2="33.655" y2="12.065" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="33.655" y1="12.065" x2="33.02" y2="11.43" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="33.02" y1="11.43" x2="26.289" y2="11.43" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="26.289" y1="11.43" x2="26.035" y2="11.684" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="48.895" y1="19.685" x2="48.895" y2="23.495" width="0.4064" layer="16"/>
|
||||||
|
<via x="49.53" y="34.29" extent="1-16" drill="0.6" shape="square"/>
|
||||||
|
<via x="49.53" y="39.37" extent="1-16" drill="0.6" shape="square"/>
|
||||||
|
<wire x1="49.53" y1="34.29" x2="49.53" y2="39.37" width="0.4064" layer="1"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="MOSI">
|
||||||
|
<contactref element="ISP1" pad="1"/>
|
||||||
|
<contactref element="IC1" pad="17"/>
|
||||||
|
<wire x1="44.45" y1="38.1" x2="45.72" y2="38.1" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="45.72" y1="38.1" x2="46.355" y2="37.465" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="46.355" y1="37.465" x2="56.515" y2="37.465" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="56.515" y1="37.465" x2="57.15" y2="36.83" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="57.15" y1="36.83" x2="57.15" y2="31.75" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="57.15" y1="31.75" x2="56.515" y2="31.115" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="56.515" y1="31.115" x2="55.245" y2="31.115" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="MISO">
|
||||||
|
<contactref element="ISP1" pad="9"/>
|
||||||
|
<contactref element="IC1" pad="18"/>
|
||||||
|
<wire x1="44.45" y1="48.26" x2="57.15" y2="48.26" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="55.245" y1="28.575" x2="57.15" y2="28.575" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="57.15" y1="28.575" x2="58.42" y2="29.845" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="58.42" y1="29.845" x2="58.42" y2="46.99" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="58.42" y1="46.99" x2="57.15" y2="48.26" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="SCK">
|
||||||
|
<contactref element="ISP1" pad="7"/>
|
||||||
|
<contactref element="IC1" pad="19"/>
|
||||||
|
<wire x1="44.45" y1="45.72" x2="45.72" y2="45.72" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="55.245" y1="26.035" x2="53.34" y2="26.035" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="53.34" y1="26.035" x2="51.435" y2="27.94" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="51.435" y1="27.94" x2="51.435" y2="35.56" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="51.435" y1="35.56" x2="50.8" y2="36.195" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="50.8" y1="36.195" x2="43.815" y2="36.195" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="43.815" y1="36.195" x2="43.18" y2="36.83" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="43.18" y1="36.83" x2="43.18" y2="41.275" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="43.18" y1="41.275" x2="43.815" y2="41.91" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="43.815" y1="41.91" x2="45.72" y2="41.91" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="45.72" y1="41.91" x2="46.355" y2="42.545" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="46.355" y1="42.545" x2="46.355" y2="45.085" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="46.355" y1="45.085" x2="45.72" y2="45.72" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="RESET">
|
||||||
|
<contactref element="R1" pad="1"/>
|
||||||
|
<contactref element="ISP1" pad="5"/>
|
||||||
|
<contactref element="IC1" pad="1"/>
|
||||||
|
<wire x1="62.865" y1="23.495" x2="60.96" y2="23.495" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="60.96" y1="23.495" x2="59.69" y2="24.765" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="59.69" y1="24.765" x2="59.69" y2="48.26" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="59.69" y1="48.26" x2="59.055" y2="48.895" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="59.055" y1="48.895" x2="58.42" y2="49.53" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="58.42" y1="49.53" x2="43.815" y2="49.53" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="43.815" y1="49.53" x2="43.18" y2="48.895" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="43.18" y1="48.895" x2="43.18" y2="44.45" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="43.18" y1="44.45" x2="44.45" y2="43.18" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="59.69" y1="52.07" x2="59.69" y2="49.53" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="59.69" y1="49.53" x2="59.055" y2="48.895" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="TXD">
|
||||||
|
<contactref element="IC5" pad="11"/>
|
||||||
|
<contactref element="IC1" pad="3"/>
|
||||||
|
<wire x1="38.735" y1="15.24" x2="64.77" y2="15.24" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="64.77" y1="15.24" x2="67.31" y2="17.78" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="67.31" y1="17.78" x2="67.31" y2="26.67" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="67.31" y1="26.67" x2="65.405" y2="28.575" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="65.405" y1="28.575" x2="62.865" y2="28.575" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="RXD">
|
||||||
|
<contactref element="IC5" pad="12"/>
|
||||||
|
<contactref element="IC1" pad="2"/>
|
||||||
|
<wire x1="38.735" y1="17.78" x2="41.275" y2="17.78" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="41.275" y1="17.78" x2="42.545" y2="16.51" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="42.545" y1="16.51" x2="64.135" y2="16.51" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="64.135" y1="16.51" x2="66.04" y2="18.415" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="66.04" y1="18.415" x2="66.04" y2="24.765" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="66.04" y1="24.765" x2="64.77" y2="26.035" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="64.77" y1="26.035" x2="62.865" y2="26.035" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="TX">
|
||||||
|
<contactref element="X1" pad="6"/>
|
||||||
|
<contactref element="IC5" pad="14"/>
|
||||||
|
<wire x1="38.735" y1="22.86" x2="38.1" y2="22.86" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="38.1" y1="22.86" x2="34.29" y2="19.05" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="34.29" y1="19.05" x2="34.29" y2="9.525" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="34.29" y1="9.525" x2="32.385" y2="7.62" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="32.385" y1="7.62" x2="25.4" y2="7.62" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="25.4" y1="7.62" x2="21.59" y2="11.43" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="21.59" y1="11.43" x2="21.59" y2="43.18" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="21.59" y1="43.18" x2="22.86" y2="44.45" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="22.86" y1="44.45" x2="31.115" y2="44.45" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="31.115" y1="44.45" x2="33.02" y2="42.545" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="33.02" y1="42.545" x2="33.02" y2="41.91" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="RX">
|
||||||
|
<contactref element="X1" pad="3"/>
|
||||||
|
<contactref element="IC5" pad="13"/>
|
||||||
|
<wire x1="38.735" y1="20.32" x2="37.465" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="37.465" y1="20.32" x2="35.56" y2="18.415" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="35.56" y1="18.415" x2="35.56" y2="8.89" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="35.56" y1="8.89" x2="33.02" y2="6.35" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="33.02" y1="6.35" x2="24.765" y2="6.35" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="24.765" y1="6.35" x2="20.32" y2="10.795" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="20.32" y1="10.795" x2="20.32" y2="43.815" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="20.32" y1="43.815" x2="22.225" y2="45.72" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="22.225" y1="45.72" x2="30.48" y2="45.72" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="+12V">
|
||||||
|
<contactref element="X1" pad="8"/>
|
||||||
|
<contactref element="X1" pad="7"/>
|
||||||
|
<contactref element="IC3" pad="1"/>
|
||||||
|
<contactref element="C1" pad="+"/>
|
||||||
|
<wire x1="30.48" y1="40.64" x2="31.75" y2="39.37" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="31.75" y1="39.37" x2="33.02" y2="39.37" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="30.48" y1="57.658" x2="32.385" y2="57.785" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="32.385" y1="57.785" x2="36.195" y2="53.975" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="36.195" y1="53.975" x2="36.195" y2="41.275" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="36.195" y1="41.275" x2="34.29" y2="39.37" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="34.29" y1="39.37" x2="33.02" y2="39.37" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="30.48" y1="57.658" x2="25.4" y2="57.785" width="0.8128" layer="16"/>
|
||||||
|
<wire x1="25.4" y1="57.785" x2="23.495" y2="58.42" width="0.8128" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$54">
|
||||||
|
<contactref element="IC5" pad="1"/>
|
||||||
|
<contactref element="C2" pad="+"/>
|
||||||
|
<wire x1="31.115" y1="27.94" x2="29.845" y2="27.94" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="29.845" y1="27.94" x2="28.575" y2="29.21" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="28.575" y1="29.21" x2="26.289" y2="29.21" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="26.289" y1="29.21" x2="26.035" y2="28.956" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$55">
|
||||||
|
<contactref element="IC5" pad="3"/>
|
||||||
|
<contactref element="C2" pad="-"/>
|
||||||
|
<wire x1="31.115" y1="22.86" x2="29.845" y2="22.86" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="29.845" y1="22.86" x2="27.305" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="27.305" y1="20.32" x2="24.765" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="24.765" y1="20.32" x2="23.495" y2="21.59" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="23.495" y1="21.59" x2="23.495" y2="25.4" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="23.495" y1="25.4" x2="24.765" y2="26.67" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="24.765" y1="26.67" x2="25.781" y2="26.67" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="25.781" y1="26.67" x2="26.035" y2="26.924" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$56">
|
||||||
|
<contactref element="IC5" pad="5"/>
|
||||||
|
<contactref element="C12" pad="-"/>
|
||||||
|
<wire x1="31.115" y1="17.78" x2="29.845" y2="17.78" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="29.845" y1="17.78" x2="28.575" y2="16.51" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="28.575" y1="16.51" x2="26.289" y2="16.51" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="26.289" y1="16.51" x2="26.035" y2="16.764" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$57">
|
||||||
|
<contactref element="IC5" pad="4"/>
|
||||||
|
<contactref element="C12" pad="+"/>
|
||||||
|
<wire x1="31.115" y1="20.32" x2="29.845" y2="20.32" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="29.845" y1="20.32" x2="28.575" y2="19.05" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="28.575" y1="19.05" x2="26.289" y2="19.05" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="26.289" y1="19.05" x2="26.035" y2="18.796" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$58">
|
||||||
|
<contactref element="IC5" pad="2"/>
|
||||||
|
<contactref element="C14" pad="+"/>
|
||||||
|
<wire x1="26.035" y1="23.876" x2="26.035" y2="24.13" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="26.035" y1="24.13" x2="27.305" y2="25.4" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="27.305" y1="25.4" x2="31.115" y2="25.4" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$59">
|
||||||
|
<contactref element="IC5" pad="6"/>
|
||||||
|
<contactref element="C13" pad="-"/>
|
||||||
|
<wire x1="31.115" y1="15.24" x2="29.845" y2="15.24" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="29.845" y1="15.24" x2="28.575" y2="13.97" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="28.575" y1="13.97" x2="26.289" y2="13.97" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="26.289" y1="13.97" x2="26.035" y2="13.716" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
<signal name="N$4">
|
||||||
|
<contactref element="JP1" pad="1"/>
|
||||||
|
<contactref element="IC1" pad="15"/>
|
||||||
|
<wire x1="52.705" y1="28.575" x2="53.975" y2="27.305" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="53.975" y1="27.305" x2="57.785" y2="27.305" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="57.785" y1="27.305" x2="58.42" y2="26.67" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="58.42" y1="26.67" x2="58.42" y2="22.225" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="50.165" y1="21.59" x2="51.435" y2="21.59" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="51.435" y1="21.59" x2="52.07" y2="20.955" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="52.07" y1="20.955" x2="57.15" y2="20.955" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="57.15" y1="20.955" x2="58.42" y2="22.225" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="52.705" y1="28.575" x2="52.705" y2="35.56" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="52.705" y1="35.56" x2="53.34" y2="36.195" width="0.4064" layer="16"/>
|
||||||
|
<wire x1="53.34" y1="36.195" x2="55.245" y2="36.195" width="0.4064" layer="16"/>
|
||||||
|
</signal>
|
||||||
|
</signals>
|
||||||
|
</board>
|
||||||
|
</drawing>
|
||||||
|
</eagle>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,276 @@
|
||||||
|
# On command line:
|
||||||
|
#
|
||||||
|
# make all = Make software.
|
||||||
|
#
|
||||||
|
# make clean = Clean out built project files.
|
||||||
|
#
|
||||||
|
# make program = Download the hex file to the device, using avrdude. Please
|
||||||
|
# customize the avrdude settings below first!
|
||||||
|
#
|
||||||
|
# To rebuild project do "make clean" then "make all".
|
||||||
|
#
|
||||||
|
|
||||||
|
MCU = attiny2313
|
||||||
|
F_CPU = 8000000
|
||||||
|
|
||||||
|
# Output format. (can be srec, ihex, binary)
|
||||||
|
FORMAT = ihex
|
||||||
|
|
||||||
|
# Target file name (without extension).
|
||||||
|
TARGET = main
|
||||||
|
|
||||||
|
SRC = src/$(TARGET).c src/utils.c src/uart.c
|
||||||
|
|
||||||
|
|
||||||
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
|
OPT = s
|
||||||
|
|
||||||
|
|
||||||
|
# List any extra directories to look for include files here.
|
||||||
|
# Each directory must be seperated by a space.
|
||||||
|
EXTRAINCDIRS = src/
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flag to set the C Standard level.
|
||||||
|
# c89 - "ANSI" C
|
||||||
|
# gnu89 - c89 plus GCC extensions
|
||||||
|
# c99 - ISO C99 standard (not yet fully implemented)
|
||||||
|
# gnu99 - c99 plus GCC extensions
|
||||||
|
CSTANDARD = -std=gnu99
|
||||||
|
|
||||||
|
# Place -D or -U options here
|
||||||
|
CDEFS =
|
||||||
|
|
||||||
|
# Place -I options here
|
||||||
|
CINCS =
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flags.
|
||||||
|
# -O*: optimization level
|
||||||
|
# -f...: tuning, see GCC manual and avr-libc documentation
|
||||||
|
# -Wall...: warning level
|
||||||
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
|
# -adhlns...: create assembler listing
|
||||||
|
CFLAGS += $(CDEFS) $(CINCS)
|
||||||
|
CFLAGS += -O$(OPT)
|
||||||
|
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
|
||||||
|
CFLAGS += -Wall -Wstrict-prototypes
|
||||||
|
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
|
||||||
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
CFLAGS += $(CSTANDARD)
|
||||||
|
CFLAGS += -DF_CPU=$(F_CPU) #-DDEBUG
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# External memory options
|
||||||
|
|
||||||
|
|
||||||
|
# Linker flags.
|
||||||
|
# -Wl,...: tell GCC to pass this to linker.
|
||||||
|
# -Map: create map file
|
||||||
|
# --cref: add cross reference to map file
|
||||||
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
|
|
||||||
|
|
||||||
|
# Programming support using avrdude. Settings and variables.
|
||||||
|
AVRDUDE_PROGRAMMER = usbtiny
|
||||||
|
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
|
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
||||||
|
|
||||||
|
AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Define programs and commands.
|
||||||
|
SHELL = sh
|
||||||
|
CC = avr-gcc
|
||||||
|
OBJCOPY = avr-objcopy
|
||||||
|
OBJDUMP = avr-objdump
|
||||||
|
SIZE = avr-size
|
||||||
|
NM = avr-nm
|
||||||
|
AVRDUDE = avrdude
|
||||||
|
REMOVE = rm -f
|
||||||
|
COPY = cp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Define Messages
|
||||||
|
# English
|
||||||
|
MSG_ERRORS_NONE = Errors: none
|
||||||
|
MSG_BEGIN = -------- begin --------
|
||||||
|
MSG_END = -------- end --------
|
||||||
|
MSG_SIZE_BEFORE = Size before:
|
||||||
|
MSG_SIZE_AFTER = Size after:
|
||||||
|
MSG_COFF = Converting to AVR COFF:
|
||||||
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
MSG_FLASH = Creating load file for Flash:
|
||||||
|
MSG_EEPROM = Creating load file for EEPROM:
|
||||||
|
MSG_EXTENDED_LISTING = Creating Extended Listing:
|
||||||
|
MSG_SYMBOL_TABLE = Creating Symbol Table:
|
||||||
|
MSG_LINKING = Linking:
|
||||||
|
MSG_COMPILING = Compiling:
|
||||||
|
MSG_ASSEMBLING = Assembling:
|
||||||
|
MSG_CLEANING = Cleaning project:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Define all object files.
|
||||||
|
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
|
||||||
|
|
||||||
|
# Define all listing files.
|
||||||
|
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flags to generate dependency files.
|
||||||
|
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
|
||||||
|
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
|
||||||
|
|
||||||
|
# Combine all necessary flags and optional flags.
|
||||||
|
# Add target processor to flags.
|
||||||
|
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Default target.
|
||||||
|
all: begin gccversion sizebefore build sizeafter finished end
|
||||||
|
|
||||||
|
build: elf hex eep lss sym
|
||||||
|
|
||||||
|
elf: $(TARGET).elf
|
||||||
|
hex: $(TARGET).hex
|
||||||
|
eep: $(TARGET).eep
|
||||||
|
lss: $(TARGET).lss
|
||||||
|
sym: $(TARGET).sym
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Eye candy.
|
||||||
|
# AVR Studio 3.x does not check make's exit code but relies on
|
||||||
|
# the following magic strings to be generated by the compile job.
|
||||||
|
begin:
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_BEGIN)
|
||||||
|
|
||||||
|
finished:
|
||||||
|
@echo $(MSG_ERRORS_NONE)
|
||||||
|
|
||||||
|
end:
|
||||||
|
@echo $(MSG_END)
|
||||||
|
@echo
|
||||||
|
|
||||||
|
|
||||||
|
# Display size of file.
|
||||||
|
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
|
||||||
|
ELFSIZE = $(SIZE) -A $(TARGET).elf
|
||||||
|
sizebefore:
|
||||||
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
sizeafter:
|
||||||
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Display compiler version information.
|
||||||
|
gccversion :
|
||||||
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Program the device.
|
||||||
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
||||||
|
# Create final output files (.hex, .eep) from ELF output file.
|
||||||
|
%.hex: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_FLASH) $@
|
||||||
|
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||||
|
|
||||||
|
%.eep: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_EEPROM) $@
|
||||||
|
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||||
|
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
||||||
|
|
||||||
|
# Create extended listing file from ELF output file.
|
||||||
|
%.lss: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_EXTENDED_LISTING) $@
|
||||||
|
$(OBJDUMP) -h -S $< > $@
|
||||||
|
|
||||||
|
# Create a symbol table from ELF output file.
|
||||||
|
%.sym: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_SYMBOL_TABLE) $@
|
||||||
|
$(NM) -n $< > $@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Link: create ELF output file from object files.
|
||||||
|
.SECONDARY : $(TARGET).elf
|
||||||
|
.PRECIOUS : $(OBJ)
|
||||||
|
%.elf: $(OBJ)
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_LINKING) $@
|
||||||
|
$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create object files from C source files.
|
||||||
|
%.o : %.c
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_COMPILING) $<
|
||||||
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create assembler files from C source files.
|
||||||
|
%.s : %.c
|
||||||
|
$(CC) -S $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
# Assemble: create object files from assembler source files.
|
||||||
|
%.o : %.S
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_ASSEMBLING) $<
|
||||||
|
$(CC) -c $(ALL_ASFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Target: clean project.
|
||||||
|
clean: begin clean_list finished end
|
||||||
|
|
||||||
|
clean_list :
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_CLEANING)
|
||||||
|
$(REMOVE) $(TARGET).hex
|
||||||
|
$(REMOVE) $(TARGET).eep
|
||||||
|
$(REMOVE) $(TARGET).obj
|
||||||
|
$(REMOVE) $(TARGET).cof
|
||||||
|
$(REMOVE) $(TARGET).elf
|
||||||
|
$(REMOVE) $(TARGET).map
|
||||||
|
$(REMOVE) $(TARGET).obj
|
||||||
|
$(REMOVE) $(TARGET).a90
|
||||||
|
$(REMOVE) $(TARGET).sym
|
||||||
|
$(REMOVE) $(TARGET).lnk
|
||||||
|
$(REMOVE) $(TARGET).lss
|
||||||
|
$(REMOVE) $(OBJ)
|
||||||
|
$(REMOVE) $(LST)
|
||||||
|
$(REMOVE) $(SRC:.c=.s)
|
||||||
|
$(REMOVE) $(SRC:.c=.d)
|
||||||
|
$(REMOVE) .dep/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Include the dependency files.
|
||||||
|
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
||||||
|
|
||||||
|
|
||||||
|
# Listing of phony targets.
|
||||||
|
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
||||||
|
build elf hex eep lss sym coff extcoff \
|
||||||
|
clean clean_list program
|
||||||
|
|
|
@ -0,0 +1,146 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "utils.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
#define BUFSIZE 40
|
||||||
|
|
||||||
|
volatile uint16_t syscounter = 0;
|
||||||
|
|
||||||
|
// values send over uart from powerboard
|
||||||
|
uint16_t power_gen = 0;
|
||||||
|
|
||||||
|
unsigned char data_count = 0;
|
||||||
|
unsigned char data_in[BUFSIZE];
|
||||||
|
char command_in[BUFSIZE];
|
||||||
|
|
||||||
|
|
||||||
|
static void timer_init(void) {
|
||||||
|
// clock is 8MHz
|
||||||
|
TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10); // CTC Mode for Timer 1 (16Bit) with prescale of 64
|
||||||
|
OCR1A = 2312; // Neutralposition ((2500-2312)*0.008ms)=1,5ms)
|
||||||
|
TIMSK = _BV(OCIE1A);
|
||||||
|
TCCR1A = (1<<COM1A0); // Togglen bei Compare Match
|
||||||
|
|
||||||
|
sei(); // enable interrupts
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ports_init(void) {
|
||||||
|
|
||||||
|
DDRB |= (1<<PB4)|(1<<PB3);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void process_command() {
|
||||||
|
if(strstr(command_in,"A") != NULL) {
|
||||||
|
// we have an A and B (from check in work_uart()
|
||||||
|
// so our message should be complete and consist of:
|
||||||
|
// A$voltage,$current_in,$current_out,$power_in,$power_out,loadsw,dumpsw,gensw\n
|
||||||
|
|
||||||
|
//A12.5,65464,00000,00000,00000,1,0,1B
|
||||||
|
|
||||||
|
char *token;
|
||||||
|
uint8_t tokencounter = 0;
|
||||||
|
|
||||||
|
char *start = strrchr(command_in, 'A');
|
||||||
|
|
||||||
|
// remove first (B is ignored by atoi)
|
||||||
|
start++;
|
||||||
|
|
||||||
|
token = strtok(start, ",");
|
||||||
|
|
||||||
|
while( token ) {
|
||||||
|
if (tokencounter == 3) {
|
||||||
|
power_gen = atoi(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
tokencounter++;
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void work_uart() {
|
||||||
|
|
||||||
|
uint8_t c = uart_getc();
|
||||||
|
|
||||||
|
if ( !(c & UART_NO_DATA) ) {
|
||||||
|
data_in[data_count] = c;
|
||||||
|
|
||||||
|
if (data_in[data_count] == 'B') {
|
||||||
|
data_count = 0;
|
||||||
|
|
||||||
|
memcpy(command_in, data_in, BUFSIZE);
|
||||||
|
memset(data_in, 0, BUFSIZE);
|
||||||
|
|
||||||
|
process_command();
|
||||||
|
} else {
|
||||||
|
data_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_servo(uint8_t power) {
|
||||||
|
|
||||||
|
uint8_t display = 0;
|
||||||
|
|
||||||
|
// display = power * 10; // shift, since we have to divide by 2,4 (24)
|
||||||
|
// display = display / 24; // instead of dividing by 2,4
|
||||||
|
// display = display + 125;
|
||||||
|
|
||||||
|
display = power;
|
||||||
|
|
||||||
|
OCR1A = 2500-display;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void demo_display(void) {
|
||||||
|
for(uint8_t i = 0; i< 30;i = i+1) {
|
||||||
|
set_servo(i*10);
|
||||||
|
wait(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint8_t i = 10; i>= 0;i = i-1) {
|
||||||
|
set_servo(i*5);
|
||||||
|
wait(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
ports_init();
|
||||||
|
timer_init();
|
||||||
|
uart_init(UART_BAUD_SELECT(19200,F_CPU));
|
||||||
|
memset(data_in, 0, BUFSIZE);
|
||||||
|
|
||||||
|
demo_display();
|
||||||
|
|
||||||
|
// while(1) {
|
||||||
|
// work_uart();
|
||||||
|
|
||||||
|
if(syscounter >= 10) {
|
||||||
|
uart_putc('a'); // send a to receive values
|
||||||
|
|
||||||
|
set_servo(power_gen);
|
||||||
|
syscounter = 0;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SIGNAL(TIMER1_COMPA_vect) {
|
||||||
|
syscounter++;
|
||||||
|
|
||||||
|
OCR1A = 2500-OCR1A; // Das Servosignal wird aus der Differenz von
|
||||||
|
// Periodenlänge (2500*0,008ms=20ms) und letztem
|
||||||
|
// Vergleichswert (OCR1A) gebildet
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef _main_h
|
||||||
|
#define _main_h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,479 @@
|
||||||
|
/*************************************************************************
|
||||||
|
Title: Interrupt UART library with receive/transmit circular buffers
|
||||||
|
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
|
||||||
|
File: $Id: uart.c,v 1.10 2013/06/02 07:27:04 peter Exp $
|
||||||
|
Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher
|
||||||
|
Hardware: any AVR with built-in UART,
|
||||||
|
License: GNU General Public License
|
||||||
|
|
||||||
|
DESCRIPTION:
|
||||||
|
An interrupt is generated when the UART has finished transmitting or
|
||||||
|
receiving a byte. The interrupt handling routines use circular buffers
|
||||||
|
for buffering received and transmitted data.
|
||||||
|
|
||||||
|
The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE variables define
|
||||||
|
the buffer size in bytes. Note that these variables must be a
|
||||||
|
power of 2.
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
Refere to the header file uart.h for a description of the routines.
|
||||||
|
See also example test_uart.c.
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
Based on Atmel Application Note AVR306
|
||||||
|
|
||||||
|
LICENSE:
|
||||||
|
Copyright (C) 2006 Peter Fleury
|
||||||
|
|
||||||
|
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, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
*************************************************************************/
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* constants and macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* size of RX/TX buffers */
|
||||||
|
#define UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1)
|
||||||
|
#define UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1)
|
||||||
|
|
||||||
|
#if ( UART_RX_BUFFER_SIZE & UART_RX_BUFFER_MASK )
|
||||||
|
#error RX buffer size is not a power of 2
|
||||||
|
#endif
|
||||||
|
#if ( UART_TX_BUFFER_SIZE & UART_TX_BUFFER_MASK )
|
||||||
|
#error TX buffer size is not a power of 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__AVR_AT90S2313__) \
|
||||||
|
|| defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \
|
||||||
|
|| defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \
|
||||||
|
|| defined(__AVR_ATmega103__)
|
||||||
|
/* old AVR classic or ATmega103 with one UART */
|
||||||
|
#define AT90_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS USR
|
||||||
|
#define UART0_CONTROL UCR
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__)
|
||||||
|
/* old AVR classic with one UART */
|
||||||
|
#define AT90_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \
|
||||||
|
|| defined(__AVR_ATmega323__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RXC_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__)
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega163__)
|
||||||
|
/* ATmega163 with one UART */
|
||||||
|
#define ATMEGA_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega162__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RXC_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RXC_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega161__)
|
||||||
|
/* ATmega with UART */
|
||||||
|
#error "AVR ATmega161 currently not supported by this libaray !"
|
||||||
|
#elif defined(__AVR_ATmega169__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \
|
||||||
|
|| defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATtiny2313__)
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega329__) || \
|
||||||
|
defined(__AVR_ATmega649__) || \
|
||||||
|
defined(__AVR_ATmega325__) || \
|
||||||
|
defined(__AVR_ATmega645__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega644__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#else
|
||||||
|
#error "no UART definition for MCU available"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* module global variables
|
||||||
|
*/
|
||||||
|
static volatile unsigned char UART_TxBuf[UART_TX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART_RxBuf[UART_RX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART_TxHead;
|
||||||
|
static volatile unsigned char UART_TxTail;
|
||||||
|
static volatile unsigned char UART_RxHead;
|
||||||
|
static volatile unsigned char UART_RxTail;
|
||||||
|
static volatile unsigned char UART_LastRxError;
|
||||||
|
|
||||||
|
#if defined( ATMEGA_USART1 )
|
||||||
|
static volatile unsigned char UART1_TxBuf[UART_TX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART1_RxBuf[UART_RX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART1_TxHead;
|
||||||
|
static volatile unsigned char UART1_TxTail;
|
||||||
|
static volatile unsigned char UART1_RxHead;
|
||||||
|
static volatile unsigned char UART1_RxTail;
|
||||||
|
static volatile unsigned char UART1_LastRxError;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ISR (UART0_RECEIVE_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART Receive Complete interrupt
|
||||||
|
Purpose: called when the UART has received a character
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
unsigned char data;
|
||||||
|
unsigned char usr;
|
||||||
|
unsigned char lastRxError;
|
||||||
|
|
||||||
|
|
||||||
|
/* read UART status register and UART data register */
|
||||||
|
usr = UART0_STATUS;
|
||||||
|
data = UART0_DATA;
|
||||||
|
|
||||||
|
/* */
|
||||||
|
#if defined( AT90_UART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#elif defined( ATMEGA_USART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#elif defined( ATMEGA_USART0 )
|
||||||
|
lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) );
|
||||||
|
#elif defined ( ATMEGA_UART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* calculate buffer index */
|
||||||
|
tmphead = ( UART_RxHead + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
|
||||||
|
if ( tmphead == UART_RxTail ) {
|
||||||
|
/* error: receive buffer overflow */
|
||||||
|
lastRxError = UART_BUFFER_OVERFLOW >> 8;
|
||||||
|
}else{
|
||||||
|
/* store new index */
|
||||||
|
UART_RxHead = tmphead;
|
||||||
|
/* store received data in buffer */
|
||||||
|
UART_RxBuf[tmphead] = data;
|
||||||
|
}
|
||||||
|
UART_LastRxError |= lastRxError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ISR (UART0_TRANSMIT_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART Data Register Empty interrupt
|
||||||
|
Purpose: called when the UART is ready to transmit the next byte
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART_TxHead != UART_TxTail) {
|
||||||
|
/* calculate and store new buffer index */
|
||||||
|
tmptail = (UART_TxTail + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
UART_TxTail = tmptail;
|
||||||
|
/* get one byte from buffer and write it to UART */
|
||||||
|
UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */
|
||||||
|
}else{
|
||||||
|
/* tx buffer empty, disable UDRE interrupt */
|
||||||
|
UART0_CONTROL &= ~_BV(UART0_UDRIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_init()
|
||||||
|
Purpose: initialize UART and set baudrate
|
||||||
|
Input: baudrate using macro UART_BAUD_SELECT()
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_init(unsigned int baudrate)
|
||||||
|
{
|
||||||
|
UART_TxHead = 0;
|
||||||
|
UART_TxTail = 0;
|
||||||
|
UART_RxHead = 0;
|
||||||
|
UART_RxTail = 0;
|
||||||
|
|
||||||
|
#if defined( AT90_UART )
|
||||||
|
/* set baud rate */
|
||||||
|
UBRR = (unsigned char)baudrate;
|
||||||
|
|
||||||
|
/* enable UART receiver and transmmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN);
|
||||||
|
|
||||||
|
#elif defined (ATMEGA_USART)
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRRH = (unsigned char)(baudrate>>8);
|
||||||
|
UBRRL = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|(1<<RXEN)|(1<<TXEN);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL
|
||||||
|
UCSRC = (1<<URSEL)|(3<<UCSZ0);
|
||||||
|
#else
|
||||||
|
UCSRC = (3<<UCSZ0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined (ATMEGA_USART0 )
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X0); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRR0H = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR0L = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE0)|(1<<RXEN0)|(1<<TXEN0);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL0
|
||||||
|
UCSR0C = (1<<URSEL0)|(3<<UCSZ00);
|
||||||
|
#else
|
||||||
|
UCSR0C = (3<<UCSZ00);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( ATMEGA_UART )
|
||||||
|
/* set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRRHI = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable UART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|(1<<RXEN)|(1<<TXEN);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}/* uart_init */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_getc()
|
||||||
|
Purpose: return byte from ringbuffer
|
||||||
|
Returns: lower byte: received byte from ringbuffer
|
||||||
|
higher byte: last receive error
|
||||||
|
**************************************************************************/
|
||||||
|
unsigned int uart_getc(void)
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
unsigned char data;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART_RxHead == UART_RxTail ) {
|
||||||
|
return UART_NO_DATA; /* no data available */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate /store buffer index */
|
||||||
|
tmptail = (UART_RxTail + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
UART_RxTail = tmptail;
|
||||||
|
|
||||||
|
/* get data from receive buffer */
|
||||||
|
data = UART_RxBuf[tmptail];
|
||||||
|
|
||||||
|
data = (UART_LastRxError << 8) + data;
|
||||||
|
UART_LastRxError = 0;
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}/* uart_getc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_putc()
|
||||||
|
Purpose: write byte to ringbuffer for transmitting via UART
|
||||||
|
Input: byte to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_putc(unsigned char data)
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
|
||||||
|
|
||||||
|
tmphead = (UART_TxHead + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
|
||||||
|
while ( tmphead == UART_TxTail ){
|
||||||
|
;/* wait for free space in buffer */
|
||||||
|
}
|
||||||
|
|
||||||
|
UART_TxBuf[tmphead] = data;
|
||||||
|
UART_TxHead = tmphead;
|
||||||
|
|
||||||
|
/* enable UDRE interrupt */
|
||||||
|
UART0_CONTROL |= _BV(UART0_UDRIE);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}/* uart_putc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_puts()
|
||||||
|
Purpose: transmit string to UART
|
||||||
|
Input: string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_puts(const char *s )
|
||||||
|
{
|
||||||
|
while (*s)
|
||||||
|
uart_putc(*s++);
|
||||||
|
|
||||||
|
}/* uart_puts */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_puts_p()
|
||||||
|
Purpose: transmit string from program memory to UART
|
||||||
|
Input: program memory string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_puts_p(const char *progmem_s )
|
||||||
|
{
|
||||||
|
register char c;
|
||||||
|
|
||||||
|
while ( (c = pgm_read_byte(progmem_s++)) )
|
||||||
|
uart_putc(c);
|
||||||
|
|
||||||
|
}/* uart_puts_p */
|
||||||
|
|
|
@ -0,0 +1,180 @@
|
||||||
|
#ifndef UART_H
|
||||||
|
#define UART_H
|
||||||
|
/************************************************************************
|
||||||
|
Title: Interrupt UART library with receive/transmit circular buffers
|
||||||
|
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
|
||||||
|
File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $
|
||||||
|
Software: AVR-GCC 4.1, AVR Libc 1.4
|
||||||
|
Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz
|
||||||
|
License: GNU General Public License
|
||||||
|
Usage: see Doxygen manual
|
||||||
|
|
||||||
|
LICENSE:
|
||||||
|
Copyright (C) 2006 Peter Fleury
|
||||||
|
|
||||||
|
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, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup pfleury_uart UART Library
|
||||||
|
* @code #include <uart.h> @endcode
|
||||||
|
*
|
||||||
|
* @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers.
|
||||||
|
*
|
||||||
|
* This library can be used to transmit and receive data through the built in UART.
|
||||||
|
*
|
||||||
|
* An interrupt is generated when the UART has finished transmitting or
|
||||||
|
* receiving a byte. The interrupt handling routines use circular buffers
|
||||||
|
* for buffering received and transmitted data.
|
||||||
|
*
|
||||||
|
* The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE constants define
|
||||||
|
* the size of the circular buffers in bytes. Note that these constants must be a power of 2.
|
||||||
|
* You may need to adapt this constants to your target and your application by adding
|
||||||
|
* CDEFS += -DUART_RX_BUFFER_SIZE=nn -DUART_RX_BUFFER_SIZE=nn to your Makefile.
|
||||||
|
*
|
||||||
|
* @note Based on Atmel Application Note AVR306
|
||||||
|
* @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**@{*/
|
||||||
|
|
||||||
|
|
||||||
|
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304
|
||||||
|
#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** constants and macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @brief UART Baudrate Expression
|
||||||
|
* @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
||||||
|
* @param baudrate baudrate in bps, e.g. 1200, 2400, 9600
|
||||||
|
*/
|
||||||
|
#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL)
|
||||||
|
|
||||||
|
/** @brief UART Baudrate Expression for ATmega double speed mode
|
||||||
|
* @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
||||||
|
* @param baudrate baudrate in bps, e.g. 1200, 2400, 9600
|
||||||
|
*/
|
||||||
|
#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000)
|
||||||
|
|
||||||
|
|
||||||
|
/** Size of the circular receive buffer, must be power of 2 */
|
||||||
|
#ifndef UART_RX_BUFFER_SIZE
|
||||||
|
#define UART_RX_BUFFER_SIZE 32
|
||||||
|
#endif
|
||||||
|
/** Size of the circular transmit buffer, must be power of 2 */
|
||||||
|
#ifndef UART_TX_BUFFER_SIZE
|
||||||
|
#define UART_TX_BUFFER_SIZE 32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* test if the size of the circular buffers fits into SRAM */
|
||||||
|
#if ( (UART_RX_BUFFER_SIZE+UART_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) )
|
||||||
|
#error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** high byte error return code of uart_getc()
|
||||||
|
*/
|
||||||
|
#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */
|
||||||
|
#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */
|
||||||
|
#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */
|
||||||
|
#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */
|
||||||
|
#define UART_NO_DATA 0x0100 /* no receive data available */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** function prototypes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Initialize UART and set baudrate
|
||||||
|
@param baudrate Specify baudrate using macro UART_BAUD_SELECT()
|
||||||
|
@return none
|
||||||
|
*/
|
||||||
|
extern void uart_init(unsigned int baudrate);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get received byte from ringbuffer
|
||||||
|
*
|
||||||
|
* Returns in the lower byte the received character and in the
|
||||||
|
* higher byte the last receive error.
|
||||||
|
* UART_NO_DATA is returned when no data is available.
|
||||||
|
*
|
||||||
|
* @param void
|
||||||
|
* @return lower byte: received byte from ringbuffer
|
||||||
|
* @return higher byte: last receive status
|
||||||
|
* - \b 0 successfully received data from UART
|
||||||
|
* - \b UART_NO_DATA
|
||||||
|
* <br>no receive data available
|
||||||
|
* - \b UART_BUFFER_OVERFLOW
|
||||||
|
* <br>Receive ringbuffer overflow.
|
||||||
|
* We are not reading the receive buffer fast enough,
|
||||||
|
* one or more received character have been dropped
|
||||||
|
* - \b UART_OVERRUN_ERROR
|
||||||
|
* <br>Overrun condition by UART.
|
||||||
|
* A character already present in the UART UDR register was
|
||||||
|
* not read by the interrupt handler before the next character arrived,
|
||||||
|
* one or more received characters have been dropped.
|
||||||
|
* - \b UART_FRAME_ERROR
|
||||||
|
* <br>Framing Error by UART
|
||||||
|
*/
|
||||||
|
extern unsigned int uart_getc(void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put byte to ringbuffer for transmitting via UART
|
||||||
|
* @param data byte to be transmitted
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
extern void uart_putc(unsigned char data);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put string to ringbuffer for transmitting via UART
|
||||||
|
*
|
||||||
|
* The string is buffered by the uart library in a circular buffer
|
||||||
|
* and one character at a time is transmitted to the UART using interrupts.
|
||||||
|
* Blocks if it can not write the whole string into the circular buffer.
|
||||||
|
*
|
||||||
|
* @param s string to be transmitted
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
extern void uart_puts(const char *s );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put string from program memory to ringbuffer for transmitting via UART.
|
||||||
|
*
|
||||||
|
* The string is buffered by the uart library in a circular buffer
|
||||||
|
* and one character at a time is transmitted to the UART using interrupts.
|
||||||
|
* Blocks if it can not write the whole string into the circular buffer.
|
||||||
|
*
|
||||||
|
* @param s program memory string to be transmitted
|
||||||
|
* @return none
|
||||||
|
* @see uart_puts_P
|
||||||
|
*/
|
||||||
|
extern void uart_puts_p(const char *s );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Macro to automatically put a string constant into program memory
|
||||||
|
*/
|
||||||
|
#define uart_puts_P(__s) uart_puts_p(PSTR(__s))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // UART_H
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
void wait(uint8_t count) {
|
||||||
|
uint8_t i;
|
||||||
|
if(count == 0) count = 100;
|
||||||
|
for(i=0;i<count;i++) {
|
||||||
|
_delay_ms(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_voltage(uint16_t x) {
|
||||||
|
uart_putc(48 + (x / 10000));
|
||||||
|
uart_putc(48 + (x % 10000 /1000));
|
||||||
|
uart_putc('.');
|
||||||
|
uart_putc(48 + (x % 1000 / 100 ));
|
||||||
|
//uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
//uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_int16(int16_t x) {
|
||||||
|
if(x <0) uart_putc('-');
|
||||||
|
uart_putc(48 + (x / 10000));
|
||||||
|
uart_putc(48 + (x % 10000 /1000));
|
||||||
|
uart_putc(48 + (x % 1000 / 100 ));
|
||||||
|
uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_uint16(uint16_t x) {
|
||||||
|
uart_putc(48 + (x / 10000));
|
||||||
|
uart_putc(48 + (x % 10000 /1000));
|
||||||
|
uart_putc(48 + (x % 1000 / 100 ));
|
||||||
|
uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef _utils_h
|
||||||
|
#define _utils_h
|
||||||
|
|
||||||
|
extern void wait(uint8_t count);
|
||||||
|
extern void uart_print_voltage(uint16_t);
|
||||||
|
extern void uart_print_int16(int16_t);
|
||||||
|
extern void uart_print_uint16(uint16_t);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,429 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="1771.6534"
|
||||||
|
height="1062.9921"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.48.3.1 r9886"
|
||||||
|
sodipodi:docname="New document 1">
|
||||||
|
<defs
|
||||||
|
id="defs4" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="0.8640935"
|
||||||
|
inkscape:cx="742.99543"
|
||||||
|
inkscape:cy="242.72129"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
units="mm"
|
||||||
|
inkscape:window-width="1600"
|
||||||
|
inkscape:window-height="827"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="25"
|
||||||
|
inkscape:window-maximized="1" />
|
||||||
|
<metadata
|
||||||
|
id="metadata7">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(0,10.630059)">
|
||||||
|
<rect
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.56647122;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="rect2985"
|
||||||
|
width="513.21307"
|
||||||
|
height="249.23668"
|
||||||
|
x="106.58244"
|
||||||
|
y="661.1098" />
|
||||||
|
<rect
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.17761338;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="rect2987"
|
||||||
|
width="1416.1453"
|
||||||
|
height="566.08698"
|
||||||
|
x="0.42110351"
|
||||||
|
y="485.85394" />
|
||||||
|
<rect
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:0.56647122;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="rect2985-3"
|
||||||
|
width="513.21307"
|
||||||
|
height="249.23668"
|
||||||
|
x="797.52734"
|
||||||
|
y="661.1098" />
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
|
||||||
|
x="126.14376"
|
||||||
|
y="603.33655"
|
||||||
|
id="text3007"
|
||||||
|
sodipodi:linespacing="125%"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan3009"
|
||||||
|
x="126.14376"
|
||||||
|
y="603.33655"
|
||||||
|
style="font-size:84px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Stencilia-A;-inkscape-font-specification:Stencilia-A">Erzeugung Verbrauch</tspan></text>
|
||||||
|
<g
|
||||||
|
id="g3164"
|
||||||
|
transform="translate(1.0702335,-35.433062)">
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,1162.5019)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-1"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,1134.1555)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-4-6"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,1105.809)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-6-9"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,1077.4625)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-4-9-1"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,1049.1161)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-2-4"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,1020.7696)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-4-7-6"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,992.42317)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-6-1-3"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,964.07671)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-4-9-9-0"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3164-7"
|
||||||
|
transform="translate(89.652911,-35.433062)">
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,1162.5019)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-1-6"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,1134.1555)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-4-6-6"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,1105.809)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-6-9-8"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,1077.4625)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-4-9-1-4"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,1049.1161)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-2-4-4"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,1020.7696)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-4-7-6-2"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,992.42317)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-6-1-3-4"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<path
|
||||||
|
transform="matrix(-0.2422953,0,0,-0.2422953,705.60389,964.07671)"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
id="path3011-4-9-9-0-5"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3291"
|
||||||
|
transform="translate(327.93307,-4.9099324)">
|
||||||
|
<g
|
||||||
|
id="g3239">
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,72.499105,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-4"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,107.93218,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-6"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,143.36525,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-4-9"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,178.79833,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-2"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,214.23139,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-4-7"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,249.66447,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-6-1"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,285.09754,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-4-9-9"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,320.53062,729.97801)" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g3239-6"
|
||||||
|
transform="translate(283.46457,-9.9047384e-8)">
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-3"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,72.499105,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-4-0"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,107.93218,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-6-92"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,143.36525,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-4-9-94"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,178.79833,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-2-0"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,214.23139,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-4-7-9"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,249.66447,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-6-1-1"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,285.09754,729.97801)" />
|
||||||
|
<path
|
||||||
|
sodipodi:type="arc"
|
||||||
|
style="fill:none;stroke:#000000;stroke-width:1.0629921;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||||
|
id="path3011-4-9-9-7"
|
||||||
|
sodipodi:cx="175.32825"
|
||||||
|
sodipodi:cy="1002.2347"
|
||||||
|
sodipodi:rx="35.297108"
|
||||||
|
sodipodi:ry="35.297108"
|
||||||
|
d="m 210.62535,1002.2347 c 0,19.494 -15.80305,35.2971 -35.2971,35.2971 -19.49406,0 -35.29711,-15.8031 -35.29711,-35.2971 0,-19.49407 15.80305,-35.29713 35.29711,-35.29713 19.49405,0 35.2971,15.80306 35.2971,35.29713 z"
|
||||||
|
transform="matrix(0.2422953,0,0,0.2422953,320.53062,729.97801)" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 23 KiB |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,276 @@
|
||||||
|
# On command line:
|
||||||
|
#
|
||||||
|
# make all = Make software.
|
||||||
|
#
|
||||||
|
# make clean = Clean out built project files.
|
||||||
|
#
|
||||||
|
# make program = Download the hex file to the device, using avrdude. Please
|
||||||
|
# customize the avrdude settings below first!
|
||||||
|
#
|
||||||
|
# To rebuild project do "make clean" then "make all".
|
||||||
|
#
|
||||||
|
|
||||||
|
MCU = atmega8
|
||||||
|
F_CPU = 8000000
|
||||||
|
|
||||||
|
# Output format. (can be srec, ihex, binary)
|
||||||
|
FORMAT = ihex
|
||||||
|
|
||||||
|
# Target file name (without extension).
|
||||||
|
TARGET = main
|
||||||
|
|
||||||
|
SRC = src/$(TARGET).c src/adc.c src/utils.c src/uart.c
|
||||||
|
|
||||||
|
|
||||||
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
|
OPT = s
|
||||||
|
|
||||||
|
|
||||||
|
# List any extra directories to look for include files here.
|
||||||
|
# Each directory must be seperated by a space.
|
||||||
|
EXTRAINCDIRS = src/
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flag to set the C Standard level.
|
||||||
|
# c89 - "ANSI" C
|
||||||
|
# gnu89 - c89 plus GCC extensions
|
||||||
|
# c99 - ISO C99 standard (not yet fully implemented)
|
||||||
|
# gnu99 - c99 plus GCC extensions
|
||||||
|
CSTANDARD = -std=gnu99
|
||||||
|
|
||||||
|
# Place -D or -U options here
|
||||||
|
CDEFS =
|
||||||
|
|
||||||
|
# Place -I options here
|
||||||
|
CINCS =
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flags.
|
||||||
|
# -O*: optimization level
|
||||||
|
# -f...: tuning, see GCC manual and avr-libc documentation
|
||||||
|
# -Wall...: warning level
|
||||||
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
|
# -adhlns...: create assembler listing
|
||||||
|
CFLAGS += $(CDEFS) $(CINCS)
|
||||||
|
CFLAGS += -O$(OPT)
|
||||||
|
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
|
||||||
|
CFLAGS += -Wall -Wstrict-prototypes
|
||||||
|
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
|
||||||
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
CFLAGS += $(CSTANDARD)
|
||||||
|
CFLAGS += -DF_CPU=$(F_CPU) #-DDEBUG
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# External memory options
|
||||||
|
|
||||||
|
|
||||||
|
# Linker flags.
|
||||||
|
# -Wl,...: tell GCC to pass this to linker.
|
||||||
|
# -Map: create map file
|
||||||
|
# --cref: add cross reference to map file
|
||||||
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
|
|
||||||
|
|
||||||
|
# Programming support using avrdude. Settings and variables.
|
||||||
|
AVRDUDE_PROGRAMMER = usbasp
|
||||||
|
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
|
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
||||||
|
|
||||||
|
AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Define programs and commands.
|
||||||
|
SHELL = sh
|
||||||
|
CC = avr-gcc
|
||||||
|
OBJCOPY = avr-objcopy
|
||||||
|
OBJDUMP = avr-objdump
|
||||||
|
SIZE = avr-size
|
||||||
|
NM = avr-nm
|
||||||
|
AVRDUDE = avrdude
|
||||||
|
REMOVE = rm -f
|
||||||
|
COPY = cp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Define Messages
|
||||||
|
# English
|
||||||
|
MSG_ERRORS_NONE = Errors: none
|
||||||
|
MSG_BEGIN = -------- begin --------
|
||||||
|
MSG_END = -------- end --------
|
||||||
|
MSG_SIZE_BEFORE = Size before:
|
||||||
|
MSG_SIZE_AFTER = Size after:
|
||||||
|
MSG_COFF = Converting to AVR COFF:
|
||||||
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
MSG_FLASH = Creating load file for Flash:
|
||||||
|
MSG_EEPROM = Creating load file for EEPROM:
|
||||||
|
MSG_EXTENDED_LISTING = Creating Extended Listing:
|
||||||
|
MSG_SYMBOL_TABLE = Creating Symbol Table:
|
||||||
|
MSG_LINKING = Linking:
|
||||||
|
MSG_COMPILING = Compiling:
|
||||||
|
MSG_ASSEMBLING = Assembling:
|
||||||
|
MSG_CLEANING = Cleaning project:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Define all object files.
|
||||||
|
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
|
||||||
|
|
||||||
|
# Define all listing files.
|
||||||
|
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flags to generate dependency files.
|
||||||
|
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
|
||||||
|
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
|
||||||
|
|
||||||
|
# Combine all necessary flags and optional flags.
|
||||||
|
# Add target processor to flags.
|
||||||
|
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Default target.
|
||||||
|
all: begin gccversion sizebefore build sizeafter finished end
|
||||||
|
|
||||||
|
build: elf hex eep lss sym
|
||||||
|
|
||||||
|
elf: $(TARGET).elf
|
||||||
|
hex: $(TARGET).hex
|
||||||
|
eep: $(TARGET).eep
|
||||||
|
lss: $(TARGET).lss
|
||||||
|
sym: $(TARGET).sym
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Eye candy.
|
||||||
|
# AVR Studio 3.x does not check make's exit code but relies on
|
||||||
|
# the following magic strings to be generated by the compile job.
|
||||||
|
begin:
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_BEGIN)
|
||||||
|
|
||||||
|
finished:
|
||||||
|
@echo $(MSG_ERRORS_NONE)
|
||||||
|
|
||||||
|
end:
|
||||||
|
@echo $(MSG_END)
|
||||||
|
@echo
|
||||||
|
|
||||||
|
|
||||||
|
# Display size of file.
|
||||||
|
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
|
||||||
|
ELFSIZE = $(SIZE) -A $(TARGET).elf
|
||||||
|
sizebefore:
|
||||||
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
sizeafter:
|
||||||
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Display compiler version information.
|
||||||
|
gccversion :
|
||||||
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Program the device.
|
||||||
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
||||||
|
# Create final output files (.hex, .eep) from ELF output file.
|
||||||
|
%.hex: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_FLASH) $@
|
||||||
|
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||||
|
|
||||||
|
%.eep: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_EEPROM) $@
|
||||||
|
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||||
|
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
||||||
|
|
||||||
|
# Create extended listing file from ELF output file.
|
||||||
|
%.lss: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_EXTENDED_LISTING) $@
|
||||||
|
$(OBJDUMP) -h -S $< > $@
|
||||||
|
|
||||||
|
# Create a symbol table from ELF output file.
|
||||||
|
%.sym: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_SYMBOL_TABLE) $@
|
||||||
|
$(NM) -n $< > $@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Link: create ELF output file from object files.
|
||||||
|
.SECONDARY : $(TARGET).elf
|
||||||
|
.PRECIOUS : $(OBJ)
|
||||||
|
%.elf: $(OBJ)
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_LINKING) $@
|
||||||
|
$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create object files from C source files.
|
||||||
|
%.o : %.c
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_COMPILING) $<
|
||||||
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create assembler files from C source files.
|
||||||
|
%.s : %.c
|
||||||
|
$(CC) -S $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
# Assemble: create object files from assembler source files.
|
||||||
|
%.o : %.S
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_ASSEMBLING) $<
|
||||||
|
$(CC) -c $(ALL_ASFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Target: clean project.
|
||||||
|
clean: begin clean_list finished end
|
||||||
|
|
||||||
|
clean_list :
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_CLEANING)
|
||||||
|
$(REMOVE) $(TARGET).hex
|
||||||
|
$(REMOVE) $(TARGET).eep
|
||||||
|
$(REMOVE) $(TARGET).obj
|
||||||
|
$(REMOVE) $(TARGET).cof
|
||||||
|
$(REMOVE) $(TARGET).elf
|
||||||
|
$(REMOVE) $(TARGET).map
|
||||||
|
$(REMOVE) $(TARGET).obj
|
||||||
|
$(REMOVE) $(TARGET).a90
|
||||||
|
$(REMOVE) $(TARGET).sym
|
||||||
|
$(REMOVE) $(TARGET).lnk
|
||||||
|
$(REMOVE) $(TARGET).lss
|
||||||
|
$(REMOVE) $(OBJ)
|
||||||
|
$(REMOVE) $(LST)
|
||||||
|
$(REMOVE) $(SRC:.c=.s)
|
||||||
|
$(REMOVE) $(SRC:.c=.d)
|
||||||
|
$(REMOVE) .dep/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Include the dependency files.
|
||||||
|
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
||||||
|
|
||||||
|
|
||||||
|
# Listing of phony targets.
|
||||||
|
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
||||||
|
build elf hex eep lss sym coff extcoff \
|
||||||
|
clean clean_list program
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
|
||||||
|
void adc_init(void) {
|
||||||
|
uint16_t dummyResult;
|
||||||
|
// AVCC with external capacitor at AREF pin
|
||||||
|
ADMUX = _BV(REFS0);
|
||||||
|
|
||||||
|
// set frequency prescaler to 8
|
||||||
|
ADCSRA = _BV(ADPS1) | _BV(ADPS0);
|
||||||
|
|
||||||
|
// enable ADC
|
||||||
|
ADCSRA |= _BV(ADEN);
|
||||||
|
|
||||||
|
// make a dummy read out
|
||||||
|
ADCSRA |= _BV(ADSC);
|
||||||
|
while (ADCSRA & _BV(ADSC) ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// we have to read, otherwise the next result is not available
|
||||||
|
dummyResult = ADCW;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t adc_read_single(uint8_t channel) {
|
||||||
|
ADMUX = (ADMUX & ~(0x1F)) | (channel & 0x1F);
|
||||||
|
ADCSRA |= _BV(ADSC);
|
||||||
|
while (ADCSRA & (1<<ADSC) ) {
|
||||||
|
}
|
||||||
|
return ADCW;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t adc_read_avg(const uint8_t channel, const uint8_t nsamples) {
|
||||||
|
uint16_t sum = 0;
|
||||||
|
uint8_t count = nsamples % 60;
|
||||||
|
|
||||||
|
for (uint8_t i=0; i<count;++i ) {
|
||||||
|
sum += adc_read_single(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (sum / count);
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef _adc_h
|
||||||
|
#define _adc_h
|
||||||
|
|
||||||
|
extern void adc_init(void);
|
||||||
|
extern uint16_t adc_read_single(uint8_t);
|
||||||
|
extern uint16_t adc_read_avg(uint8_t, uint8_t);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,232 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "utils.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "adc.h"
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
volatile uint16_t syscounter = 0;
|
||||||
|
uint16_t voltage = 0;
|
||||||
|
uint16_t current_in = 0;
|
||||||
|
uint16_t current_out = 0;
|
||||||
|
|
||||||
|
uint8_t overvoltage_counter1 = 0;
|
||||||
|
uint8_t overvoltage_off_counter1 = 0;
|
||||||
|
uint8_t overvoltage_counter2 = 0;
|
||||||
|
uint8_t overvoltage_off_counter2 = 0;
|
||||||
|
uint8_t undervoltage_counter = 0;
|
||||||
|
uint8_t undervoltage_off_counter = 0;
|
||||||
|
|
||||||
|
|
||||||
|
static void timer_init(void) {
|
||||||
|
// clock is 8MHz
|
||||||
|
TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10) ; // CTC Mode for Timer 1 (16Bit) with prescale of 64
|
||||||
|
OCR1A = 1250; // 100Hz
|
||||||
|
TIMSK = _BV(OCIE1A);
|
||||||
|
sei(); // enable interrupts
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ports_init(void) {
|
||||||
|
DDR_SW |= _BV(LOADSW) | _BV(GENSW) | _BV(DUMPSW);
|
||||||
|
PORT_SW &= ~(_BV(LOADSW) | _BV(GENSW) | _BV(DUMPSW));
|
||||||
|
}
|
||||||
|
|
||||||
|
void measure(void) {
|
||||||
|
static int16_t temp;
|
||||||
|
|
||||||
|
voltage = adc_read_avg(AD_V, 4);
|
||||||
|
voltage *= VOLTAGE_PER_TICK;
|
||||||
|
|
||||||
|
temp = adc_read_avg(AD_I_GEN, 4);
|
||||||
|
temp -= CURRENT_OFFSET;
|
||||||
|
if(temp < 0) temp = 0;
|
||||||
|
current_in = temp * CURRENT_PER_TICK;
|
||||||
|
|
||||||
|
temp = adc_read_avg(AD_I_LOAD, 4);
|
||||||
|
temp -= CURRENT_OFFSET;
|
||||||
|
if(temp < 0) temp = 0;
|
||||||
|
current_out = temp * CURRENT_PER_TICK;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t get_power(uint16_t voltage, int16_t currents) {
|
||||||
|
return (voltage/100 * (currents/100)) / 100 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void pretty_print_all_values(void) {
|
||||||
|
uart_puts_P("Voltage: ");
|
||||||
|
uart_print_uint16(voltage);
|
||||||
|
uart_puts_P("mV\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("Load: ");
|
||||||
|
uart_print_uint16(current_out);
|
||||||
|
uart_puts_P("mA ");
|
||||||
|
uart_print_uint16( get_power(voltage, current_out));
|
||||||
|
uart_puts_P("W\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("Generator: ");
|
||||||
|
uart_print_uint16(current_in);
|
||||||
|
uart_puts_P("mA ");
|
||||||
|
uart_print_uint16(get_power(voltage, current_in));
|
||||||
|
uart_puts_P("W\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("switches (load, dump, gen): ");
|
||||||
|
uart_putc(48 + (IS_LOAD_ON >> LOADSW));
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48 + (IS_DUMP_ON >> DUMPSW));
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48 + (IS_GEN_ON >> GENSW));
|
||||||
|
uart_puts_P("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_over_and_undervoltage(void) {
|
||||||
|
if(voltage > OVERVOLTAGE1) {
|
||||||
|
overvoltage_off_counter1 = 0;
|
||||||
|
if(overvoltage_counter1<OVERVOLTAGE_TIMEOUT1) overvoltage_counter1++;
|
||||||
|
} else {
|
||||||
|
overvoltage_counter1 = 0;
|
||||||
|
if(overvoltage_off_counter1<OVERVOLTAGEOFF_TIMEOUT1) overvoltage_off_counter1++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(voltage > OVERVOLTAGE2) {
|
||||||
|
overvoltage_off_counter2 = 0;
|
||||||
|
if(overvoltage_counter2<OVERVOLTAGE_TIMEOUT2) overvoltage_counter2++;
|
||||||
|
} else {
|
||||||
|
overvoltage_counter2 = 0;
|
||||||
|
if(overvoltage_off_counter2<OVERVOLTAGEOFF_TIMEOUT2) overvoltage_off_counter2++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(voltage < UNDERVOLTAGE) {
|
||||||
|
undervoltage_off_counter = 0;
|
||||||
|
if(undervoltage_counter<UNDERVOLTAGE_TIMEOUT) undervoltage_counter++;
|
||||||
|
} else {
|
||||||
|
undervoltage_counter = 0;
|
||||||
|
if(undervoltage_off_counter<UNDERVOLTAGEOFF_TIMEOUT) undervoltage_off_counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(overvoltage_counter1 >= OVERVOLTAGE_TIMEOUT1) {
|
||||||
|
overvoltage_off_counter1 = 0;
|
||||||
|
DUMP_ON;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(overvoltage_off_counter1 >= OVERVOLTAGEOFF_TIMEOUT1) {
|
||||||
|
overvoltage_counter1 = 0;
|
||||||
|
DUMP_OFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(overvoltage_counter2 >= OVERVOLTAGE_TIMEOUT2) {
|
||||||
|
overvoltage_off_counter2 = 0;
|
||||||
|
GEN_OFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(overvoltage_off_counter2 >= OVERVOLTAGEOFF_TIMEOUT2) {
|
||||||
|
overvoltage_counter2 = 0;
|
||||||
|
GEN_ON;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(undervoltage_counter >= UNDERVOLTAGE_TIMEOUT) {
|
||||||
|
undervoltage_off_counter = 0;
|
||||||
|
overvoltage_off_counter1 = OVERVOLTAGEOFF_TIMEOUT1;
|
||||||
|
LOAD_OFF;
|
||||||
|
DUMP_OFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(undervoltage_off_counter >= UNDERVOLTAGEOFF_TIMEOUT) {
|
||||||
|
undervoltage_counter = 0;
|
||||||
|
LOAD_ON;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
uart_puts_P("ov1=");
|
||||||
|
uart_print_uint8(overvoltage_counter1);
|
||||||
|
uart_puts_P(" ovo1=");
|
||||||
|
uart_print_uint8 (overvoltage_off_counter1);
|
||||||
|
uart_puts_P("\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("ov2=");
|
||||||
|
uart_print_uint8(overvoltage_counter2);
|
||||||
|
uart_puts_P(" ovo2=");
|
||||||
|
uart_print_uint8 (overvoltage_off_counter2);
|
||||||
|
uart_puts_P("\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("uv =");
|
||||||
|
uart_print_uint8(undervoltage_counter);
|
||||||
|
uart_puts_P(" uvo =");
|
||||||
|
uart_print_uint8(undervoltage_off_counter);
|
||||||
|
uart_puts_P("\r\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void work_uart(void) {
|
||||||
|
uint16_t uart_char = uart_getc();
|
||||||
|
|
||||||
|
if(uart_char != UART_NO_DATA) {
|
||||||
|
switch(uart_char & 0xff) {
|
||||||
|
case 'p':
|
||||||
|
pretty_print_all_values();
|
||||||
|
break;
|
||||||
|
case 'a':
|
||||||
|
uart_putc('A');
|
||||||
|
uart_print_uint16(voltage);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_print_uint16(current_in);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_print_uint16(current_out);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_print_uint16(get_power(voltage, current_in));
|
||||||
|
uart_putc(',');
|
||||||
|
uart_print_uint16(get_power(voltage, current_out));
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48 + (IS_LOAD_ON >> LOADSW));
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48 + (IS_DUMP_ON >> DUMPSW));
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48 + (IS_GEN_ON >> GENSW));
|
||||||
|
uart_putc('B');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
ports_init();
|
||||||
|
adc_init();
|
||||||
|
timer_init();
|
||||||
|
uart_init(UART_BAUD_SELECT(19200,F_CPU));
|
||||||
|
|
||||||
|
LOAD_OFF;
|
||||||
|
GEN_ON;
|
||||||
|
DUMP_OFF;
|
||||||
|
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
|
||||||
|
if(syscounter >= 100) {
|
||||||
|
syscounter = 0;
|
||||||
|
|
||||||
|
measure();
|
||||||
|
|
||||||
|
//pretty_print_all_values();
|
||||||
|
|
||||||
|
handle_over_and_undervoltage();
|
||||||
|
}
|
||||||
|
|
||||||
|
work_uart();
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// system timer
|
||||||
|
SIGNAL(TIMER1_COMPA_vect) {
|
||||||
|
syscounter++;
|
||||||
|
syscounter %= 60000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
#ifndef _main_h
|
||||||
|
#define _main_h
|
||||||
|
|
||||||
|
#define AD_I_LOAD 0
|
||||||
|
#define AD_I_GEN 1
|
||||||
|
#define AD_V 2
|
||||||
|
|
||||||
|
#define LOADSW PB0
|
||||||
|
#define GENSW PB1
|
||||||
|
#define DUMPSW PB2
|
||||||
|
#define PORT_SW PORTB
|
||||||
|
#define DDR_SW DDRB
|
||||||
|
#define PIN_SW PINB
|
||||||
|
|
||||||
|
#define LOAD_ON PORT_SW |= _BV(LOADSW)
|
||||||
|
#define LOAD_OFF PORT_SW &= ~_BV(LOADSW)
|
||||||
|
#define GEN_ON PORT_SW |= _BV(GENSW)
|
||||||
|
#define GEN_OFF PORT_SW &= ~_BV(GENSW)
|
||||||
|
#define DUMP_ON PORT_SW |= _BV(DUMPSW)
|
||||||
|
#define DUMP_OFF PORT_SW &= ~_BV(DUMPSW)
|
||||||
|
|
||||||
|
#define IS_LOAD_ON (PIN_SW & _BV(LOADSW))
|
||||||
|
#define IS_DUMP_ON (PIN_SW & _BV(DUMPSW))
|
||||||
|
#define IS_GEN_ON (PIN_SW & _BV(GENSW))
|
||||||
|
|
||||||
|
#define UNDERVOLTAGE 11200
|
||||||
|
#define OVERVOLTAGE1 15000
|
||||||
|
#define OVERVOLTAGE2 16500
|
||||||
|
#define OVERVOLTAGE_TIMEOUT1 8
|
||||||
|
#define OVERVOLTAGEOFF_TIMEOUT1 1
|
||||||
|
#define OVERVOLTAGE_TIMEOUT2 6
|
||||||
|
#define OVERVOLTAGEOFF_TIMEOUT2 3
|
||||||
|
#define UNDERVOLTAGE_TIMEOUT 5
|
||||||
|
#define UNDERVOLTAGEOFF_TIMEOUT 2
|
||||||
|
|
||||||
|
#define CURRENT_OFFSET 511
|
||||||
|
#define CURRENT_PER_TICK 72
|
||||||
|
#define VOLTAGE_PER_TICK 15.5
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,663 @@
|
||||||
|
/*************************************************************************
|
||||||
|
Title: Interrupt UART library with receive/transmit circular buffers
|
||||||
|
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
|
||||||
|
File: $Id: uart.c,v 1.10 2013/06/02 07:27:04 peter Exp $
|
||||||
|
Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher
|
||||||
|
Hardware: any AVR with built-in UART,
|
||||||
|
License: GNU General Public License
|
||||||
|
|
||||||
|
DESCRIPTION:
|
||||||
|
An interrupt is generated when the UART has finished transmitting or
|
||||||
|
receiving a byte. The interrupt handling routines use circular buffers
|
||||||
|
for buffering received and transmitted data.
|
||||||
|
|
||||||
|
The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE variables define
|
||||||
|
the buffer size in bytes. Note that these variables must be a
|
||||||
|
power of 2.
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
Refere to the header file uart.h for a description of the routines.
|
||||||
|
See also example test_uart.c.
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
Based on Atmel Application Note AVR306
|
||||||
|
|
||||||
|
LICENSE:
|
||||||
|
Copyright (C) 2006 Peter Fleury
|
||||||
|
|
||||||
|
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, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
*************************************************************************/
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* constants and macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* size of RX/TX buffers */
|
||||||
|
#define UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1)
|
||||||
|
#define UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1)
|
||||||
|
|
||||||
|
#if ( UART_RX_BUFFER_SIZE & UART_RX_BUFFER_MASK )
|
||||||
|
#error RX buffer size is not a power of 2
|
||||||
|
#endif
|
||||||
|
#if ( UART_TX_BUFFER_SIZE & UART_TX_BUFFER_MASK )
|
||||||
|
#error TX buffer size is not a power of 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__AVR_AT90S2313__) \
|
||||||
|
|| defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \
|
||||||
|
|| defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \
|
||||||
|
|| defined(__AVR_ATmega103__)
|
||||||
|
/* old AVR classic or ATmega103 with one UART */
|
||||||
|
#define AT90_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS USR
|
||||||
|
#define UART0_CONTROL UCR
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__)
|
||||||
|
/* old AVR classic with one UART */
|
||||||
|
#define AT90_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \
|
||||||
|
|| defined(__AVR_ATmega323__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RXC_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__)
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega163__)
|
||||||
|
/* ATmega163 with one UART */
|
||||||
|
#define ATMEGA_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega162__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RXC_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RXC_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega161__)
|
||||||
|
/* ATmega with UART */
|
||||||
|
#error "AVR ATmega161 currently not supported by this libaray !"
|
||||||
|
#elif defined(__AVR_ATmega169__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \
|
||||||
|
|| defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATtiny2313__)
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega329__) || \
|
||||||
|
defined(__AVR_ATmega649__) || \
|
||||||
|
defined(__AVR_ATmega325__) || \
|
||||||
|
defined(__AVR_ATmega645__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega644__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#else
|
||||||
|
#error "no UART definition for MCU available"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* module global variables
|
||||||
|
*/
|
||||||
|
static volatile unsigned char UART_TxBuf[UART_TX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART_RxBuf[UART_RX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART_TxHead;
|
||||||
|
static volatile unsigned char UART_TxTail;
|
||||||
|
static volatile unsigned char UART_RxHead;
|
||||||
|
static volatile unsigned char UART_RxTail;
|
||||||
|
static volatile unsigned char UART_LastRxError;
|
||||||
|
|
||||||
|
#if defined( ATMEGA_USART1 )
|
||||||
|
static volatile unsigned char UART1_TxBuf[UART_TX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART1_RxBuf[UART_RX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART1_TxHead;
|
||||||
|
static volatile unsigned char UART1_TxTail;
|
||||||
|
static volatile unsigned char UART1_RxHead;
|
||||||
|
static volatile unsigned char UART1_RxTail;
|
||||||
|
static volatile unsigned char UART1_LastRxError;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ISR (UART0_RECEIVE_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART Receive Complete interrupt
|
||||||
|
Purpose: called when the UART has received a character
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
unsigned char data;
|
||||||
|
unsigned char usr;
|
||||||
|
unsigned char lastRxError;
|
||||||
|
|
||||||
|
|
||||||
|
/* read UART status register and UART data register */
|
||||||
|
usr = UART0_STATUS;
|
||||||
|
data = UART0_DATA;
|
||||||
|
|
||||||
|
/* */
|
||||||
|
#if defined( AT90_UART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#elif defined( ATMEGA_USART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#elif defined( ATMEGA_USART0 )
|
||||||
|
lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) );
|
||||||
|
#elif defined ( ATMEGA_UART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* calculate buffer index */
|
||||||
|
tmphead = ( UART_RxHead + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
|
||||||
|
if ( tmphead == UART_RxTail ) {
|
||||||
|
/* error: receive buffer overflow */
|
||||||
|
lastRxError = UART_BUFFER_OVERFLOW >> 8;
|
||||||
|
}else{
|
||||||
|
/* store new index */
|
||||||
|
UART_RxHead = tmphead;
|
||||||
|
/* store received data in buffer */
|
||||||
|
UART_RxBuf[tmphead] = data;
|
||||||
|
}
|
||||||
|
UART_LastRxError |= lastRxError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ISR (UART0_TRANSMIT_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART Data Register Empty interrupt
|
||||||
|
Purpose: called when the UART is ready to transmit the next byte
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART_TxHead != UART_TxTail) {
|
||||||
|
/* calculate and store new buffer index */
|
||||||
|
tmptail = (UART_TxTail + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
UART_TxTail = tmptail;
|
||||||
|
/* get one byte from buffer and write it to UART */
|
||||||
|
UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */
|
||||||
|
}else{
|
||||||
|
/* tx buffer empty, disable UDRE interrupt */
|
||||||
|
UART0_CONTROL &= ~_BV(UART0_UDRIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_init()
|
||||||
|
Purpose: initialize UART and set baudrate
|
||||||
|
Input: baudrate using macro UART_BAUD_SELECT()
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_init(unsigned int baudrate)
|
||||||
|
{
|
||||||
|
UART_TxHead = 0;
|
||||||
|
UART_TxTail = 0;
|
||||||
|
UART_RxHead = 0;
|
||||||
|
UART_RxTail = 0;
|
||||||
|
|
||||||
|
#if defined( AT90_UART )
|
||||||
|
/* set baud rate */
|
||||||
|
UBRR = (unsigned char)baudrate;
|
||||||
|
|
||||||
|
/* enable UART receiver and transmmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN);
|
||||||
|
|
||||||
|
#elif defined (ATMEGA_USART)
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRRH = (unsigned char)(baudrate>>8);
|
||||||
|
UBRRL = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|(1<<RXEN)|(1<<TXEN);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL
|
||||||
|
UCSRC = (1<<URSEL)|(3<<UCSZ0);
|
||||||
|
#else
|
||||||
|
UCSRC = (3<<UCSZ0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined (ATMEGA_USART0 )
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X0); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRR0H = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR0L = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE0)|(1<<RXEN0)|(1<<TXEN0);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL0
|
||||||
|
UCSR0C = (1<<URSEL0)|(3<<UCSZ00);
|
||||||
|
#else
|
||||||
|
UCSR0C = (3<<UCSZ00);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( ATMEGA_UART )
|
||||||
|
/* set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRRHI = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable UART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|(1<<RXEN)|(1<<TXEN);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}/* uart_init */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_getc()
|
||||||
|
Purpose: return byte from ringbuffer
|
||||||
|
Returns: lower byte: received byte from ringbuffer
|
||||||
|
higher byte: last receive error
|
||||||
|
**************************************************************************/
|
||||||
|
unsigned int uart_getc(void)
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
unsigned char data;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART_RxHead == UART_RxTail ) {
|
||||||
|
return UART_NO_DATA; /* no data available */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate /store buffer index */
|
||||||
|
tmptail = (UART_RxTail + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
UART_RxTail = tmptail;
|
||||||
|
|
||||||
|
/* get data from receive buffer */
|
||||||
|
data = UART_RxBuf[tmptail];
|
||||||
|
|
||||||
|
data = (UART_LastRxError << 8) + data;
|
||||||
|
UART_LastRxError = 0;
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}/* uart_getc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_putc()
|
||||||
|
Purpose: write byte to ringbuffer for transmitting via UART
|
||||||
|
Input: byte to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_putc(unsigned char data)
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
|
||||||
|
|
||||||
|
tmphead = (UART_TxHead + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
|
||||||
|
while ( tmphead == UART_TxTail ){
|
||||||
|
;/* wait for free space in buffer */
|
||||||
|
}
|
||||||
|
|
||||||
|
UART_TxBuf[tmphead] = data;
|
||||||
|
UART_TxHead = tmphead;
|
||||||
|
|
||||||
|
/* enable UDRE interrupt */
|
||||||
|
UART0_CONTROL |= _BV(UART0_UDRIE);
|
||||||
|
|
||||||
|
}/* uart_putc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_puts()
|
||||||
|
Purpose: transmit string to UART
|
||||||
|
Input: string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_puts(const char *s )
|
||||||
|
{
|
||||||
|
while (*s)
|
||||||
|
uart_putc(*s++);
|
||||||
|
|
||||||
|
}/* uart_puts */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_puts_p()
|
||||||
|
Purpose: transmit string from program memory to UART
|
||||||
|
Input: program memory string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_puts_p(const char *progmem_s )
|
||||||
|
{
|
||||||
|
register char c;
|
||||||
|
|
||||||
|
while ( (c = pgm_read_byte(progmem_s++)) )
|
||||||
|
uart_putc(c);
|
||||||
|
|
||||||
|
}/* uart_puts_p */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* these functions are only for ATmegas with two USART
|
||||||
|
*/
|
||||||
|
#if defined( ATMEGA_USART1 )
|
||||||
|
|
||||||
|
ISR(UART1_RECEIVE_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART1 Receive Complete interrupt
|
||||||
|
Purpose: called when the UART1 has received a character
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
unsigned char data;
|
||||||
|
unsigned char usr;
|
||||||
|
unsigned char lastRxError;
|
||||||
|
|
||||||
|
|
||||||
|
/* read UART status register and UART data register */
|
||||||
|
usr = UART1_STATUS;
|
||||||
|
data = UART1_DATA;
|
||||||
|
|
||||||
|
/* */
|
||||||
|
lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) );
|
||||||
|
|
||||||
|
/* calculate buffer index */
|
||||||
|
tmphead = ( UART1_RxHead + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
|
||||||
|
if ( tmphead == UART1_RxTail ) {
|
||||||
|
/* error: receive buffer overflow */
|
||||||
|
lastRxError = UART_BUFFER_OVERFLOW >> 8;
|
||||||
|
}else{
|
||||||
|
/* store new index */
|
||||||
|
UART1_RxHead = tmphead;
|
||||||
|
/* store received data in buffer */
|
||||||
|
UART1_RxBuf[tmphead] = data;
|
||||||
|
}
|
||||||
|
UART1_LastRxError |= lastRxError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ISR(UART1_TRANSMIT_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART1 Data Register Empty interrupt
|
||||||
|
Purpose: called when the UART1 is ready to transmit the next byte
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART1_TxHead != UART1_TxTail) {
|
||||||
|
/* calculate and store new buffer index */
|
||||||
|
tmptail = (UART1_TxTail + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
UART1_TxTail = tmptail;
|
||||||
|
/* get one byte from buffer and write it to UART */
|
||||||
|
UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */
|
||||||
|
}else{
|
||||||
|
/* tx buffer empty, disable UDRE interrupt */
|
||||||
|
UART1_CONTROL &= ~_BV(UART1_UDRIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_init()
|
||||||
|
Purpose: initialize UART1 and set baudrate
|
||||||
|
Input: baudrate using macro UART_BAUD_SELECT()
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart1_init(unsigned int baudrate)
|
||||||
|
{
|
||||||
|
UART1_TxHead = 0;
|
||||||
|
UART1_TxTail = 0;
|
||||||
|
UART1_RxHead = 0;
|
||||||
|
UART1_RxTail = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART1_STATUS = (1<<U2X1); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRR1H = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR1L = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART1_CONTROL = _BV(RXCIE1)|(1<<RXEN1)|(1<<TXEN1);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL1
|
||||||
|
UCSR1C = (1<<URSEL1)|(3<<UCSZ10);
|
||||||
|
#else
|
||||||
|
UCSR1C = (3<<UCSZ10);
|
||||||
|
#endif
|
||||||
|
}/* uart_init */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_getc()
|
||||||
|
Purpose: return byte from ringbuffer
|
||||||
|
Returns: lower byte: received byte from ringbuffer
|
||||||
|
higher byte: last receive error
|
||||||
|
**************************************************************************/
|
||||||
|
unsigned int uart1_getc(void)
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
unsigned char data;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART1_RxHead == UART1_RxTail ) {
|
||||||
|
return UART_NO_DATA; /* no data available */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate /store buffer index */
|
||||||
|
tmptail = (UART1_RxTail + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
UART1_RxTail = tmptail;
|
||||||
|
|
||||||
|
/* get data from receive buffer */
|
||||||
|
data = UART1_RxBuf[tmptail];
|
||||||
|
|
||||||
|
data = (UART1_LastRxError << 8) + data;
|
||||||
|
UART1_LastRxError = 0;
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}/* uart1_getc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_putc()
|
||||||
|
Purpose: write byte to ringbuffer for transmitting via UART
|
||||||
|
Input: byte to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart1_putc(unsigned char data)
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
|
||||||
|
|
||||||
|
tmphead = (UART1_TxHead + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
|
||||||
|
while ( tmphead == UART1_TxTail ){
|
||||||
|
;/* wait for free space in buffer */
|
||||||
|
}
|
||||||
|
|
||||||
|
UART1_TxBuf[tmphead] = data;
|
||||||
|
UART1_TxHead = tmphead;
|
||||||
|
|
||||||
|
/* enable UDRE interrupt */
|
||||||
|
UART1_CONTROL |= _BV(UART1_UDRIE);
|
||||||
|
|
||||||
|
}/* uart1_putc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_puts()
|
||||||
|
Purpose: transmit string to UART1
|
||||||
|
Input: string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart1_puts(const char *s )
|
||||||
|
{
|
||||||
|
while (*s)
|
||||||
|
uart1_putc(*s++);
|
||||||
|
|
||||||
|
}/* uart1_puts */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_puts_p()
|
||||||
|
Purpose: transmit string from program memory to UART1
|
||||||
|
Input: program memory string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart1_puts_p(const char *progmem_s )
|
||||||
|
{
|
||||||
|
register char c;
|
||||||
|
|
||||||
|
while ( (c = pgm_read_byte(progmem_s++)) )
|
||||||
|
uart1_putc(c);
|
||||||
|
|
||||||
|
}/* uart1_puts_p */
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,180 @@
|
||||||
|
#ifndef UART_H
|
||||||
|
#define UART_H
|
||||||
|
/************************************************************************
|
||||||
|
Title: Interrupt UART library with receive/transmit circular buffers
|
||||||
|
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
|
||||||
|
File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $
|
||||||
|
Software: AVR-GCC 4.1, AVR Libc 1.4
|
||||||
|
Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz
|
||||||
|
License: GNU General Public License
|
||||||
|
Usage: see Doxygen manual
|
||||||
|
|
||||||
|
LICENSE:
|
||||||
|
Copyright (C) 2006 Peter Fleury
|
||||||
|
|
||||||
|
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, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup pfleury_uart UART Library
|
||||||
|
* @code #include <uart.h> @endcode
|
||||||
|
*
|
||||||
|
* @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers.
|
||||||
|
*
|
||||||
|
* This library can be used to transmit and receive data through the built in UART.
|
||||||
|
*
|
||||||
|
* An interrupt is generated when the UART has finished transmitting or
|
||||||
|
* receiving a byte. The interrupt handling routines use circular buffers
|
||||||
|
* for buffering received and transmitted data.
|
||||||
|
*
|
||||||
|
* The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE constants define
|
||||||
|
* the size of the circular buffers in bytes. Note that these constants must be a power of 2.
|
||||||
|
* You may need to adapt this constants to your target and your application by adding
|
||||||
|
* CDEFS += -DUART_RX_BUFFER_SIZE=nn -DUART_RX_BUFFER_SIZE=nn to your Makefile.
|
||||||
|
*
|
||||||
|
* @note Based on Atmel Application Note AVR306
|
||||||
|
* @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**@{*/
|
||||||
|
|
||||||
|
|
||||||
|
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304
|
||||||
|
#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** constants and macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @brief UART Baudrate Expression
|
||||||
|
* @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
||||||
|
* @param baudrate baudrate in bps, e.g. 1200, 2400, 9600
|
||||||
|
*/
|
||||||
|
#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL)
|
||||||
|
|
||||||
|
/** @brief UART Baudrate Expression for ATmega double speed mode
|
||||||
|
* @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
||||||
|
* @param baudrate baudrate in bps, e.g. 1200, 2400, 9600
|
||||||
|
*/
|
||||||
|
#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000)
|
||||||
|
|
||||||
|
|
||||||
|
/** Size of the circular receive buffer, must be power of 2 */
|
||||||
|
#ifndef UART_RX_BUFFER_SIZE
|
||||||
|
#define UART_RX_BUFFER_SIZE 32
|
||||||
|
#endif
|
||||||
|
/** Size of the circular transmit buffer, must be power of 2 */
|
||||||
|
#ifndef UART_TX_BUFFER_SIZE
|
||||||
|
#define UART_TX_BUFFER_SIZE 32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* test if the size of the circular buffers fits into SRAM */
|
||||||
|
#if ( (UART_RX_BUFFER_SIZE+UART_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) )
|
||||||
|
#error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** high byte error return code of uart_getc()
|
||||||
|
*/
|
||||||
|
#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */
|
||||||
|
#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */
|
||||||
|
#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */
|
||||||
|
#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */
|
||||||
|
#define UART_NO_DATA 0x0100 /* no receive data available */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** function prototypes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Initialize UART and set baudrate
|
||||||
|
@param baudrate Specify baudrate using macro UART_BAUD_SELECT()
|
||||||
|
@return none
|
||||||
|
*/
|
||||||
|
extern void uart_init(unsigned int baudrate);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get received byte from ringbuffer
|
||||||
|
*
|
||||||
|
* Returns in the lower byte the received character and in the
|
||||||
|
* higher byte the last receive error.
|
||||||
|
* UART_NO_DATA is returned when no data is available.
|
||||||
|
*
|
||||||
|
* @param void
|
||||||
|
* @return lower byte: received byte from ringbuffer
|
||||||
|
* @return higher byte: last receive status
|
||||||
|
* - \b 0 successfully received data from UART
|
||||||
|
* - \b UART_NO_DATA
|
||||||
|
* <br>no receive data available
|
||||||
|
* - \b UART_BUFFER_OVERFLOW
|
||||||
|
* <br>Receive ringbuffer overflow.
|
||||||
|
* We are not reading the receive buffer fast enough,
|
||||||
|
* one or more received character have been dropped
|
||||||
|
* - \b UART_OVERRUN_ERROR
|
||||||
|
* <br>Overrun condition by UART.
|
||||||
|
* A character already present in the UART UDR register was
|
||||||
|
* not read by the interrupt handler before the next character arrived,
|
||||||
|
* one or more received characters have been dropped.
|
||||||
|
* - \b UART_FRAME_ERROR
|
||||||
|
* <br>Framing Error by UART
|
||||||
|
*/
|
||||||
|
extern unsigned int uart_getc(void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put byte to ringbuffer for transmitting via UART
|
||||||
|
* @param data byte to be transmitted
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
extern void uart_putc(unsigned char data);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put string to ringbuffer for transmitting via UART
|
||||||
|
*
|
||||||
|
* The string is buffered by the uart library in a circular buffer
|
||||||
|
* and one character at a time is transmitted to the UART using interrupts.
|
||||||
|
* Blocks if it can not write the whole string into the circular buffer.
|
||||||
|
*
|
||||||
|
* @param s string to be transmitted
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
extern void uart_puts(const char *s );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put string from program memory to ringbuffer for transmitting via UART.
|
||||||
|
*
|
||||||
|
* The string is buffered by the uart library in a circular buffer
|
||||||
|
* and one character at a time is transmitted to the UART using interrupts.
|
||||||
|
* Blocks if it can not write the whole string into the circular buffer.
|
||||||
|
*
|
||||||
|
* @param s program memory string to be transmitted
|
||||||
|
* @return none
|
||||||
|
* @see uart_puts_P
|
||||||
|
*/
|
||||||
|
extern void uart_puts_p(const char *s );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Macro to automatically put a string constant into program memory
|
||||||
|
*/
|
||||||
|
#define uart_puts_P(__s) uart_puts_p(PSTR(__s))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // UART_H
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
void wait(uint8_t count) {
|
||||||
|
uint8_t i;
|
||||||
|
if(count == 0) count = 100;
|
||||||
|
for(i=0;i<count;i++) {
|
||||||
|
_delay_ms(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_voltage(uint16_t x) {
|
||||||
|
uart_putc(48 + (x / 10000));
|
||||||
|
uart_putc(48 + (x % 10000 /1000));
|
||||||
|
uart_putc('.');
|
||||||
|
uart_putc(48 + (x % 1000 / 100 ));
|
||||||
|
//uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
//uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_uint8(uint8_t x) {
|
||||||
|
uart_putc(48 + (x / 100 ));
|
||||||
|
uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_uint16(uint16_t x) {
|
||||||
|
uart_putc(48 + (x / 10000));
|
||||||
|
uart_putc(48 + (x % 10000 /1000));
|
||||||
|
uart_putc(48 + (x % 1000 / 100 ));
|
||||||
|
uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef _utils_h
|
||||||
|
#define _utils_h
|
||||||
|
|
||||||
|
extern void wait(uint8_t count);
|
||||||
|
extern void uart_print_voltage(uint16_t);
|
||||||
|
extern void uart_print_uint8_t(uint8_t);
|
||||||
|
extern void uart_print_uint16(uint16_t);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,276 @@
|
||||||
|
# On command line:
|
||||||
|
#
|
||||||
|
# make all = Make software.
|
||||||
|
#
|
||||||
|
# make clean = Clean out built project files.
|
||||||
|
#
|
||||||
|
# make program = Download the hex file to the device, using avrdude. Please
|
||||||
|
# customize the avrdude settings below first!
|
||||||
|
#
|
||||||
|
# To rebuild project do "make clean" then "make all".
|
||||||
|
#
|
||||||
|
|
||||||
|
MCU = atmega8
|
||||||
|
F_CPU = 8000000
|
||||||
|
|
||||||
|
# Output format. (can be srec, ihex, binary)
|
||||||
|
FORMAT = ihex
|
||||||
|
|
||||||
|
# Target file name (without extension).
|
||||||
|
TARGET = main
|
||||||
|
|
||||||
|
SRC = src/$(TARGET).c src/adc.c src/utils.c src/uart.c
|
||||||
|
|
||||||
|
|
||||||
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
|
OPT = s
|
||||||
|
|
||||||
|
|
||||||
|
# List any extra directories to look for include files here.
|
||||||
|
# Each directory must be seperated by a space.
|
||||||
|
EXTRAINCDIRS = src/
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flag to set the C Standard level.
|
||||||
|
# c89 - "ANSI" C
|
||||||
|
# gnu89 - c89 plus GCC extensions
|
||||||
|
# c99 - ISO C99 standard (not yet fully implemented)
|
||||||
|
# gnu99 - c99 plus GCC extensions
|
||||||
|
CSTANDARD = -std=gnu99
|
||||||
|
|
||||||
|
# Place -D or -U options here
|
||||||
|
CDEFS =
|
||||||
|
|
||||||
|
# Place -I options here
|
||||||
|
CINCS =
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flags.
|
||||||
|
# -O*: optimization level
|
||||||
|
# -f...: tuning, see GCC manual and avr-libc documentation
|
||||||
|
# -Wall...: warning level
|
||||||
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
|
# -adhlns...: create assembler listing
|
||||||
|
CFLAGS += $(CDEFS) $(CINCS)
|
||||||
|
CFLAGS += -O$(OPT)
|
||||||
|
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
|
||||||
|
CFLAGS += -Wall -Wstrict-prototypes
|
||||||
|
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
|
||||||
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
CFLAGS += $(CSTANDARD)
|
||||||
|
CFLAGS += -DF_CPU=$(F_CPU) #-DDEBUG
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# External memory options
|
||||||
|
|
||||||
|
|
||||||
|
# Linker flags.
|
||||||
|
# -Wl,...: tell GCC to pass this to linker.
|
||||||
|
# -Map: create map file
|
||||||
|
# --cref: add cross reference to map file
|
||||||
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
|
|
||||||
|
|
||||||
|
# Programming support using avrdude. Settings and variables.
|
||||||
|
AVRDUDE_PROGRAMMER = usbasp
|
||||||
|
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
|
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
||||||
|
|
||||||
|
AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Define programs and commands.
|
||||||
|
SHELL = sh
|
||||||
|
CC = avr-gcc
|
||||||
|
OBJCOPY = avr-objcopy
|
||||||
|
OBJDUMP = avr-objdump
|
||||||
|
SIZE = avr-size
|
||||||
|
NM = avr-nm
|
||||||
|
AVRDUDE = avrdude
|
||||||
|
REMOVE = rm -f
|
||||||
|
COPY = cp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Define Messages
|
||||||
|
# English
|
||||||
|
MSG_ERRORS_NONE = Errors: none
|
||||||
|
MSG_BEGIN = -------- begin --------
|
||||||
|
MSG_END = -------- end --------
|
||||||
|
MSG_SIZE_BEFORE = Size before:
|
||||||
|
MSG_SIZE_AFTER = Size after:
|
||||||
|
MSG_COFF = Converting to AVR COFF:
|
||||||
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
MSG_FLASH = Creating load file for Flash:
|
||||||
|
MSG_EEPROM = Creating load file for EEPROM:
|
||||||
|
MSG_EXTENDED_LISTING = Creating Extended Listing:
|
||||||
|
MSG_SYMBOL_TABLE = Creating Symbol Table:
|
||||||
|
MSG_LINKING = Linking:
|
||||||
|
MSG_COMPILING = Compiling:
|
||||||
|
MSG_ASSEMBLING = Assembling:
|
||||||
|
MSG_CLEANING = Cleaning project:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Define all object files.
|
||||||
|
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
|
||||||
|
|
||||||
|
# Define all listing files.
|
||||||
|
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flags to generate dependency files.
|
||||||
|
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
|
||||||
|
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
|
||||||
|
|
||||||
|
# Combine all necessary flags and optional flags.
|
||||||
|
# Add target processor to flags.
|
||||||
|
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Default target.
|
||||||
|
all: begin gccversion sizebefore build sizeafter finished end
|
||||||
|
|
||||||
|
build: elf hex eep lss sym
|
||||||
|
|
||||||
|
elf: $(TARGET).elf
|
||||||
|
hex: $(TARGET).hex
|
||||||
|
eep: $(TARGET).eep
|
||||||
|
lss: $(TARGET).lss
|
||||||
|
sym: $(TARGET).sym
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Eye candy.
|
||||||
|
# AVR Studio 3.x does not check make's exit code but relies on
|
||||||
|
# the following magic strings to be generated by the compile job.
|
||||||
|
begin:
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_BEGIN)
|
||||||
|
|
||||||
|
finished:
|
||||||
|
@echo $(MSG_ERRORS_NONE)
|
||||||
|
|
||||||
|
end:
|
||||||
|
@echo $(MSG_END)
|
||||||
|
@echo
|
||||||
|
|
||||||
|
|
||||||
|
# Display size of file.
|
||||||
|
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
|
||||||
|
ELFSIZE = $(SIZE) -A $(TARGET).elf
|
||||||
|
sizebefore:
|
||||||
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
sizeafter:
|
||||||
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Display compiler version information.
|
||||||
|
gccversion :
|
||||||
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Program the device.
|
||||||
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
||||||
|
# Create final output files (.hex, .eep) from ELF output file.
|
||||||
|
%.hex: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_FLASH) $@
|
||||||
|
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||||
|
|
||||||
|
%.eep: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_EEPROM) $@
|
||||||
|
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||||
|
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
||||||
|
|
||||||
|
# Create extended listing file from ELF output file.
|
||||||
|
%.lss: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_EXTENDED_LISTING) $@
|
||||||
|
$(OBJDUMP) -h -S $< > $@
|
||||||
|
|
||||||
|
# Create a symbol table from ELF output file.
|
||||||
|
%.sym: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_SYMBOL_TABLE) $@
|
||||||
|
$(NM) -n $< > $@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Link: create ELF output file from object files.
|
||||||
|
.SECONDARY : $(TARGET).elf
|
||||||
|
.PRECIOUS : $(OBJ)
|
||||||
|
%.elf: $(OBJ)
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_LINKING) $@
|
||||||
|
$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create object files from C source files.
|
||||||
|
%.o : %.c
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_COMPILING) $<
|
||||||
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create assembler files from C source files.
|
||||||
|
%.s : %.c
|
||||||
|
$(CC) -S $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
# Assemble: create object files from assembler source files.
|
||||||
|
%.o : %.S
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_ASSEMBLING) $<
|
||||||
|
$(CC) -c $(ALL_ASFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Target: clean project.
|
||||||
|
clean: begin clean_list finished end
|
||||||
|
|
||||||
|
clean_list :
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_CLEANING)
|
||||||
|
$(REMOVE) $(TARGET).hex
|
||||||
|
$(REMOVE) $(TARGET).eep
|
||||||
|
$(REMOVE) $(TARGET).obj
|
||||||
|
$(REMOVE) $(TARGET).cof
|
||||||
|
$(REMOVE) $(TARGET).elf
|
||||||
|
$(REMOVE) $(TARGET).map
|
||||||
|
$(REMOVE) $(TARGET).obj
|
||||||
|
$(REMOVE) $(TARGET).a90
|
||||||
|
$(REMOVE) $(TARGET).sym
|
||||||
|
$(REMOVE) $(TARGET).lnk
|
||||||
|
$(REMOVE) $(TARGET).lss
|
||||||
|
$(REMOVE) $(OBJ)
|
||||||
|
$(REMOVE) $(LST)
|
||||||
|
$(REMOVE) $(SRC:.c=.s)
|
||||||
|
$(REMOVE) $(SRC:.c=.d)
|
||||||
|
$(REMOVE) .dep/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Include the dependency files.
|
||||||
|
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
||||||
|
|
||||||
|
|
||||||
|
# Listing of phony targets.
|
||||||
|
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
||||||
|
build elf hex eep lss sym coff extcoff \
|
||||||
|
clean clean_list program
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
|
||||||
|
void adc_init(void) {
|
||||||
|
uint16_t dummyResult;
|
||||||
|
// AVCC with external capacitor at AREF pin
|
||||||
|
ADMUX = _BV(REFS0);
|
||||||
|
|
||||||
|
// set frequency prescaler to 8
|
||||||
|
ADCSRA = _BV(ADPS1) | _BV(ADPS0);
|
||||||
|
|
||||||
|
// enable ADC
|
||||||
|
ADCSRA |= _BV(ADEN);
|
||||||
|
|
||||||
|
// make a dummy read out
|
||||||
|
ADCSRA |= _BV(ADSC);
|
||||||
|
while (ADCSRA & _BV(ADSC) ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// we have to read, otherwise the next result is not available
|
||||||
|
dummyResult = ADCW;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t adc_read_single(uint8_t channel) {
|
||||||
|
ADMUX = (ADMUX & ~(0x1F)) | (channel & 0x1F);
|
||||||
|
ADCSRA |= _BV(ADSC);
|
||||||
|
while (ADCSRA & (1<<ADSC) ) {
|
||||||
|
}
|
||||||
|
return ADCW;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t adc_read_avg(const uint8_t channel, const uint8_t nsamples) {
|
||||||
|
uint16_t sum = 0;
|
||||||
|
uint8_t count = nsamples % 60;
|
||||||
|
|
||||||
|
for (uint8_t i=0; i<count;++i ) {
|
||||||
|
sum += adc_read_single(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (sum / count);
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef _adc_h
|
||||||
|
#define _adc_h
|
||||||
|
|
||||||
|
extern void adc_init(void);
|
||||||
|
extern uint16_t adc_read_single(uint8_t);
|
||||||
|
extern uint16_t adc_read_avg(uint8_t, uint8_t);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,204 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "utils.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "adc.h"
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
volatile uint16_t syscounter = 0;
|
||||||
|
uint16_t voltage_bat = 0;
|
||||||
|
uint16_t voltage_gen = 0;
|
||||||
|
uint16_t current_in = 0;
|
||||||
|
|
||||||
|
uint8_t overvoltage_counter = 0;
|
||||||
|
uint8_t overvoltage_off_counter = 0;
|
||||||
|
uint8_t undervoltage_counter = 0;
|
||||||
|
uint8_t undervoltage_off_counter = 0;
|
||||||
|
uint8_t generator_counter = 0;
|
||||||
|
uint8_t generator_off_counter = 0;
|
||||||
|
|
||||||
|
|
||||||
|
static void timer_init(void) {
|
||||||
|
// clock is 8MHz
|
||||||
|
TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10) ; // CTC Mode for Timer 1 (16Bit) with prescale of 64
|
||||||
|
OCR1A = 1250; // 100Hz
|
||||||
|
TIMSK = _BV(OCIE1A);
|
||||||
|
sei(); // enable interrupts
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ports_init(void) {
|
||||||
|
DDR_SW |= _BV(LOADSW) | _BV(GENSW);
|
||||||
|
PORT_SW &= ~(_BV(LOADSW) | _BV(GENSW));
|
||||||
|
}
|
||||||
|
|
||||||
|
void measure(void) {
|
||||||
|
|
||||||
|
static int16_t temp;
|
||||||
|
|
||||||
|
voltage_bat = adc_read_avg(AD_V_BAT, 4);
|
||||||
|
voltage_bat *= VOLTAGE_PER_TICK;
|
||||||
|
voltage_bat += 790;
|
||||||
|
|
||||||
|
voltage_gen = adc_read_avg(AD_V_GEN, 4);
|
||||||
|
voltage_gen *= VOLTAGE_PER_TICK;
|
||||||
|
|
||||||
|
temp = adc_read_avg(AD_I_GEN, 4);
|
||||||
|
temp -= CURRENT_OFFSET;
|
||||||
|
if(temp < 0) temp = 0;
|
||||||
|
current_in = temp * CURRENT_PER_TICK;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t get_power(uint16_t voltage, int16_t currents) {
|
||||||
|
return (voltage/100 * (currents/100)) / 100 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pretty_print_all_values(void) {
|
||||||
|
uart_puts_P("Battery Voltage: ");
|
||||||
|
uart_print_uint16(voltage_bat);
|
||||||
|
uart_puts_P("mV\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("Generator Voltage: ");
|
||||||
|
uart_print_uint16(voltage_gen);
|
||||||
|
uart_puts_P("mV\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("Generator: ");
|
||||||
|
uart_print_uint16(current_in);
|
||||||
|
uart_puts_P("mA ");
|
||||||
|
uart_print_uint16(get_power(voltage_bat, current_in));
|
||||||
|
uart_puts_P("W\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("switches (load, gen): ");
|
||||||
|
uart_putc(48 + (IS_LOAD_ON >> LOADSW));
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48 + (IS_GEN_ON >> GENSW));
|
||||||
|
uart_puts_P("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_over_and_undervoltage(void) {
|
||||||
|
|
||||||
|
if(voltage_bat < UNDERVOLTAGE) {
|
||||||
|
undervoltage_off_counter = 0;
|
||||||
|
if(undervoltage_counter<UNDERVOLTAGE_TIMEOUT) undervoltage_counter++;
|
||||||
|
} else {
|
||||||
|
undervoltage_counter = 0;
|
||||||
|
if(undervoltage_off_counter<UNDERVOLTAGEOFF_TIMEOUT) undervoltage_off_counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(voltage_gen > GENERATOR) {
|
||||||
|
generator_off_counter = 0;
|
||||||
|
if(generator_counter<GENERATOR_TIMEOUT) generator_counter++;
|
||||||
|
} else {
|
||||||
|
generator_counter = 0;
|
||||||
|
if(generator_off_counter<GENERATOR_OFF_TIMEOUT) generator_off_counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(undervoltage_counter >= UNDERVOLTAGE_TIMEOUT) {
|
||||||
|
// spannung zu niedrig => abschalten
|
||||||
|
undervoltage_off_counter = 0;
|
||||||
|
LOAD_OFF;
|
||||||
|
} else {
|
||||||
|
// spannung ist okay
|
||||||
|
|
||||||
|
// ist die spannung schon lange genug okay?
|
||||||
|
if(undervoltage_off_counter >= UNDERVOLTAGEOFF_TIMEOUT) {
|
||||||
|
undervoltage_counter = 0;
|
||||||
|
|
||||||
|
// ja, also schauen ob der generator schon lange genug läuft
|
||||||
|
if(generator_counter >= GENERATOR_TIMEOUT) {
|
||||||
|
// ja, also einschalten
|
||||||
|
LOAD_ON;
|
||||||
|
} else {
|
||||||
|
// nein, generator nicht lange genug an
|
||||||
|
|
||||||
|
// ist er vielleicht schon lange aus?
|
||||||
|
if(generator_off_counter >= GENERATOR_OFF_TIMEOUT) {
|
||||||
|
// ja, also abschalten, egal ob akku okay
|
||||||
|
LOAD_OFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
uart_puts_P("ov1=");
|
||||||
|
uart_print_uint8(overvoltage_counter1);
|
||||||
|
uart_puts_P(" ovo1=");
|
||||||
|
uart_print_uint8 (overvoltage_off_counter1);
|
||||||
|
uart_puts_P("\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("uv =");
|
||||||
|
uart_print_uint8(undervoltage_counter);
|
||||||
|
uart_puts_P(" uvo =");
|
||||||
|
uart_print_uint8(undervoltage_off_counter);
|
||||||
|
uart_puts_P("\r\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void work_uart(void) {
|
||||||
|
uint16_t uart_char = uart_getc();
|
||||||
|
|
||||||
|
if(uart_char != UART_NO_DATA) {
|
||||||
|
switch(uart_char & 0xff) {
|
||||||
|
case 'p':
|
||||||
|
pretty_print_all_values();
|
||||||
|
break;
|
||||||
|
case 'a':
|
||||||
|
uart_putc('A');
|
||||||
|
uart_print_uint16(voltage_bat);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_print_uint16(current_in);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_print_uint16(0);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_print_uint16(get_power(voltage_bat, current_in));
|
||||||
|
uart_putc(',');
|
||||||
|
uart_print_uint16(0);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48 + (IS_LOAD_ON >> LOADSW));
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48 + (IS_GEN_ON >> GENSW));
|
||||||
|
uart_putc('B');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
ports_init();
|
||||||
|
adc_init();
|
||||||
|
timer_init();
|
||||||
|
uart_init(UART_BAUD_SELECT(19200,F_CPU));
|
||||||
|
|
||||||
|
LOAD_OFF;
|
||||||
|
GEN_ON;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
if(syscounter >= 100) {
|
||||||
|
syscounter = 0;
|
||||||
|
|
||||||
|
measure();
|
||||||
|
|
||||||
|
//pretty_print_all_values();
|
||||||
|
|
||||||
|
handle_over_and_undervoltage();
|
||||||
|
}
|
||||||
|
|
||||||
|
work_uart();
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// system timer
|
||||||
|
SIGNAL(TIMER1_COMPA_vect) {
|
||||||
|
syscounter++;
|
||||||
|
syscounter %= 60000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef _main_h
|
||||||
|
#define _main_h
|
||||||
|
|
||||||
|
#define AD_V_GEN 0
|
||||||
|
#define AD_I_GEN 1
|
||||||
|
#define AD_V_BAT 2
|
||||||
|
|
||||||
|
#define LOADSW PB0
|
||||||
|
#define GENSW PB1
|
||||||
|
#define PORT_SW PORTB
|
||||||
|
#define DDR_SW DDRB
|
||||||
|
#define PIN_SW PINB
|
||||||
|
|
||||||
|
#define LOAD_ON PORT_SW |= _BV(LOADSW)
|
||||||
|
#define LOAD_OFF PORT_SW &= ~_BV(LOADSW)
|
||||||
|
#define GEN_ON PORT_SW |= _BV(GENSW)
|
||||||
|
#define GEN_OFF PORT_SW &= ~_BV(GENSW)
|
||||||
|
|
||||||
|
#define IS_LOAD_ON (PIN_SW & _BV(LOADSW))
|
||||||
|
#define IS_GEN_ON (PIN_SW & _BV(GENSW))
|
||||||
|
|
||||||
|
#define GENERATOR 13000
|
||||||
|
#define GENERATOR_TIMEOUT 3
|
||||||
|
#define GENERATOR_OFF_TIMEOUT 1
|
||||||
|
|
||||||
|
#define UNDERVOLTAGE 11200
|
||||||
|
#define OVERVOLTAGE 15000
|
||||||
|
#define OVERVOLTAGE_TIMEOUT 5
|
||||||
|
#define OVERVOLTAGEOFF_TIMEOUT 3
|
||||||
|
#define UNDERVOLTAGE_TIMEOUT 5
|
||||||
|
#define UNDERVOLTAGEOFF_TIMEOUT 3
|
||||||
|
|
||||||
|
#define CURRENT_OFFSET 511
|
||||||
|
#define CURRENT_PER_TICK 72
|
||||||
|
#define VOLTAGE_PER_TICK 15
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,663 @@
|
||||||
|
/*************************************************************************
|
||||||
|
Title: Interrupt UART library with receive/transmit circular buffers
|
||||||
|
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
|
||||||
|
File: $Id: uart.c,v 1.10 2013/06/02 07:27:04 peter Exp $
|
||||||
|
Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher
|
||||||
|
Hardware: any AVR with built-in UART,
|
||||||
|
License: GNU General Public License
|
||||||
|
|
||||||
|
DESCRIPTION:
|
||||||
|
An interrupt is generated when the UART has finished transmitting or
|
||||||
|
receiving a byte. The interrupt handling routines use circular buffers
|
||||||
|
for buffering received and transmitted data.
|
||||||
|
|
||||||
|
The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE variables define
|
||||||
|
the buffer size in bytes. Note that these variables must be a
|
||||||
|
power of 2.
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
Refere to the header file uart.h for a description of the routines.
|
||||||
|
See also example test_uart.c.
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
Based on Atmel Application Note AVR306
|
||||||
|
|
||||||
|
LICENSE:
|
||||||
|
Copyright (C) 2006 Peter Fleury
|
||||||
|
|
||||||
|
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, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
*************************************************************************/
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* constants and macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* size of RX/TX buffers */
|
||||||
|
#define UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1)
|
||||||
|
#define UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1)
|
||||||
|
|
||||||
|
#if ( UART_RX_BUFFER_SIZE & UART_RX_BUFFER_MASK )
|
||||||
|
#error RX buffer size is not a power of 2
|
||||||
|
#endif
|
||||||
|
#if ( UART_TX_BUFFER_SIZE & UART_TX_BUFFER_MASK )
|
||||||
|
#error TX buffer size is not a power of 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__AVR_AT90S2313__) \
|
||||||
|
|| defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \
|
||||||
|
|| defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \
|
||||||
|
|| defined(__AVR_ATmega103__)
|
||||||
|
/* old AVR classic or ATmega103 with one UART */
|
||||||
|
#define AT90_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS USR
|
||||||
|
#define UART0_CONTROL UCR
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__)
|
||||||
|
/* old AVR classic with one UART */
|
||||||
|
#define AT90_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \
|
||||||
|
|| defined(__AVR_ATmega323__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RXC_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__)
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega163__)
|
||||||
|
/* ATmega163 with one UART */
|
||||||
|
#define ATMEGA_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega162__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RXC_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RXC_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega161__)
|
||||||
|
/* ATmega with UART */
|
||||||
|
#error "AVR ATmega161 currently not supported by this libaray !"
|
||||||
|
#elif defined(__AVR_ATmega169__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \
|
||||||
|
|| defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATtiny2313__)
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega329__) || \
|
||||||
|
defined(__AVR_ATmega649__) || \
|
||||||
|
defined(__AVR_ATmega325__) || \
|
||||||
|
defined(__AVR_ATmega645__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega644__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#else
|
||||||
|
#error "no UART definition for MCU available"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* module global variables
|
||||||
|
*/
|
||||||
|
static volatile unsigned char UART_TxBuf[UART_TX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART_RxBuf[UART_RX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART_TxHead;
|
||||||
|
static volatile unsigned char UART_TxTail;
|
||||||
|
static volatile unsigned char UART_RxHead;
|
||||||
|
static volatile unsigned char UART_RxTail;
|
||||||
|
static volatile unsigned char UART_LastRxError;
|
||||||
|
|
||||||
|
#if defined( ATMEGA_USART1 )
|
||||||
|
static volatile unsigned char UART1_TxBuf[UART_TX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART1_RxBuf[UART_RX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART1_TxHead;
|
||||||
|
static volatile unsigned char UART1_TxTail;
|
||||||
|
static volatile unsigned char UART1_RxHead;
|
||||||
|
static volatile unsigned char UART1_RxTail;
|
||||||
|
static volatile unsigned char UART1_LastRxError;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ISR (UART0_RECEIVE_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART Receive Complete interrupt
|
||||||
|
Purpose: called when the UART has received a character
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
unsigned char data;
|
||||||
|
unsigned char usr;
|
||||||
|
unsigned char lastRxError;
|
||||||
|
|
||||||
|
|
||||||
|
/* read UART status register and UART data register */
|
||||||
|
usr = UART0_STATUS;
|
||||||
|
data = UART0_DATA;
|
||||||
|
|
||||||
|
/* */
|
||||||
|
#if defined( AT90_UART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#elif defined( ATMEGA_USART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#elif defined( ATMEGA_USART0 )
|
||||||
|
lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) );
|
||||||
|
#elif defined ( ATMEGA_UART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* calculate buffer index */
|
||||||
|
tmphead = ( UART_RxHead + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
|
||||||
|
if ( tmphead == UART_RxTail ) {
|
||||||
|
/* error: receive buffer overflow */
|
||||||
|
lastRxError = UART_BUFFER_OVERFLOW >> 8;
|
||||||
|
}else{
|
||||||
|
/* store new index */
|
||||||
|
UART_RxHead = tmphead;
|
||||||
|
/* store received data in buffer */
|
||||||
|
UART_RxBuf[tmphead] = data;
|
||||||
|
}
|
||||||
|
UART_LastRxError |= lastRxError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ISR (UART0_TRANSMIT_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART Data Register Empty interrupt
|
||||||
|
Purpose: called when the UART is ready to transmit the next byte
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART_TxHead != UART_TxTail) {
|
||||||
|
/* calculate and store new buffer index */
|
||||||
|
tmptail = (UART_TxTail + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
UART_TxTail = tmptail;
|
||||||
|
/* get one byte from buffer and write it to UART */
|
||||||
|
UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */
|
||||||
|
}else{
|
||||||
|
/* tx buffer empty, disable UDRE interrupt */
|
||||||
|
UART0_CONTROL &= ~_BV(UART0_UDRIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_init()
|
||||||
|
Purpose: initialize UART and set baudrate
|
||||||
|
Input: baudrate using macro UART_BAUD_SELECT()
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_init(unsigned int baudrate)
|
||||||
|
{
|
||||||
|
UART_TxHead = 0;
|
||||||
|
UART_TxTail = 0;
|
||||||
|
UART_RxHead = 0;
|
||||||
|
UART_RxTail = 0;
|
||||||
|
|
||||||
|
#if defined( AT90_UART )
|
||||||
|
/* set baud rate */
|
||||||
|
UBRR = (unsigned char)baudrate;
|
||||||
|
|
||||||
|
/* enable UART receiver and transmmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN);
|
||||||
|
|
||||||
|
#elif defined (ATMEGA_USART)
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRRH = (unsigned char)(baudrate>>8);
|
||||||
|
UBRRL = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|(1<<RXEN)|(1<<TXEN);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL
|
||||||
|
UCSRC = (1<<URSEL)|(3<<UCSZ0);
|
||||||
|
#else
|
||||||
|
UCSRC = (3<<UCSZ0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined (ATMEGA_USART0 )
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X0); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRR0H = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR0L = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE0)|(1<<RXEN0)|(1<<TXEN0);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL0
|
||||||
|
UCSR0C = (1<<URSEL0)|(3<<UCSZ00);
|
||||||
|
#else
|
||||||
|
UCSR0C = (3<<UCSZ00);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( ATMEGA_UART )
|
||||||
|
/* set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRRHI = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable UART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|(1<<RXEN)|(1<<TXEN);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}/* uart_init */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_getc()
|
||||||
|
Purpose: return byte from ringbuffer
|
||||||
|
Returns: lower byte: received byte from ringbuffer
|
||||||
|
higher byte: last receive error
|
||||||
|
**************************************************************************/
|
||||||
|
unsigned int uart_getc(void)
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
unsigned char data;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART_RxHead == UART_RxTail ) {
|
||||||
|
return UART_NO_DATA; /* no data available */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate /store buffer index */
|
||||||
|
tmptail = (UART_RxTail + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
UART_RxTail = tmptail;
|
||||||
|
|
||||||
|
/* get data from receive buffer */
|
||||||
|
data = UART_RxBuf[tmptail];
|
||||||
|
|
||||||
|
data = (UART_LastRxError << 8) + data;
|
||||||
|
UART_LastRxError = 0;
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}/* uart_getc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_putc()
|
||||||
|
Purpose: write byte to ringbuffer for transmitting via UART
|
||||||
|
Input: byte to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_putc(unsigned char data)
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
|
||||||
|
|
||||||
|
tmphead = (UART_TxHead + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
|
||||||
|
while ( tmphead == UART_TxTail ){
|
||||||
|
;/* wait for free space in buffer */
|
||||||
|
}
|
||||||
|
|
||||||
|
UART_TxBuf[tmphead] = data;
|
||||||
|
UART_TxHead = tmphead;
|
||||||
|
|
||||||
|
/* enable UDRE interrupt */
|
||||||
|
UART0_CONTROL |= _BV(UART0_UDRIE);
|
||||||
|
|
||||||
|
}/* uart_putc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_puts()
|
||||||
|
Purpose: transmit string to UART
|
||||||
|
Input: string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_puts(const char *s )
|
||||||
|
{
|
||||||
|
while (*s)
|
||||||
|
uart_putc(*s++);
|
||||||
|
|
||||||
|
}/* uart_puts */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_puts_p()
|
||||||
|
Purpose: transmit string from program memory to UART
|
||||||
|
Input: program memory string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_puts_p(const char *progmem_s )
|
||||||
|
{
|
||||||
|
register char c;
|
||||||
|
|
||||||
|
while ( (c = pgm_read_byte(progmem_s++)) )
|
||||||
|
uart_putc(c);
|
||||||
|
|
||||||
|
}/* uart_puts_p */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* these functions are only for ATmegas with two USART
|
||||||
|
*/
|
||||||
|
#if defined( ATMEGA_USART1 )
|
||||||
|
|
||||||
|
ISR(UART1_RECEIVE_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART1 Receive Complete interrupt
|
||||||
|
Purpose: called when the UART1 has received a character
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
unsigned char data;
|
||||||
|
unsigned char usr;
|
||||||
|
unsigned char lastRxError;
|
||||||
|
|
||||||
|
|
||||||
|
/* read UART status register and UART data register */
|
||||||
|
usr = UART1_STATUS;
|
||||||
|
data = UART1_DATA;
|
||||||
|
|
||||||
|
/* */
|
||||||
|
lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) );
|
||||||
|
|
||||||
|
/* calculate buffer index */
|
||||||
|
tmphead = ( UART1_RxHead + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
|
||||||
|
if ( tmphead == UART1_RxTail ) {
|
||||||
|
/* error: receive buffer overflow */
|
||||||
|
lastRxError = UART_BUFFER_OVERFLOW >> 8;
|
||||||
|
}else{
|
||||||
|
/* store new index */
|
||||||
|
UART1_RxHead = tmphead;
|
||||||
|
/* store received data in buffer */
|
||||||
|
UART1_RxBuf[tmphead] = data;
|
||||||
|
}
|
||||||
|
UART1_LastRxError |= lastRxError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ISR(UART1_TRANSMIT_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART1 Data Register Empty interrupt
|
||||||
|
Purpose: called when the UART1 is ready to transmit the next byte
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART1_TxHead != UART1_TxTail) {
|
||||||
|
/* calculate and store new buffer index */
|
||||||
|
tmptail = (UART1_TxTail + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
UART1_TxTail = tmptail;
|
||||||
|
/* get one byte from buffer and write it to UART */
|
||||||
|
UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */
|
||||||
|
}else{
|
||||||
|
/* tx buffer empty, disable UDRE interrupt */
|
||||||
|
UART1_CONTROL &= ~_BV(UART1_UDRIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_init()
|
||||||
|
Purpose: initialize UART1 and set baudrate
|
||||||
|
Input: baudrate using macro UART_BAUD_SELECT()
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart1_init(unsigned int baudrate)
|
||||||
|
{
|
||||||
|
UART1_TxHead = 0;
|
||||||
|
UART1_TxTail = 0;
|
||||||
|
UART1_RxHead = 0;
|
||||||
|
UART1_RxTail = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART1_STATUS = (1<<U2X1); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRR1H = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR1L = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART1_CONTROL = _BV(RXCIE1)|(1<<RXEN1)|(1<<TXEN1);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL1
|
||||||
|
UCSR1C = (1<<URSEL1)|(3<<UCSZ10);
|
||||||
|
#else
|
||||||
|
UCSR1C = (3<<UCSZ10);
|
||||||
|
#endif
|
||||||
|
}/* uart_init */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_getc()
|
||||||
|
Purpose: return byte from ringbuffer
|
||||||
|
Returns: lower byte: received byte from ringbuffer
|
||||||
|
higher byte: last receive error
|
||||||
|
**************************************************************************/
|
||||||
|
unsigned int uart1_getc(void)
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
unsigned char data;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART1_RxHead == UART1_RxTail ) {
|
||||||
|
return UART_NO_DATA; /* no data available */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate /store buffer index */
|
||||||
|
tmptail = (UART1_RxTail + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
UART1_RxTail = tmptail;
|
||||||
|
|
||||||
|
/* get data from receive buffer */
|
||||||
|
data = UART1_RxBuf[tmptail];
|
||||||
|
|
||||||
|
data = (UART1_LastRxError << 8) + data;
|
||||||
|
UART1_LastRxError = 0;
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}/* uart1_getc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_putc()
|
||||||
|
Purpose: write byte to ringbuffer for transmitting via UART
|
||||||
|
Input: byte to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart1_putc(unsigned char data)
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
|
||||||
|
|
||||||
|
tmphead = (UART1_TxHead + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
|
||||||
|
while ( tmphead == UART1_TxTail ){
|
||||||
|
;/* wait for free space in buffer */
|
||||||
|
}
|
||||||
|
|
||||||
|
UART1_TxBuf[tmphead] = data;
|
||||||
|
UART1_TxHead = tmphead;
|
||||||
|
|
||||||
|
/* enable UDRE interrupt */
|
||||||
|
UART1_CONTROL |= _BV(UART1_UDRIE);
|
||||||
|
|
||||||
|
}/* uart1_putc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_puts()
|
||||||
|
Purpose: transmit string to UART1
|
||||||
|
Input: string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart1_puts(const char *s )
|
||||||
|
{
|
||||||
|
while (*s)
|
||||||
|
uart1_putc(*s++);
|
||||||
|
|
||||||
|
}/* uart1_puts */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_puts_p()
|
||||||
|
Purpose: transmit string from program memory to UART1
|
||||||
|
Input: program memory string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart1_puts_p(const char *progmem_s )
|
||||||
|
{
|
||||||
|
register char c;
|
||||||
|
|
||||||
|
while ( (c = pgm_read_byte(progmem_s++)) )
|
||||||
|
uart1_putc(c);
|
||||||
|
|
||||||
|
}/* uart1_puts_p */
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,180 @@
|
||||||
|
#ifndef UART_H
|
||||||
|
#define UART_H
|
||||||
|
/************************************************************************
|
||||||
|
Title: Interrupt UART library with receive/transmit circular buffers
|
||||||
|
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
|
||||||
|
File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $
|
||||||
|
Software: AVR-GCC 4.1, AVR Libc 1.4
|
||||||
|
Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz
|
||||||
|
License: GNU General Public License
|
||||||
|
Usage: see Doxygen manual
|
||||||
|
|
||||||
|
LICENSE:
|
||||||
|
Copyright (C) 2006 Peter Fleury
|
||||||
|
|
||||||
|
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, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup pfleury_uart UART Library
|
||||||
|
* @code #include <uart.h> @endcode
|
||||||
|
*
|
||||||
|
* @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers.
|
||||||
|
*
|
||||||
|
* This library can be used to transmit and receive data through the built in UART.
|
||||||
|
*
|
||||||
|
* An interrupt is generated when the UART has finished transmitting or
|
||||||
|
* receiving a byte. The interrupt handling routines use circular buffers
|
||||||
|
* for buffering received and transmitted data.
|
||||||
|
*
|
||||||
|
* The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE constants define
|
||||||
|
* the size of the circular buffers in bytes. Note that these constants must be a power of 2.
|
||||||
|
* You may need to adapt this constants to your target and your application by adding
|
||||||
|
* CDEFS += -DUART_RX_BUFFER_SIZE=nn -DUART_RX_BUFFER_SIZE=nn to your Makefile.
|
||||||
|
*
|
||||||
|
* @note Based on Atmel Application Note AVR306
|
||||||
|
* @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**@{*/
|
||||||
|
|
||||||
|
|
||||||
|
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304
|
||||||
|
#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** constants and macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @brief UART Baudrate Expression
|
||||||
|
* @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
||||||
|
* @param baudrate baudrate in bps, e.g. 1200, 2400, 9600
|
||||||
|
*/
|
||||||
|
#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL)
|
||||||
|
|
||||||
|
/** @brief UART Baudrate Expression for ATmega double speed mode
|
||||||
|
* @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
||||||
|
* @param baudrate baudrate in bps, e.g. 1200, 2400, 9600
|
||||||
|
*/
|
||||||
|
#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000)
|
||||||
|
|
||||||
|
|
||||||
|
/** Size of the circular receive buffer, must be power of 2 */
|
||||||
|
#ifndef UART_RX_BUFFER_SIZE
|
||||||
|
#define UART_RX_BUFFER_SIZE 32
|
||||||
|
#endif
|
||||||
|
/** Size of the circular transmit buffer, must be power of 2 */
|
||||||
|
#ifndef UART_TX_BUFFER_SIZE
|
||||||
|
#define UART_TX_BUFFER_SIZE 32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* test if the size of the circular buffers fits into SRAM */
|
||||||
|
#if ( (UART_RX_BUFFER_SIZE+UART_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) )
|
||||||
|
#error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** high byte error return code of uart_getc()
|
||||||
|
*/
|
||||||
|
#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */
|
||||||
|
#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */
|
||||||
|
#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */
|
||||||
|
#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */
|
||||||
|
#define UART_NO_DATA 0x0100 /* no receive data available */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** function prototypes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Initialize UART and set baudrate
|
||||||
|
@param baudrate Specify baudrate using macro UART_BAUD_SELECT()
|
||||||
|
@return none
|
||||||
|
*/
|
||||||
|
extern void uart_init(unsigned int baudrate);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get received byte from ringbuffer
|
||||||
|
*
|
||||||
|
* Returns in the lower byte the received character and in the
|
||||||
|
* higher byte the last receive error.
|
||||||
|
* UART_NO_DATA is returned when no data is available.
|
||||||
|
*
|
||||||
|
* @param void
|
||||||
|
* @return lower byte: received byte from ringbuffer
|
||||||
|
* @return higher byte: last receive status
|
||||||
|
* - \b 0 successfully received data from UART
|
||||||
|
* - \b UART_NO_DATA
|
||||||
|
* <br>no receive data available
|
||||||
|
* - \b UART_BUFFER_OVERFLOW
|
||||||
|
* <br>Receive ringbuffer overflow.
|
||||||
|
* We are not reading the receive buffer fast enough,
|
||||||
|
* one or more received character have been dropped
|
||||||
|
* - \b UART_OVERRUN_ERROR
|
||||||
|
* <br>Overrun condition by UART.
|
||||||
|
* A character already present in the UART UDR register was
|
||||||
|
* not read by the interrupt handler before the next character arrived,
|
||||||
|
* one or more received characters have been dropped.
|
||||||
|
* - \b UART_FRAME_ERROR
|
||||||
|
* <br>Framing Error by UART
|
||||||
|
*/
|
||||||
|
extern unsigned int uart_getc(void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put byte to ringbuffer for transmitting via UART
|
||||||
|
* @param data byte to be transmitted
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
extern void uart_putc(unsigned char data);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put string to ringbuffer for transmitting via UART
|
||||||
|
*
|
||||||
|
* The string is buffered by the uart library in a circular buffer
|
||||||
|
* and one character at a time is transmitted to the UART using interrupts.
|
||||||
|
* Blocks if it can not write the whole string into the circular buffer.
|
||||||
|
*
|
||||||
|
* @param s string to be transmitted
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
extern void uart_puts(const char *s );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put string from program memory to ringbuffer for transmitting via UART.
|
||||||
|
*
|
||||||
|
* The string is buffered by the uart library in a circular buffer
|
||||||
|
* and one character at a time is transmitted to the UART using interrupts.
|
||||||
|
* Blocks if it can not write the whole string into the circular buffer.
|
||||||
|
*
|
||||||
|
* @param s program memory string to be transmitted
|
||||||
|
* @return none
|
||||||
|
* @see uart_puts_P
|
||||||
|
*/
|
||||||
|
extern void uart_puts_p(const char *s );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Macro to automatically put a string constant into program memory
|
||||||
|
*/
|
||||||
|
#define uart_puts_P(__s) uart_puts_p(PSTR(__s))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // UART_H
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
void wait(uint8_t count) {
|
||||||
|
uint8_t i;
|
||||||
|
if(count == 0) count = 100;
|
||||||
|
for(i=0;i<count;i++) {
|
||||||
|
_delay_ms(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_voltage(uint16_t x) {
|
||||||
|
uart_putc(48 + (x / 10000));
|
||||||
|
uart_putc(48 + (x % 10000 /1000));
|
||||||
|
uart_putc('.');
|
||||||
|
uart_putc(48 + (x % 1000 / 100 ));
|
||||||
|
//uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
//uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_uint8(uint8_t x) {
|
||||||
|
uart_putc(48 + (x / 100 ));
|
||||||
|
uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_uint16(uint16_t x) {
|
||||||
|
uart_putc(48 + (x / 10000));
|
||||||
|
uart_putc(48 + (x % 10000 /1000));
|
||||||
|
uart_putc(48 + (x % 1000 / 100 ));
|
||||||
|
uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef _utils_h
|
||||||
|
#define _utils_h
|
||||||
|
|
||||||
|
extern void wait(uint8_t count);
|
||||||
|
extern void uart_print_voltage(uint16_t);
|
||||||
|
extern void uart_print_uint8_t(uint8_t);
|
||||||
|
extern void uart_print_uint16(uint16_t);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,56 @@
|
||||||
|
Stückliste exportiert aus /home/lucas/home/ctdo/bikegenerator/display/pb_v3/pb_mainboard_v3.sch am 21.05.14 22:01
|
||||||
|
|
||||||
|
Part Value Device Package Description MF MPN OC_FARNELL OC_NEWARK
|
||||||
|
BAT+ 236-740-5,08 236-740-5,08 236-4XX Anreihbare Einzelklemme 2,5 mm² 16A Rastermaß 5/5,08 | 7,5/7,62 | 10/10,16
|
||||||
|
BAT- 236-740-5,08 236-740-5,08 236-4XX Anreihbare Einzelklemme 2,5 mm² 16A Rastermaß 5/5,08 | 7,5/7,62 | 10/10,16
|
||||||
|
C1 X5R-G0603 1,0/25 C-EUC0603 C0603 CAPACITOR, European symbol
|
||||||
|
C2 X7R-G0603 100N C-EUC0603 C0603 CAPACITOR, European symbol
|
||||||
|
C3 X5R-G0603 1,0/25 C-EUC0603 C0603 CAPACITOR, European symbol
|
||||||
|
C4 X5R-G0603 1,0/25 C-EUC0603 C0603 CAPACITOR, European symbol
|
||||||
|
C5 X5R-G0603 1,0/25 C-EUC0603 C0603 CAPACITOR, European symbol
|
||||||
|
C7 VF 470/25 K-G CPOL-EUD PANASONIC_D POLARIZED CAPACITOR, European symbol
|
||||||
|
C8 VF 470/25 K-G CPOL-EUD PANASONIC_D POLARIZED CAPACITOR, European symbol
|
||||||
|
C9 X7R-G0603 100N C-EUC0603 C0603 CAPACITOR, European symbol
|
||||||
|
C10 X7R-G0603 100N C-EUC0603 C0603 CAPACITOR, European symbol
|
||||||
|
C12 X7R-G0603 100N C-EUC0603 C0603 CAPACITOR, European symbol
|
||||||
|
C14 100n C-EUC0603 C0603 CAPACITOR, European symbol
|
||||||
|
C15 100n C-EUC0603 C0603 CAPACITOR, European symbol
|
||||||
|
C17 X7R-G0603 100N C-EUC0603 C0603 CAPACITOR, European symbol
|
||||||
|
C18 X7R-G0603 100N C-EUC0603 C0603 CAPACITOR, European symbol
|
||||||
|
D1 BAT48 DIODE-MINIMELF MINIMELF DIODE
|
||||||
|
D2 bav103 DIODE-MINIMELF MINIMELF DIODE
|
||||||
|
D3 bav103 DIODE-MINIMELF MINIMELF DIODE
|
||||||
|
D4 BAT48 DIODE-MINIMELF MINIMELF DIODE
|
||||||
|
D5 bav103 DIODE-MINIMELF MINIMELF DIODE
|
||||||
|
GEN+ 236-740-5,08 236-740-5,08 236-4XX Anreihbare Einzelklemme 2,5 mm² 16A Rastermaß 5/5,08 | 7,5/7,62 | 10/10,16
|
||||||
|
GEN- 236-740-5,08 236-740-5,08 236-4XX Anreihbare Einzelklemme 2,5 mm² 16A Rastermaß 5/5,08 | 7,5/7,62 | 10/10,16
|
||||||
|
IC1 ACS712 ACS712ELCTR-30A-T SO08
|
||||||
|
IC4 MEGA8-AI MEGA8-AI TQFP32-08 MICROCONTROLLER ATMEGA8-16AU 9171371 73M8863
|
||||||
|
IC5 MAX232ECWE MAX232ECWE SO16L RS232 TRANSEIVER MAXIM MAX232ECWE+ 9724435 67K4440
|
||||||
|
IC6 UA78M05DCY UA78M05DCY SOT223 POSITIVE-VOLTAGE REGULATORS
|
||||||
|
J1 5555764-1 555764-1 555764-1 AMP connector
|
||||||
|
JP1 PINHD-2X3_2.54-SMD 2X03SMD PIN HEADER
|
||||||
|
K1 G2R2 G2R2 G2R2 RELAY OMRON COMPONENTS USA G2R-2-DC6 unknown 89C5317
|
||||||
|
K2 G2R2 G2R2 G2R2 RELAY OMRON COMPONENTS USA G2R-2-DC6 unknown 89C5317
|
||||||
|
K3 G2R2 G2R2 G2R2 RELAY OMRON COMPONENTS USA G2R-2-DC6 unknown 89C5317
|
||||||
|
L1 L-1212FPS 10µ L-EUL4532P L4532P INDUCTOR, European symbol
|
||||||
|
LOAD+ 236-740-5,08 236-740-5,08 236-4XX Anreihbare Einzelklemme 2,5 mm² 16A Rastermaß 5/5,08 | 7,5/7,62 | 10/10,16
|
||||||
|
LOAD- 236-740-5,08 236-740-5,08 236-4XX Anreihbare Einzelklemme 2,5 mm² 16A Rastermaß 5/5,08 | 7,5/7,62 | 10/10,16
|
||||||
|
R1 10k R-EU_R0603 R0603 RESISTOR, European symbol
|
||||||
|
R2 2k2 R-EU_R0603 R0603 RESISTOR, European symbol
|
||||||
|
R4 10k R-EU_R0603 R0603 RESISTOR, European symbol
|
||||||
|
R5 10k R-EU_R0603 R0603 RESISTOR, European symbol
|
||||||
|
R6 68k R-EU_R0603 R0603 RESISTOR, European symbol
|
||||||
|
R7 10k R-EU_R0603 R0603 RESISTOR, European symbol
|
||||||
|
R8 10k R-EU_R0603 R0603 RESISTOR, European symbol
|
||||||
|
R9 10k R-EU_R0603 R0603 RESISTOR, European symbol
|
||||||
|
R10 10k R-EU_R0603 R0603 RESISTOR, European symbol
|
||||||
|
R11 56k R-EU_R0603 R0603 RESISTOR, European symbol
|
||||||
|
R12 27k R-EU_R0603 R0603 RESISTOR, European symbol
|
||||||
|
REGI+ 236-740-5,08 236-740-5,08 236-4XX Anreihbare Einzelklemme 2,5 mm² 16A Rastermaß 5/5,08 | 7,5/7,62 | 10/10,16
|
||||||
|
REGI- 236-740-5,08 236-740-5,08 236-4XX Anreihbare Einzelklemme 2,5 mm² 16A Rastermaß 5/5,08 | 7,5/7,62 | 10/10,16
|
||||||
|
REGO+ 236-740-5,08 236-740-5,08 236-4XX Anreihbare Einzelklemme 2,5 mm² 16A Rastermaß 5/5,08 | 7,5/7,62 | 10/10,16
|
||||||
|
REGO- 236-740-5,08 236-740-5,08 236-4XX Anreihbare Einzelklemme 2,5 mm² 16A Rastermaß 5/5,08 | 7,5/7,62 | 10/10,16
|
||||||
|
T1 IRLML2502 NMOSSOT23 SOT-23 MOS FET unknown unknown
|
||||||
|
T2 IRLML2502 NMOSSOT23 SOT-23 MOS FET unknown unknown
|
||||||
|
T3 IRLML2502 NMOSSOT23 SOT-23 MOS FET unknown unknown
|
|
@ -0,0 +1,276 @@
|
||||||
|
# On command line:
|
||||||
|
#
|
||||||
|
# make all = Make software.
|
||||||
|
#
|
||||||
|
# make clean = Clean out built project files.
|
||||||
|
#
|
||||||
|
# make program = Download the hex file to the device, using avrdude. Please
|
||||||
|
# customize the avrdude settings below first!
|
||||||
|
#
|
||||||
|
# To rebuild project do "make clean" then "make all".
|
||||||
|
#
|
||||||
|
|
||||||
|
MCU = atmega8
|
||||||
|
F_CPU = 8000000
|
||||||
|
|
||||||
|
# Output format. (can be srec, ihex, binary)
|
||||||
|
FORMAT = ihex
|
||||||
|
|
||||||
|
# Target file name (without extension).
|
||||||
|
TARGET = main
|
||||||
|
|
||||||
|
SRC = src/$(TARGET).c src/adc.c src/utils.c src/uart.c
|
||||||
|
|
||||||
|
|
||||||
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
|
OPT = s
|
||||||
|
|
||||||
|
|
||||||
|
# List any extra directories to look for include files here.
|
||||||
|
# Each directory must be seperated by a space.
|
||||||
|
EXTRAINCDIRS = src/
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flag to set the C Standard level.
|
||||||
|
# c89 - "ANSI" C
|
||||||
|
# gnu89 - c89 plus GCC extensions
|
||||||
|
# c99 - ISO C99 standard (not yet fully implemented)
|
||||||
|
# gnu99 - c99 plus GCC extensions
|
||||||
|
CSTANDARD = -std=gnu99
|
||||||
|
|
||||||
|
# Place -D or -U options here
|
||||||
|
CDEFS =
|
||||||
|
|
||||||
|
# Place -I options here
|
||||||
|
CINCS =
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flags.
|
||||||
|
# -O*: optimization level
|
||||||
|
# -f...: tuning, see GCC manual and avr-libc documentation
|
||||||
|
# -Wall...: warning level
|
||||||
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
|
# -adhlns...: create assembler listing
|
||||||
|
CFLAGS += $(CDEFS) $(CINCS)
|
||||||
|
CFLAGS += -O$(OPT)
|
||||||
|
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
|
||||||
|
CFLAGS += -Wall -Wstrict-prototypes
|
||||||
|
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
|
||||||
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
|
CFLAGS += $(CSTANDARD)
|
||||||
|
CFLAGS += -DF_CPU=$(F_CPU) #-DDEBUG
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# External memory options
|
||||||
|
|
||||||
|
|
||||||
|
# Linker flags.
|
||||||
|
# -Wl,...: tell GCC to pass this to linker.
|
||||||
|
# -Map: create map file
|
||||||
|
# --cref: add cross reference to map file
|
||||||
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
|
|
||||||
|
|
||||||
|
# Programming support using avrdude. Settings and variables.
|
||||||
|
AVRDUDE_PROGRAMMER = usbasp
|
||||||
|
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
|
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
||||||
|
|
||||||
|
AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Define programs and commands.
|
||||||
|
SHELL = sh
|
||||||
|
CC = avr-gcc
|
||||||
|
OBJCOPY = avr-objcopy
|
||||||
|
OBJDUMP = avr-objdump
|
||||||
|
SIZE = avr-size
|
||||||
|
NM = avr-nm
|
||||||
|
AVRDUDE = avrdude
|
||||||
|
REMOVE = rm -f
|
||||||
|
COPY = cp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Define Messages
|
||||||
|
# English
|
||||||
|
MSG_ERRORS_NONE = Errors: none
|
||||||
|
MSG_BEGIN = -------- begin --------
|
||||||
|
MSG_END = -------- end --------
|
||||||
|
MSG_SIZE_BEFORE = Size before:
|
||||||
|
MSG_SIZE_AFTER = Size after:
|
||||||
|
MSG_COFF = Converting to AVR COFF:
|
||||||
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
MSG_FLASH = Creating load file for Flash:
|
||||||
|
MSG_EEPROM = Creating load file for EEPROM:
|
||||||
|
MSG_EXTENDED_LISTING = Creating Extended Listing:
|
||||||
|
MSG_SYMBOL_TABLE = Creating Symbol Table:
|
||||||
|
MSG_LINKING = Linking:
|
||||||
|
MSG_COMPILING = Compiling:
|
||||||
|
MSG_ASSEMBLING = Assembling:
|
||||||
|
MSG_CLEANING = Cleaning project:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Define all object files.
|
||||||
|
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
|
||||||
|
|
||||||
|
# Define all listing files.
|
||||||
|
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
|
||||||
|
|
||||||
|
|
||||||
|
# Compiler flags to generate dependency files.
|
||||||
|
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
|
||||||
|
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
|
||||||
|
|
||||||
|
# Combine all necessary flags and optional flags.
|
||||||
|
# Add target processor to flags.
|
||||||
|
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Default target.
|
||||||
|
all: begin gccversion sizebefore build sizeafter finished end
|
||||||
|
|
||||||
|
build: elf hex eep lss sym
|
||||||
|
|
||||||
|
elf: $(TARGET).elf
|
||||||
|
hex: $(TARGET).hex
|
||||||
|
eep: $(TARGET).eep
|
||||||
|
lss: $(TARGET).lss
|
||||||
|
sym: $(TARGET).sym
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Eye candy.
|
||||||
|
# AVR Studio 3.x does not check make's exit code but relies on
|
||||||
|
# the following magic strings to be generated by the compile job.
|
||||||
|
begin:
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_BEGIN)
|
||||||
|
|
||||||
|
finished:
|
||||||
|
@echo $(MSG_ERRORS_NONE)
|
||||||
|
|
||||||
|
end:
|
||||||
|
@echo $(MSG_END)
|
||||||
|
@echo
|
||||||
|
|
||||||
|
|
||||||
|
# Display size of file.
|
||||||
|
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
|
||||||
|
ELFSIZE = $(SIZE) -A $(TARGET).elf
|
||||||
|
sizebefore:
|
||||||
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
sizeafter:
|
||||||
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Display compiler version information.
|
||||||
|
gccversion :
|
||||||
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Program the device.
|
||||||
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
||||||
|
# Create final output files (.hex, .eep) from ELF output file.
|
||||||
|
%.hex: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_FLASH) $@
|
||||||
|
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||||
|
|
||||||
|
%.eep: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_EEPROM) $@
|
||||||
|
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||||
|
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
||||||
|
|
||||||
|
# Create extended listing file from ELF output file.
|
||||||
|
%.lss: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_EXTENDED_LISTING) $@
|
||||||
|
$(OBJDUMP) -h -S $< > $@
|
||||||
|
|
||||||
|
# Create a symbol table from ELF output file.
|
||||||
|
%.sym: %.elf
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_SYMBOL_TABLE) $@
|
||||||
|
$(NM) -n $< > $@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Link: create ELF output file from object files.
|
||||||
|
.SECONDARY : $(TARGET).elf
|
||||||
|
.PRECIOUS : $(OBJ)
|
||||||
|
%.elf: $(OBJ)
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_LINKING) $@
|
||||||
|
$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create object files from C source files.
|
||||||
|
%.o : %.c
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_COMPILING) $<
|
||||||
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
# Compile: create assembler files from C source files.
|
||||||
|
%.s : %.c
|
||||||
|
$(CC) -S $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
# Assemble: create object files from assembler source files.
|
||||||
|
%.o : %.S
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_ASSEMBLING) $<
|
||||||
|
$(CC) -c $(ALL_ASFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Target: clean project.
|
||||||
|
clean: begin clean_list finished end
|
||||||
|
|
||||||
|
clean_list :
|
||||||
|
@echo
|
||||||
|
@echo $(MSG_CLEANING)
|
||||||
|
$(REMOVE) $(TARGET).hex
|
||||||
|
$(REMOVE) $(TARGET).eep
|
||||||
|
$(REMOVE) $(TARGET).obj
|
||||||
|
$(REMOVE) $(TARGET).cof
|
||||||
|
$(REMOVE) $(TARGET).elf
|
||||||
|
$(REMOVE) $(TARGET).map
|
||||||
|
$(REMOVE) $(TARGET).obj
|
||||||
|
$(REMOVE) $(TARGET).a90
|
||||||
|
$(REMOVE) $(TARGET).sym
|
||||||
|
$(REMOVE) $(TARGET).lnk
|
||||||
|
$(REMOVE) $(TARGET).lss
|
||||||
|
$(REMOVE) $(OBJ)
|
||||||
|
$(REMOVE) $(LST)
|
||||||
|
$(REMOVE) $(SRC:.c=.s)
|
||||||
|
$(REMOVE) $(SRC:.c=.d)
|
||||||
|
$(REMOVE) .dep/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Include the dependency files.
|
||||||
|
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
||||||
|
|
||||||
|
|
||||||
|
# Listing of phony targets.
|
||||||
|
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
||||||
|
build elf hex eep lss sym coff extcoff \
|
||||||
|
clean clean_list program
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
|
||||||
|
void adc_init(void) {
|
||||||
|
uint16_t dummyResult;
|
||||||
|
// AVCC with external capacitor at AREF pin
|
||||||
|
ADMUX = _BV(REFS0);
|
||||||
|
|
||||||
|
// set frequency prescaler to 8
|
||||||
|
ADCSRA = _BV(ADPS1) | _BV(ADPS0);
|
||||||
|
|
||||||
|
// enable ADC
|
||||||
|
ADCSRA |= _BV(ADEN);
|
||||||
|
|
||||||
|
// make a dummy read out
|
||||||
|
ADCSRA |= _BV(ADSC);
|
||||||
|
while (ADCSRA & _BV(ADSC) ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// we have to read, otherwise the next result is not available
|
||||||
|
dummyResult = ADCW;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t adc_read_single(uint8_t channel) {
|
||||||
|
ADMUX = (ADMUX & ~(0x1F)) | (channel & 0x1F);
|
||||||
|
ADCSRA |= _BV(ADSC);
|
||||||
|
while (ADCSRA & (1<<ADSC) ) {
|
||||||
|
}
|
||||||
|
return ADCW;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t adc_read_avg(const uint8_t channel, const uint8_t nsamples) {
|
||||||
|
uint16_t sum = 0;
|
||||||
|
uint8_t count = nsamples % 60;
|
||||||
|
|
||||||
|
for (uint8_t i=0; i<count;++i ) {
|
||||||
|
sum += adc_read_single(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (sum / count);
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef _adc_h
|
||||||
|
#define _adc_h
|
||||||
|
|
||||||
|
extern void adc_init(void);
|
||||||
|
extern uint16_t adc_read_single(uint8_t);
|
||||||
|
extern uint16_t adc_read_avg(uint8_t, uint8_t);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,246 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "utils.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "adc.h"
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* ideensammlung für spätere implementierung:
|
||||||
|
*
|
||||||
|
* anstelle der vielen counter bauen wir zwei statemachines (gen/reg).
|
||||||
|
* states:
|
||||||
|
* generator_spannung_ok
|
||||||
|
* generator_überspannung
|
||||||
|
* generator_unterspannung
|
||||||
|
*
|
||||||
|
* regler_spannung_ok
|
||||||
|
* regler_überspannung
|
||||||
|
* regler_unterspannung
|
||||||
|
*
|
||||||
|
* eingänge:
|
||||||
|
* modeswitch
|
||||||
|
* reglerspannung
|
||||||
|
* generatorspannung
|
||||||
|
* gen_einaus
|
||||||
|
* reg_einaus
|
||||||
|
* bat_einaus
|
||||||
|
*
|
||||||
|
* ausgänge:
|
||||||
|
* relais_bat
|
||||||
|
* relais_gen
|
||||||
|
* relais_reg
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
volatile uint16_t syscounter = 0;
|
||||||
|
uint16_t voltage_reg = 0;
|
||||||
|
uint16_t voltage_gen = 0;
|
||||||
|
uint16_t current_gen = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
uint8_t overvoltage_counter = 0;
|
||||||
|
uint8_t overvoltage_off_counter = 0;
|
||||||
|
uint8_t undervoltage_counter = 0;
|
||||||
|
uint8_t undervoltage_off_counter = 0;
|
||||||
|
uint8_t generator_counter = 0;
|
||||||
|
uint8_t generator_off_counter = 0;
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void timer_init(void) {
|
||||||
|
// clock is 8MHz
|
||||||
|
TCCR1B |= _BV(WGM12) | _BV(CS11) | _BV(CS10) ; // CTC Mode for Timer 1 (16Bit) with prescale of 64
|
||||||
|
OCR1A = 1250; // 100Hz
|
||||||
|
TIMSK = _BV(OCIE1A);
|
||||||
|
sei();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ports_init(void) {
|
||||||
|
// set all switch port to output mode
|
||||||
|
DDR_SW |= _BV(LOADSW) | _BV(GENSW) | _BV(BATSW);
|
||||||
|
|
||||||
|
// set all ports to low
|
||||||
|
PORT_SW &= ~(_BV(LOADSW) | _BV(GENSW) | _BV(BATSW));
|
||||||
|
|
||||||
|
// set inputs
|
||||||
|
DDR_TP &= ~(_BV(TP1));
|
||||||
|
|
||||||
|
// enable pullups for inputs
|
||||||
|
PORT_TP |= _BV(TP1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void measure(void) {
|
||||||
|
|
||||||
|
static int16_t temp;
|
||||||
|
|
||||||
|
voltage_bat = adc_read_avg(AD_V_BAT, 4);
|
||||||
|
voltage_bat *= VOLTAGE_PER_TICK;
|
||||||
|
voltage_bat += 790;
|
||||||
|
|
||||||
|
voltage_gen = adc_read_avg(AD_V_GEN, 4);
|
||||||
|
voltage_gen *= VOLTAGE_PER_TICK;
|
||||||
|
|
||||||
|
temp = adc_read_avg(AD_I_GEN, 4);
|
||||||
|
temp -= CURRENT_OFFSET;
|
||||||
|
if(temp < 0) temp = 0;
|
||||||
|
current_in = temp * CURRENT_PER_TICK;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t get_power(uint16_t voltage, int16_t currents) {
|
||||||
|
return (voltage/100 * (currents/100)) / 100 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pretty_print_all_values(void) {
|
||||||
|
uart_puts_P("Battery Voltage: ");
|
||||||
|
uart_print_uint16(voltage_bat);
|
||||||
|
uart_puts_P("mV\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("Generator Voltage: ");
|
||||||
|
uart_print_uint16(voltage_gen);
|
||||||
|
uart_puts_P("mV\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("Generator: ");
|
||||||
|
uart_print_uint16(current_in);
|
||||||
|
uart_puts_P("mA ");
|
||||||
|
uart_print_uint16(get_power(voltage_bat, current_in));
|
||||||
|
uart_puts_P("W\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("switches (load, gen): ");
|
||||||
|
uart_putc(48 + (IS_LOAD_ON >> LOADSW));
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48 + (IS_GEN_ON >> GENSW));
|
||||||
|
uart_puts_P("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_over_and_undervoltage(void) {
|
||||||
|
/*
|
||||||
|
if(voltage_bat < UNDERVOLTAGE) {
|
||||||
|
undervoltage_off_counter = 0;
|
||||||
|
if(undervoltage_counter<UNDERVOLTAGE_TIMEOUT) undervoltage_counter++;
|
||||||
|
} else {
|
||||||
|
undervoltage_counter = 0;
|
||||||
|
if(undervoltage_off_counter<UNDERVOLTAGEOFF_TIMEOUT) undervoltage_off_counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(voltage_gen > GENERATOR) {
|
||||||
|
generator_off_counter = 0;
|
||||||
|
if(generator_counter<GENERATOR_TIMEOUT) generator_counter++;
|
||||||
|
} else {
|
||||||
|
generator_counter = 0;
|
||||||
|
if(generator_off_counter<GENERATOR_OFF_TIMEOUT) generator_off_counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(undervoltage_counter >= UNDERVOLTAGE_TIMEOUT) {
|
||||||
|
// spannung zu niedrig => abschalten
|
||||||
|
undervoltage_off_counter = 0;
|
||||||
|
LOAD_OFF;
|
||||||
|
} else {
|
||||||
|
// spannung ist okay
|
||||||
|
|
||||||
|
// ist die spannung schon lange genug okay?
|
||||||
|
if(undervoltage_off_counter >= UNDERVOLTAGEOFF_TIMEOUT) {
|
||||||
|
undervoltage_counter = 0;
|
||||||
|
|
||||||
|
// ja, also schauen ob der generator schon lange genug läuft
|
||||||
|
if(generator_counter >= GENERATOR_TIMEOUT) {
|
||||||
|
// ja, also einschalten
|
||||||
|
LOAD_ON;
|
||||||
|
} else {
|
||||||
|
// nein, generator nicht lange genug an
|
||||||
|
|
||||||
|
// ist er vielleicht schon lange aus?
|
||||||
|
if(generator_off_counter >= GENERATOR_OFF_TIMEOUT) {
|
||||||
|
// ja, also abschalten, egal ob akku okay
|
||||||
|
LOAD_OFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
uart_puts_P("ov1=");
|
||||||
|
uart_print_uint8(overvoltage_counter1);
|
||||||
|
uart_puts_P(" ovo1=");
|
||||||
|
uart_print_uint8 (overvoltage_off_counter1);
|
||||||
|
uart_puts_P("\r\n");
|
||||||
|
|
||||||
|
uart_puts_P("uv =");
|
||||||
|
uart_print_uint8(undervoltage_counter);
|
||||||
|
uart_puts_P(" uvo =");
|
||||||
|
uart_print_uint8(undervoltage_off_counter);
|
||||||
|
uart_puts_P("\r\n");
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void work_uart(void) {
|
||||||
|
uint16_t uart_char = uart_getc();
|
||||||
|
|
||||||
|
if(uart_char != UART_NO_DATA) {
|
||||||
|
switch(uart_char & 0xff) {
|
||||||
|
case 'p':
|
||||||
|
pretty_print_all_values();
|
||||||
|
break;
|
||||||
|
case 'a':
|
||||||
|
uart_putc('A');
|
||||||
|
uart_print_uint16(voltage_bat);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_print_uint16(current_in);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_print_uint16(0);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_print_uint16(get_power(voltage_bat, current_in));
|
||||||
|
uart_putc(',');
|
||||||
|
uart_print_uint16(0);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48 + (IS_LOAD_ON));
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48 + (IS_BAT_ON);
|
||||||
|
uart_putc(',');
|
||||||
|
uart_putc(48 + (IS_GEN_ON));
|
||||||
|
uart_putc('B');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
ports_init();
|
||||||
|
adc_init();
|
||||||
|
timer_init();
|
||||||
|
uart_init(UART_BAUD_SELECT(19200,F_CPU));
|
||||||
|
|
||||||
|
//LOAD_OFF;
|
||||||
|
//GEN_ON;
|
||||||
|
//BAT_ON;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
if(syscounter >= 100) {
|
||||||
|
syscounter = 0;
|
||||||
|
|
||||||
|
measure();
|
||||||
|
|
||||||
|
//pretty_print_all_values();
|
||||||
|
|
||||||
|
handle_over_and_undervoltage();
|
||||||
|
}
|
||||||
|
|
||||||
|
work_uart();
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// system timer
|
||||||
|
SIGNAL(TIMER1_COMPA_vect) {
|
||||||
|
syscounter++;
|
||||||
|
syscounter %= 60000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
#ifndef _main_h
|
||||||
|
#define _main_h
|
||||||
|
|
||||||
|
#define AD_V_GEN 0
|
||||||
|
#define AD_I_GEN 1
|
||||||
|
#define AD_V_REG 2
|
||||||
|
|
||||||
|
#define LOADSW PB0
|
||||||
|
#define BATSW PB1
|
||||||
|
#define GENSW PB2
|
||||||
|
#define PORT_SW PORTB
|
||||||
|
#define DDR_SW DDRB
|
||||||
|
#define PIN_SW PINB
|
||||||
|
|
||||||
|
#define TP1 PD7 // used for operating mode switching
|
||||||
|
#define TP2 PD6
|
||||||
|
#define TP3 PD5
|
||||||
|
#define PORT_TP PORTD
|
||||||
|
#define DDR_TP DDRD
|
||||||
|
#define PIN_TP PIND
|
||||||
|
|
||||||
|
#define LOAD_ON PORT_SW |= _BV(LOADSW)
|
||||||
|
#define LOAD_OFF PORT_SW &= ~_BV(LOADSW)
|
||||||
|
#define GEN_ON PORT_SW |= _BV(GENSW)
|
||||||
|
#define GEN_OFF PORT_SW &= ~_BV(GENSW)
|
||||||
|
#define BAT_ON PORT_SW |= _BV(BATSW)
|
||||||
|
#define BAT_OFF PORT_SW &= ~_BV(BATSW)
|
||||||
|
|
||||||
|
#define IS_LOAD_ON (PIN_SW & _BV(LOADSW)) >> LOADSW
|
||||||
|
#define IS_GEN_ON (PIN_SW & _BV(GENSW)) >> GENSW
|
||||||
|
#define IS_BAT_ON (PIN_SW & _BV(BATSW)) >> BATSW
|
||||||
|
|
||||||
|
#define GENERATOR 13000
|
||||||
|
#define GENERATOR_TIMEOUT 3
|
||||||
|
#define GENERATOR_OFF_TIMEOUT 1
|
||||||
|
|
||||||
|
#define UNDERVOLTAGE 11200
|
||||||
|
#define OVERVOLTAGE 15000
|
||||||
|
#define OVERVOLTAGE_TIMEOUT 5
|
||||||
|
#define OVERVOLTAGEOFF_TIMEOUT 3
|
||||||
|
#define UNDERVOLTAGE_TIMEOUT 5
|
||||||
|
#define UNDERVOLTAGEOFF_TIMEOUT 3
|
||||||
|
|
||||||
|
#define CURRENT_OFFSET 511
|
||||||
|
#define CURRENT_PER_TICK 72
|
||||||
|
#define VOLTAGE_PER_TICK 15
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,663 @@
|
||||||
|
/*************************************************************************
|
||||||
|
Title: Interrupt UART library with receive/transmit circular buffers
|
||||||
|
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
|
||||||
|
File: $Id: uart.c,v 1.10 2013/06/02 07:27:04 peter Exp $
|
||||||
|
Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher
|
||||||
|
Hardware: any AVR with built-in UART,
|
||||||
|
License: GNU General Public License
|
||||||
|
|
||||||
|
DESCRIPTION:
|
||||||
|
An interrupt is generated when the UART has finished transmitting or
|
||||||
|
receiving a byte. The interrupt handling routines use circular buffers
|
||||||
|
for buffering received and transmitted data.
|
||||||
|
|
||||||
|
The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE variables define
|
||||||
|
the buffer size in bytes. Note that these variables must be a
|
||||||
|
power of 2.
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
Refere to the header file uart.h for a description of the routines.
|
||||||
|
See also example test_uart.c.
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
Based on Atmel Application Note AVR306
|
||||||
|
|
||||||
|
LICENSE:
|
||||||
|
Copyright (C) 2006 Peter Fleury
|
||||||
|
|
||||||
|
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, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
*************************************************************************/
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* constants and macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* size of RX/TX buffers */
|
||||||
|
#define UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1)
|
||||||
|
#define UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1)
|
||||||
|
|
||||||
|
#if ( UART_RX_BUFFER_SIZE & UART_RX_BUFFER_MASK )
|
||||||
|
#error RX buffer size is not a power of 2
|
||||||
|
#endif
|
||||||
|
#if ( UART_TX_BUFFER_SIZE & UART_TX_BUFFER_MASK )
|
||||||
|
#error TX buffer size is not a power of 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__AVR_AT90S2313__) \
|
||||||
|
|| defined(__AVR_AT90S4414__) || defined(__AVR_AT90S4434__) \
|
||||||
|
|| defined(__AVR_AT90S8515__) || defined(__AVR_AT90S8535__) \
|
||||||
|
|| defined(__AVR_ATmega103__)
|
||||||
|
/* old AVR classic or ATmega103 with one UART */
|
||||||
|
#define AT90_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS USR
|
||||||
|
#define UART0_CONTROL UCR
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__)
|
||||||
|
/* old AVR classic with one UART */
|
||||||
|
#define AT90_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \
|
||||||
|
|| defined(__AVR_ATmega323__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RXC_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined (__AVR_ATmega8515__) || defined(__AVR_ATmega8535__)
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega163__)
|
||||||
|
/* ATmega163 with one UART */
|
||||||
|
#define ATMEGA_UART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT UART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT UART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega162__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RXC_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RXC_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega161__)
|
||||||
|
/* ATmega with UART */
|
||||||
|
#error "AVR ATmega161 currently not supported by this libaray !"
|
||||||
|
#elif defined(__AVR_ATmega169__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega48P__) || defined(__AVR_ATmega88P__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) \
|
||||||
|
|| defined(__AVR_ATmega3250__) || defined(__AVR_ATmega3290__) ||defined(__AVR_ATmega6450__) || defined(__AVR_ATmega6490__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATtiny2313__)
|
||||||
|
#define ATMEGA_USART
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSRA
|
||||||
|
#define UART0_CONTROL UCSRB
|
||||||
|
#define UART0_DATA UDR
|
||||||
|
#define UART0_UDRIE UDRIE
|
||||||
|
#elif defined(__AVR_ATmega329__) || \
|
||||||
|
defined(__AVR_ATmega649__) || \
|
||||||
|
defined(__AVR_ATmega325__) || \
|
||||||
|
defined(__AVR_ATmega645__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega640__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#elif defined(__AVR_ATmega644__)
|
||||||
|
/* ATmega with one USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#elif defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__)
|
||||||
|
/* ATmega with two USART */
|
||||||
|
#define ATMEGA_USART0
|
||||||
|
#define ATMEGA_USART1
|
||||||
|
#define UART0_RECEIVE_INTERRUPT USART0_RX_vect
|
||||||
|
#define UART1_RECEIVE_INTERRUPT USART1_RX_vect
|
||||||
|
#define UART0_TRANSMIT_INTERRUPT USART0_UDRE_vect
|
||||||
|
#define UART1_TRANSMIT_INTERRUPT USART1_UDRE_vect
|
||||||
|
#define UART0_STATUS UCSR0A
|
||||||
|
#define UART0_CONTROL UCSR0B
|
||||||
|
#define UART0_DATA UDR0
|
||||||
|
#define UART0_UDRIE UDRIE0
|
||||||
|
#define UART1_STATUS UCSR1A
|
||||||
|
#define UART1_CONTROL UCSR1B
|
||||||
|
#define UART1_DATA UDR1
|
||||||
|
#define UART1_UDRIE UDRIE1
|
||||||
|
#else
|
||||||
|
#error "no UART definition for MCU available"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* module global variables
|
||||||
|
*/
|
||||||
|
static volatile unsigned char UART_TxBuf[UART_TX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART_RxBuf[UART_RX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART_TxHead;
|
||||||
|
static volatile unsigned char UART_TxTail;
|
||||||
|
static volatile unsigned char UART_RxHead;
|
||||||
|
static volatile unsigned char UART_RxTail;
|
||||||
|
static volatile unsigned char UART_LastRxError;
|
||||||
|
|
||||||
|
#if defined( ATMEGA_USART1 )
|
||||||
|
static volatile unsigned char UART1_TxBuf[UART_TX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART1_RxBuf[UART_RX_BUFFER_SIZE];
|
||||||
|
static volatile unsigned char UART1_TxHead;
|
||||||
|
static volatile unsigned char UART1_TxTail;
|
||||||
|
static volatile unsigned char UART1_RxHead;
|
||||||
|
static volatile unsigned char UART1_RxTail;
|
||||||
|
static volatile unsigned char UART1_LastRxError;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ISR (UART0_RECEIVE_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART Receive Complete interrupt
|
||||||
|
Purpose: called when the UART has received a character
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
unsigned char data;
|
||||||
|
unsigned char usr;
|
||||||
|
unsigned char lastRxError;
|
||||||
|
|
||||||
|
|
||||||
|
/* read UART status register and UART data register */
|
||||||
|
usr = UART0_STATUS;
|
||||||
|
data = UART0_DATA;
|
||||||
|
|
||||||
|
/* */
|
||||||
|
#if defined( AT90_UART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#elif defined( ATMEGA_USART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#elif defined( ATMEGA_USART0 )
|
||||||
|
lastRxError = (usr & (_BV(FE0)|_BV(DOR0)) );
|
||||||
|
#elif defined ( ATMEGA_UART )
|
||||||
|
lastRxError = (usr & (_BV(FE)|_BV(DOR)) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* calculate buffer index */
|
||||||
|
tmphead = ( UART_RxHead + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
|
||||||
|
if ( tmphead == UART_RxTail ) {
|
||||||
|
/* error: receive buffer overflow */
|
||||||
|
lastRxError = UART_BUFFER_OVERFLOW >> 8;
|
||||||
|
}else{
|
||||||
|
/* store new index */
|
||||||
|
UART_RxHead = tmphead;
|
||||||
|
/* store received data in buffer */
|
||||||
|
UART_RxBuf[tmphead] = data;
|
||||||
|
}
|
||||||
|
UART_LastRxError |= lastRxError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ISR (UART0_TRANSMIT_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART Data Register Empty interrupt
|
||||||
|
Purpose: called when the UART is ready to transmit the next byte
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART_TxHead != UART_TxTail) {
|
||||||
|
/* calculate and store new buffer index */
|
||||||
|
tmptail = (UART_TxTail + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
UART_TxTail = tmptail;
|
||||||
|
/* get one byte from buffer and write it to UART */
|
||||||
|
UART0_DATA = UART_TxBuf[tmptail]; /* start transmission */
|
||||||
|
}else{
|
||||||
|
/* tx buffer empty, disable UDRE interrupt */
|
||||||
|
UART0_CONTROL &= ~_BV(UART0_UDRIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_init()
|
||||||
|
Purpose: initialize UART and set baudrate
|
||||||
|
Input: baudrate using macro UART_BAUD_SELECT()
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_init(unsigned int baudrate)
|
||||||
|
{
|
||||||
|
UART_TxHead = 0;
|
||||||
|
UART_TxTail = 0;
|
||||||
|
UART_RxHead = 0;
|
||||||
|
UART_RxTail = 0;
|
||||||
|
|
||||||
|
#if defined( AT90_UART )
|
||||||
|
/* set baud rate */
|
||||||
|
UBRR = (unsigned char)baudrate;
|
||||||
|
|
||||||
|
/* enable UART receiver and transmmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|_BV(RXEN)|_BV(TXEN);
|
||||||
|
|
||||||
|
#elif defined (ATMEGA_USART)
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRRH = (unsigned char)(baudrate>>8);
|
||||||
|
UBRRL = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|(1<<RXEN)|(1<<TXEN);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL
|
||||||
|
UCSRC = (1<<URSEL)|(3<<UCSZ0);
|
||||||
|
#else
|
||||||
|
UCSRC = (3<<UCSZ0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined (ATMEGA_USART0 )
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X0); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRR0H = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR0L = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE0)|(1<<RXEN0)|(1<<TXEN0);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL0
|
||||||
|
UCSR0C = (1<<URSEL0)|(3<<UCSZ00);
|
||||||
|
#else
|
||||||
|
UCSR0C = (3<<UCSZ00);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( ATMEGA_UART )
|
||||||
|
/* set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART0_STATUS = (1<<U2X); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRRHI = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable UART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART0_CONTROL = _BV(RXCIE)|(1<<RXEN)|(1<<TXEN);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}/* uart_init */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_getc()
|
||||||
|
Purpose: return byte from ringbuffer
|
||||||
|
Returns: lower byte: received byte from ringbuffer
|
||||||
|
higher byte: last receive error
|
||||||
|
**************************************************************************/
|
||||||
|
unsigned int uart_getc(void)
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
unsigned char data;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART_RxHead == UART_RxTail ) {
|
||||||
|
return UART_NO_DATA; /* no data available */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate /store buffer index */
|
||||||
|
tmptail = (UART_RxTail + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
UART_RxTail = tmptail;
|
||||||
|
|
||||||
|
/* get data from receive buffer */
|
||||||
|
data = UART_RxBuf[tmptail];
|
||||||
|
|
||||||
|
data = (UART_LastRxError << 8) + data;
|
||||||
|
UART_LastRxError = 0;
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}/* uart_getc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_putc()
|
||||||
|
Purpose: write byte to ringbuffer for transmitting via UART
|
||||||
|
Input: byte to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_putc(unsigned char data)
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
|
||||||
|
|
||||||
|
tmphead = (UART_TxHead + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
|
||||||
|
while ( tmphead == UART_TxTail ){
|
||||||
|
;/* wait for free space in buffer */
|
||||||
|
}
|
||||||
|
|
||||||
|
UART_TxBuf[tmphead] = data;
|
||||||
|
UART_TxHead = tmphead;
|
||||||
|
|
||||||
|
/* enable UDRE interrupt */
|
||||||
|
UART0_CONTROL |= _BV(UART0_UDRIE);
|
||||||
|
|
||||||
|
}/* uart_putc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_puts()
|
||||||
|
Purpose: transmit string to UART
|
||||||
|
Input: string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_puts(const char *s )
|
||||||
|
{
|
||||||
|
while (*s)
|
||||||
|
uart_putc(*s++);
|
||||||
|
|
||||||
|
}/* uart_puts */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart_puts_p()
|
||||||
|
Purpose: transmit string from program memory to UART
|
||||||
|
Input: program memory string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart_puts_p(const char *progmem_s )
|
||||||
|
{
|
||||||
|
register char c;
|
||||||
|
|
||||||
|
while ( (c = pgm_read_byte(progmem_s++)) )
|
||||||
|
uart_putc(c);
|
||||||
|
|
||||||
|
}/* uart_puts_p */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* these functions are only for ATmegas with two USART
|
||||||
|
*/
|
||||||
|
#if defined( ATMEGA_USART1 )
|
||||||
|
|
||||||
|
ISR(UART1_RECEIVE_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART1 Receive Complete interrupt
|
||||||
|
Purpose: called when the UART1 has received a character
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
unsigned char data;
|
||||||
|
unsigned char usr;
|
||||||
|
unsigned char lastRxError;
|
||||||
|
|
||||||
|
|
||||||
|
/* read UART status register and UART data register */
|
||||||
|
usr = UART1_STATUS;
|
||||||
|
data = UART1_DATA;
|
||||||
|
|
||||||
|
/* */
|
||||||
|
lastRxError = (usr & (_BV(FE1)|_BV(DOR1)) );
|
||||||
|
|
||||||
|
/* calculate buffer index */
|
||||||
|
tmphead = ( UART1_RxHead + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
|
||||||
|
if ( tmphead == UART1_RxTail ) {
|
||||||
|
/* error: receive buffer overflow */
|
||||||
|
lastRxError = UART_BUFFER_OVERFLOW >> 8;
|
||||||
|
}else{
|
||||||
|
/* store new index */
|
||||||
|
UART1_RxHead = tmphead;
|
||||||
|
/* store received data in buffer */
|
||||||
|
UART1_RxBuf[tmphead] = data;
|
||||||
|
}
|
||||||
|
UART1_LastRxError |= lastRxError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ISR(UART1_TRANSMIT_INTERRUPT)
|
||||||
|
/*************************************************************************
|
||||||
|
Function: UART1 Data Register Empty interrupt
|
||||||
|
Purpose: called when the UART1 is ready to transmit the next byte
|
||||||
|
**************************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART1_TxHead != UART1_TxTail) {
|
||||||
|
/* calculate and store new buffer index */
|
||||||
|
tmptail = (UART1_TxTail + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
UART1_TxTail = tmptail;
|
||||||
|
/* get one byte from buffer and write it to UART */
|
||||||
|
UART1_DATA = UART1_TxBuf[tmptail]; /* start transmission */
|
||||||
|
}else{
|
||||||
|
/* tx buffer empty, disable UDRE interrupt */
|
||||||
|
UART1_CONTROL &= ~_BV(UART1_UDRIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_init()
|
||||||
|
Purpose: initialize UART1 and set baudrate
|
||||||
|
Input: baudrate using macro UART_BAUD_SELECT()
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart1_init(unsigned int baudrate)
|
||||||
|
{
|
||||||
|
UART1_TxHead = 0;
|
||||||
|
UART1_TxTail = 0;
|
||||||
|
UART1_RxHead = 0;
|
||||||
|
UART1_RxTail = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* Set baud rate */
|
||||||
|
if ( baudrate & 0x8000 )
|
||||||
|
{
|
||||||
|
UART1_STATUS = (1<<U2X1); //Enable 2x speed
|
||||||
|
baudrate &= ~0x8000;
|
||||||
|
}
|
||||||
|
UBRR1H = (unsigned char)(baudrate>>8);
|
||||||
|
UBRR1L = (unsigned char) baudrate;
|
||||||
|
|
||||||
|
/* Enable USART receiver and transmitter and receive complete interrupt */
|
||||||
|
UART1_CONTROL = _BV(RXCIE1)|(1<<RXEN1)|(1<<TXEN1);
|
||||||
|
|
||||||
|
/* Set frame format: asynchronous, 8data, no parity, 1stop bit */
|
||||||
|
#ifdef URSEL1
|
||||||
|
UCSR1C = (1<<URSEL1)|(3<<UCSZ10);
|
||||||
|
#else
|
||||||
|
UCSR1C = (3<<UCSZ10);
|
||||||
|
#endif
|
||||||
|
}/* uart_init */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_getc()
|
||||||
|
Purpose: return byte from ringbuffer
|
||||||
|
Returns: lower byte: received byte from ringbuffer
|
||||||
|
higher byte: last receive error
|
||||||
|
**************************************************************************/
|
||||||
|
unsigned int uart1_getc(void)
|
||||||
|
{
|
||||||
|
unsigned char tmptail;
|
||||||
|
unsigned char data;
|
||||||
|
|
||||||
|
|
||||||
|
if ( UART1_RxHead == UART1_RxTail ) {
|
||||||
|
return UART_NO_DATA; /* no data available */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate /store buffer index */
|
||||||
|
tmptail = (UART1_RxTail + 1) & UART_RX_BUFFER_MASK;
|
||||||
|
UART1_RxTail = tmptail;
|
||||||
|
|
||||||
|
/* get data from receive buffer */
|
||||||
|
data = UART1_RxBuf[tmptail];
|
||||||
|
|
||||||
|
data = (UART1_LastRxError << 8) + data;
|
||||||
|
UART1_LastRxError = 0;
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}/* uart1_getc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_putc()
|
||||||
|
Purpose: write byte to ringbuffer for transmitting via UART
|
||||||
|
Input: byte to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart1_putc(unsigned char data)
|
||||||
|
{
|
||||||
|
unsigned char tmphead;
|
||||||
|
|
||||||
|
|
||||||
|
tmphead = (UART1_TxHead + 1) & UART_TX_BUFFER_MASK;
|
||||||
|
|
||||||
|
while ( tmphead == UART1_TxTail ){
|
||||||
|
;/* wait for free space in buffer */
|
||||||
|
}
|
||||||
|
|
||||||
|
UART1_TxBuf[tmphead] = data;
|
||||||
|
UART1_TxHead = tmphead;
|
||||||
|
|
||||||
|
/* enable UDRE interrupt */
|
||||||
|
UART1_CONTROL |= _BV(UART1_UDRIE);
|
||||||
|
|
||||||
|
}/* uart1_putc */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_puts()
|
||||||
|
Purpose: transmit string to UART1
|
||||||
|
Input: string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart1_puts(const char *s )
|
||||||
|
{
|
||||||
|
while (*s)
|
||||||
|
uart1_putc(*s++);
|
||||||
|
|
||||||
|
}/* uart1_puts */
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Function: uart1_puts_p()
|
||||||
|
Purpose: transmit string from program memory to UART1
|
||||||
|
Input: program memory string to be transmitted
|
||||||
|
Returns: none
|
||||||
|
**************************************************************************/
|
||||||
|
void uart1_puts_p(const char *progmem_s )
|
||||||
|
{
|
||||||
|
register char c;
|
||||||
|
|
||||||
|
while ( (c = pgm_read_byte(progmem_s++)) )
|
||||||
|
uart1_putc(c);
|
||||||
|
|
||||||
|
}/* uart1_puts_p */
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,180 @@
|
||||||
|
#ifndef UART_H
|
||||||
|
#define UART_H
|
||||||
|
/************************************************************************
|
||||||
|
Title: Interrupt UART library with receive/transmit circular buffers
|
||||||
|
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
|
||||||
|
File: $Id: uart.h,v 1.12 2012/11/19 19:52:27 peter Exp $
|
||||||
|
Software: AVR-GCC 4.1, AVR Libc 1.4
|
||||||
|
Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz
|
||||||
|
License: GNU General Public License
|
||||||
|
Usage: see Doxygen manual
|
||||||
|
|
||||||
|
LICENSE:
|
||||||
|
Copyright (C) 2006 Peter Fleury
|
||||||
|
|
||||||
|
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, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup pfleury_uart UART Library
|
||||||
|
* @code #include <uart.h> @endcode
|
||||||
|
*
|
||||||
|
* @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers.
|
||||||
|
*
|
||||||
|
* This library can be used to transmit and receive data through the built in UART.
|
||||||
|
*
|
||||||
|
* An interrupt is generated when the UART has finished transmitting or
|
||||||
|
* receiving a byte. The interrupt handling routines use circular buffers
|
||||||
|
* for buffering received and transmitted data.
|
||||||
|
*
|
||||||
|
* The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE constants define
|
||||||
|
* the size of the circular buffers in bytes. Note that these constants must be a power of 2.
|
||||||
|
* You may need to adapt this constants to your target and your application by adding
|
||||||
|
* CDEFS += -DUART_RX_BUFFER_SIZE=nn -DUART_RX_BUFFER_SIZE=nn to your Makefile.
|
||||||
|
*
|
||||||
|
* @note Based on Atmel Application Note AVR306
|
||||||
|
* @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**@{*/
|
||||||
|
|
||||||
|
|
||||||
|
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304
|
||||||
|
#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** constants and macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @brief UART Baudrate Expression
|
||||||
|
* @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
||||||
|
* @param baudrate baudrate in bps, e.g. 1200, 2400, 9600
|
||||||
|
*/
|
||||||
|
#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL)
|
||||||
|
|
||||||
|
/** @brief UART Baudrate Expression for ATmega double speed mode
|
||||||
|
* @param xtalcpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
||||||
|
* @param baudrate baudrate in bps, e.g. 1200, 2400, 9600
|
||||||
|
*/
|
||||||
|
#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000)
|
||||||
|
|
||||||
|
|
||||||
|
/** Size of the circular receive buffer, must be power of 2 */
|
||||||
|
#ifndef UART_RX_BUFFER_SIZE
|
||||||
|
#define UART_RX_BUFFER_SIZE 32
|
||||||
|
#endif
|
||||||
|
/** Size of the circular transmit buffer, must be power of 2 */
|
||||||
|
#ifndef UART_TX_BUFFER_SIZE
|
||||||
|
#define UART_TX_BUFFER_SIZE 32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* test if the size of the circular buffers fits into SRAM */
|
||||||
|
#if ( (UART_RX_BUFFER_SIZE+UART_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) )
|
||||||
|
#error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** high byte error return code of uart_getc()
|
||||||
|
*/
|
||||||
|
#define UART_FRAME_ERROR 0x1000 /* Framing Error by UART */
|
||||||
|
#define UART_OVERRUN_ERROR 0x0800 /* Overrun condition by UART */
|
||||||
|
#define UART_PARITY_ERROR 0x0400 /* Parity Error by UART */
|
||||||
|
#define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */
|
||||||
|
#define UART_NO_DATA 0x0100 /* no receive data available */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** function prototypes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Initialize UART and set baudrate
|
||||||
|
@param baudrate Specify baudrate using macro UART_BAUD_SELECT()
|
||||||
|
@return none
|
||||||
|
*/
|
||||||
|
extern void uart_init(unsigned int baudrate);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get received byte from ringbuffer
|
||||||
|
*
|
||||||
|
* Returns in the lower byte the received character and in the
|
||||||
|
* higher byte the last receive error.
|
||||||
|
* UART_NO_DATA is returned when no data is available.
|
||||||
|
*
|
||||||
|
* @param void
|
||||||
|
* @return lower byte: received byte from ringbuffer
|
||||||
|
* @return higher byte: last receive status
|
||||||
|
* - \b 0 successfully received data from UART
|
||||||
|
* - \b UART_NO_DATA
|
||||||
|
* <br>no receive data available
|
||||||
|
* - \b UART_BUFFER_OVERFLOW
|
||||||
|
* <br>Receive ringbuffer overflow.
|
||||||
|
* We are not reading the receive buffer fast enough,
|
||||||
|
* one or more received character have been dropped
|
||||||
|
* - \b UART_OVERRUN_ERROR
|
||||||
|
* <br>Overrun condition by UART.
|
||||||
|
* A character already present in the UART UDR register was
|
||||||
|
* not read by the interrupt handler before the next character arrived,
|
||||||
|
* one or more received characters have been dropped.
|
||||||
|
* - \b UART_FRAME_ERROR
|
||||||
|
* <br>Framing Error by UART
|
||||||
|
*/
|
||||||
|
extern unsigned int uart_getc(void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put byte to ringbuffer for transmitting via UART
|
||||||
|
* @param data byte to be transmitted
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
extern void uart_putc(unsigned char data);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put string to ringbuffer for transmitting via UART
|
||||||
|
*
|
||||||
|
* The string is buffered by the uart library in a circular buffer
|
||||||
|
* and one character at a time is transmitted to the UART using interrupts.
|
||||||
|
* Blocks if it can not write the whole string into the circular buffer.
|
||||||
|
*
|
||||||
|
* @param s string to be transmitted
|
||||||
|
* @return none
|
||||||
|
*/
|
||||||
|
extern void uart_puts(const char *s );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put string from program memory to ringbuffer for transmitting via UART.
|
||||||
|
*
|
||||||
|
* The string is buffered by the uart library in a circular buffer
|
||||||
|
* and one character at a time is transmitted to the UART using interrupts.
|
||||||
|
* Blocks if it can not write the whole string into the circular buffer.
|
||||||
|
*
|
||||||
|
* @param s program memory string to be transmitted
|
||||||
|
* @return none
|
||||||
|
* @see uart_puts_P
|
||||||
|
*/
|
||||||
|
extern void uart_puts_p(const char *s );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Macro to automatically put a string constant into program memory
|
||||||
|
*/
|
||||||
|
#define uart_puts_P(__s) uart_puts_p(PSTR(__s))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // UART_H
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
void wait(uint8_t count) {
|
||||||
|
uint8_t i;
|
||||||
|
if(count == 0) count = 100;
|
||||||
|
for(i=0;i<count;i++) {
|
||||||
|
_delay_ms(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_voltage(uint16_t x) {
|
||||||
|
uart_putc(48 + (x / 10000));
|
||||||
|
uart_putc(48 + (x % 10000 /1000));
|
||||||
|
uart_putc('.');
|
||||||
|
uart_putc(48 + (x % 1000 / 100 ));
|
||||||
|
//uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
//uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_uint8(uint8_t x) {
|
||||||
|
uart_putc(48 + (x / 100 ));
|
||||||
|
uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_print_uint16(uint16_t x) {
|
||||||
|
uart_putc(48 + (x / 10000));
|
||||||
|
uart_putc(48 + (x % 10000 /1000));
|
||||||
|
uart_putc(48 + (x % 1000 / 100 ));
|
||||||
|
uart_putc(48 + (x % 100 / 10 ));
|
||||||
|
uart_putc(48 + (x % 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef _utils_h
|
||||||
|
#define _utils_h
|
||||||
|
|
||||||
|
extern void wait(uint8_t count);
|
||||||
|
extern void uart_print_voltage(uint16_t);
|
||||||
|
extern void uart_print_uint8_t(uint8_t);
|
||||||
|
extern void uart_print_uint16(uint16_t);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
Loading…
Reference in New Issue