diff options
-rw-r--r-- | doc/pio.txt | 2 | ||||
-rw-r--r-- | doc/schematic.svg | 396 | ||||
-rw-r--r-- | src/common/includes/GPIO/analog.h | 9 | ||||
-rw-r--r-- | src/common/src/Core/main.c | 19 | ||||
-rw-r--r-- | src/glutt-o-logique/analog_input.c | 63 | ||||
-rw-r--r-- | src/glutt-o-logique/analog_input.h | 10 |
6 files changed, 287 insertions, 212 deletions
diff --git a/doc/pio.txt b/doc/pio.txt index ddebe88..f536171 100644 --- a/doc/pio.txt +++ b/doc/pio.txt @@ -21,9 +21,9 @@ Connexions Relais TODO Analog signals ------------------- - in f_0 deviation +- in Vcc 12V PA5 (ADC12 IN5) - in SWR forward PA6 (ADC12 IN6) - in SWR reflected PA7 (ADC12 IN7) -- in Vcc 12V PA5 (ADC12 IN5) u-blox NEO-M8N GPS module connection ------------------------------------ diff --git a/doc/schematic.svg b/doc/schematic.svg index ad4fdbf..73a04c3 100644 --- a/doc/schematic.svg +++ b/doc/schematic.svg @@ -154,9 +154,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="2.0254789" - inkscape:cx="395.99371" - inkscape:cy="348.38167" + inkscape:zoom="4.0509578" + inkscape:cx="297.9484" + inkscape:cy="237.47223" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -4436,7 +4436,7 @@ sodipodi:role="line" x="718.53662" y="983.32874" - id="tspan29929">2016-06-23 HB9EGM</tspan></text> + id="tspan29929">2016-06-24 HB9EGM</tspan></text> <g transform="matrix(0.5,0,0,0.5,110,236.80611)" id="g26374-6"> @@ -4754,50 +4754,6 @@ id="path5178" d="m 285,797.36221 -195,0 0,-120 85,0" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.40000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> - <g - transform="translate(14.695614,19.999994)" - id="g5180"> - <path - sodipodi:nodetypes="cccc" - inkscape:connector-curvature="0" - id="path5182" - d="m 270,832.36221 0,-30 30,15 z" - style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.98501229px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> - <text - xml:space="preserve" - style="font-style:normal;font-weight:normal;font-size:6.25px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - x="273" - y="813.36218" - id="text5184" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan5186" - x="273" - y="813.36218">–</tspan></text> - <text - sodipodi:linespacing="125%" - id="text5188" - y="824.36218" - x="272" - style="font-style:normal;font-weight:normal;font-size:6.25px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - xml:space="preserve"><tspan - y="824.36218" - x="272" - id="tspan5190" - sodipodi:role="line">+</tspan></text> - <text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:6.25px;line-height:125%;font-family:Sans;-inkscape-font-specification:'Sans Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - x="278" - y="819.36218" - id="text5192" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan5194" - x="278" - y="819.36218" - style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:5px;font-family:Sans;-inkscape-font-specification:'Sans Bold'">324</tspan></text> - </g> <path style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.40000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 285,842.36221 -205,0 0,-195 95,0" @@ -4805,17 +4761,11 @@ inkscape:connector-curvature="0" sodipodi:nodetypes="cccc" /> <path - style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.40000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 272,787.36221 0,-15 53,0 0,20" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 305,772.36221 20,0 0,20" id="path5198" inkscape:connector-curvature="0" - sodipodi:nodetypes="cccc" /> - <path - sodipodi:nodetypes="cccc" - inkscape:connector-curvature="0" - id="path5200" - d="m 272,832.36221 0,-15 53,0 0,20" - style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.40000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + sodipodi:nodetypes="ccc" /> <path style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.40000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 315,837.36221 30,0 0,-55 60,0" @@ -4934,35 +4884,6 @@ sodipodi:role="line">12V</tspan></text> </g> <g - transform="matrix(0.140625,0,0,-0.140625,264.12402,968.38165)" - id="g5299"> - <path - style="fill:none;stroke:#000000;stroke-width:2.83464575;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 255.11811,988.58266 0,21.25984" - id="path5301" - inkscape:connector-curvature="0" - transform="translate(0,2.5390623e-6)" /> - <path - style="fill:none;stroke:#000000;stroke-width:2.83464575;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 237.40157,1009.8425 35.43308,0" - id="path5303" - inkscape:connector-curvature="0" - transform="translate(0,2.5390623e-6)" /> - <text - xml:space="preserve" - style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none" - x="230.36812" - y="-1015.4689" - id="text5305" - sodipodi:linespacing="125%" - transform="scale(1,-1)"><tspan - sodipodi:role="line" - id="tspan5307" - x="230.36812" - y="-1015.4689" - style="font-weight:bold;font-size:24px;-inkscape-font-specification:'Sans Bold'">12V</tspan></text> - </g> - <g transform="matrix(0.140625,0,0,0.140625,264.12402,661.35311)" id="g27992-3"> <path @@ -4979,22 +4900,6 @@ transform="translate(0,2.5390623e-6)" /> </g> <g - transform="matrix(0.140625,0,0,0.140625,264.12402,706.34277)" - id="g27992-9"> - <path - style="fill:none;stroke:#000000;stroke-width:2.84444451;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 255.11811,988.58266 0,21.25984" - id="path27994-03" - inkscape:connector-curvature="0" - transform="translate(0,2.5390623e-6)" /> - <path - style="fill:none;stroke:#000000;stroke-width:7.11111116;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 237.40157,1009.8425 35.43308,0" - id="path27996-30" - inkscape:connector-curvature="0" - transform="translate(0,2.5390623e-6)" /> - </g> - <g id="g5340" transform="translate(15,64.999996)"> <path @@ -6018,7 +5923,7 @@ </g> <g id="g5493-4" - transform="matrix(0.5,0,0,0.5,134.98967,348.68111)"> + transform="matrix(0.5,0,0,0.5,155.5,333.68111)"> <rect style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" id="rect5495-3" @@ -6055,99 +5960,13 @@ xml:space="preserve" style="font-style:normal;font-weight:normal;font-size:6.25px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" x="280" - y="767.36218" + y="763.36218" id="text5523-4" sodipodi:linespacing="125%"><tspan sodipodi:role="line" x="280" - y="767.36218" - id="tspan5527-3">gain=100</tspan></text> - <g - transform="matrix(0.140625,0,0,0.140625,224.12402,693.34277)" - id="g5447"> - <path - style="fill:none;stroke:#000000;stroke-width:2.84444451;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 255.11811,988.58266 0,21.25984" - id="path5449" - inkscape:connector-curvature="0" - transform="translate(0,2.5390623e-6)" /> - <path - style="fill:none;stroke:#000000;stroke-width:7.11111116;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 237.40157,1009.8425 35.43308,0" - id="path5451" - inkscape:connector-curvature="0" - transform="translate(0,2.5390623e-6)" /> - </g> - <g - id="g5453" - transform="matrix(0.5,0,0,0.5,122.5,393.68111)"> - <rect - style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - id="rect5455" - width="5.99998" - height="13" - x="-880.36218" - y="281" - transform="matrix(0,-1,1,0,0,0)" /> - <path - style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 275,877.3622 5.97933,0" - id="path5457" - inkscape:connector-curvature="0" /> - <path - sodipodi:nodetypes="cc" - style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 301,877.3622 -6.97934,0" - id="path5459" - inkscape:connector-curvature="0" /> - <text - xml:space="preserve" - style="font-style:normal;font-weight:normal;font-size:11.25px;line-height:125%;font-family:Sans;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none" - x="288.39352" - y="887.36218" - id="text5461" - sodipodi:linespacing="125%"><tspan - sodipodi:role="line" - id="tspan5463" - x="288.39352" - y="887.36218" - style="font-weight:bold;font-size:6.75px;-inkscape-font-specification:'Sans Bold';text-align:center;text-anchor:middle">8k2</tspan></text> - </g> - <g - transform="matrix(0.5,0,0,0.5,134.98967,393.68111)" - id="g5465"> - <rect - transform="matrix(0,-1,1,0,0,0)" - y="281" - x="-880.36218" - height="13" - width="5.99998" - id="rect5467" - style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> - <path - inkscape:connector-curvature="0" - id="path5469" - d="m 275,877.3622 5.97933,0" - style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> - <path - inkscape:connector-curvature="0" - id="path5471" - d="m 299,877.3622 -4.97934,0" - style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - sodipodi:nodetypes="cc" /> - <text - sodipodi:linespacing="125%" - id="text5473" - y="872.62335" - x="288.39352" - style="font-style:normal;font-weight:normal;font-size:11.25px;line-height:125%;font-family:Sans;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none" - xml:space="preserve"><tspan - style="font-weight:bold;font-size:6.75px;-inkscape-font-specification:'Sans Bold';text-align:center;text-anchor:middle" - y="872.62335" - x="288.39352" - id="tspan5475" - sodipodi:role="line">820k</tspan></text> - </g> + y="763.36218" + id="tspan5527-3">gain=101</tspan></text> <g id="g5479" transform="matrix(0.5,0,0,0.5,266.25,333.68112)"> @@ -7992,5 +7811,198 @@ id="tspan5656-6-7" sodipodi:role="line">IDENT</tspan></text> </g> + <path + sodipodi:nodetypes="cccc" + inkscape:connector-curvature="0" + id="path5525" + d="m 293,772.36221 -20,0 0,15 12,0" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.40000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <g + transform="translate(14.695614,19.999992)" + id="g5527"> + <path + sodipodi:nodetypes="cccc" + inkscape:connector-curvature="0" + id="path5534" + d="m 270,832.36221 0,-30 30,15 z" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.98501229px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:6.25px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + x="273" + y="813.36218" + id="text5536" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5538" + x="273" + y="813.36218">–</tspan></text> + <text + sodipodi:linespacing="125%" + id="text5540" + y="824.36218" + x="272" + style="font-style:normal;font-weight:normal;font-size:6.25px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve"><tspan + y="824.36218" + x="272" + id="tspan5542" + sodipodi:role="line">+</tspan></text> + <text + xml:space="preserve" + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:6.25px;line-height:125%;font-family:Sans;-inkscape-font-specification:'Sans Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + x="278" + y="819.36218" + id="text5544" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5546" + x="278" + y="819.36218" + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:5px;font-family:Sans;-inkscape-font-specification:'Sans Bold'">324</tspan></text> + </g> + <path + sodipodi:nodetypes="ccc" + inkscape:connector-curvature="0" + id="path5548" + d="m 305,817.36221 20,0 0,20" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.40000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <g + transform="matrix(0.140625,0,0,-0.140625,264.12402,968.38165)" + id="g5550"> + <path + style="fill:none;stroke:#000000;stroke-width:2.83464575;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 255.11811,988.58266 0,21.25984" + id="path5557" + inkscape:connector-curvature="0" + transform="translate(0,2.5390623e-6)" /> + <path + style="fill:none;stroke:#000000;stroke-width:2.83464575;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 237.40157,1009.8425 35.43308,0" + id="path5567" + inkscape:connector-curvature="0" + transform="translate(0,2.5390623e-6)" /> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none" + x="230.36812" + y="-1015.4689" + id="text5569" + sodipodi:linespacing="125%" + transform="scale(1,-1)"><tspan + sodipodi:role="line" + id="tspan5571" + x="230.36812" + y="-1015.4689" + style="font-weight:bold;font-size:24px;-inkscape-font-specification:'Sans Bold'">12V</tspan></text> + </g> + <g + id="g5573" + transform="matrix(0.140625,0,0,0.140625,264.12402,706.35311)"> + <path + transform="translate(0,2.5390623e-6)" + inkscape:connector-curvature="0" + id="path5575" + d="m 255.11811,988.58266 0,21.25984" + style="fill:none;stroke:#000000;stroke-width:2.84444451;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + transform="translate(0,2.5390623e-6)" + inkscape:connector-curvature="0" + id="path5577" + d="m 237.40157,1009.8425 35.43308,0" + style="fill:none;stroke:#000000;stroke-width:7.11111116;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + </g> + <g + transform="matrix(0.140625,0,0,0.140625,224.12402,693.34277)" + id="g5579"> + <path + style="fill:none;stroke:#000000;stroke-width:2.84444451;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 255.11811,988.58266 0,21.25984" + id="path5581" + inkscape:connector-curvature="0" + transform="translate(0,2.5390623e-6)" /> + <path + style="fill:none;stroke:#000000;stroke-width:7.11111116;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 237.40157,1009.8425 35.43308,0" + id="path5583" + inkscape:connector-curvature="0" + transform="translate(0,2.5390623e-6)" /> + </g> + <g + id="g5585" + transform="matrix(0.5,0,0,0.5,122.5,393.68111)"> + <rect + style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect5587" + width="5.99998" + height="13" + x="-880.36218" + y="281" + transform="matrix(0,-1,1,0,0,0)" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 275,877.3622 5.97933,0" + id="path5589" + inkscape:connector-curvature="0" /> + <path + sodipodi:nodetypes="cc" + style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 301,877.3622 -6.97934,0" + id="path5591" + inkscape:connector-curvature="0" /> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:11.25px;line-height:125%;font-family:Sans;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none" + x="288.39352" + y="887.36218" + id="text5593" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5595" + x="288.39352" + y="887.36218" + style="font-weight:bold;font-size:6.75px;-inkscape-font-specification:'Sans Bold';text-align:center;text-anchor:middle">8k2</tspan></text> + </g> + <g + transform="matrix(0.5,0,0,0.5,155.5,378.68111)" + id="g5597"> + <rect + transform="matrix(0,-1,1,0,0,0)" + y="281" + x="-880.36218" + height="13" + width="5.99998" + id="rect5599" + style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + inkscape:connector-curvature="0" + id="path5601" + d="m 275,877.3622 5.97933,0" + style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + inkscape:connector-curvature="0" + id="path5603" + d="m 299,877.3622 -4.97934,0" + style="fill:none;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + sodipodi:nodetypes="cc" /> + <text + sodipodi:linespacing="125%" + id="text5605" + y="872.62335" + x="288.39352" + style="font-style:normal;font-weight:normal;font-size:11.25px;line-height:125%;font-family:Sans;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none" + xml:space="preserve"><tspan + style="font-weight:bold;font-size:6.75px;-inkscape-font-specification:'Sans Bold';text-align:center;text-anchor:middle" + y="872.62335" + x="288.39352" + id="tspan5607" + sodipodi:role="line">820k</tspan></text> + </g> + <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.40000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 293,817.36221 -20,0 0,15 12,0" + id="path5609" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" /> </g> </svg> diff --git a/src/common/includes/GPIO/analog.h b/src/common/includes/GPIO/analog.h index 54dfb5d..0c45f0c 100644 --- a/src/common/includes/GPIO/analog.h +++ b/src/common/includes/GPIO/analog.h @@ -23,13 +23,20 @@ */ #pragma once +#include <stdint.h> void analog_init(void); /* Measure the 12V supply voltage, in 0.5V increments. - * Returns 0.0f in case of error */ + * Returns 0.0f in case of error + */ float analog_measure_12v(void); +/* Measure SWR, and return raw values. + * Returns 0 in case of error, 1 in case of success + */ +int analog_measure_swr(uint16_t *forward, uint16_t* reflected); + /* Keep an average of measurements, and decide if the repeater should enter * QRP. Returns 1 if low power must be activated */ diff --git a/src/common/src/Core/main.c b/src/common/src/Core/main.c index f3c1057..8db5f20 100644 --- a/src/common/src/Core/main.c +++ b/src/common/src/Core/main.c @@ -204,11 +204,19 @@ static void launcher_task(void __attribute__ ((unused))*pvParameters) const int qrp = analog_supply_too_low(); if (qrp != last_qrp) { - usart_debug("QRP should be %d\r\n", qrp); + usart_debug("QRP = %d\r\n", qrp); last_qrp = qrp; pio_set_qrp(qrp); } + + struct fsm_output_signals_t fsm_out; + fsm_get_outputs(&fsm_out); + if (1) { + //if (fsm_out.tx_on) { + uint16_t swr_fwd, swr_refl; + analog_measure_swr(&swr_fwd, &swr_refl); + } } } @@ -457,7 +465,12 @@ static void exercise_fsm(void __attribute__ ((unused))*pvParameters) } last_tm_trigger_button = tm_trigger_button; - if (tm_trigger == 1 && last_tm_trigger == 0) { + /* Do not time-trigger BALISE if + * the trigger occurs in the first minute, + * or if we happen to start up in an even hour + */ + if ( timestamp_now() > 60 * 1000 && + tm_trigger == 1 && last_tm_trigger == 0) { fsm_input.start_tm = 1; } last_tm_trigger = tm_trigger; @@ -465,7 +478,7 @@ static void exercise_fsm(void __attribute__ ((unused))*pvParameters) int cw_done = !cw_psk31_busy(); if (last_cw_done != cw_done) { - // On fait le switch du cw_done vers 1 QUE si les buffers audio ont été flusés + // On fait le switch du cw_done vers 1 QUE si les buffers audio ont été flushés if (!cw_done || only_zero_in_audio_buffer) { usart_debug("In CW done %d\r\n", cw_done); last_cw_done = cw_done; diff --git a/src/glutt-o-logique/analog_input.c b/src/glutt-o-logique/analog_input.c index d970238..103d933 100644 --- a/src/glutt-o-logique/analog_input.c +++ b/src/glutt-o-logique/analog_input.c @@ -25,6 +25,8 @@ #include "analog_input.h" #include "stm32f4xx_adc.h" #include <math.h> +#include "GPIO/usart.h" + void analog_init(void) { @@ -32,10 +34,10 @@ void analog_init(void) RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); - // Set Pin PA5 to analog input + // Set analog input pins mode GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; + GPIO_InitStructure.GPIO_Pin = PINS_ANALOG; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; @@ -53,32 +55,37 @@ void analog_init(void) ADC_InitTypeDef ADC_InitStruct; ADC_InitStruct.ADC_Resolution = ADC_Resolution_12b; ADC_InitStruct.ADC_ScanConvMode = DISABLE; - ADC_InitStruct.ADC_ContinuousConvMode = ENABLE; + ADC_InitStruct.ADC_ContinuousConvMode = DISABLE; ADC_InitStruct.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; ADC_InitStruct.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1; ADC_InitStruct.ADC_DataAlign = ADC_DataAlign_Right; - ADC_InitStruct.ADC_NbrOfConversion = 1; + ADC_InitStruct.ADC_NbrOfConversion = 3; ADC_Init(ADC1, &ADC_InitStruct); - // Configure ADC1 to use the converted 12V signal (see schematics) - const uint8_t rank = 1; - ADC_RegularChannelConfig(ADC1, - ADC_Channel_5, - rank, - ADC_SampleTime_480Cycles); - // Enable ADC ADC_Cmd(ADC1, ENABLE); } -float analog_measure_12v(void) +static uint16_t analog_read_channel(uint8_t channel) { - ADC_SoftwareStartConv(ADC1); //Start the conversion + ADC_RegularChannelConfig(ADC1, + channel, + 1, + ADC_SampleTime_480Cycles); + + ADC_SoftwareStartConv(ADC1); // TODO add timeout - while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET); - const uint16_t raw_value = ADC_GetConversionValue(ADC1); + /* wait for end of conversion */ + while((ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET)); + + return ADC_GetConversionValue(ADC1); +} + +float analog_measure_12v(void) +{ + const uint16_t raw_value = analog_read_channel(ADC_CHANNEL_SUPPLY); const float adc_max_value = (1 << 12); const float v_ref = 2.965f; @@ -90,3 +97,29 @@ float analog_measure_12v(void) return voltage * 202.0f / 22.0f; } + +int analog_measure_swr(uint16_t *forward, uint16_t* reflected) +{ + const uint16_t raw_swr_fwd_value = analog_read_channel(ADC_CHANNEL_SWR_FWD); + const uint16_t raw_swr_refl_value = analog_read_channel(ADC_CHANNEL_SWR_REFL); + + *forward = raw_swr_fwd_value; + *reflected = raw_swr_refl_value; + + const int supply_decivolts = analog_measure_12v() * 10.0f; + + const float adc_max_value = (1 << 12); + const float v_ref = 2.965f; + + // Convert ADC measurement to mV (includes times 100 amplifier) + const int swr_fwd = ((float)raw_swr_fwd_value*10.0f*v_ref/adc_max_value); + const int swr_refl = ((float)raw_swr_refl_value*10.0f*v_ref/adc_max_value); + + usart_debug("RAW Meas %d dV - %d mV - %d mV\r\n", + supply_decivolts, + swr_fwd, + swr_refl); + + return 1; +} + diff --git a/src/glutt-o-logique/analog_input.h b/src/glutt-o-logique/analog_input.h index 9c8ef8c..0385ec4 100644 --- a/src/glutt-o-logique/analog_input.h +++ b/src/glutt-o-logique/analog_input.h @@ -28,3 +28,13 @@ #include "stm32f4xx_gpio.h" #include "GPIO/analog.h" +#define PIN_SUPPLY GPIO_Pin_5 +#define PIN_SWR_FWD GPIO_Pin_6 +#define PIN_SWR_REFL GPIO_Pin_7 + +#define PINS_ANALOG (GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7) + +#define ADC_CHANNEL_SUPPLY ADC_Channel_5 +#define ADC_CHANNEL_SWR_FWD ADC_Channel_6 +#define ADC_CHANNEL_SWR_REFL ADC_Channel_7 + |