diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-04-11 16:22:04 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-04-11 16:22:04 +0200 |
commit | eed7072d6336a3cfdc8b52eb20166529a4de4d81 (patch) | |
tree | 1505819a1216406e6f15c4315bed93750c7ed68d | |
parent | 3555e921a0c743dbc2cc10d8655827be975c61e0 (diff) | |
download | glutte-o-matic-eed7072d6336a3cfdc8b52eb20166529a4de4d81.tar.gz glutte-o-matic-eed7072d6336a3cfdc8b52eb20166529a4de4d81.tar.bz2 glutte-o-matic-eed7072d6336a3cfdc8b52eb20166529a4de4d81.zip |
Add some 1750 detection code to glutt-o-logic
-rw-r--r-- | doc/perfboard.svg | 496 | ||||
-rw-r--r-- | doc/pio.txt | 26 | ||||
-rw-r--r-- | doc/schematic.svg | 478 | ||||
-rw-r--r-- | qucs/af_5vpp_to_adc.sch | 81 | ||||
-rw-r--r-- | src/common/includes/Audio/audio_in.h | 15 | ||||
-rw-r--r-- | src/common/includes/Audio/tone.h | 7 | ||||
-rw-r--r-- | src/common/includes/Core/common.h | 1 | ||||
-rw-r--r-- | src/common/src/Audio/audio_in.c | 26 | ||||
-rw-r--r-- | src/common/src/Audio/tone.c | 24 | ||||
-rw-r--r-- | src/common/src/Core/main.c | 60 | ||||
-rw-r--r-- | src/common/src/GPIO/usart.c | 3 | ||||
-rw-r--r-- | src/glutt-o-logique/analog_input.c | 27 | ||||
-rw-r--r-- | src/glutt-o-logique/analog_input.h | 13 | ||||
-rw-r--r-- | src/glutt-o-logique/audio_in.c | 148 | ||||
-rw-r--r-- | src/glutt-o-logique/pio.c | 2 | ||||
-rw-r--r-- | src/glutt-o-logique/stm32f4discovery-with-stlinkv2.1.cfg | 10 | ||||
-rw-r--r-- | src/simulator/src/Audio/audio.c | 8 | ||||
-rw-r--r-- | src/simulator/src/Audio/audio_in.c | 37 | ||||
-rw-r--r-- | src/simulator/src/Gui/gui.c | 5 | ||||
-rw-r--r-- | src/simulator/src/Gui/nuklear.h | 2 | ||||
-rwxr-xr-x | src/tone-test-sim/analyse.py | 6 | ||||
-rw-r--r-- | src/tone-test-sim/src/test.c | 17 |
22 files changed, 1246 insertions, 246 deletions
diff --git a/doc/perfboard.svg b/doc/perfboard.svg index 6aaa0ef..5c2ed38 100644 --- a/doc/perfboard.svg +++ b/doc/perfboard.svg @@ -2312,9 +2312,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="1.4142136" - inkscape:cx="683.86634" - inkscape:cy="322.31479" + inkscape:zoom="2.8284272" + inkscape:cx="442.8626" + inkscape:cy="320.50152" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -20673,6 +20673,24 @@ transform="translate(0,-308.26772)" style="display:inline"> <path + sodipodi:nodetypes="ccccccc" + inkscape:connector-curvature="0" + id="path7241" + d="m 651.96853,442.91336 v 7.08661 l 0,28.34646 h 70.86615 l 15.59055,12.75591 h 75.11811 l 8.50394,8.50393" + style="fill:none;fill-rule:evenodd;stroke:#ff7106;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" /> + <path + sodipodi:nodetypes="cc" + inkscape:connector-curvature="0" + d="M 646.29923,485.43305 623.62208,442.91336" + style="fill:none;fill-rule:evenodd;stroke:#e00000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path7239" /> + <path + style="fill:none;fill-rule:evenodd;stroke:#ffd234;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" + d="m 396.85041,981.49606 226.77167,-85.03937 0,-170.07875 H 737.00791 V 556.29919 h 56.69291 l 14.17323,-14.17323" + id="path7119" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccc" /> + <path sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" id="path11567" @@ -24666,7 +24684,7 @@ y="1007.1062" x="398.24316" sodipodi:role="line" - style="font-size:14px;line-height:1.25;font-family:sans-serif">2019-03-02 HB9EGM — HB9FOH</tspan></text> + style="font-size:14px;line-height:1.25;font-family:sans-serif">2019-03-22 HB9EGM — HB9FOH</tspan></text> </g> <g transform="matrix(0,1,1,0,-400.39366,329.52752)" @@ -24834,13 +24852,13 @@ sodipodi:nodetypes="cc" /> <text id="text47021-9" - y="468.42517" - x="335.90552" + y="468.38654" + x="285.29633" style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;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 style="font-size:7.5px;line-height:1.25;font-family:sans-serif" - y="468.42517" - x="335.90552" + y="468.38654" + x="285.29633" id="tspan47023-7" sodipodi:role="line">470k</tspan></text> <path @@ -25389,7 +25407,7 @@ sodipodi:nodetypes="ccccccc" inkscape:connector-curvature="0" id="path11532" - d="m 822.04727,499.60628 h 28.34646 l 21.25985,14.17322 -1e-5,178.58269 7.08661,5.66929 38.26772,-7.08662 h 32.59843" + d="m 836.22051,542.12596 v 7.08661 l 35.43307,34.01575 -1e-5,109.13387 7.08661,5.66929 38.26772,-7.08662 h 32.59843" style="fill:none;fill-rule:evenodd;stroke:#ffd234;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" /> <path sodipodi:nodetypes="cccccccc" @@ -25416,11 +25434,6 @@ d="m 524.40946,797.24409 -5.66929,5.66929 v 136.063 h 246.61418" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" /> <path - inkscape:connector-curvature="0" - id="path10161" - d="m 822.04729,513.77951 h 7.08661 v 14.17322 h -7.08661" - style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" /> - <path style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" d="m 779.5276,457.08658 h -7.08661 v -14.17322 h 7.08661" id="path10157" @@ -25451,7 +25464,7 @@ sodipodi:nodetypes="ccccccc" inkscape:connector-curvature="0" id="path11536" - d="m 779.52758,499.60628 9.92126,9.92126 h 60.94489 v 107.71654 l 28.34645,9.92125 35.43308,25.51182 h 21.25984" + d="m 779.52758,499.60628 9.92126,9.92126 7.08663,-10e-6 v 117.6378 l 82.20471,0 35.43308,25.51182 h 21.25984" style="fill:none;fill-rule:evenodd;stroke:#34c3ff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" /> <text xml:space="preserve" @@ -27214,7 +27227,7 @@ </g> <path style="fill:none;fill-rule:evenodd;stroke:#b000e3;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" - d="m 325.98426,457.08659 14.17323,-14.17323 h 365.6693 v 252.28348 h 144.56694 l 28.34645,31.1811 38.26772,-21.25985 h 32.59843" + d="m 325.98426,457.08659 7.08662,7.08661 372.75592,0 -1e-5,231.02364 h 144.56694 l 28.34645,31.1811 38.26772,-21.25985 h 32.59843" id="path47548" inkscape:connector-curvature="0" sodipodi:nodetypes="cccccccc" /> @@ -27222,7 +27235,7 @@ sodipodi:nodetypes="ccccccccc" inkscape:connector-curvature="0" id="path35344" - d="m 524.40946,457.08659 h 14.17323 164.40946 v 240.94489 h 147.40158 v 80.78741 l 28.34645,4.25196 43.93701,-49.6063 h 26.92914" + d="m 524.40946,457.08659 14.17324,12.7559 h 164.40946 l -10e-6,228.18899 h 147.40158 v 80.78741 l 28.34645,4.25196 43.93701,-49.6063 h 26.92914" style="fill:none;fill-rule:evenodd;stroke:#008607;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" /> <g id="g9148" @@ -27302,9 +27315,9 @@ y="554.84326" style="font-size:7.5px;line-height:1.25;font-family:sans-serif">8k2</tspan></text> <path - sodipodi:nodetypes="ccc" + sodipodi:nodetypes="cc" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" - d="m 765.35434,513.7795 h 7.08664 7.08661" + d="M 836.22051,527.95273 850.39374,513.7795" id="path9221" inkscape:connector-curvature="0" /> <text @@ -27496,19 +27509,6 @@ y="427.7695" style="font-size:5px;line-height:1.25;font-family:sans-serif">SWR Refl</tspan></text> <text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:sans-serif;-inkscape-font-specification:Sans;text-align:start;letter-spacing:0px;word-spacing:0px;text-anchor:start;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" - x="825.36292" - y="498.14804" - id="text47426-3"><tspan - sodipodi:role="line" - id="tspan47428-6" - x="825.36292" - y="498.14804" - style="font-size:5px;line-height:1.25;font-family:sans-serif">f<tspan - style="font-size:64.99999762%;font-family:sans-serif;baseline-shift:sub" - id="tspan47434-8">0</tspan> OFFSET</tspan></text> - <text id="text47418-7" y="552.4939" x="760.07379" @@ -29249,72 +29249,6 @@ id="path11297" inkscape:connector-curvature="0" sodipodi:nodetypes="cccc" /> - <g - id="g11544" - transform="translate(297.63781,7.0866053)" - style="opacity:0.717"> - <circle - style="opacity:1;fill:#007f00;fill-opacity:1;stroke:none;stroke-width:1.41732287;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="circle11538" - cx="170.07875" - cy="705.1181" - r="15" /> - <text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:7.5px;line-height:23.4375px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;opacity:1;fill:#faff5a;fill-opacity:1;stroke:none;stroke-width:1.41732287;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - x="158.20619" - y="707.84821" - id="text11542"><tspan - sodipodi:role="line" - id="tspan11540" - x="158.20619" - y="707.84821" - style="fill:#faff5a;fill-opacity:1;stroke-width:1.41732287">TODO</tspan></text> - </g> - <g - id="g11552" - transform="translate(382.67718,7.0866053)" - style="opacity:0.717"> - <circle - style="opacity:1;fill:#007f00;fill-opacity:1;stroke:none;stroke-width:1.41732287;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="circle11546" - cx="170.07875" - cy="705.1181" - r="15" /> - <text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:7.5px;line-height:23.4375px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;opacity:1;fill:#faff5a;fill-opacity:1;stroke:none;stroke-width:1.41732287;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - x="158.20619" - y="707.84821" - id="text11550"><tspan - sodipodi:role="line" - id="tspan11548" - x="158.20619" - y="707.84821" - style="fill:#faff5a;fill-opacity:1;stroke-width:1.41732287">TODO</tspan></text> - </g> - <g - transform="translate(240.94489,191.33858)" - id="g11560" - style="opacity:0.717"> - <circle - style="opacity:1;fill:#007f00;fill-opacity:1;stroke:none;stroke-width:1.41732287;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - id="circle11554" - cx="170.07875" - cy="705.1181" - r="15" /> - <text - xml:space="preserve" - style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:7.5px;line-height:23.4375px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;opacity:1;fill:#faff5a;fill-opacity:1;stroke:none;stroke-width:1.41732287;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - x="158.20619" - y="707.84821" - id="text11558"><tspan - sodipodi:role="line" - id="tspan11556" - x="158.20619" - y="707.84821" - style="fill:#faff5a;fill-opacity:1;stroke-width:1.41732287">TODO</tspan></text> - </g> <path sodipodi:nodetypes="cccccc" inkscape:connector-curvature="0" @@ -29494,6 +29428,372 @@ y="545.66931" x="-634.25195" sodipodi:role="line">DET 1750</tspan></text> + <g + style="display:inline" + id="g34108-3" + transform="rotate(90,942.51975,974.40946)"> + <g + id="g33915-67"> + <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 496.06302,1080.7087 h 5.66929 v -5.6693 11.3385" + id="path33911-5" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" /> + <path + inkscape:connector-curvature="0" + id="path33913-3" + d="m 510.23625,1080.7087 h -5.6693 v -5.6693 11.3385" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + sodipodi:nodetypes="cccc" /> + </g> + <path + d="m 496.06301,1077.797 c -1.60373,0 -2.91168,1.3096 -2.91168,2.9116 0,1.6038 1.30795,2.9117 2.91168,2.9117 1.60203,0 2.91169,-1.3148 2.91169,-2.9117 0,-1.602 -1.30966,-2.9116 -2.91169,-2.9116" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + id="path25107-4-5" + inkscape:connector-curvature="0" /> + <path + inkscape:connector-curvature="0" + id="path33940-6" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + d="m 510.23624,1077.797 c -1.60373,0 -2.91168,1.3096 -2.91168,2.9116 0,1.6038 1.30795,2.9117 2.91168,2.9117 1.60203,0 2.91169,-1.3148 2.91169,-2.9117 0,-1.602 -1.30966,-2.9116 -2.91169,-2.9116" /> + <rect + y="1072.2047" + x="491.81104" + height="17.007875" + width="22.677166" + id="rect33942-2" + style="opacity:1;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + </g> + <text + id="text7074" + y="554.00098" + x="819.17279" + style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;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 + style="font-size:7.5px;line-height:1.25;font-family:sans-serif" + y="554.00098" + x="819.17279" + id="tspan7072" + sodipodi:role="line">1µF</tspan></text> + <g + transform="matrix(0,1,1,0,24.803191,46.062952)" + id="g7084"> + <path + d="m 467.71654,808.50563 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + id="path7076" + inkscape:connector-curvature="0" /> + <ellipse + style="opacity:1;fill:none;fill-opacity:1;stroke:#00001c;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="ellipse7078" + cx="467.71655" + cy="811.4173" + rx="8.5039444" + ry="8.5039177" /> + <path + inkscape:connector-curvature="0" + id="path7080" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + d="m 467.71654,822.67886 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" /> + <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" + d="m 467.71655,825.59054 c -1.44203,-4.4297 -1.51518,-9.08849 0,-14.17322" + id="path7082" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cc" /> + </g> + <path + inkscape:connector-curvature="0" + id="path7095" + d="m 822.04728,513.7795 14.17323,0" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" + sodipodi:nodetypes="cc" /> + <g + id="g7105" + transform="rotate(-90,503.14963,506.69289)"> + <path + inkscape:connector-curvature="0" + id="path7097" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + d="m 467.71654,808.50563 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" /> + <ellipse + ry="8.5039177" + rx="8.5039444" + cy="811.4173" + cx="467.71655" + id="ellipse7099" + style="opacity:1;fill:none;fill-opacity:1;stroke:#00001c;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + <path + d="m 467.71654,822.67886 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + id="path7101" + inkscape:connector-curvature="0" /> + <path + sodipodi:nodetypes="cc" + inkscape:connector-curvature="0" + id="path7103" + d="m 467.71655,825.59054 c -1.44203,-4.4297 -1.51518,-9.08849 0,-14.17322" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" /> + </g> + <path + inkscape:connector-curvature="0" + id="path7107" + d="m 807.87405,542.12596 14.17323,-14.17323" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" + sodipodi:nodetypes="cc" /> + <path + sodipodi:nodetypes="cccc" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" + d="m 822.04728,542.12596 4.25197,-4.25197 0,-19.84252 -4.25197,-4.25197" + id="path7109" + inkscape:connector-curvature="0" /> + <text + id="text7113" + y="554.84326" + x="801.04602" + style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;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 + style="font-size:7.5px;line-height:1.25;font-family:sans-serif" + y="554.84326" + x="801.04602" + id="tspan7111" + sodipodi:role="line">4k7</tspan></text> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;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="847.83417" + y="509.54202" + id="text7117"><tspan + sodipodi:role="line" + id="tspan7115" + x="847.83417" + y="509.54202" + style="font-size:7.5px;line-height:1.25;font-family:sans-serif">4k7</tspan></text> + <g + style="display:inline" + transform="rotate(90,775.98429,751.1811)" + id="g9171-9"> + <path + style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1" + d="m 459.21261,848.2677 17.00787,10e-6 -8.50393,12.75591 z" + id="path9205-1" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" /> + <path + d="m 467.71654,829.76548 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + id="path9207-2" + inkscape:connector-curvature="0" /> + <path + inkscape:connector-curvature="0" + id="path9268-7" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + d="m 467.71654,872.28517 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" /> + <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" + d="m 467.71654,875.19685 10e-6,-14.17324" + id="path9270-0" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cc" /> + <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + d="m 459.21261,863.85827 2.83464,-2.83465 h 11.33859 l 2.83464,-2.83465" + id="path9277-9" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" /> + <path + sodipodi:nodetypes="cc" + inkscape:connector-curvature="0" + id="path11265-3" + d="m 467.71654,847.55906 v -14.8819" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" /> + </g> + <text + id="text9352-6" + y="459.81668" + x="658.92194" + style="font-style:normal;font-weight:normal;font-size:12px;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve"><tspan + style="font-size:7.5px;line-height:1.25;font-family:sans-serif;stroke-width:1px" + y="459.81668" + x="658.92194" + sodipodi:role="line" + id="tspan9356-6">4V3</tspan></text> + <g + transform="rotate(-90,361.41733,549.21257)" + id="g7173"> + <path + d="m 467.71654,808.50563 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + id="path7165" + inkscape:connector-curvature="0" /> + <ellipse + style="opacity:1;fill:none;fill-opacity:1;stroke:#00001c;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="ellipse7167" + cx="467.71655" + cy="811.4173" + rx="8.5039444" + ry="8.5039177" /> + <path + inkscape:connector-curvature="0" + id="path7169" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + d="m 467.71654,822.67886 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" /> + <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" + d="m 467.71655,825.59054 c -1.44203,-4.4297 -1.51518,-9.08849 0,-14.17322" + id="path7171" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cc" /> + </g> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;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="616.77393" + y="459.9357" + id="text7177"><tspan + sodipodi:role="line" + id="tspan7175" + x="616.77393" + y="459.9357" + style="font-size:7.5px;line-height:1.25;font-family:sans-serif">2k2</tspan></text> + <path + inkscape:connector-curvature="0" + id="path7095-6" + d="m 637.79531,442.91336 h 14.17323" + style="display:inline;fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" + sodipodi:nodetypes="cc" /> + <g + style="display:inline" + id="g9178-1" + transform="translate(-128.51774,-44.895669)"> + <path + inkscape:connector-curvature="0" + id="path10167-8" + d="m 825.8406,491.35233 h 5.66929" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.39999998;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + sodipodi:nodetypes="cc" /> + <path + sodipodi:nodetypes="ccc" + inkscape:connector-curvature="0" + id="path10187-7" + d="m 823.00595,487.80903 h 5.66929 v 4.25196" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" /> + </g> + <g + style="display:inline" + id="g7105-9" + transform="rotate(-90,517.32284,931.88975)"> + <path + inkscape:connector-curvature="0" + id="path7097-2" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + d="m 467.71654,808.50563 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" /> + <ellipse + ry="8.5039177" + rx="8.5039444" + cy="811.4173" + cx="467.71655" + id="ellipse7099-0" + style="opacity:1;fill:none;fill-opacity:1;stroke:#00001c;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + <path + d="m 467.71654,822.67886 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + id="path7101-2" + inkscape:connector-curvature="0" /> + <path + sodipodi:nodetypes="cc" + inkscape:connector-curvature="0" + id="path7103-3" + d="m 467.71655,825.59054 c -1.44203,-4.4297 -1.51518,-9.08849 0,-14.17322" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" /> + </g> + <text + id="text7113-7" + y="970.17194" + x="390.03885" + style="font-style:normal;font-weight:normal;font-size:12px;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve"><tspan + style="font-size:7.5px;line-height:1.25;font-family:sans-serif;stroke-width:1px" + y="970.17194" + x="390.03885" + id="tspan7111-5" + sodipodi:role="line">4k7</tspan></text> + <g + style="display:inline" + id="g7105-92" + transform="rotate(-90,531.49607,917.71652)"> + <path + inkscape:connector-curvature="0" + id="path7097-28" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + d="m 467.71654,808.50563 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" /> + <ellipse + ry="8.5039177" + rx="8.5039444" + cy="811.4173" + cx="467.71655" + id="ellipse7099-9" + style="opacity:1;fill:none;fill-opacity:1;stroke:#00001c;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + <path + d="m 467.71654,822.67886 c -1.60373,0 -2.91168,1.30966 -2.91168,2.91168 0,1.60374 1.30795,2.91169 2.91168,2.91169 1.60203,0 2.91169,-1.31479 2.91169,-2.91169 0,-1.60202 -1.30966,-2.91168 -2.91169,-2.91168" + style="fill:#174568;fill-opacity:1;fill-rule:nonzero;stroke:none" + id="path7101-7" + inkscape:connector-curvature="0" /> + <path + sodipodi:nodetypes="cc" + inkscape:connector-curvature="0" + id="path7103-36" + d="m 467.71655,825.59054 c -1.44203,-4.4297 -1.51518,-9.08849 0,-14.17322" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" /> + </g> + <text + id="text7113-1" + y="970.17194" + x="418.38538" + style="font-style:normal;font-weight:normal;font-size:12px;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve"><tspan + style="font-size:7.5px;line-height:1.25;font-family:sans-serif;stroke-width:1px" + y="970.17194" + x="418.38538" + id="tspan7111-2" + sodipodi:role="line">4k7</tspan></text> + <path + inkscape:connector-curvature="0" + id="path7095-6-9" + d="m 411.02363,981.49606 h 14.17323" + style="display:inline;fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" + sodipodi:nodetypes="cc" /> + <g + transform="translate(-383.63588,493.68701)" + id="g7324" + style="display:inline"> + <path + sodipodi:nodetypes="cc" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.39999998;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 825.8406,491.35233 h 5.66929" + id="path7320" + inkscape:connector-curvature="0" /> + <path + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:bevel;stroke-opacity:1" + d="m 823.00595,487.80903 h 5.66929 v 4.25196" + id="path7322" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccc" /> + </g> + <path + sodipodi:nodetypes="cccc" + inkscape:connector-curvature="0" + id="path33224-3" + d="m 411.02364,981.49606 -24.13519,-140.3894 0.0407,-15.51612 -4.25197,-14.17323" + style="display:inline;fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + <path + style="display:inline;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 386.92915,829.13384 4.25197,7.08662 -8.50394,-10e-6 z" + id="path33298-1" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" /> </g> <g inkscape:groupmode="layer" diff --git a/doc/pio.txt b/doc/pio.txt index c8d74c0..856111c 100644 --- a/doc/pio.txt +++ b/doc/pio.txt @@ -24,11 +24,15 @@ Connexions Relais Analog signals -------------- -- in NF (demod audio) PB1 (ADC12 IN9) + +on ADC1, configured in single-shot mode, software trigger: - in Vcc 12V PA5 (ADC12 IN5) - in SWR forward PA6 (ADC12 IN6) - in SWR reflected PA7 (ADC12 IN7) +on ADC2, configured in single-shot mode, triggered by a timer: +- in NF (demod audio) PB1 (ADC12 IN9) + u-blox NEO-M8N GPS module connection ------------------------------------ Yellow out UART3 TX to GPS RX PD8 @@ -52,10 +56,20 @@ I2C to Audio Codec STM32DISCOVERY onboard things ----------------------------- -- out Green LED PD12 -- out Orange LED PD13 -- out Red LED PD14 -- out Blue LED PD15 -- in Blue Push Button PA0 +- out Green LED (launcher) PD12 +- out Orange LED (fsm) PD13 +- out Red LED (audio) PD14 +- out Blue LED (audio in) PD15 +- in Blue Push Button PA0 + + +Analog audio input for 1750 tone detector +----------------------------------------- +1. Timer 6 set to 8kHz triggers ADC2 sample. +1. Timer 6 ISR accumulates N samples into a buffer. +1. When buffer full, copy it into queue. +1. `nf_analyse` task retrieves audio from queue, and gives it to tone detector. +1. Tone detector returns one of [yes, no, more samples needed]. +1. `nf_analyse` task updates FSM input accordingly. diff --git a/doc/schematic.svg b/doc/schematic.svg index a30c62c..acd22ee 100644 --- a/doc/schematic.svg +++ b/doc/schematic.svg @@ -146,6 +146,48 @@ effect="spiro" id="path-effect36408-1-1-09-2" is_visible="true" /> + <marker + inkscape:stockid="Arrow2Mstart" + orient="auto" + refY="0" + refX="0" + id="Arrow2Mstart-7" + style="overflow:visible"> + <path + id="path5430-5" + style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round" + d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z" + transform="scale(0.6)" + inkscape:connector-curvature="0" /> + </marker> + <marker + inkscape:stockid="Arrow2Mstart" + orient="auto" + refY="0" + refX="0" + id="Arrow2Mstart-7-9" + style="overflow:visible"> + <path + id="path5430-5-4" + style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round" + d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z" + transform="scale(0.6)" + inkscape:connector-curvature="0" /> + </marker> + <marker + inkscape:stockid="Arrow2Mstart" + orient="auto" + refY="0" + refX="0" + id="Arrow2Mstart-7-9-5" + style="overflow:visible"> + <path + id="path5430-5-4-0" + style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round" + d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z" + transform="scale(0.6)" + inkscape:connector-curvature="0" /> + </marker> </defs> <sodipodi:namedview id="base" @@ -154,16 +196,16 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="4.9730289" - inkscape:cx="607.84454" - inkscape:cy="255.58511" + inkscape:zoom="1" + inkscape:cx="514.80553" + inkscape:cy="368.45754" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" inkscape:object-nodes="true" - inkscape:window-width="1876" - inkscape:window-height="1044" - inkscape:window-x="0" + inkscape:window-width="1884" + inkscape:window-height="1164" + inkscape:window-x="1920" inkscape:window-y="0" inkscape:window-maximized="1" inkscape:snap-text-baseline="true" @@ -233,7 +275,7 @@ x="718.53662" y="983.32874" id="tspan29929" - style="font-size:14px;line-height:1.25;font-family:sans-serif">2019-03-01 HB9EGM</tspan></text> + style="font-size:14px;line-height:1.25;font-family:sans-serif">2019-03-22 HB9EGM</tspan></text> </g> <g inkscape:label="Layer 1" @@ -4369,10 +4411,10 @@ </g> <path style="fill:none;stroke:#000000;stroke-width:0.60000002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="m 255.48404,974.89657 h -15 v -22.5 h 75 v 30.00002" + d="m 255.00001,974.86221 -12.50001,0 V 952.3622 l 25.00001,10e-6" id="path5356" inkscape:connector-curvature="0" - sodipodi:nodetypes="ccccc" /> + sodipodi:nodetypes="cccc" /> <g id="g5362" transform="matrix(0.2109375,0,0,-0.2109375,224.17007,1178.9257)"> @@ -4419,7 +4461,7 @@ </g> <path style="fill:none;stroke:#000000;stroke-width:0.60000002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - d="M 255.02746,989.89659 200,989.86222 V 792.3622 h 70 v -110 h -70 v 0" + d="m 205,974.86221 -5,10e-6 0,-182.50002 h 70 v -110 h -70 v 0" id="path5380" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccccc" /> @@ -4464,7 +4506,7 @@ sodipodi:nodetypes="cccc" inkscape:connector-curvature="0" id="path5404" - d="m 300.02746,982.39659 h 60 V 847.39657 h 75" + d="m 355.00001,982.36221 h 5 l 0,-135 h 75" style="fill:none;stroke:#000000;stroke-width:0.60000002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> <g id="g5362-0" @@ -5570,45 +5612,11 @@ id="path5554" d="m 457.52746,824.89657 v 7.5" style="fill:none;stroke:#000000;stroke-width:0.60000002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> - <g - id="g5556" - transform="matrix(0.75,0,0,0.75,226.90246,189.37494)"> - <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="rect5558" - width="5.99998" - height="13" - x="-880.36218" - y="281" - transform="rotate(-90)" /> - <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 h 5.97933" - id="path5560" - 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 h -6.97934" - id="path5562" - inkscape:connector-curvature="0" /> - <text - xml:space="preserve" - style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none" - x="288.39352" - y="888.67877" - id="text5564"><tspan - sodipodi:role="line" - x="288.39352" - y="888.67877" - style="font-weight:bold;font-size:9px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'Sans Bold';text-align:center;text-anchor:middle" - id="tspan5566">1k2</tspan></text> - </g> <path sodipodi:nodetypes="cc" inkscape:connector-curvature="0" id="path5568" - d="m 450.02746,847.39657 h 52.5" + d="m 435.00001,847.36221 67.52745,0.0344" style="fill:none;stroke:#000000;stroke-width:0.60000002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> <g transform="matrix(0.2109375,0,0,0.2109375,418.71349,631.36741)" @@ -8012,6 +8020,384 @@ x="605" y="849.86218" style="font-size:5.625px;line-height:1.25;font-family:sans-serif">ADC12 IN9</tspan></text> + <g + id="g5686-3" + transform="matrix(1.5,0,0,1.5,-489.77908,231.18097)"> + <path + sodipodi:nodetypes="cc" + style="fill:none;stroke:#000000;stroke-width:0.39999998;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 406.51937,505.37082 v -3.53229" + id="path5500-9-6" + inkscape:connector-curvature="0" /> + <path + sodipodi:nodetypes="cc" + style="fill:none;stroke:#000000;stroke-width:0.39999998;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 406.51937,495.37082 v 3.48063" + id="path5502-2-7" + inkscape:connector-curvature="0" /> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none" + x="383.18607" + y="499.12082" + id="text5504-0-5"><tspan + sodipodi:role="line" + id="tspan5506-2-3" + x="383.18607" + y="499.12082" + style="font-weight:bold;font-size:4.5px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'Sans Bold'">1N749A</tspan><tspan + sodipodi:role="line" + x="383.18607" + y="504.74582" + style="font-weight:bold;font-size:4.5px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'Sans Bold'" + id="tspan2497">4V3</tspan></text> + <path + sodipodi:nodetypes="cc" + inkscape:connector-curvature="0" + id="path5508-3-5" + d="m 408.51075,499.84714 v -0.99569 h -3.98277 v -0.9957" + style="fill:none;stroke:#000000;stroke-width:0.49784675;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + inkscape:connector-curvature="0" + id="path5510-7-6" + d="m 406.51937,499.34929 1.49354,2.48924 h -2.98708 z" + style="fill:none;stroke:#000000;stroke-width:0.49784675;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + </g> + <g + transform="matrix(0.2109375,0,0,0.2109375,66.186021,780.70804)" + id="g5694-2"> + <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 v 21.25984" + id="path5696-9" + 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 h 35.43308" + id="path5698-1" + inkscape:connector-curvature="0" + transform="translate(0,2.5390623e-6)" /> + </g> + <g + id="g5714-2" + transform="matrix(0.75,0,0,0.75,-573.75,588.09055)"> + <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="rect5716-7" + width="5.99998" + height="13" + x="922" + y="495.86221" /> + <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 925,489.86222 v 5.97933" + id="path5718-0" + inkscape:connector-curvature="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 925,514.86222 v -5.97934" + id="path5720-9" + inkscape:connector-curvature="0" /> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none" + x="901.66669" + y="504.71198" + id="text5722-3"><tspan + sodipodi:role="line" + id="tspan5724-6" + x="901.66669" + y="504.71198" + style="font-weight:bold;font-size:9px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'Sans Bold'">2k2</tspan></text> + </g> + <g + id="g5726-0" + transform="matrix(0.2109375,0,0,-0.2109375,66.186021,1167.7663)"> + <path + transform="translate(0,2.5390623e-6)" + inkscape:connector-curvature="0" + id="path5728-6" + d="m 255.11811,988.58266 v 21.25984" + style="fill:none;stroke:#000000;stroke-width:2.83464575;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="path5730-2" + d="m 237.40157,1009.8425 h 35.43308" + style="fill:none;stroke:#000000;stroke-width:2.83464575;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <text + transform="scale(1,-1)" + id="text5732-6" + y="-1015.4689" + x="253.54678" + style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;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:48px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'Sans Bold';text-align:center;text-anchor:middle" + y="-1015.4689" + x="253.54678" + id="tspan5734-1" + sodipodi:role="line">12V</tspan></text> + </g> + <g + id="g25241-8" + transform="translate(-72.465546,45.499977)"> + <path + inkscape:connector-curvature="0" + id="path3872-1-8-7" + d="m 274,929.3622 10.96555,3e-5" + style="fill:none;stroke:#000000;stroke-width:0.5988189;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + sodipodi:nodetypes="cc" /> + <path + inkscape:connector-curvature="0" + id="path3874-5-1-9" + d="m 299,929.3622 -10.04823,3e-5" + style="fill:none;stroke:#000000;stroke-width:0.5988189;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + sodipodi:nodetypes="cc" /> + <text + id="text3876-2-8-2" + y="940.36224" + x="277.46555" + style="font-style:normal;font-weight:normal;font-size:6.75px;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none" + xml:space="preserve"><tspan + style="font-weight:bold;font-size:6.75px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'Sans Bold'" + y="940.36224" + x="277.46555" + id="tspan3878-7-2-0" + sodipodi:role="line">1µF</tspan></text> + <path + style="fill:none;stroke:#000000;stroke-width:0.99655509;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 288.45349,934.34501 v -9.96555" + id="path3920-6-2" + inkscape:connector-curvature="0" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.99655509;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 285.46383,934.34501 v -9.96555" + id="path3922-6-3" + inkscape:connector-curvature="0" /> + </g> + <g + transform="matrix(0.75,0,0,0.75,16.765507,316.84056)" + id="g2542"> + <rect + transform="rotate(-90)" + y="281" + x="-880.36218" + height="13" + width="5.99998" + id="rect2532" + 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="path2534" + d="m 275,877.3622 h 5.97933" + style="fill:none;stroke:#000000;stroke-width:0.79999995;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + inkscape:connector-curvature="0" + id="path2536" + d="m 301,877.3622 h -6.97934" + 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 + id="text2540" + y="890.64972" + x="288.39352" + style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;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:9px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'Sans Bold';text-align:center;text-anchor:middle" + y="890.64972" + x="288.39352" + id="tspan2538" + sodipodi:role="line">4k7</tspan></text> + </g> + <g + id="g2554" + transform="matrix(0.75,0,0,0.75,59.375005,294.34057)"> + <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="rect2544" + width="5.99998" + height="13" + x="-880.36218" + y="281" + transform="rotate(-90)" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.79999995;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 275,877.3622 h 5.97933" + id="path2546" + 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 h -6.97934" + id="path2548" + inkscape:connector-curvature="0" /> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none" + x="287.5" + y="870.6955" + id="text2552"><tspan + sodipodi:role="line" + id="tspan2550" + x="287.5" + y="870.6955" + style="font-weight:bold;font-size:9px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'Sans Bold';text-align:center;text-anchor:middle">4k7</tspan></text> + </g> + <path + sodipodi:nodetypes="ccc" + inkscape:connector-curvature="0" + id="path2556" + d="m 280.00001,952.36221 35,-10e-6 v 30.00001" + style="fill:none;stroke:#000000;stroke-width:0.60000002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + sodipodi:nodetypes="cccc" + inkscape:connector-curvature="0" + id="path2558" + d="m 120,974.86221 h 42.5 v 15 l 92.5,10e-6" + style="fill:none;stroke:#000000;stroke-width:0.60000002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + sodipodi:nodetypes="ccc" + inkscape:connector-curvature="0" + id="path5556-9" + d="m 122.5,973.36221 7.5,-5 h 20" + style="fill:none;stroke:#000000;stroke-width:0.59999996;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow2Mstart-7)" /> + <text + xml:space="preserve" + style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:9px;line-height:0%;font-family:Sans;-inkscape-font-specification:'Sans Italic';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75" + x="130" + y="967.36218" + id="text5722-3-2"><tspan + sodipodi:role="line" + id="tspan5724-6-2" + x="130" + y="967.36218" + style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:6.75px;line-height:1.25;font-family:Sans;-inkscape-font-specification:'Sans Italic';stroke-width:0.75">3.85V</tspan></text> + <g + transform="matrix(0.75,0,0,0.75,129.25001,324.34056)" + id="g2665"> + <rect + transform="rotate(-90)" + y="281" + x="-880.36218" + height="13" + width="5.99998" + id="rect2655" + 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="path2657" + d="m 275,877.3622 h 5.97933" + style="fill:none;stroke:#000000;stroke-width:0.79999995;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + inkscape:connector-curvature="0" + id="path2659" + d="m 301,877.3622 h -6.97934" + 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 + id="text2663" + y="870.6955" + x="287.5" + style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;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:9px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'Sans Bold';text-align:center;text-anchor:middle" + y="870.6955" + x="287.5" + id="tspan2661" + sodipodi:role="line">4k7</tspan></text> + </g> + <g + id="g5433-8" + transform="matrix(0.2109375,0,0,0.2109375,329.18603,773.83305)"> + <path + transform="translate(0,2.5390623e-6)" + inkscape:connector-curvature="0" + id="path5435-9" + d="m 255.11811,988.58266 v 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="path5437-7" + d="m 237.40157,1009.8425 h 35.43308" + 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 + id="g5493-3" + transform="matrix(0.75,0,0,0.75,158.75001,324.34056)"> + <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-6" + width="5.99998" + height="13" + x="-880.36218" + y="281" + transform="rotate(-90)" /> + <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 268.33333,877.3622 12.646,0" + id="path5497-1" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cc" /> + <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 299,877.3622 h -4.97934" + id="path5499-2" + inkscape:connector-curvature="0" /> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none" + x="288.33334" + y="870.69556" + id="text5501-93"><tspan + sodipodi:role="line" + id="tspan5503-1" + x="288.33334" + y="870.69556" + style="font-weight:bold;font-size:9px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'Sans Bold';text-align:center;text-anchor:middle">3k3</tspan></text> + </g> + <path + style="fill:none;stroke:#000000;stroke-width:0.60000002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 300.00001,982.36221 37.5,0" + id="path2718" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cc" /> + <path + sodipodi:nodetypes="ccc" + inkscape:connector-curvature="0" + id="path5556-9-7" + d="m 198,973.86221 -7.5,-5 h -20" + style="fill:none;stroke:#000000;stroke-width:0.59999996;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow2Mstart-7-9)" /> + <text + xml:space="preserve" + style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:9px;line-height:0%;font-family:Sans;-inkscape-font-specification:'Sans Italic';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75" + x="170.50002" + y="966.86224" + id="text5722-3-2-8"><tspan + sodipodi:role="line" + id="tspan5724-6-2-4" + x="170.50002" + y="966.86224" + style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:6.75px;line-height:1.25;font-family:Sans;-inkscape-font-specification:'Sans Italic';stroke-width:0.75">5Vpp</tspan></text> + <path + sodipodi:nodetypes="ccc" + inkscape:connector-curvature="0" + id="path5556-9-7-3" + d="m 357.50001,984.86221 -15,10 -27.5,0" + style="fill:none;stroke:#000000;stroke-width:0.59999996;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow2Mstart-7-9-5)" /> + <text + xml:space="preserve" + style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:9px;line-height:0%;font-family:Sans;-inkscape-font-specification:'Sans Italic';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.75" + x="315" + y="992.86224" + id="text5722-3-2-8-6"><tspan + sodipodi:role="line" + id="tspan5724-6-2-4-1" + x="315" + y="992.86224" + style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:6.75px;line-height:1.25;font-family:Sans;-inkscape-font-specification:'Sans Italic';stroke-width:0.75">0.5–2.9V</tspan></text> </g> <g inkscape:groupmode="layer" diff --git a/qucs/af_5vpp_to_adc.sch b/qucs/af_5vpp_to_adc.sch new file mode 100644 index 0000000..d84e659 --- /dev/null +++ b/qucs/af_5vpp_to_adc.sch @@ -0,0 +1,81 @@ +<Qucs Schematic 0.0.19> +<Properties> + <View=-103,-100,1487,868,1,15,0> + <Grid=10,10,1> + <DataSet=af_5vpp_to_adc.dat> + <DataDisplay=af_5vpp_to_adc.dpl> + <OpenDisplay=1> + <Script=af_5vpp_to_adc.m> + <RunScript=0> + <showFrame=0> + <FrameText0=Title> + <FrameText1=Drawn By:> + <FrameText2=Date:> + <FrameText3=Revision:> +</Properties> +<Symbol> +</Symbol> +<Components> + <GND * 1 30 190 0 0 0 0> + <VProbe IN 1 20 170 28 -31 0 0> + <C C1 1 160 240 -26 17 0 0 "1 uF" 1 "" 0 "neutral" 0> + <Vac Vsrc 1 10 300 18 -26 0 1 "2.5 V" 1 "1750 Hz" 0 "0" 0 "0" 0> + <.TR TR1 1 710 520 0 73 0 0 "lin" 1 "0" 1 "0.002 s" 1 "101" 0 "Trapezoidal" 0 "2" 0 "1 ns" 0 "1e-16" 0 "300" 0 "0.001" 0 "1 pA" 0 "1 uV" 0 "26.85" 0 "1e-3" 0 "1e-6" 0 "1" 0 "CroutLU" 0 "no" 0 "yes" 0 "0" 0> + <GND * 1 680 400 0 0 0 0> + <VProbe OUT 1 890 200 28 -31 0 0> + <Lib OP1 1 620 220 25 20 0 0 "OpAmps" 0 "uA741" 0> + <GND * 1 580 150 0 0 0 0> + <Vdc V2 1 970 80 18 -26 0 1 "12 V" 1> + <R R8 1 830 310 -132 -26 0 3 "3.3 kOhm" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0> + <R R7 1 750 220 -26 -65 0 2 "4.7 kOhm" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0> + <R R6 1 330 240 -26 -65 0 2 "4.7 kOhm" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0> + <R R5 1 520 320 -26 -65 0 2 "4.7 kOhm" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0> + <Lib D1 1 580 120 -42 -1 0 3 "Z-Diodes" 0 "1N749" 0> + <R R10 1 580 50 -138 -26 0 3 "2.2 kOhm" 1 "26.85" 0 "0.0" 0 "0.0" 0 "26.85" 0 "european" 0> +</Components> +<Wires> + <10 190 10 240 "" 0 0 0 ""> + <10 240 10 270 "" 0 0 0 ""> + <10 240 130 240 "" 0 0 0 ""> + <10 330 10 390 "" 0 0 0 ""> + <680 390 680 400 "" 0 0 0 ""> + <10 390 630 390 "" 0 0 0 ""> + <630 390 680 390 "" 0 0 0 ""> + <630 260 630 390 "" 0 0 0 ""> + <680 390 830 390 "" 0 0 0 ""> + <830 340 830 390 "" 0 0 0 ""> + <830 220 830 280 "" 0 0 0 ""> + <830 390 900 390 "" 0 0 0 ""> + <900 220 900 390 "" 0 0 0 ""> + <830 220 880 220 "" 0 0 0 ""> + <190 240 300 240 "" 0 0 0 ""> + <360 240 470 240 "" 0 0 0 ""> + <470 320 490 320 "" 0 0 0 ""> + <470 240 470 320 "" 0 0 0 ""> + <780 220 830 220 "" 0 0 0 ""> + <680 220 720 220 "" 0 0 0 ""> + <680 220 680 320 "" 0 0 0 ""> + <550 320 680 320 "" 0 0 0 ""> + <470 240 580 240 "" 0 0 0 ""> + <900 390 970 390 "" 0 0 0 ""> + <970 110 970 390 "" 0 0 0 ""> + <970 20 970 50 "" 0 0 0 ""> + <580 80 580 90 "" 0 0 0 ""> + <580 20 630 20 "" 0 0 0 ""> + <630 20 970 20 "" 0 0 0 ""> + <630 20 630 180 "" 0 0 0 ""> + <530 200 580 200 "" 0 0 0 ""> + <530 90 530 200 "" 0 0 0 ""> + <530 90 580 90 "" 0 0 0 ""> +</Wires> +<Diagrams> + <Rect 70 755 590 310 3 #c0c0c0 1 00 1 0 0.0002 0.004 1 -3.19938 0.5 3.69314 1 -1 0.2 1 315 0 225 "" "" ""> + <"IN.Vt" #0000ff 0 3 0 0 0> + <"OUT.Vt" #ff0000 0 3 0 0 0> + </Rect> +</Diagrams> +<Paintings> + <Text 10 -40 16 #000000 0 "This is a simulation for the audio\nfrequency input to the STM32 ADC.\nIt receives a 5Vpp signal, must be\nAC coupled, and the ADC wants a\n0 to 3V signal."> + <Text 450 110 12 #000000 0 "1N749A\n(4.3V)"> + <Text 640 170 12 #000000 0 "LM324"> +</Paintings> diff --git a/src/common/includes/Audio/audio_in.h b/src/common/includes/Audio/audio_in.h index 86c93b2..3bc543c 100644 --- a/src/common/includes/Audio/audio_in.h +++ b/src/common/includes/Audio/audio_in.h @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2018 Maximilien Cuony + * Copyright (c) 2019 Matthias P. Braendli, Maximilien Cuony * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,19 +22,16 @@ * SOFTWARE. */ -#ifndef __AUDIO_IN_H__ -#define __AUDIO_IN_H__ +#pragma once #include <stdio.h> #include "FreeRTOS.h" -#define AUDIO_IN_BUF_LEN 2048 #define AUDIO_IN_RATE 8000 - -int16_t * audio_in_buffer; +#define AUDIO_IN_BUF_LEN 32 void audio_in_initialize(int rate); -void audio_in_initialize_plateform(int rate); -void audio_in_buffer_ready(void); -#endif +// Fill the buffer with AUDIO_IN_BUF_LEN samples. +void audio_in_get_buffer(int16_t *buffer /*of length AUDIO_IN_BUF_LEN*/ ); + diff --git a/src/common/includes/Audio/tone.h b/src/common/includes/Audio/tone.h index 0e80228..861a472 100644 --- a/src/common/includes/Audio/tone.h +++ b/src/common/includes/Audio/tone.h @@ -42,6 +42,11 @@ struct tone_detector { }; void tone_init(int threshold); -int tone_detect_1750(int16_t sample); + +/* Return 1 when 1750 detected, 0 otherwise */ +int tone_1750_status(void); + +/* Update 1750 tone detection status */ +void tone_detect_1750(const int16_t *samples, int len); #endif diff --git a/src/common/includes/Core/common.h b/src/common/includes/Core/common.h index b5dc881..3f7dbcc 100644 --- a/src/common/includes/Core/common.h +++ b/src/common/includes/Core/common.h @@ -63,6 +63,7 @@ int random_bool(void); #define FAULT_SOURCE_TASK_OVERFLOW 5 #define FAULT_SOURCE_CW_AUDIO_QUEUE 6 #define FAULT_SOURCE_ADC1 7 +#define FAULT_SOURCE_ADC2 8 void trigger_fault(int source); int find_last_sunday(const struct tm*); diff --git a/src/common/src/Audio/audio_in.c b/src/common/src/Audio/audio_in.c index b046a62..dd1994e 100644 --- a/src/common/src/Audio/audio_in.c +++ b/src/common/src/Audio/audio_in.c @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2018 Maximilien Cuony + * Copyright (c) 2019 Matthias P. Braendli, Maximilien Cuony * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,27 +22,3 @@ * SOFTWARE. */ -#include "Audio/tone.h" -#include "Audio/audio_in.h" - -int16_t audio_in_buffer_0[AUDIO_IN_BUF_LEN]; -int16_t audio_in_buffer_1[AUDIO_IN_BUF_LEN]; - -void audio_in_initialize(int rate) { - audio_in_buffer = audio_in_buffer_0; - audio_in_initialize_plateform(rate); -} - -void audio_in_buffer_ready() { - - for (int i = 0; i < AUDIO_IN_BUF_LEN; i++) { - tone_detect_1750(audio_in_buffer[i]); - } - - if (audio_in_buffer == audio_in_buffer_0) { - audio_in_buffer = audio_in_buffer_1; - } else { - audio_in_buffer = audio_in_buffer_0; - } - -} diff --git a/src/common/src/Audio/tone.c b/src/common/src/Audio/tone.c index 60226ce..5065b31 100644 --- a/src/common/src/Audio/tone.c +++ b/src/common/src/Audio/tone.c @@ -37,7 +37,12 @@ static struct tone_detector detector_1750; -int TONE_1750_DETECTED = 0; +static int tone_1750_detected = 0; + +int tone_1750_status() +{ + return tone_1750_detected; +} static void init_tone(struct tone_detector* detector, int freq, int threshold) { detector->coef = 2.0f * arm_cos_f32(2.0f * FLOAT_PI * freq / AUDIO_IN_RATE); @@ -68,6 +73,12 @@ static inline int analyse_sample(int16_t sample, struct tone_detector *detector) detector->Q2 * detector->Q2 - detector->coef * detector->Q1 * detector->Q2); +#ifdef SIMULATOR +#define FRMT "%- 12.4f" + fprintf(stderr, "1750: Q1 " FRMT " Q2 " FRMT " m " FRMT " thresh " FRMT "\n", detector->Q1, detector->Q2, m, detector->threshold); +#endif + + detector->Q1 = 0; detector->Q2 = 0; detector->num_samples_analysed = 0; @@ -84,12 +95,13 @@ static inline int analyse_sample(int16_t sample, struct tone_detector *detector) } } -int tone_detect_1750(int16_t sample) +void tone_detect_1750(const int16_t *samples, int len) { - int r = analyse_sample(sample, &detector_1750); - if (r == 0 || r == 1) { - TONE_1750_DETECTED = r; + for (int i = 0; i < len; i++) { + int r = analyse_sample(samples[i], &detector_1750); + if (r == 0 || r == 1) { + tone_1750_detected = r; + } } - return r; } diff --git a/src/common/src/Core/main.c b/src/common/src/Core/main.c index d303e09..ed3dfef 100644 --- a/src/common/src/Core/main.c +++ b/src/common/src/Core/main.c @@ -50,13 +50,15 @@ #include "GPIO/analog.h" #include "vc.h" +#ifdef SIMULATOR +extern int gui_in_tone_1750; +#endif + static int tm_trigger_button = 0; static struct fsm_input_signals_t fsm_input; static int hour_is_even = 0; -extern int TONE_1750_DETECTED; - /* Threshold for SWR measurement */ const int swr_refl_threshold = 10; // mV @@ -79,6 +81,7 @@ void init(void); // Tasks static void detect_button_press(void *pvParameters); static void exercise_fsm(void *pvParameters); +static void nf_analyse(void *pvParameters); static void gps_monit_task(void *pvParameters); static void launcher_task(void *pvParameters); @@ -198,10 +201,6 @@ static void launcher_task(void __attribute__ ((unused))*pvParameters) trigger_fault(FAULT_SOURCE_MAIN); } - usart_debug_puts("Tone init\r\n"); -#warning TODO - tone_init(20000); - usart_debug_puts("Audio init\r\n"); audio_initialize(Audio16000HzSettings); @@ -211,9 +210,26 @@ static void launcher_task(void __attribute__ ((unused))*pvParameters) usart_debug_puts("Audio set callback\r\n"); audio_play_with_callback(audio_callback, NULL); + usart_debug_puts("Tone init\r\n"); + tone_init(120000); + usart_debug_puts("Audio in init\r\n"); audio_in_initialize(AUDIO_IN_RATE); + usart_debug_puts("TaskNF init\r\n"); + + xTaskCreate( + nf_analyse, + "TaskNF", + 1*configMINIMAL_STACK_SIZE, + (void*) NULL, + tskIDLE_PRIORITY + 2UL, + &task_handle); + + if (!task_handle) { + trigger_fault(FAULT_SOURCE_MAIN); + } + usart_debug_puts("Init done.\r\n"); int last_qrp_from_supply = 0; @@ -489,11 +505,12 @@ static void gps_monit_task(void __attribute__ ((unused))*pvParameters) { static void exercise_fsm(void __attribute__ ((unused))*pvParameters) { + fsm_init(); + int cw_last_trigger = 0; int last_tm_trigger_button = 0; int last_sq = 0; - int last_1750 = 0; int last_qrp = 0; int last_cw_done = 0; int last_discrim_d = 0; @@ -561,8 +578,10 @@ static void exercise_fsm(void __attribute__ ((unused))*pvParameters) leds_turn_on(LED_ORANGE); } -#warning "TODO: from tone detector" - fsm_input.det_1750 = TONE_1750_DETECTED; +#ifdef SIMULATOR + gui_in_tone_1750 = +#endif + fsm_input.det_1750 = tone_1750_status(); fsm_input.fax_mode = 0; fsm_input.swr_high = swr_error_flag; @@ -589,3 +608,26 @@ static void exercise_fsm(void __attribute__ ((unused))*pvParameters) } } + +static int16_t audio_in_buffer[AUDIO_IN_BUF_LEN]; +static int led_phase = 0; +static void nf_analyse(void __attribute__ ((unused))*pvParameters) +{ + while (1) { + if (led_phase == 0) { + leds_turn_on(LED_BLUE); + } + else if (led_phase == 400) { + leds_turn_off(LED_BLUE); + } + + led_phase++; + + if (led_phase >= 800) { + led_phase = 0; + } + + audio_in_get_buffer(audio_in_buffer); + tone_detect_1750(audio_in_buffer, AUDIO_IN_BUF_LEN); + } +} diff --git a/src/common/src/GPIO/usart.c b/src/common/src/GPIO/usart.c index 052c546..535b062 100644 --- a/src/common/src/GPIO/usart.c +++ b/src/common/src/GPIO/usart.c @@ -99,6 +99,9 @@ void usart_debug(const char *format, ...) { } void usart_debug_puts(const char* str) { +#ifdef SIMULATOR + fprintf(stderr, "DEBUG: %s", str); +#endif vTaskSuspendAll(); usart_debug_timestamp(); usart_puts(USART2, str); diff --git a/src/glutt-o-logique/analog_input.c b/src/glutt-o-logique/analog_input.c index 5f0e700..fb9db48 100644 --- a/src/glutt-o-logique/analog_input.c +++ b/src/glutt-o-logique/analog_input.c @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2016 Matthias P. Braendli, Maximilien Cuony + * Copyright (c) 2019 Matthias P. Braendli, Maximilien Cuony * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,15 +30,26 @@ #include "Core/delay.h" #include "Core/common.h" +#include "stm32f4xx_conf.h" #include "stm32f4xx_adc.h" +#include "stm32f4xx_gpio.h" #include <math.h> #include "GPIO/usart.h" +#define PIN_SUPPLY GPIO_Pin_5 +#define PIN_SWR_FWD GPIO_Pin_6 +#define PIN_SWR_REFL GPIO_Pin_7 + +// see doc/pio.txt for allocation +#define PINS_ADC1 /* PA pins */ (GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7) + +#define ADC1_CHANNEL_SUPPLY ADC_Channel_5 +#define ADC1_CHANNEL_SWR_FWD ADC_Channel_6 +#define ADC1_CHANNEL_SWR_REFL ADC_Channel_7 + // Measured on the board itself const float v_ref = 2.965f; -#warning "TODO: initialise ADC2 and use it for NF input" - void analog_init(void) { // Enable ADC and GPIOA clocks @@ -48,7 +59,7 @@ void analog_init(void) // Set analog input pins mode GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; - GPIO_InitStructure.GPIO_Pin = PINS_ANALOG; + GPIO_InitStructure.GPIO_Pin = PINS_ADC1; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; @@ -77,7 +88,7 @@ void analog_init(void) ADC_Cmd(ADC1, ENABLE); } -static uint16_t analog_read_channel(uint8_t channel) +static uint16_t adc1_read(uint8_t channel) { ADC_RegularChannelConfig(ADC1, channel, @@ -115,7 +126,7 @@ static uint16_t analog_read_channel(uint8_t channel) float analog_measure_12v(void) { - const uint16_t raw_value = analog_read_channel(ADC_CHANNEL_SUPPLY); + const uint16_t raw_value = adc1_read(ADC1_CHANNEL_SUPPLY); const float adc_max_value = (1 << 12); @@ -129,8 +140,8 @@ float analog_measure_12v(void) int analog_measure_swr(int *forward_mv, int* reflected_mv) { - 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); + const uint16_t raw_swr_fwd_value = adc1_read(ADC1_CHANNEL_SWR_FWD); + const uint16_t raw_swr_refl_value = adc1_read(ADC1_CHANNEL_SWR_REFL); const float adc_max_value = (1 << 12); diff --git a/src/glutt-o-logique/analog_input.h b/src/glutt-o-logique/analog_input.h index 0385ec4..635482f 100644 --- a/src/glutt-o-logique/analog_input.h +++ b/src/glutt-o-logique/analog_input.h @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2016 Matthias P. Braendli, Maximilien Cuony + * Copyright (c) 2019 Matthias P. Braendli, Maximilien Cuony * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,17 +24,6 @@ #pragma once -#include "stm32f4xx_conf.h" -#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 diff --git a/src/glutt-o-logique/audio_in.c b/src/glutt-o-logique/audio_in.c new file mode 100644 index 0000000..743c79b --- /dev/null +++ b/src/glutt-o-logique/audio_in.c @@ -0,0 +1,148 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2019 Matthias P. Braendli, Maximilien Cuony + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. +*/ + +#include "stm32f4xx_conf.h" +#include "stm32f4xx_gpio.h" +#include "stm32f4xx_adc.h" + +#include "Core/common.h" +#include "Audio/audio_in.h" +#include "queue.h" + +// APB1 prescaler = 4, see bsp/system_stm32f4xx.c +#define APB1_FREQ (168000000ul / 4) +#define ADC2_SAMPLE_FREQ 16000 +#define ADC2_CHANNEL_AUDIO ADC_Channel_14 + +// see doc/pio.txt for allocation +#define PINS_ADC2 /* PB1 on ADC2 IN9 */ (GPIO_Pin_1) + +#warning "TODO: initialise ADC2 and use it for NF input" + +// The TIM6 ISR reads from ADC2 and writes into this buffer +static int16_t adc2_values[AUDIO_IN_BUF_LEN]; +static int adc2_values_end = 0; + +// ADC2 data from interrupt to userspace goes through the queue +static QueueHandle_t adc2_values_queue; + +/* ISR for Timer6 and DAC1&2 underrun */ +void TIM6_DAC_IRQHandler(void) +{ + if (TIM_GetITStatus(TIM6, TIM_IT_Update)) { + if (ADC_GetFlagStatus(ADC2, ADC_FLAG_EOC) == SET) { + uint16_t value = ADC_GetConversionValue(ADC2); + /* input range: 0 to 65535 + * output range: -32768 to 32767 */ + adc2_values[adc2_values_end++] = (int32_t)value - 32768; + if (adc2_values_end == AUDIO_IN_BUF_LEN) { + int success = xQueueSendToBackFromISR( + adc2_values_queue, + adc2_values, + NULL); + + adc2_values_end = 0; + + if (success == pdFALSE) { + trigger_fault(FAULT_SOURCE_ADC2); + } + } + } + else { +#warning "handle fault" + } + + ADC_SoftwareStartConv(ADC2); + + TIM_ClearITPendingBit(TIM6, TIM_IT_Update); + } +} + +// Timer6 is used for ADC2 sampling +static void enable_timer6(void) +{ + /* TIM6 Periph clock enable */ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE); + + /* Time base configuration */ + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); + TIM_TimeBaseStructure.TIM_Period = (int)(APB1_FREQ/ADC2_SAMPLE_FREQ); + TIM_TimeBaseStructure.TIM_Prescaler = 0; + TIM_TimeBaseStructure.TIM_ClockDivision = 0; + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; + TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure); + + NVIC_InitTypeDef NVIC_InitStructure; + NVIC_InitStructure.NVIC_IRQChannel = TIM6_DAC_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + TIM_Cmd(TIM6, ENABLE); + ADC_SoftwareStartConv(ADC2); + TIM_ITConfig(TIM6, TIM_IT_Update, ENABLE); +} + + +void audio_in_initialize(int rate) +{ + RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC2, ENABLE); + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); + + GPIO_InitTypeDef GPIO_InitStructure; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; + GPIO_InitStructure.GPIO_Pin = PINS_ADC2; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_Init(GPIOB, &GPIO_InitStructure); + + // Init ADC2 for NF input + ADC_InitTypeDef ADC_InitStruct; + ADC_InitStruct.ADC_Resolution = ADC_Resolution_12b; + ADC_InitStruct.ADC_ScanConvMode = DISABLE; + 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_Init(ADC2, &ADC_InitStruct); + + ADC_Cmd(ADC2, ENABLE); + + adc2_values_queue = xQueueCreate(4, AUDIO_IN_BUF_LEN); + if (adc2_values_queue == 0) { + while(1); /* fatal error */ + } + + enable_timer6(); +} + +void audio_in_get_buffer(int16_t *buffer /*of length AUDIO_IN_BUF_LEN*/ ) +{ + while (!xQueueReceive(adc2_values_queue, buffer, portMAX_DELAY)) {} +} + diff --git a/src/glutt-o-logique/pio.c b/src/glutt-o-logique/pio.c index e944671..1069886 100644 --- a/src/glutt-o-logique/pio.c +++ b/src/glutt-o-logique/pio.c @@ -304,7 +304,7 @@ void pio_set_mod_off(int mod_off) } int pio_read_button() { - return GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == Bit_SET; + return GPIO_ReadInputDataBit(GPIOA,GPIOA_PIN_PUSHBTN) == Bit_SET; } void pio_set_gps_epps(int on) diff --git a/src/glutt-o-logique/stm32f4discovery-with-stlinkv2.1.cfg b/src/glutt-o-logique/stm32f4discovery-with-stlinkv2.1.cfg new file mode 100644 index 0000000..18369f5 --- /dev/null +++ b/src/glutt-o-logique/stm32f4discovery-with-stlinkv2.1.cfg @@ -0,0 +1,10 @@ +# This is an STM32F4 discovery board with a single STM32F407VGT6 chip. +# http://www.st.com/internet/evalboard/product/252419.jsp + +source [find interface/stlink-v2-1.cfg] + +transport select hla_swd + +source [find target/stm32f4x.cfg] + +reset_config srst_only diff --git a/src/simulator/src/Audio/audio.c b/src/simulator/src/Audio/audio.c index 31f4c98..ab9773a 100644 --- a/src/simulator/src/Audio/audio.c +++ b/src/simulator/src/Audio/audio.c @@ -48,15 +48,19 @@ void audio_initialize_platform(int __attribute__ ((unused))plln, int __attribute ss.rate = rate; + fprintf(stderr, "Pulseaudio out init\n"); s = pa_simple_new(NULL, "Glutte", PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, NULL, &error); + fprintf(stderr, "Pulseaudio %p\n", s); if (!s) { - printf("Pulseaudio playback init error\n"); + fprintf(stderr, "Pulseaudio playback init error\n"); while(1); } + TaskHandle_t task_handle; + fprintf(stderr, "Pulseaudio task\n"); xTaskCreate( audio_buffer_sender, "Audio buffer sender", @@ -64,7 +68,7 @@ void audio_initialize_platform(int __attribute__ ((unused))plln, int __attribute (void*) NULL, tskIDLE_PRIORITY + 2UL, &task_handle); - + fprintf(stderr, "Pulseaudio buffer sender created\n"); } static void audio_buffer_sender(void __attribute__ ((unused)) *args) { diff --git a/src/simulator/src/Audio/audio_in.c b/src/simulator/src/Audio/audio_in.c index 936fe1c..d17e8bc 100644 --- a/src/simulator/src/Audio/audio_in.c +++ b/src/simulator/src/Audio/audio_in.c @@ -26,15 +26,31 @@ #include <assert.h> #include <pulse/simple.h> #include "Audio/audio_in.h" +#include "Audio/tone.h" #include "FreeRTOS.h" #include "task.h" +#include "queue.h" pa_simple *s_in = NULL; +static QueueHandle_t adc2_values_queue; -static void audio_buffer_reader(void *args); +static void audio_buffer_reader(void __attribute__((unused))*args) +{ + while (1) { + int16_t buffer[AUDIO_IN_BUF_LEN]; + pa_simple_read(s_in, buffer, AUDIO_IN_BUF_LEN * sizeof(int16_t), NULL); + int success = xQueueSendToBack( + adc2_values_queue, + buffer, + portMAX_DELAY); + assert(success); + taskYIELD(); + } +} -void audio_in_initialize_plateform(int rate) { + +void audio_in_initialize(int rate) { int error; static pa_sample_spec ss = { @@ -46,9 +62,11 @@ void audio_in_initialize_plateform(int rate) { ss.rate = rate; s_in = pa_simple_new(NULL, "GlutteR", PA_STREAM_RECORD, NULL, "record", &ss, NULL, NULL, &error); - assert(s_in); + adc2_values_queue = xQueueCreate(4, AUDIO_IN_BUF_LEN); + assert(adc2_values_queue); + TaskHandle_t task_handle; xTaskCreate( audio_buffer_reader, @@ -59,13 +77,8 @@ void audio_in_initialize_plateform(int rate) { &task_handle); } -static void audio_buffer_reader(void __attribute__ ((unused)) *args) { - - while(1) { - pa_simple_read(s_in, audio_in_buffer, AUDIO_IN_BUF_LEN * 2, NULL); - audio_in_buffer_ready(); - - taskYIELD(); - } - +void audio_in_get_buffer(int16_t *buffer /*of length AUDIO_IN_BUF_LEN*/ ) +{ + while (!xQueueReceive(adc2_values_queue, buffer, portMAX_DELAY)) {} } + diff --git a/src/simulator/src/Gui/gui.c b/src/simulator/src/Gui/gui.c index fd4fe7a..f6f9ab9 100644 --- a/src/simulator/src/Gui/gui.c +++ b/src/simulator/src/Gui/gui.c @@ -152,6 +152,7 @@ int gui_in_sq_n = 1; int gui_in_u = 0; int gui_in_d = 0; int gui_in_replie = 0; +int gui_in_tone_1750 = 0; static const char *replie_status[] = {"In vent", "Replié"}; int gui_in_fax_n = 1; @@ -163,8 +164,6 @@ int in_u = 0; int in_d = 0; int in_fax_n = 1; -extern int TONE_1750_DETECTED; - /** * FSM @@ -821,7 +820,7 @@ void main_gui() { nk_property_float(ctx, "V", 0.0f, &gui_measured_voltage, 24.0f, 0.5f, 0.5f); - if (TONE_1750_DETECTED) { + if (gui_in_tone_1750) { c = color_on; } else { c = color_off; diff --git a/src/simulator/src/Gui/nuklear.h b/src/simulator/src/Gui/nuklear.h index 5602251..3d10c4a 100644 --- a/src/simulator/src/Gui/nuklear.h +++ b/src/simulator/src/Gui/nuklear.h @@ -13625,7 +13625,7 @@ nk_do_color_picker(nk_flags *state, * ===============================================================*/ NK_API void nk_style_default(struct nk_context *ctx){nk_style_from_table(ctx, 0);} #define NK_COLOR_MAP(NK_COLOR)\ - NK_COLOR(NK_COLOR_TEXT, 175,175,175,255) \ + NK_COLOR(NK_COLOR_TEXT, 255,255,255,255) \ NK_COLOR(NK_COLOR_WINDOW, 45, 45, 45, 255) \ NK_COLOR(NK_COLOR_HEADER, 40, 40, 40, 255) \ NK_COLOR(NK_COLOR_BORDER, 65, 65, 65, 255) \ diff --git a/src/tone-test-sim/analyse.py b/src/tone-test-sim/analyse.py index 8222213..b1b0649 100755 --- a/src/tone-test-sim/analyse.py +++ b/src/tone-test-sim/analyse.py @@ -4,10 +4,12 @@ import numpy as np import matplotlib.pyplot as plt dat = np.loadtxt("tone.csv", dtype=np.int32, delimiter=",") -# columns :"freq, threshold, num_samples, detector_output" +# columns :"freq, threshold, num_samples, detector_output, avg_rms" fig, ax = plt.subplots() -plt.scatter(dat[...,0], dat[...,1], c=dat[...,3].astype(np.float32)) +plt.scatter(dat[...,0], dat[...,1] / dat[...,4], c=dat[...,3].astype(np.float32)) +plt.xlabel("freq") +plt.ylabel("threshold over rms") plt.show() if 0: diff --git a/src/tone-test-sim/src/test.c b/src/tone-test-sim/src/test.c index 3bff6d7..716b7ae 100644 --- a/src/tone-test-sim/src/test.c +++ b/src/tone-test-sim/src/test.c @@ -33,7 +33,7 @@ int main(int argc, char **argv) { printf("Hello, ver %s\n", vc_get_version()); printf("Saving results to tone.csv\n"); - printf("freq, threshold, num_samples, detector_output\n"); + printf("freq, threshold, num_samples, detector_output, avg_rms\n"); FILE *fd = fopen("tone.csv", "w"); if (!fd) { @@ -48,12 +48,19 @@ int main(int argc, char **argv) for (int threshold = 100000; threshold < 4000000; threshold += 100000) { tone_init(threshold); - for (size_t j = 0; j < 200; j++) { - float samplef = cosf(j * 2.0f * FLOAT_PI * freq / AUDIO_IN_RATE); - int16_t sample = samplef * 32767.0f; + double accu = 0; + + for (size_t j = 0; j < 100; j++) { + const float samplef = cosf(j * 2.0f * FLOAT_PI * freq / AUDIO_IN_RATE); + const float noisef = (drand48() * 2.0f) - 1; + int16_t sample = (0.9f * samplef + 0.1f * noisef) * 32767.0f; + + accu += (sample * sample); + int r = tone_detect_1750(sample); if (r != -1) { - fprintf(fd, "%d,%d,%zu,%d\n",freq, threshold, j, r); + const double rms = sqrt(accu / (double)j); + fprintf(fd, "%d,%d,%zu,%d,%f\n",freq, threshold, j, r, rms); } } } |