mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2024-11-22 05:54:19 +00:00
update
This commit is contained in:
parent
1c773d745a
commit
2bc9cc61b3
22 changed files with 1244 additions and 108 deletions
|
@ -644,18 +644,18 @@
|
|||
<buildTargets>
|
||||
<target name="all" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>mingw32-make.exe</buildCommand>
|
||||
<buildArguments>-s -j 2</buildArguments>
|
||||
<buildArguments>-s -j 16</buildArguments>
|
||||
<buildTarget>all</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
<runAllBuilders>false</runAllBuilders>
|
||||
</target>
|
||||
<target name="clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>-s</buildArguments>
|
||||
<buildCommand>mingw32-make.exe</buildCommand>
|
||||
<buildArguments>-s -j 16</buildArguments>
|
||||
<buildTarget>clean</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
<runAllBuilders>false</runAllBuilders>
|
||||
</target>
|
||||
<target name="flashburn" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
|
|
119
ExampleHTM/dygraph/ina2.css
Normal file
119
ExampleHTM/dygraph/ina2.css
Normal file
|
@ -0,0 +1,119 @@
|
|||
/**
|
||||
* Default styles for the dygraphs charting library.
|
||||
*/
|
||||
|
||||
.dygraph-legend {
|
||||
position: relative;
|
||||
font-size: 12px;
|
||||
z-index: 10;
|
||||
width: 250px; /* labelsDivWidth */
|
||||
/*
|
||||
dygraphs determines these based on the presence of chart labels.
|
||||
It might make more sense to create a wrapper div around the chart proper.
|
||||
top: 0px;
|
||||
right: 2px;
|
||||
*/
|
||||
background: white;
|
||||
line-height: normal;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* styles for a solid line in the legend */
|
||||
.dygraph-legend-line {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
bottom: .5ex;
|
||||
padding-left: 1em;
|
||||
height: 1px;
|
||||
border-bottom-width: 2px;
|
||||
border-bottom-style: solid;
|
||||
/* border-bottom-color is set based on the series color */
|
||||
}
|
||||
|
||||
/* styles for a dashed line in the legend, e.g. when strokePattern is set */
|
||||
.dygraph-legend-dash {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
bottom: .5ex;
|
||||
height: 1px;
|
||||
border-bottom-width: 2px;
|
||||
border-bottom-style: solid;
|
||||
/* border-bottom-color is set based on the series color */
|
||||
/* margin-right is set based on the stroke pattern */
|
||||
/* padding-left is set based on the stroke pattern */
|
||||
}
|
||||
|
||||
.dygraph-roller {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
/* This class is shared by all annotations, including those with icons */
|
||||
.dygraph-annotation {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* This class only applies to annotations without icons */
|
||||
/* Old class name: .dygraphDefaultAnnotation */
|
||||
.dygraph-default-annotation {
|
||||
border: 1px solid black;
|
||||
background-color: white;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dygraph-axis-label {
|
||||
/* position: absolute; */
|
||||
/* font-size: 14px; */
|
||||
z-index: 10;
|
||||
line-height: normal;
|
||||
overflow: hidden;
|
||||
color: black; /* replaces old axisLabelColor option */
|
||||
}
|
||||
|
||||
.dygraph-axis-label-x {
|
||||
}
|
||||
|
||||
.dygraph-axis-label-y {
|
||||
color: rgb(51,204,204);
|
||||
}
|
||||
|
||||
.dygraph-axis-label-y2 {
|
||||
color: rgb(255,100,100);
|
||||
}
|
||||
|
||||
.dygraph-title {
|
||||
font-weight: bold;
|
||||
z-index: 10;
|
||||
text-align: center;
|
||||
/* font-size: based on titleHeight option */
|
||||
}
|
||||
|
||||
.dygraph-xlabel {
|
||||
text-align: center;
|
||||
/* font-size: based on xLabelHeight option */
|
||||
}
|
||||
|
||||
/* For y-axis label */
|
||||
.dygraph-label-rotate-left {
|
||||
text-align: center;
|
||||
/* See http://caniuse.com/#feat=transforms2d */
|
||||
transform: rotate(90deg);
|
||||
-webkit-transform: rotate(90deg);
|
||||
-moz-transform: rotate(90deg);
|
||||
-o-transform: rotate(90deg);
|
||||
-ms-transform: rotate(90deg);
|
||||
}
|
||||
|
||||
/* For y2-axis label */
|
||||
.dygraph-label-rotate-right {
|
||||
text-align: center;
|
||||
/* See http://caniuse.com/#feat=transforms2d */
|
||||
transform: rotate(-90deg);
|
||||
-webkit-transform: rotate(-90deg);
|
||||
-moz-transform: rotate(-90deg);
|
||||
-o-transform: rotate(-90deg);
|
||||
-ms-transform: rotate(-90deg);
|
||||
}
|
178
ExampleHTM/dygraph/ws_adcs.htm
Normal file
178
ExampleHTM/dygraph/ws_adcs.htm
Normal file
|
@ -0,0 +1,178 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="ina2.css">
|
||||
<title>Get ADC data</title>
|
||||
<script type="text/javascript" src="dygraph.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div style="height: auto; width: auto; text-align: center;">
|
||||
<div id="div_v" style="height:400px;"></div>
|
||||
<input type="button" id="butOnOff" value="Stop">
|
||||
<input type="radio" checked name='rm1' id="FixEnd"/>
|
||||
<label for="FixEnd">Fixed</label>
|
||||
<input type="radio" name='rm1' id="FixNone"/>
|
||||
<label for="FixNone">Float</label>
|
||||
<input type="button" id="butSave" value="Save data.csv"><br>
|
||||
Window: <span id='wdsize'>?</span> sec, Sample Rate: <span id='smprate'>?</span> smps
|
||||
<div id='labdiv' style=></div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
var $ = function(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
var stg = 0;
|
||||
var smprate = 975; // adc1: 3900 sps, adc2: 1950 sps, adc4: 975 sps, adc8: 487.5 sps
|
||||
var smps = smprate;
|
||||
var sttim = 0;
|
||||
var cur_idx = 0;
|
||||
var old_idx = 0;
|
||||
var smpsa = [];
|
||||
function wsSmpRate() {
|
||||
var idx = cur_idx, tt = new Date().getTime();
|
||||
var sps = (idx - old_idx) * 1000/ (tt - sttim);
|
||||
sttim = tt; old_idx = idx;
|
||||
smpsa.push(sps);
|
||||
var len = smpsa.length;
|
||||
if(len > 100) { smpsa.shift(); len-- };
|
||||
var csps = 0;
|
||||
for (var i = 0; i < len; i++) csps += smpsa[i];
|
||||
csps = csps/len;
|
||||
$('smprate').innerHTML = csps.toFixed(1);
|
||||
}
|
||||
var samples = 10*smprate;
|
||||
var rend = 1;
|
||||
var oldblkid = 0;
|
||||
var rdnextflg = false;
|
||||
$("butOnOff").onclick = function() {
|
||||
if(rend) {rend = 0; $("butOnOff").value = "Run";}
|
||||
else {rend = 1; $("butOnOff").value = "Stop";}
|
||||
}
|
||||
var datau = [];
|
||||
var gu;
|
||||
function wsping() {
|
||||
clearTimeout(wstt);
|
||||
ws.send('adc*');
|
||||
wstt = setTimeout(wsping, 400);
|
||||
}
|
||||
var wsUri = 'ws://rtl871x1/web.cgi'
|
||||
//var wsUri = "ws://"+window.location.host.toString()+"/web.cgi";
|
||||
ws = new WebSocket(wsUri);
|
||||
ws.binaryType = 'arraybuffer';
|
||||
ws.onopen = function(){
|
||||
ws.send('user=rtl871x:supervisor');
|
||||
ws.send('adcz'); // drv deinit
|
||||
ws.send('adcy'); // mode 2 chnl
|
||||
ws.send('adc4'); // decimation
|
||||
ws.send('adcd'); // xclk
|
||||
ws.send('sys_debug=0'); // print off
|
||||
wstt = setTimeout(wsping,50);};
|
||||
ws.onmessage = function (event) {
|
||||
if(event.data instanceof ArrayBuffer) {
|
||||
clearTimeout(wstt);
|
||||
var wordarray = new Uint16Array(event.data);
|
||||
if(wordarray.length > 2) {
|
||||
var blksz = wordarray[0];
|
||||
if(wordarray.length == blksz*2 + 2) {
|
||||
if(!sttim) {
|
||||
sttim = new Date().getTime();
|
||||
setInterval(function(){wsSmpRate()}, 500);
|
||||
} else {
|
||||
var blkid = wordarray[1] & 0xFFFF;
|
||||
if(rdnextflg) cur_idx += (blkid - oldblkid) & 0xFFFF;
|
||||
else rdnextflg = true;
|
||||
oldblkid = blkid + blksz;
|
||||
for (var i=2; i<wordarray.length; i+=2) {
|
||||
if(rend) {
|
||||
if(cur_idx >= samples) datau.shift();
|
||||
datau.push([cur_idx/smprate, (wordarray[i]-10500)*0.000078, (wordarray[i+1]-10500)*0.000078]);
|
||||
}
|
||||
cur_idx++;
|
||||
}
|
||||
if(!stg) {
|
||||
gu = new Dygraph(
|
||||
$("div_v"),
|
||||
datau,
|
||||
{
|
||||
title: 'RTL871xAx ADCs',
|
||||
showRangeSelector: true,
|
||||
showRoller: true,
|
||||
xlabel: 'T(sec)',
|
||||
ylabel: 'U19(V)',
|
||||
y2label: 'Uvbat(V)',
|
||||
colors: ['red','green'],
|
||||
series : { 'Uvbat': { axis: 'y2' } },
|
||||
axes: {
|
||||
x: {valueFormatter: function(x){return this.getLabels()[0] + ': '+ x.toPrecision(5);}}},
|
||||
labels: ['T', 'U19', 'Uvbat'],
|
||||
labelsDiv: $('labdiv'),
|
||||
legend: 'always', // "follow"
|
||||
digitsAfterDecimal: 3,
|
||||
});
|
||||
setInterval(function(){renderChart()}, 50);
|
||||
stg = 1;
|
||||
}
|
||||
} }
|
||||
wstt = setTimeout(wsping, 40);
|
||||
} } }
|
||||
function avg(arr) {
|
||||
var arrLen = arr.length, result = 0;
|
||||
for (var i = 0; i < arrLen; i++) result += arr[i];
|
||||
return result / arrLen;
|
||||
}
|
||||
var renderChart = function() {
|
||||
var dl;
|
||||
if (gu.dateWindow_) {
|
||||
dl = gu.dateWindow_[1] - gu.dateWindow_[0];
|
||||
if ($("FixEnd").checked) {
|
||||
var ls = datau.length - 1;
|
||||
gu.dateWindow_[1] = datau[ls][0];
|
||||
gu.dateWindow_[0] = datau[ls][0] - dl;
|
||||
} else if (gu.dateWindow_[0] < datau[0][0]) {
|
||||
gu.dateWindow_[0] = datau[0][0];
|
||||
gu.dateWindow_[1] = datau[0][0] + dl;
|
||||
}
|
||||
} else dl = datau.length/smprate;
|
||||
$("wdsize").innerHTML = dl.toFixed(3);
|
||||
if(rend) gu.updateOptions({'file': datau});
|
||||
}
|
||||
function convertArrayOfObjectsToCSV(value){
|
||||
var result, ctr, keys, columnDelimiter, lineDelimiter, data;
|
||||
|
||||
data = value.data || null;
|
||||
if (data == null || !data.length) {return null;}
|
||||
columnDelimiter = value.columnDelimiter || ';';
|
||||
lineDelimiter = value.lineDelimiter || '\n';
|
||||
keys = Object.keys(data[1]);
|
||||
result = '';
|
||||
result += keys.join(columnDelimiter);
|
||||
result += lineDelimiter;
|
||||
data.forEach(function(item){
|
||||
ctr = 0;
|
||||
keys.forEach(function(key){
|
||||
if (ctr > 0)
|
||||
result += columnDelimiter;
|
||||
result += item[key];
|
||||
ctr++;
|
||||
});
|
||||
result += lineDelimiter;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
$("butSave").onclick = function() {
|
||||
var csv = convertArrayOfObjectsToCSV({data: datau});
|
||||
if (!csv.match(/^data:text\/csv/i)) {csv = 'data:text/csv;charset=utf-8,' + csv;}
|
||||
var encodedUri = encodeURI(csv);
|
||||
var link = document.createElement('a');
|
||||
link.setAttribute('href', encodedUri);
|
||||
link.setAttribute('download',"data.csv");
|
||||
link.click();
|
||||
}
|
||||
if(window.innerHeight > 320) $('div_v').style.height = (window.innerHeight-80) + 'px';
|
||||
window.onresize = function(){
|
||||
if(window.innerHeight > 320) $('div_v').style.height = (window.innerHeight-80) + 'px';
|
||||
// $('div_v').style.width = (window.innerWidth-50) + 'px';
|
||||
}
|
||||
</script>
|
||||
</html>
|
|
@ -25,7 +25,7 @@ var $ = function(id) {
|
|||
return document.getElementById(id);
|
||||
}
|
||||
var stg = 0;
|
||||
var smprate = 1819;
|
||||
var smprate = 963.4; // 1819;
|
||||
var smps = smprate;
|
||||
var samples = 10*smprate;
|
||||
var rend = 1;
|
||||
|
@ -91,7 +91,6 @@ ws.onmessage = function (event) {
|
|||
// fillGraph: true,
|
||||
showRoller: true,
|
||||
// maxNumberWidth: 10,
|
||||
// digitsAfterDecimal: 3,
|
||||
xlabel: 'T(sec)',
|
||||
ylabel: 'U(V)',
|
||||
y2label: 'I(mA)',
|
||||
|
@ -99,12 +98,13 @@ ws.onmessage = function (event) {
|
|||
// highlightSeriesOpts: { strokeWidth: 2 },
|
||||
series : { 'I': { axis: 'y2' } },
|
||||
axes: {
|
||||
x: {valueFormatter: function(x){return this.getLabels()[0] + ': '+ x.toPrecision(3);}},
|
||||
x: {valueFormatter: function(x){return this.getLabels()[0] + ': '+ x.toPrecision(5);}},
|
||||
y: {valueRange: [0,]},
|
||||
y2: {valueRange: [0,]}},
|
||||
labels: ['T', 'U', 'I'],
|
||||
labelsDiv: $('labdiv'),
|
||||
legend: 'always', // "follow"
|
||||
digitsAfterDecimal: 3,
|
||||
// legendFormatter: legendFormatter
|
||||
});
|
||||
setInterval(function(){renderChart()}, 50);
|
||||
|
|
155
ExampleHTM/dygraph/wso_adcs.htm
Normal file
155
ExampleHTM/dygraph/wso_adcs.htm
Normal file
|
@ -0,0 +1,155 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="ina2.css">
|
||||
<title>Get ADC data</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="height: auto; width: auto; text-align: center;">
|
||||
<div id='div_v' style="height:512px;">
|
||||
<canvas id='scope' width=975 height=512></canvas>
|
||||
</div>
|
||||
Window: <span id='wdsize'>?</span> sec, Sample Rate: <span id='smprate'>?</span> smps
|
||||
<div>
|
||||
<span id='labdiv'>?</span>
|
||||
<input type="button" id="butOnOff" value="Stop">
|
||||
<input type="button" id="butSave" value="Save data.csv"><br>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
var $ = function(id) {return document.getElementById(id);}
|
||||
var smprate = 3900; // adc1: 3900 sps, adc2: 1950 sps, adc4: 975 sps, adc8: 487.5 sps
|
||||
var sttim = 0;
|
||||
var cur_idx = 0;
|
||||
var old_idx = 0;
|
||||
var frend = 0;
|
||||
function wsSmpRate() {
|
||||
var idx = cur_idx, tt = new Date().getTime();
|
||||
var sps = (idx - old_idx) * 1000/ (tt - sttim);
|
||||
sttim = tt; old_idx = idx;
|
||||
if(smprate) smprate = smprate * 0.9 + sps * 0.1;
|
||||
else smprate = sps;
|
||||
$('smprate').innerHTML = smprate.toFixed(1);
|
||||
$('wdsize').innerHTML = ($('scope').width/smprate).toFixed(2);
|
||||
$('labdiv').innerHTML = 'Render ' + frend + ' Hz';
|
||||
frend = 0;
|
||||
}
|
||||
var samples = smprate*3;
|
||||
var rend = 1;
|
||||
var oldblkid = 0;
|
||||
var rdnextflg = false;
|
||||
$("butOnOff").onclick = function() {
|
||||
if(rend) {rend = 0; $("butOnOff").value = "Run";}
|
||||
else {rend = 1; $("butOnOff").value = "Stop";}
|
||||
}
|
||||
var data_ch1 = [];
|
||||
var data_ch2 = [];
|
||||
var gu;
|
||||
function wsping() {
|
||||
clearTimeout(wstt);
|
||||
ws.send('adc*');
|
||||
wstt = setTimeout(wsping, 400);
|
||||
}
|
||||
var ctx = document.getElementById('scope').getContext('2d');
|
||||
function draw() {
|
||||
var width = ctx.canvas.width;
|
||||
var height = ctx.canvas.height;
|
||||
var timeData1 = data_ch1;
|
||||
var timeData2 = data_ch2;
|
||||
var scaling = height / 65536 / 2;
|
||||
var risingEdge = 0;
|
||||
var len = timeData1.length;
|
||||
ctx.fillStyle = 'rgba(0, 20, 0, 0.1)';
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
ctx.lineWidth = 1;
|
||||
ctx.strokeStyle = 'rgb(0, 255, 0)';
|
||||
ctx.beginPath();
|
||||
while (timeData1[486 + risingEdge++] > 32768 && risingEdge <= width);
|
||||
if (risingEdge >= width) risingEdge = 0;
|
||||
while (timeData1[486 + risingEdge++] < 32768 && risingEdge <= width);
|
||||
if (risingEdge >= width) risingEdge = 0;
|
||||
for (var x = risingEdge; x < timeData1.length && x - risingEdge < width; x++)
|
||||
ctx.lineTo(x - risingEdge, height - timeData1[x] * scaling);
|
||||
ctx.moveTo(0,0);
|
||||
for (var x = risingEdge; x < timeData2.length && x - risingEdge < width; x++)
|
||||
ctx.lineTo(x - risingEdge, height - 256 - timeData2[x] * scaling);
|
||||
ctx.stroke();
|
||||
frend++;
|
||||
requestAnimationFrame(draw);
|
||||
}
|
||||
var wsUri = 'ws://rtl871x1/web.cgi'
|
||||
//var wsUri = "ws://"+window.location.host.toString()+"/web.cgi";
|
||||
ws = new WebSocket(wsUri);
|
||||
ws.binaryType = 'arraybuffer';
|
||||
ws.onopen = function(){
|
||||
ws.send('user=rtl871x:supervisor');
|
||||
ws.send('sys_debug=0');
|
||||
ws.send('adcz'); // drv deinit
|
||||
ws.send('adcy'); // mode 2 chls
|
||||
ws.send('adc1'); // decimation
|
||||
ws.send('adcd'); // xclk
|
||||
wstt = setTimeout(wsping,100);};
|
||||
ws.onmessage = function (event) {
|
||||
if(event.data instanceof ArrayBuffer) {
|
||||
clearTimeout(wstt);
|
||||
var wordarray = new Uint16Array(event.data);
|
||||
if(wordarray.length > 2) {
|
||||
var blksz = wordarray[0];
|
||||
if(wordarray.length == blksz*2 + 2) {
|
||||
var blkid = wordarray[1] & 0xFFFF;
|
||||
if(rdnextflg) cur_idx += (blkid - oldblkid) & 0xFFFF;
|
||||
else {
|
||||
rdnextflg = true;
|
||||
sttim = new Date().getTime();
|
||||
setInterval(function(){wsSmpRate()}, 1000);
|
||||
$('wdsize').innerHTML = 975/smprate;
|
||||
draw();
|
||||
}
|
||||
oldblkid = blkid + blksz;
|
||||
for (var i=2; i<wordarray.length; i+=2) {
|
||||
if(rend) {
|
||||
if(data_ch1.length >= samples) {
|
||||
data_ch1.shift();
|
||||
data_ch2.shift();
|
||||
}
|
||||
data_ch1.push([wordarray[i]]);
|
||||
data_ch2.push([wordarray[i+1]]);
|
||||
}
|
||||
cur_idx++;
|
||||
} }
|
||||
wstt = setTimeout(wsping, 40);
|
||||
} } }
|
||||
function convertArrayOfObjectsToCSV(value){
|
||||
var result, ctr, keys, columnDelimiter, lineDelimiter, data;
|
||||
data = value.data || null;
|
||||
if (data == null || !data.length) {return null;}
|
||||
columnDelimiter = value.columnDelimiter || ';';
|
||||
lineDelimiter = value.lineDelimiter || '\n';
|
||||
keys = Object.keys(data[1]);
|
||||
result = '';
|
||||
result += keys.join(columnDelimiter);
|
||||
result += lineDelimiter;
|
||||
data.forEach(function(item){
|
||||
ctr = 0;
|
||||
keys.forEach(function(key){
|
||||
if (ctr > 0)
|
||||
result += columnDelimiter;
|
||||
result += item[key];
|
||||
ctr++;
|
||||
});
|
||||
result += lineDelimiter;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
$("butSave").onclick = function() {
|
||||
var csv = convertArrayOfObjectsToCSV({data: datau});
|
||||
if (!csv.match(/^data:text\/csv/i)) {csv = 'data:text/csv;charset=utf-8,' + csv;}
|
||||
var encodedUri = encodeURI(csv);
|
||||
var link = document.createElement('a');
|
||||
link.setAttribute('href', encodedUri);
|
||||
link.setAttribute('download',"data.csv");
|
||||
link.click();
|
||||
}
|
||||
</script>
|
||||
</html>
|
167
ExampleHTM/dygraph/wso_audio.htm
Normal file
167
ExampleHTM/dygraph/wso_audio.htm
Normal file
|
@ -0,0 +1,167 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="ina2.css">
|
||||
<title>Get ADC data</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="height: auto; width: auto; text-align: center;">
|
||||
<div id='div_v' style="height:512px;">
|
||||
<canvas id='scope' width=976 height=512></canvas>
|
||||
</div>
|
||||
Window: <span id='wdsize'>?</span> sec, Sample Rate: <span id='smprate'>?</span> sps
|
||||
<div>
|
||||
<span id='labdiv'>?</span>
|
||||
<input type="button" id="butOnOff" value="Stop">
|
||||
<input type="button" id="butSave" value="Save data.csv"><br>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
var $ = function(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
var ctx = $('scope').getContext('2d');
|
||||
//===================================
|
||||
// | adc1 adc2 adc4 adc8
|
||||
//----+------------------------------
|
||||
//adca| 12200 6100 3050 1525
|
||||
//adcb| 24400 12200 6100 3050
|
||||
//adcc| 48800 24400 12200 6100
|
||||
//adcd| 97600 48800 24400 12200
|
||||
//===================================
|
||||
var data_ch1 = [];
|
||||
var smprate = 0;
|
||||
var smpbuffer = ctx.canvas.width*10;
|
||||
zero_level = 10500;
|
||||
trigger = 32768-zero_level/2;
|
||||
var sttim = 0;
|
||||
var cur_idx = 0;
|
||||
var old_idx = 0;
|
||||
var frend = 0;
|
||||
function wsSmpRate() {
|
||||
var idx = cur_idx, tt = new Date().getTime();
|
||||
var sps = (idx - old_idx) * 2000/ (tt - sttim);
|
||||
sttim = tt; old_idx = idx;
|
||||
if(smprate) smprate = smprate * 0.9 + sps * 0.1;
|
||||
else smprate = sps;
|
||||
$('smprate').innerHTML = smprate.toFixed(1);
|
||||
$('wdsize').innerHTML = ($('scope').width/smprate).toFixed(3);
|
||||
$('labdiv').innerHTML = 'Render ' + frend + ' Hz';
|
||||
frend = 0;
|
||||
}
|
||||
var rend = 1;
|
||||
var oldblkid = 0;
|
||||
var rdnextflg = false;
|
||||
$("butOnOff").onclick = function() {
|
||||
if(rend) {rend = 0; $("butOnOff").value = "Run";}
|
||||
else {rend = 1; $("butOnOff").value = "Stop";}
|
||||
}
|
||||
var gu;
|
||||
function wsping() {
|
||||
clearTimeout(wstt);
|
||||
ws.send('adc*');
|
||||
wstt = setTimeout(wsping, 100);
|
||||
}
|
||||
var scope_height = ctx.canvas.height;
|
||||
var scaling = scope_height / (65536 - zero_level);
|
||||
function draw() {
|
||||
var scope_width = ctx.canvas.width;
|
||||
ctx.fillStyle = 'rgba(0, 20, 0, 0.1)';
|
||||
ctx.fillRect(0, 0, scope_width, scope_height);
|
||||
ctx.lineWidth = 1;
|
||||
ctx.beginPath();
|
||||
var data_start = scope_width/2;
|
||||
var timeData1 = data_ch1.slice();
|
||||
var data_max = timeData1.length - scope_width;
|
||||
if(scope_width > data_max) scope_width = data_max;
|
||||
var risingEdge = data_start;
|
||||
while(risingEdge < data_max && timeData1[risingEdge++] < trigger);
|
||||
while(risingEdge < data_max && timeData1[risingEdge++] > trigger);
|
||||
if(risingEdge >= data_max) {
|
||||
risingEdge = data_start;
|
||||
ctx.strokeStyle = 'rgb(0, 0, 255)';
|
||||
} else ctx.strokeStyle = 'rgb(0, 255, 0)';
|
||||
risingEdge -= data_start;
|
||||
for(var x = 0; x < scope_width; x++)
|
||||
ctx.lineTo(x, scope_height - timeData1[x + risingEdge] * scaling);
|
||||
ctx.stroke();
|
||||
frend++;
|
||||
requestAnimationFrame(draw);
|
||||
}
|
||||
var wsUri = 'ws://rtl871x1/web.cgi'
|
||||
//var wsUri = "ws://"+window.location.host.toString()+"/web.cgi";
|
||||
ws = new WebSocket(wsUri);
|
||||
ws.binaryType = 'arraybuffer';
|
||||
ws.onopen = function(){
|
||||
ws.send('user=rtl871x:supervisor');
|
||||
ws.send('sys_debug=0');
|
||||
ws.send('adcz'); // drv deinit
|
||||
ws.send('adcx'); // mode Audio
|
||||
ws.send('adc1'); // decimation
|
||||
ws.send('adcd'); // xclk
|
||||
wstt = setTimeout(wsping,50);
|
||||
};
|
||||
ws.onmessage = function (event) {
|
||||
if(event.data instanceof ArrayBuffer) {
|
||||
clearTimeout(wstt);
|
||||
var wordarray = new Uint16Array(event.data);
|
||||
if(wordarray.length > 2) {
|
||||
var blksz = wordarray[0];
|
||||
if(wordarray.length == blksz*2 + 2) {
|
||||
var blkid = wordarray[1] & 0xFFFF;
|
||||
if(rdnextflg) cur_idx += (blkid - oldblkid) & 0xFFFF;
|
||||
else {
|
||||
rdnextflg = true;
|
||||
sttim = new Date().getTime();
|
||||
setInterval(function(){wsSmpRate()}, 1000);
|
||||
draw();
|
||||
}
|
||||
oldblkid = blkid + blksz;
|
||||
for (var i=2; i<wordarray.length; i+=2) {
|
||||
if(rend) {
|
||||
if(data_ch1.length > smpbuffer) {
|
||||
data_ch1.shift();
|
||||
data_ch1.shift();
|
||||
}
|
||||
data_ch1.push([wordarray[i]-zero_level]);
|
||||
data_ch1.push([wordarray[i+1]-zero_level]);
|
||||
}
|
||||
cur_idx++;
|
||||
} }
|
||||
wstt = setTimeout(wsping, 5);
|
||||
} } }
|
||||
function convertArrayOfObjectsToCSV(value){
|
||||
var result, ctr, keys, columnDelimiter, lineDelimiter, data;
|
||||
|
||||
data = value.data || null;
|
||||
if (data == null || !data.length) return null;
|
||||
columnDelimiter = value.columnDelimiter || ';';
|
||||
lineDelimiter = value.lineDelimiter || '\n';
|
||||
keys = Object.keys(data[1]);
|
||||
result = '';
|
||||
result += keys.join(columnDelimiter);
|
||||
result += lineDelimiter;
|
||||
data.forEach(function(item){
|
||||
ctr = 0;
|
||||
keys.forEach(function(key){
|
||||
if (ctr > 0)
|
||||
result += columnDelimiter;
|
||||
result += item[key];
|
||||
ctr++;
|
||||
});
|
||||
result += lineDelimiter;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
$("butSave").onclick = function() {
|
||||
var csv = convertArrayOfObjectsToCSV({data: datau});
|
||||
if (!csv.match(/^data:text\/csv/i)) {csv = 'data:text/csv;charset=utf-8,' + csv;}
|
||||
var encodedUri = encodeURI(csv);
|
||||
var link = document.createElement('a');
|
||||
link.setAttribute('href', encodedUri);
|
||||
link.setAttribute('download',"data.csv");
|
||||
link.click();
|
||||
}
|
||||
</script>
|
||||
</html>
|
|
@ -447,7 +447,12 @@ int wifi_get_lps_dtim(unsigned char *dtim);
|
|||
* @return RTW_SUCCESS : if successfully creates an AP
|
||||
* RTW_ERROR : if an error occurred
|
||||
*/
|
||||
int wifi_start_ap(char *ssid, rtw_security_t security_type, char *password, int channel, char ssid_hidden);
|
||||
int wifi_start_ap(
|
||||
char *ssid,
|
||||
rtw_security_t security_type,
|
||||
char *password,
|
||||
int channel,
|
||||
char ssid_hidden);
|
||||
/*
|
||||
int wifi_start_ap(
|
||||
char *ssid,
|
||||
|
|
|
@ -90,7 +90,7 @@ mp: OTA_IMAGE = $(BIN_DIR)/ota_mp.bin
|
|||
|
||||
|
||||
.PHONY: genbin flashburn reset test readfullflash flashboot flashwebfs flash_OTA runram runsdram
|
||||
.NOTPARALLEL: all mp genbin1 genbin23 flashburn reset test readfullflash _endgenbin flashwebfs flash_OTA
|
||||
.NOTPARALLEL: all mp genbin flashburn reset test readfullflash _endgenbin flashwebfs flash_OTA
|
||||
|
||||
all: $(ELFFILE) $(FLASH_IMAGE) _endgenbin
|
||||
mp: $(ELFFILE) $(FLASH_IMAGE) _endgenbin
|
||||
|
@ -110,6 +110,9 @@ $(NMAPFILE): $(ELFFILE)
|
|||
$(FLASH_IMAGE):$(ELFFILE)
|
||||
@echo "==========================================================="
|
||||
$(IMAGETOOL) -a -r -o $(BIN_DIR)/ $(ELFFILE)
|
||||
ifdef USE_SDRAM
|
||||
@cat $(RAM3P_IMAGE) >> $(RAM2P_IMAGE)
|
||||
endif
|
||||
|
||||
_endgenbin:
|
||||
@echo "-----------------------------------------------------------"
|
||||
|
@ -240,7 +243,7 @@ reset:
|
|||
-c 'mww 0x40000210 0x111157' -c 'rtl8710_reboot' -c shutdown
|
||||
|
||||
runram:
|
||||
@$(OPENOCD) -f interface/$(FLASHER).cfg -c 'transport select swd' -c 'adapter_khz 1000' \
|
||||
$(OPENOCD) -f interface/$(FLASHER).cfg -c 'transport select swd' -c 'adapter_khz 1000' \
|
||||
-f $(FLASHER_PATH)rtl8710.ocd -c 'init' -c 'reset halt' -c 'adapter_khz $(FLASHER_SPEED)' \
|
||||
-c 'load_image $(RAM1_IMAGE) 0x10000bc8 bin' \
|
||||
-c 'load_image $(RAM2_IMAGE) 0x10006000 bin' \
|
||||
|
|
6
WEBFiles/dygraph.min.js
vendored
Normal file
6
WEBFiles/dygraph.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
110
WEBFiles/i219ws.htm
Normal file
110
WEBFiles/i219ws.htm
Normal file
|
@ -0,0 +1,110 @@
|
|||
~inc:grfx1.inc~
|
||||
<td width="50%">U: <span id="xdata1" style="font-weight:bold">?</span> V, I: <span id="xdata2" style="font-weight:bold">?</span> mA</td>
|
||||
<td style="font-size:10pt">
|
||||
<div id="sl"></div>Scale: <span id="toutid" style="font-weight:bold">?</span> ms per line</td></tr></table>
|
||||
<canvas id="mycanvas1" width="620pt" height="150pt"></canvas>
|
||||
<canvas id="mycanvas2" width="620pt" height="250pt"></canvas>
|
||||
SampleRate: <span id="smprate" style="font-weight:bold">?</span> sps
|
||||
</div>
|
||||
<script src="/smoothie.js" type="text/javascript"></script>
|
||||
<script src="/slider.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var line1 = new TimeSeries();
|
||||
var line2 = new TimeSeries();
|
||||
var oldtimeout = 20;
|
||||
var smoothie1 = new SmoothieChart({ millisPerPixel: oldtimeout, maxValueScale:1.05, interpolation:'linear', maxDataSetLength: 2000,
|
||||
grid: { strokeStyle:'rgb(75, 75, 75)', lineWidth: 1, millisPerLine: oldtimeout*50, verticalSections: 6 },
|
||||
labels: { fillStyle:'rgb(255, 255, 255)' }
|
||||
});
|
||||
var smoothie2 = new SmoothieChart({ millisPerPixel: oldtimeout, maxValueScale:1.05, interpolation:'linear', maxDataSetLength: 2000,
|
||||
grid: { strokeStyle:'rgb(75, 75, 75)', lineWidth: 1, millisPerLine: oldtimeout*50, verticalSections: 6 },
|
||||
labels: { fillStyle:'rgb(255, 255, 255)' }
|
||||
});
|
||||
smoothie1.addTimeSeries(line1, { strokeStyle:'rgb(0, 255, 0)', lineWidth: 2 });
|
||||
smoothie2.addTimeSeries(line2, { strokeStyle:'rgb(255, 0, 255)', lineWidth: 2 });
|
||||
smoothie1.streamTo(document.getElementById("mycanvas1"));
|
||||
smoothie2.streamTo(document.getElementById("mycanvas2"));
|
||||
var mysl1 = new slider('sl', 333, 1, 200, 0);
|
||||
var ttout = 20;
|
||||
function NewTimeScale(t) {
|
||||
if(oldtimeout != t) {
|
||||
oldtimeout = t;
|
||||
smoothie1.options.grid.millisPerLine = t*50;
|
||||
smoothie1.options.millisPerPixel = t;
|
||||
smoothie2.options.grid.millisPerLine = t*50;
|
||||
smoothie2.options.millisPerPixel = t
|
||||
ttout = t*2;
|
||||
if(ttout < 2) ttout = 2;
|
||||
else if(ttout > 250) ttout = 250;
|
||||
document.getElementById('toutid').innerHTML = t*50; //+'/'+ttout
|
||||
} }
|
||||
mysl1.setValue(oldtimeout);
|
||||
var wstt;
|
||||
function wsSendMsg() {
|
||||
ws.send('ina219');
|
||||
wstt = setTimeout(wsSendMsg, 1000);
|
||||
}
|
||||
var smprate = 1000;
|
||||
var sttim;
|
||||
var fsmpr = 0;
|
||||
var oldblkid = 0;
|
||||
var rdnextflg = false;
|
||||
var cur_idx = 0;
|
||||
var sig = 10;
|
||||
function onMessage(evt) {
|
||||
if(event.data instanceof ArrayBuffer) {
|
||||
clearTimeout(wstt);
|
||||
var wordarray = new Int16Array(event.data);
|
||||
if(wordarray.length > 2) {
|
||||
var blksz = wordarray[0];
|
||||
if(wordarray.length == blksz*2 + 2) {
|
||||
var blkid = wordarray[1] & 0xFFFF;
|
||||
if(rdnextflg) {
|
||||
cur_idx += (blkid - oldblkid) & 0xFFFF;
|
||||
} else rdnextflg = true;
|
||||
oldblkid = blkid + blksz;
|
||||
if(!fsmpr) {
|
||||
sttim = new Date().getTime();
|
||||
fsmpr = 1;
|
||||
setInterval(wsSmpRate, 1000);
|
||||
} else {
|
||||
u = 0; s = 0; cnt = 0;
|
||||
tt = new Date().getTime();
|
||||
for (var i=2; i<wordarray.length; i+=2) {
|
||||
u += wordarray[i];
|
||||
s += wordarray[i+1];
|
||||
cnt++;
|
||||
}
|
||||
cur_idx += cnt;
|
||||
u = u*0.0005/cnt;
|
||||
s = 0.15 + s*0.1/cnt;
|
||||
line1.append(new Date().getTime(), u, true);
|
||||
document.getElementById('xdata1').innerHTML = u.toFixed(3);
|
||||
line2.append(new Date().getTime(), s, true);
|
||||
document.getElementById('xdata2').innerHTML = s.toFixed(2);
|
||||
} } }
|
||||
wstt = setTimeout(wsSendMsg, ttout);
|
||||
} }
|
||||
function wsSmpRate() {
|
||||
smprate = (new Date().getTime() - sttim) * 1000 / cur_idx;
|
||||
document.getElementById('smprate').innerHTML = smprate.toFixed(1);
|
||||
}
|
||||
function onOpen(evt) {
|
||||
ctim = new Date().getTime();
|
||||
ws.binaryType = 'arraybuffer';
|
||||
document.getElementById('xdata1').style.color = 'rgb(0, 155, 100)';
|
||||
document.getElementById('xdata2').style.color = 'rgb(155, 0, 100)';
|
||||
ws.send('user=rtl871x:supervisor');
|
||||
ws.send('sys_debug=0');
|
||||
wstt = setTimeout(wsSendMsg, ttout);
|
||||
}
|
||||
var wsUri = "ws://"+window.location.host.toString()+"/web.cgi";
|
||||
function RunWebSocket() {
|
||||
ws = new WebSocket(wsUri);
|
||||
ws.onopen = function(evt) {onOpen(evt)};
|
||||
ws.onmessage = function(evt) {onMessage(evt)};
|
||||
}
|
||||
RunWebSocket();
|
||||
</script>
|
||||
~inc:footer.inc~
|
||||
</body></html>
|
119
WEBFiles/ina2.css
Normal file
119
WEBFiles/ina2.css
Normal file
|
@ -0,0 +1,119 @@
|
|||
/**
|
||||
* Default styles for the dygraphs charting library.
|
||||
*/
|
||||
|
||||
.dygraph-legend {
|
||||
position: relative;
|
||||
font-size: 12px;
|
||||
z-index: 10;
|
||||
width: 250px; /* labelsDivWidth */
|
||||
/*
|
||||
dygraphs determines these based on the presence of chart labels.
|
||||
It might make more sense to create a wrapper div around the chart proper.
|
||||
top: 0px;
|
||||
right: 2px;
|
||||
*/
|
||||
background: white;
|
||||
line-height: normal;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* styles for a solid line in the legend */
|
||||
.dygraph-legend-line {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
bottom: .5ex;
|
||||
padding-left: 1em;
|
||||
height: 1px;
|
||||
border-bottom-width: 2px;
|
||||
border-bottom-style: solid;
|
||||
/* border-bottom-color is set based on the series color */
|
||||
}
|
||||
|
||||
/* styles for a dashed line in the legend, e.g. when strokePattern is set */
|
||||
.dygraph-legend-dash {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
bottom: .5ex;
|
||||
height: 1px;
|
||||
border-bottom-width: 2px;
|
||||
border-bottom-style: solid;
|
||||
/* border-bottom-color is set based on the series color */
|
||||
/* margin-right is set based on the stroke pattern */
|
||||
/* padding-left is set based on the stroke pattern */
|
||||
}
|
||||
|
||||
.dygraph-roller {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
/* This class is shared by all annotations, including those with icons */
|
||||
.dygraph-annotation {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* This class only applies to annotations without icons */
|
||||
/* Old class name: .dygraphDefaultAnnotation */
|
||||
.dygraph-default-annotation {
|
||||
border: 1px solid black;
|
||||
background-color: white;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dygraph-axis-label {
|
||||
/* position: absolute; */
|
||||
/* font-size: 14px; */
|
||||
z-index: 10;
|
||||
line-height: normal;
|
||||
overflow: hidden;
|
||||
color: black; /* replaces old axisLabelColor option */
|
||||
}
|
||||
|
||||
.dygraph-axis-label-x {
|
||||
}
|
||||
|
||||
.dygraph-axis-label-y {
|
||||
color: rgb(51,204,204);
|
||||
}
|
||||
|
||||
.dygraph-axis-label-y2 {
|
||||
color: rgb(255,100,100);
|
||||
}
|
||||
|
||||
.dygraph-title {
|
||||
font-weight: bold;
|
||||
z-index: 10;
|
||||
text-align: center;
|
||||
/* font-size: based on titleHeight option */
|
||||
}
|
||||
|
||||
.dygraph-xlabel {
|
||||
text-align: center;
|
||||
/* font-size: based on xLabelHeight option */
|
||||
}
|
||||
|
||||
/* For y-axis label */
|
||||
.dygraph-label-rotate-left {
|
||||
text-align: center;
|
||||
/* See http://caniuse.com/#feat=transforms2d */
|
||||
transform: rotate(90deg);
|
||||
-webkit-transform: rotate(90deg);
|
||||
-moz-transform: rotate(90deg);
|
||||
-o-transform: rotate(90deg);
|
||||
-ms-transform: rotate(90deg);
|
||||
}
|
||||
|
||||
/* For y2-axis label */
|
||||
.dygraph-label-rotate-right {
|
||||
text-align: center;
|
||||
/* See http://caniuse.com/#feat=transforms2d */
|
||||
transform: rotate(-90deg);
|
||||
-webkit-transform: rotate(-90deg);
|
||||
-moz-transform: rotate(-90deg);
|
||||
-o-transform: rotate(-90deg);
|
||||
-ms-transform: rotate(-90deg);
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<div class="content">
|
||||
<h2 class="title">Debug and Tests</h2>
|
||||
<p class="center">
|
||||
Chart <a href="/heap.htm">'heap'</a>, <a href="/tst.htm">ST-AP RSSI</a>, <a href="/i219ws.htm">INA219</a><br><br>
|
||||
Chart <a href="/heap.htm">'heap'</a>, <a href="/tst.htm">ST-AP RSSI</a>, <a href="/wso_audio.htm">ADC Audio</a><br><br>
|
||||
<a href='/protect/timeout.htm?sys_restart=12345'>System Restart</a><br><br>
|
||||
Counter erase the last flash sector config: ~sys_rdec0x980FE000~<br><br>
|
||||
</p>
|
||||
|
|
BIN
WEBFiles/rtl2.gif
Normal file
BIN
WEBFiles/rtl2.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
166
WEBFiles/wso_audio.htm
Normal file
166
WEBFiles/wso_audio.htm
Normal file
|
@ -0,0 +1,166 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="ina2.css">
|
||||
<title>Get ADC data</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="height: auto; width: auto; text-align: center;">
|
||||
<div id='div_v' style="height:512px;">
|
||||
<canvas id='scope' width=976 height=512></canvas>
|
||||
</div>
|
||||
Window: <span id='wdsize'>?</span> sec, Sample Rate: <span id='smprate'>?</span> sps
|
||||
<div>
|
||||
<span id='labdiv'>?</span>
|
||||
<input type="button" id="butOnOff" value="Stop">
|
||||
<input type="button" id="butSave" value="Save data.csv"><br>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
var $ = function(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
var ctx = $('scope').getContext('2d');
|
||||
//===================================
|
||||
// | adc1 adc2 adc4 adc8
|
||||
//----+------------------------------
|
||||
//adca| 12200 6100 3050 1525
|
||||
//adcb| 24400 12200 6100 3050
|
||||
//adcc| 48800 24400 12200 6100
|
||||
//adcd| 97600 48800 24400 12200
|
||||
//===================================
|
||||
var data_ch1 = [];
|
||||
var smprate = 0;
|
||||
var smpbuffer = ctx.canvas.width*10;
|
||||
zero_level = 10500;
|
||||
trigger = 32768-zero_level/2;
|
||||
var sttim = 0;
|
||||
var cur_idx = 0;
|
||||
var old_idx = 0;
|
||||
var frend = 0;
|
||||
function wsSmpRate() {
|
||||
var idx = cur_idx, tt = new Date().getTime();
|
||||
var sps = (idx - old_idx) * 2000/ (tt - sttim);
|
||||
sttim = tt; old_idx = idx;
|
||||
if(smprate) smprate = smprate * 0.9 + sps * 0.1;
|
||||
else smprate = sps;
|
||||
$('smprate').innerHTML = smprate.toFixed(1);
|
||||
$('wdsize').innerHTML = ($('scope').width/smprate).toFixed(3);
|
||||
$('labdiv').innerHTML = 'Render ' + frend + ' Hz';
|
||||
frend = 0;
|
||||
}
|
||||
var rend = 1;
|
||||
var oldblkid = 0;
|
||||
var rdnextflg = false;
|
||||
$("butOnOff").onclick = function() {
|
||||
if(rend) {rend = 0; $("butOnOff").value = "Run";}
|
||||
else {rend = 1; $("butOnOff").value = "Stop";}
|
||||
}
|
||||
var gu;
|
||||
function wsping() {
|
||||
clearTimeout(wstt);
|
||||
ws.send('adc*');
|
||||
wstt = setTimeout(wsping, 100);
|
||||
}
|
||||
var scope_height = ctx.canvas.height;
|
||||
var scaling = scope_height / (65536 - zero_level);
|
||||
function draw() {
|
||||
var scope_width = ctx.canvas.width;
|
||||
ctx.fillStyle = 'rgba(0, 20, 0, 0.1)';
|
||||
ctx.fillRect(0, 0, scope_width, scope_height);
|
||||
ctx.lineWidth = 1;
|
||||
ctx.beginPath();
|
||||
var data_start = scope_width/2;
|
||||
var timeData1 = data_ch1.slice();
|
||||
var data_max = timeData1.length - scope_width;
|
||||
if(scope_width > data_max) scope_width = data_max;
|
||||
var risingEdge = data_start;
|
||||
while(risingEdge < data_max && timeData1[risingEdge++] < trigger);
|
||||
while(risingEdge < data_max && timeData1[risingEdge++] > trigger);
|
||||
if(risingEdge >= data_max) {
|
||||
risingEdge = data_start;
|
||||
ctx.strokeStyle = 'rgb(0, 0, 255)';
|
||||
} else ctx.strokeStyle = 'rgb(0, 255, 0)';
|
||||
risingEdge -= data_start;
|
||||
for(var x = 0; x < scope_width; x++)
|
||||
ctx.lineTo(x, scope_height - timeData1[x + risingEdge] * scaling);
|
||||
ctx.stroke();
|
||||
frend++;
|
||||
requestAnimationFrame(draw);
|
||||
}
|
||||
//var wsUri = 'ws://rtl871x1/web.cgi'
|
||||
var wsUri = "ws://"+window.location.host.toString()+"/web.cgi";
|
||||
ws = new WebSocket(wsUri);
|
||||
ws.binaryType = 'arraybuffer';
|
||||
ws.onopen = function(){
|
||||
ws.send('user=rtl871x:supervisor');
|
||||
ws.send('sys_debug=0');
|
||||
ws.send('adcz'); // drv deinit
|
||||
ws.send('adcx'); // mode Audio
|
||||
ws.send('adc1'); // decimation
|
||||
ws.send('adcd'); // xclk
|
||||
wstt = setTimeout(wsping,50);
|
||||
};
|
||||
ws.onmessage = function (event) {
|
||||
if(event.data instanceof ArrayBuffer) {
|
||||
clearTimeout(wstt);
|
||||
var wordarray = new Uint16Array(event.data);
|
||||
if(wordarray.length > 2) {
|
||||
var blksz = wordarray[0];
|
||||
if(wordarray.length == blksz*2 + 2) {
|
||||
var blkid = wordarray[1] & 0xFFFF;
|
||||
if(rdnextflg) cur_idx += (blkid - oldblkid) & 0xFFFF;
|
||||
else {
|
||||
rdnextflg = true;
|
||||
sttim = new Date().getTime();
|
||||
setInterval(function(){wsSmpRate()}, 1000);
|
||||
draw();
|
||||
}
|
||||
oldblkid = blkid + blksz;
|
||||
for (var i=2; i<wordarray.length; i+=2) {
|
||||
if(rend) {
|
||||
if(data_ch1.length > smpbuffer) {
|
||||
data_ch1.shift();
|
||||
data_ch1.shift();
|
||||
}
|
||||
data_ch1.push([wordarray[i]-zero_level]);
|
||||
data_ch1.push([wordarray[i+1]-zero_level]);
|
||||
}
|
||||
cur_idx++;
|
||||
} }
|
||||
wstt = setTimeout(wsping, 5);
|
||||
} } }
|
||||
function convertArrayOfObjectsToCSV(value){
|
||||
var result, ctr, keys, columnDelimiter, lineDelimiter, data;
|
||||
data = value.data || null;
|
||||
if (data == null || !data.length) return null;
|
||||
columnDelimiter = value.columnDelimiter || ';';
|
||||
lineDelimiter = value.lineDelimiter || '\n';
|
||||
keys = Object.keys(data[1]);
|
||||
result = '';
|
||||
result += keys.join(columnDelimiter);
|
||||
result += lineDelimiter;
|
||||
data.forEach(function(item){
|
||||
ctr = 0;
|
||||
keys.forEach(function(key){
|
||||
if (ctr > 0)
|
||||
result += columnDelimiter;
|
||||
result += item[key];
|
||||
ctr++;
|
||||
});
|
||||
result += lineDelimiter;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
$("butSave").onclick = function() {
|
||||
var csv = convertArrayOfObjectsToCSV({data: datau});
|
||||
if (!csv.match(/^data:text\/csv/i)) {csv = 'data:text/csv;charset=utf-8,' + csv;}
|
||||
var encodedUri = encodeURI(csv);
|
||||
var link = document.createElement('a');
|
||||
link.setAttribute('href', encodedUri);
|
||||
link.setAttribute('download',"data.csv");
|
||||
link.click();
|
||||
}
|
||||
</script>
|
||||
</html>
|
|
@ -2,9 +2,9 @@
|
|||
# SDK CONFIG
|
||||
#=============================================
|
||||
USE_SDRAM = 1
|
||||
WEB_INA219_DRV = 1
|
||||
#WEB_INA219_DRV = 1
|
||||
#WEB_MLX90614_DRV = 1
|
||||
#WEB_ADC_DRV = 1
|
||||
WEB_ADC_DRV = 1
|
||||
#USE_SDCARD = 1
|
||||
#USE_UVC = 1
|
||||
#USE_AT = 1
|
||||
|
|
|
@ -14,10 +14,38 @@
|
|||
void ADCIrqInit(IRQ_FUN IrqFunc, u32 IrqData, u32 intr_enable); // intr_enable = bits: REG_ADC_INTR_EN - BIT_ADC_FIFO_RD_ERROR_EN | BIT_ADC_FIFO_RD_REQ_EN | BIT_ADC_FIFO_FULL_EN ...
|
||||
void ADCIrqDeInit(void);
|
||||
|
||||
void ADCInit(ADC_MODULE_SEL adc_idx); // RTL8711AM: adc_idx = ADC2_SEL = 2
|
||||
void ADCInit(unsigned char mode, unsigned char xclk, unsigned char dcmf);
|
||||
void ADCDeInit(void);
|
||||
void ADCEnable(void); // ADC Start
|
||||
void ADCDisable(void); // ADC Stop
|
||||
|
||||
#define ADC_DECIMATION_1 1
|
||||
#define ADC_DECIMATION_2 2
|
||||
#define ADC_DECIMATION_4 3
|
||||
#define ADC_DECIMATION_8 4
|
||||
|
||||
#define ADC_SAMPLE_CLK_x1 0
|
||||
#define ADC_SAMPLE_CLK_x2 1
|
||||
#define ADC_SAMPLE_CLK_x4 2
|
||||
#define ADC_SAMPLE_CLK_x8 3
|
||||
|
||||
#define ADC_DECIMATION_FILTER ADC_DECIMATION_1
|
||||
#define ADC_SAMPLE_XCLK ADC_SAMPLE_CLK_x8
|
||||
#define ADC_SMPS = 975*(1<<ADC_SAMPLE_XCLK)/(1<<ADC_DECIMATION_FILTER)
|
||||
// 975*(1<<2)/(1<<1) = 1950 sps
|
||||
|
||||
// Add ADC_ANAPAR_AD0
|
||||
#define BIT_SHIFT_ADC_SAMPLE_CLK 14
|
||||
#define BIT_MASK_ADC_SAMPLE_CLK 0x3
|
||||
#define BIT_CTRL_ADC_SAMPLE_CLKL(x) (((x) & BIT_MASK_ADC_SAMPLE_CLK) << BIT_SHIFT_ADC_SAMPLE_CLK)
|
||||
// Add ADC_ANAPAR_AD1
|
||||
#define BIT_SHIFT_DOWN_SAMPLE_RATE 18
|
||||
#define BIT_MASK_DOWN_SAMPLE_RATE 0x7
|
||||
#define BIT_CTRL_DOWN_SAMPLE_RATE(x) (((x) & BIT_MASK_DOWN_SAMPLE_RATE) << BIT_SHIFT_DOWN_SAMPLE_RATE)
|
||||
#define BIT_ADC_DECIMATION_FILTER_ORDER ((u32)0x00000001 << 12) /*!< decimation filter order, 0: order3, 1: order4 */
|
||||
#define BIT_ADC_EXT_VREF_EN ((u32)0x00000001 << 2)
|
||||
#define BIT_ADC_FEEDBK_CAPACITY_VAL ((u32)0x00000001 << 1)
|
||||
#define BIT_ADC_DIGITAL_RST_BAR ((u32)0x00000001 << 0)
|
||||
|
||||
|
||||
#endif /* _DRIVER_ADC_DRV_H_ */
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
|
||||
#include "hal_com_reg.h"
|
||||
|
||||
#ifndef mMIN
|
||||
#define mMIN(a, b) ((a<b)?a:b)
|
||||
#endif
|
||||
|
||||
#define MLX90614_I2CADDR 0x5A
|
||||
// RAM
|
||||
#define MLX90614_RAWIR1 0x04
|
||||
|
|
|
@ -51,13 +51,16 @@ extern void *pvPortMalloc(size_t xWantedSize);
|
|||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
typedef union _adc_data {
|
||||
unsigned short us;
|
||||
typedef struct _adc_data {
|
||||
uint16_t us0;
|
||||
uint16_t us1;
|
||||
} ADC_DATA, *PADC_DATA;
|
||||
|
||||
typedef struct _adc_drv {
|
||||
signed char init; // флаг
|
||||
unsigned char tmp;
|
||||
unsigned char dcmf; // ADC_DECIMATION_FILTER
|
||||
unsigned char xclk; // ADC_SAMPLE_XCLK
|
||||
unsigned char audio; // Audio mode
|
||||
|
||||
unsigned short count; // счетчик считанных значений
|
||||
unsigned short overrun; // счет переполнений буфера
|
||||
|
@ -71,56 +74,95 @@ typedef struct _adc_drv {
|
|||
#endif
|
||||
} ADC_DRV, *PADC_DRV;
|
||||
|
||||
//#define mMIN(a, b) ((a<b)?a:b)
|
||||
#define mMIN(a, b) ((a<b)?a:b)
|
||||
//#define mMAX(a, b) ((a>b)?a:b)
|
||||
|
||||
ADC_DRV adc_drv = {
|
||||
.buf_idx = (1460*2 - 80)/(sizeof(ADC_DATA)/2) // циклический буфер на ~1420 замеров (см. sizeof(ADC_DATA))
|
||||
// Если шаг заполнения 1 ms -> буфер на 1.4 сек
|
||||
// Оптимизация под TCP: (TCP_MSS*2 - 80)/2 = (1460*2 - 80)/2 = 1420
|
||||
.dcmf = ADC_DECIMATION_FILTER,
|
||||
.xclk = ADC_SAMPLE_XCLK,
|
||||
// .audio = 0,
|
||||
.buf_idx = 709 // (1460*2 - 80)/(sizeof(ADC_DATA)/2) // циклический буфер на ~1420 замеров (см. sizeof(ADC_DATA))
|
||||
// Если шаг заполнения 1 ms -> буфер на 1.4 сек
|
||||
// Оптимизация под TCP: (TCP_MSS*2 - 80)/2 = (1460*2 - 80)/2 = 1420
|
||||
};
|
||||
|
||||
void adc_int_handler(void *par) {
|
||||
union {
|
||||
uint16_t w[4];
|
||||
uint32_t d[2];
|
||||
}buf;
|
||||
PADC_DRV p = par; // &adc_drv
|
||||
// uint32_t adc_isr = HAL_ADC_READ32(REG_ADC_INTR_STS);
|
||||
buf.d[0] = HAL_ADC_READ32(REG_ADC_FIFO_READ);
|
||||
buf.d[1] = HAL_ADC_READ32(REG_ADC_FIFO_READ);
|
||||
if(p->pbuf) {
|
||||
#ifndef ADC_USE_TIMER
|
||||
int i = 4;
|
||||
while(i--)
|
||||
#endif
|
||||
{
|
||||
PADC_DATA pd = p->pbuf + p->buf_tx;
|
||||
pd->us = HAL_ADC_READ32(REG_ADC_FIFO_READ); // 2 -> sample -> 24.4 kHz (if ADC irq!)
|
||||
// (void)HAL_ADC_READ32(REG_ADC_FIFO_READ); // 4 sample -> 12.2 kHz (if ADC irq!)
|
||||
// (void)HAL_ADC_READ32(REG_ADC_FIFO_READ); // 6 sample -> 8.133 kHz (if ADC irq!)
|
||||
// (void)HAL_ADC_READ32(REG_ADC_FIFO_READ); // 8 sample -> 6.1 kHz (if ADC irq!)
|
||||
|
||||
if(p->buf_tx >= p->buf_idx) p->buf_tx = 0;
|
||||
else p->buf_tx++;
|
||||
if(p->buf_rx == p->buf_tx) {
|
||||
p->overrun++; // todo: if(p->overrun++ > 100000) deinit() ?
|
||||
if(p->buf_rx >= p->buf_idx) p->buf_rx = 0;
|
||||
else p->buf_rx++;
|
||||
};
|
||||
}
|
||||
/* Clear ADC Status */
|
||||
(void)HAL_ADC_READ32(REG_ADC_INTR_STS);
|
||||
PADC_DATA pd = p->pbuf + p->buf_tx;
|
||||
pd->us0 = buf.w[3];
|
||||
pd->us1 = buf.w[0];
|
||||
if(p->buf_tx >= p->buf_idx) p->buf_tx = 0;
|
||||
else p->buf_tx++;
|
||||
if(p->buf_rx == p->buf_tx) {
|
||||
p->overrun++;
|
||||
if(p->overrun == 0) p->init = 2; // overrun
|
||||
if(p->buf_rx >= p->buf_idx) p->buf_rx = 0;
|
||||
else p->buf_rx++;
|
||||
};
|
||||
};
|
||||
/* Clear ADC Status */
|
||||
// HAL_ADC_WRITE32(REG_ADC_INTR_STS, adc_isr);
|
||||
(void)HAL_ADC_READ32(REG_ADC_INTR_STS);
|
||||
}
|
||||
|
||||
size_t adc_getdata(void *pd, uint16 cnt)
|
||||
void adc_int_handler_audio(void *par) {
|
||||
union {
|
||||
uint16_t w[4];
|
||||
uint32_t d[2];
|
||||
}buf;
|
||||
PADC_DRV p = par; // &adc_drv
|
||||
buf.d[0] = HAL_ADC_READ32(REG_ADC_FIFO_READ);
|
||||
buf.d[1] = HAL_ADC_READ32(REG_ADC_FIFO_READ);
|
||||
if(p->pbuf) {
|
||||
PADC_DATA pd = p->pbuf + p->buf_tx;
|
||||
pd->us0 = buf.w[0];
|
||||
pd->us1 = buf.w[1];
|
||||
if(p->buf_tx >= p->buf_idx) p->buf_tx = 0;
|
||||
else p->buf_tx++;
|
||||
if(p->buf_rx == p->buf_tx) {
|
||||
p->overrun++;
|
||||
if(p->overrun == 0) p->init = 2; // overrun
|
||||
if(p->buf_rx >= p->buf_idx) p->buf_rx = 0;
|
||||
else p->buf_rx++;
|
||||
};
|
||||
pd = p->pbuf + p->buf_tx;
|
||||
pd->us0 = buf.w[2];
|
||||
pd->us1 = buf.w[3];
|
||||
if(p->buf_tx >= p->buf_idx) p->buf_tx = 0;
|
||||
else p->buf_tx++;
|
||||
if(p->buf_rx == p->buf_tx) {
|
||||
p->overrun++;
|
||||
if(p->overrun == 0) p->init = 2; // overrun
|
||||
if(p->buf_rx >= p->buf_idx) p->buf_rx = 0;
|
||||
else p->buf_rx++;
|
||||
};
|
||||
};
|
||||
/* Clear ADC Status */
|
||||
(void)HAL_ADC_READ32(REG_ADC_INTR_STS);
|
||||
}
|
||||
|
||||
size_t adc_getdata(void *pd, uint16_t cnt)
|
||||
{
|
||||
PADC_DRV p = &adc_drv;
|
||||
if(p->init <= 0) return 0;
|
||||
unsigned short *pus = (unsigned short *) pd;
|
||||
uint16_t *pus = (uint16_t *) pd;
|
||||
taskDISABLE_INTERRUPTS();
|
||||
uint16 buf_rx = p->buf_rx;
|
||||
uint16_t buf_rx = p->buf_rx;
|
||||
*pus++ = cnt; // кол-во замеров
|
||||
*pus++ = p->count + p->overrun; // индекс замера для анализа пропусков на стороне приемника
|
||||
// если не пропущено, то равен прошлому + кол-во считанных замеров в прошлом блоке
|
||||
p->count += cnt; // p->overrun = 0;
|
||||
unsigned char *puc = (unsigned char *) pus;
|
||||
uint8_t *puc = (uint8_t *) pus;
|
||||
if(cnt) {
|
||||
uint16 lend = buf_rx + cnt;
|
||||
uint16_t lend = buf_rx + cnt;
|
||||
if(lend > p->buf_idx) {
|
||||
lend -= p->buf_idx + 1;
|
||||
p->buf_rx = lend;
|
||||
|
@ -136,13 +178,13 @@ size_t adc_getdata(void *pd, uint16 cnt)
|
|||
return cnt * sizeof(ADC_DATA) + 4;
|
||||
}
|
||||
|
||||
uint16 adc_chkdata(uint16 cnt)
|
||||
uint16_t adc_chkdata(uint16_t cnt)
|
||||
{
|
||||
PADC_DRV p = &adc_drv;
|
||||
if(p->init <= 0) return 0;
|
||||
int len = p->buf_tx - p->buf_rx;
|
||||
if(len < 0) len += p->buf_idx + 1;
|
||||
if(cnt > (uint16)len) cnt = (uint16)len;
|
||||
if(cnt > (uint16_t)len) cnt = (uint16_t)len;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
@ -150,7 +192,47 @@ int adc_ws(TCP_SERV_CONN *ts_conn, char cmd)
|
|||
{
|
||||
PADC_DRV p = &adc_drv;
|
||||
switch(cmd) {
|
||||
case 'd': // deinit
|
||||
case '*': // get_data
|
||||
if(p->init <= 0) {
|
||||
p->count = 0;
|
||||
p->overrun = 0;
|
||||
// p->errs = 0;
|
||||
if(!p->pbuf) {
|
||||
p->pbuf = zalloc((p->buf_idx + 1) * sizeof(ADC_DATA));
|
||||
if(!p->pbuf) {
|
||||
error_printf("Error create buffer!\n");
|
||||
return -1;
|
||||
};
|
||||
p->buf_tx = 0;
|
||||
p->buf_rx = 0;
|
||||
};
|
||||
ADCInit(p->audio, p->xclk, p->dcmf);
|
||||
#ifdef ADC_USE_TIMER
|
||||
// Initial a periodical timer
|
||||
gtimer_init(&p->timer, ADC_USE_TIMER);
|
||||
gtimer_start_periodical(&p->timer, 1000, (void*)adc_int_handler, (uint32_t)p);
|
||||
rtl_printf("ADC Timer Period = %u us\n", &p->timer.hal_gtimer_adp.TimerLoadValueUs);
|
||||
#else
|
||||
if(p->audio)
|
||||
ADCIrqInit(adc_int_handler_audio,(uint32)p, BIT_ADC_FIFO_FULL_EN | BIT_ADC_FIFO_RD_REQ_EN);
|
||||
else
|
||||
ADCIrqInit(adc_int_handler,(uint32)p, BIT_ADC_FIFO_FULL_EN | BIT_ADC_FIFO_RD_REQ_EN);
|
||||
#endif
|
||||
ADCEnable();
|
||||
p->init = 1;
|
||||
}
|
||||
case 'g': // get_data
|
||||
{
|
||||
uint32_t i = adc_chkdata(p->buf_idx + 1);
|
||||
if(i) {
|
||||
WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *)ts_conn->linkd;
|
||||
i = mMIN((web_conn->msgbufsize / sizeof(ADC_DATA)), i);
|
||||
if(websock_tx_frame(ts_conn, WS_OPCODE_BINARY | WS_FRAGMENT_FIN, web_conn->msgbuf, adc_getdata(web_conn->msgbuf, i)) != ERR_OK)
|
||||
return -1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
case 'z': // deinit
|
||||
if(p->init > 0) {
|
||||
#ifdef ADC_USE_TIMER
|
||||
gtimer_stop(&p->timer);
|
||||
|
@ -169,48 +251,40 @@ int adc_ws(TCP_SERV_CONN *ts_conn, char cmd)
|
|||
return 0;
|
||||
}
|
||||
return 1;
|
||||
case 'c': // get count
|
||||
case '?': // get count
|
||||
return adc_chkdata(p->buf_idx + 1);
|
||||
case 'i': // init
|
||||
case 'i': // info init
|
||||
return p->init;
|
||||
default: // get_data
|
||||
if(p->init <= 0) {
|
||||
p->count = 0;
|
||||
p->overrun = 0;
|
||||
// p->errs = 0;
|
||||
if(!p->pbuf) {
|
||||
p->pbuf = zalloc((p->buf_idx + 1) * sizeof(ADC_DATA));
|
||||
if(!p->pbuf) {
|
||||
error_printf("Error create buffer!\n");
|
||||
return -1;
|
||||
};
|
||||
p->buf_tx = 0;
|
||||
p->buf_rx = 0;
|
||||
};
|
||||
ADCInit(ADC2_SEL);
|
||||
#ifdef ADC_USE_TIMER
|
||||
// Initial a periodical timer
|
||||
gtimer_init(&p->timer, ADC_USE_TIMER);
|
||||
gtimer_start_periodical(&p->timer, 1000, (void*)adc_int_handler, (uint32_t)p);
|
||||
rtl_printf("ADC Timer Period = %u us\n", &p->timer.hal_gtimer_adp.TimerLoadValueUs);
|
||||
#else
|
||||
ADCIrqInit(adc_int_handler,(uint32)p, BIT_ADC_FIFO_FULL_EN); // BIT_ADC_FIFO_RD_REQ_EN ?
|
||||
#endif
|
||||
ADCEnable();
|
||||
p->init = 1;
|
||||
// return 0;
|
||||
}
|
||||
case 'g': // get
|
||||
{
|
||||
uint32 i = adc_chkdata(p->buf_idx + 1);
|
||||
if(i) {
|
||||
WEB_SRV_CONN *web_conn = (WEB_SRV_CONN *)ts_conn->linkd;
|
||||
i = mMIN((web_conn->msgbufsize / sizeof(ADC_DATA)), i);
|
||||
if(websock_tx_frame(ts_conn, WS_OPCODE_BINARY | WS_FRAGMENT_FIN, web_conn->msgbuf, adc_getdata(web_conn->msgbuf, i)) != ERR_OK)
|
||||
return -1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
case '1': // set ADC_DECIMATION_1
|
||||
p->dcmf = 1;
|
||||
return 0;
|
||||
case '2': // set ADC_DECIMATION_2
|
||||
p->dcmf = 2;
|
||||
return 0;
|
||||
case '4': // set ADC_DECIMATION_4
|
||||
p->dcmf = 3;
|
||||
return 0;
|
||||
case '8': // set ADC_DECIMATION_8
|
||||
p->dcmf = 4;
|
||||
return 0;
|
||||
case 'a': // set ADC_SAMPLE_XCLK x1
|
||||
p->xclk = 0;
|
||||
return 0;
|
||||
case 'b': // set ADC_SAMPLE_XCLK x2
|
||||
p->xclk = 1;
|
||||
return 0;
|
||||
case 'c': // set ADC_SAMPLE_XCLK x4
|
||||
p->xclk = 2;
|
||||
return 0;
|
||||
case 'd': // set ADC_SAMPLE_XCLK x8
|
||||
p->xclk = 3;
|
||||
return 0;
|
||||
case 'x': // set Audio mode
|
||||
p->audio = 1;
|
||||
return 0;
|
||||
case 'y': // set 4 channel mode
|
||||
p->audio = 0;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ static void ADCEnablePS(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void ADCInit(ADC_MODULE_SEL adc_idx) {
|
||||
void ADCInit(unsigned char mode, unsigned char xclk, unsigned char dcmf) {
|
||||
/* ADC Function and Clock Enable */
|
||||
/* To release DAC delta sigma clock gating */
|
||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_SYSPLL_CTRL2,
|
||||
|
@ -97,10 +97,10 @@ void ADCInit(ADC_MODULE_SEL adc_idx) {
|
|||
HAL_ADC_WRITE32(REG_ADC_CONTROL,
|
||||
BIT_CTRL_ADC_COMP_ONLY(ADC_FEATURE_DISABLED) // compare mode only enable (without FIFO enable)
|
||||
| BIT_CTRL_ADC_ONESHOT(ADC_FEATURE_DISABLED) // one-shot mode enable
|
||||
| BIT_CTRL_ADC_OVERWRITE(ADC_FEATURE_DISABLED) // overwrite mode enable
|
||||
| BIT_CTRL_ADC_OVERWRITE(ADC_FEATURE_ENABLED) // overwrite mode enable
|
||||
| BIT_CTRL_ADC_ENDIAN(ADC_DATA_ENDIAN_LITTLE) // endian selection
|
||||
| BIT_CTRL_ADC_BURST_SIZE(8) // DMA operation threshold
|
||||
| BIT_CTRL_ADC_THRESHOLD(8) // one shot mode threshold
|
||||
| BIT_CTRL_ADC_THRESHOLD(8) // one shot mode threshold
|
||||
| BIT_CTRL_ADC_DBG_SEL(ADC_DBG_SEL_DISABLE));
|
||||
#if 0
|
||||
/* ADC compare value and compare method setting*/
|
||||
|
@ -141,23 +141,25 @@ void ADCInit(ADC_MODULE_SEL adc_idx) {
|
|||
& (~(1 << adc_idx))); // compare mode control : less than the compare threshold
|
||||
#endif
|
||||
/* ADC audio mode set-up */
|
||||
#if 0
|
||||
/* ADC enable manually setting */
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD0,
|
||||
HAL_ADC_READ32(REG_ADC_ANAPAR_AD0)
|
||||
// & (~(BIT_ADC_AUDIO_EN)))
|
||||
// & (~(BIT_ADC_EN_MANUAL))
|
||||
| BIT_ADC_AUDIO_EN // ADC audio mode enable
|
||||
// | BIT_ADC_AUDIO_EN // ADC audio mode enable
|
||||
| BIT_ADC_EN_MANUAL // ADC enable manually
|
||||
);
|
||||
#endif
|
||||
/* ADC analog parameter 0 */
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD0,
|
||||
(HAL_ADC_READ32(REG_ADC_ANAPAR_AD0)
|
||||
// & (~BIT14) //ADC Input is internal?
|
||||
| (BIT14))
|
||||
& (~(BIT3|BIT2)));
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD0, 0x00953b10
|
||||
| BIT_CTRL_ADC_AUDIO_EN(mode)
|
||||
| BIT_CTRL_ADC_SAMPLE_CLKL(xclk));
|
||||
/* ADC analog parameter 1 */
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD1,
|
||||
(HAL_ADC_READ32(REG_ADC_ANAPAR_AD1) & (~BIT1)) | (BIT2|BIT0));
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD1, BIT_ADC_DIGITAL_RST_BAR
|
||||
| BIT_ADC_EXT_VREF_EN
|
||||
| BIT_ADC_DECIMATION_FILTER_ORDER
|
||||
| BIT_CTRL_DOWN_SAMPLE_RATE(dcmf));
|
||||
/* ADC analog parameter 2 */
|
||||
HAL_ADC_WRITE32(REG_ADC_ANAPAR_AD2, 0x67884400);
|
||||
/* ADC analog parameter 3 */
|
||||
|
|
|
@ -47,8 +47,8 @@ INA219DRV ina219drv = {
|
|||
// Если шаг заполнения 1 ms -> буфер на 0.71 сек
|
||||
// Оптимизация под TCP: (TCP_MSS*2 - 80)/4 = (1460*2 - 80)/4 = 710
|
||||
.i2c.status = DRV_I2C_OFF,
|
||||
.i2c.idx = 1, // =1: I2C1
|
||||
.i2c.io_sel = S0, // =S0: PC_4, PC_5
|
||||
.i2c.idx = 3, //1, // =1: I2C1, =2: I2C2, =3: I2C3
|
||||
.i2c.io_sel = S0, // =S0: PC_4, PC_5; PB_6, PB_7; PB_2, PB_3
|
||||
.i2c.mode = DRV_I2C_FS_MODE // DRV_I2C_FS_MODE
|
||||
};
|
||||
/*
|
||||
|
|
|
@ -466,7 +466,7 @@ extern int ina219_ws(TCP_SERV_CONN *ts_conn, char cmd);
|
|||
else ifcmp("mlx90614") {
|
||||
if(CheckSCB(SCB_WEBSOC)) {
|
||||
extern int mlx90614_ws(TCP_SERV_CONN *ts_conn, char cmd);
|
||||
int x = mlx90614_ws(ts_conn, cstr[6]);
|
||||
int x = mlx90614_ws(ts_conn, cstr[8]);
|
||||
if(x < 0) SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
|
||||
else tcp_puts("%d", x);
|
||||
}
|
||||
|
@ -476,7 +476,7 @@ extern int mlx90614_ws(TCP_SERV_CONN *ts_conn, char cmd);
|
|||
else ifcmp("adc") {
|
||||
if(CheckSCB(SCB_WEBSOC)) {
|
||||
extern int adc_ws(TCP_SERV_CONN *ts_conn, char cmd);
|
||||
int x = adc_ws(ts_conn, cstr[6]);
|
||||
int x = adc_ws(ts_conn, cstr[3]);
|
||||
if(x < 0) SetSCB(SCB_FCLOSE|SCB_DISCONNECT);
|
||||
else tcp_puts("%d", x);
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ SDK_PATH = USDK/
|
|||
#GCC_PATH = d:/MCU/GNU_Tools_ARM_Embedded/6.2017-q1-update/bin/# + or set in PATH
|
||||
#OPENOCD_PATH = D:/MCU/OpenOCD/bin/# + or set in PATH
|
||||
TOOLS_PATH ?= $(SDK_PATH)component/soc/realtek/8195a/misc/iar_utility/common/tools/
|
||||
FLASHER_TYPE = Jlink
|
||||
#FLASHER_TYPE = cmsis-dap
|
||||
#FLASHER_TYPE = Jlink
|
||||
FLASHER_TYPE = cmsis-dap
|
||||
FLASHER_SPEED = 3500
|
||||
FLASHER_PATH = flasher/
|
||||
JLINK_PATH ?= D:/MCU/SEGGER/JLink_V612i/
|
||||
|
|
Loading…
Reference in a new issue