var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(f,r,k){if(f==Array.prototype||f==Object.prototype)return f;f[r]=k.value;return f};
$jscomp.getGlobal=function(f){f=["object"==typeof globalThis&&globalThis,f,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var r=0;r<f.length;++r){var k=f[r];if(k&&k.Math==Math)return k}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};
$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(f,r){var k=$jscomp.propertyToPolyfillSymbol[r];if(null==k)return f[r];k=f[k];return void 0!==k?k:f[r]};$jscomp.polyfill=function(f,r,k,m){r&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(f,r,k,m):$jscomp.polyfillUnisolated(f,r,k,m))};
$jscomp.polyfillUnisolated=function(f,r,k,m){k=$jscomp.global;f=f.split(".");for(m=0;m<f.length-1;m++){var t=f[m];if(!(t in k))return;k=k[t]}f=f[f.length-1];m=k[f];r=r(m);r!=m&&null!=r&&$jscomp.defineProperty(k,f,{configurable:!0,writable:!0,value:r})};
$jscomp.polyfillIsolated=function(f,r,k,m){var t=f.split(".");f=1===t.length;m=t[0];m=!f&&m in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var E=0;E<t.length-1;E++){var T=t[E];if(!(T in m))return;m=m[T]}t=t[t.length-1];k=$jscomp.IS_SYMBOL_NATIVE&&"es6"===k?m[t]:null;r=r(k);null!=r&&(f?$jscomp.defineProperty($jscomp.polyfills,t,{configurable:!0,writable:!0,value:r}):r!==k&&(void 0===$jscomp.propertyToPolyfillSymbol[t]&&(k=1E9*Math.random()>>>0,$jscomp.propertyToPolyfillSymbol[t]=$jscomp.IS_SYMBOL_NATIVE?
$jscomp.global.Symbol(t):$jscomp.POLYFILL_PREFIX+k+"$"+t),$jscomp.defineProperty(m,$jscomp.propertyToPolyfillSymbol[t],{configurable:!0,writable:!0,value:r})))};$jscomp.polyfill("Array.prototype.fill",function(f){return f?f:function(r,k,m){var t=this.length||0;0>k&&(k=Math.max(0,t+k));if(null==m||m>t)m=t;m=Number(m);0>m&&(m=Math.max(0,t+m));for(k=Number(k||0);k<m;k++)this[k]=r;return this}},"es6","es3");$jscomp.typedArrayFill=function(f){return f?f:Array.prototype.fill};
$jscomp.polyfill("Int8Array.prototype.fill",$jscomp.typedArrayFill,"es6","es5");$jscomp.polyfill("Uint8Array.prototype.fill",$jscomp.typedArrayFill,"es6","es5");$jscomp.polyfill("Uint8ClampedArray.prototype.fill",$jscomp.typedArrayFill,"es6","es5");$jscomp.polyfill("Int16Array.prototype.fill",$jscomp.typedArrayFill,"es6","es5");$jscomp.polyfill("Uint16Array.prototype.fill",$jscomp.typedArrayFill,"es6","es5");$jscomp.polyfill("Int32Array.prototype.fill",$jscomp.typedArrayFill,"es6","es5");
$jscomp.polyfill("Uint32Array.prototype.fill",$jscomp.typedArrayFill,"es6","es5");$jscomp.polyfill("Float32Array.prototype.fill",$jscomp.typedArrayFill,"es6","es5");$jscomp.polyfill("Float64Array.prototype.fill",$jscomp.typedArrayFill,"es6","es5");
(function(){function f(b,e,d,c,g){0==g?(b.fillStyle="black",b.textAlign="left",b.font="20px Arial"):(b.fillStyle="blue",b.textAlign="left",b.font="14px Arial");b.fillText(e,d,c)}function r(b){var e="s";.1>b&&(b*=1E3,e="ms");.1>b&&(b*=1E3,e="us");.1>b&&(b*=1E3,e="ns");return e=b.toFixed(4)+e}function k(b){var e=[],d=0,c;for(c in b)b.hasOwnProperty(c)&&(e[d]=c,d+=1);return e}function m(b,e,d){var c=k(b);if("WDT"===d)for(d=0;d<c.length;d+=1)if(id_string=c[d].toLowerCase(),-1!==id_string.indexOf("timeout")){var g=
b[c[d]];if(-1!==g.indexOf("POW")){g=g.sliceAfterX("POW").trim();if(isNaN(parseInt(g)))throw"Cannot parsing WDT time-out value!";e.Timeout=Math.pow(2,parseInt(g))}else throw"Cannot parsing WDT time-out value!";}else if(-1!==id_string.indexOf("delay"))if(g=b[c[d]],-1!==g.indexOf("CLK")){for(;-1!==g.indexOf("_");)g=g.sliceAfterX("_").trim();if(isNaN(parseInt(g)))throw"Cannot parsing WDT delay value!";e.ResetDelay=parseInt(g)}else throw"Cannot parsing WDT delay value!";else if(-1!==id_string.indexOf("reset")&&
-1!==id_string.indexOf("enable")){if(isNaN(parseInt(b[c[d]])))throw"Cannot parsing WDT reset value!";e.ResetEnable=parseInt(b[c[d]])}else if(-1!==id_string.indexOf("int")&&-1!==id_string.indexOf("enable")){if(isNaN(parseInt(b[c[d]])))throw"Cannot parsing WDT interrupt value!";e.InterruptEnable=parseInt(b[c[d]])}else{if(-1!==id_string.indexOf("wakeup")&&-1!==id_string.indexOf("enable")){if(isNaN(parseInt(b[c[d]])))throw"Cannot parsing WDT wake-up enable value!";e.WakeupEnable=parseInt(b[c[d]])}}else if(-1!==
d.indexOf("TIMER"))for(d=0;d<c.length;d+=1){if(id_string=c[d].toLowerCase(),-1===id_string.indexOf("capture")){if(-1!==id_string.indexOf("funcradio"))if(g=b[c[d]],-1!==g.indexOf("FUNC_TIMER"))e.FuncSel=1,-1!==id_string.indexOf("timer0")?e.TimerChannel=0:-1!==id_string.indexOf("timer1")?e.TimerChannel=1:-1!==id_string.indexOf("timer2")?e.TimerChannel=2:-1!==id_string.indexOf("timer3")&&(e.TimerChannel=3);else return!1;else e.FuncSel=1,-1!==id_string.indexOf("timer0")?e.TimerChannel=0:-1!==id_string.indexOf("timer1")?
e.TimerChannel=1:-1!==id_string.indexOf("timer2")?e.TimerChannel=2:-1!==id_string.indexOf("timer3")&&(e.TimerChannel=3);if(-1!==id_string.indexOf("moderadio"))if(g=b[c[d]],-1!==g.indexOf("ONESHOT"))e.TimerMode=0;else if(-1!==g.indexOf("PERIODIC"))e.TimerMode=1;else if(-1!==g.indexOf("TOGGLE"))e.TimerMode=2;else if(-1!==g.indexOf("CONTINUOUS"))e.TimerMode=3;else throw"Cannot parsing TIMER mode value!";else if(-1!==id_string.indexOf("cmphextext")){if(isNaN(parseInt(b[c[d]])))throw"Cannot parsing TIMER compare value!";
e.TimerCmp=parseInt(b[c[d]])}else if(-1!==id_string.indexOf("intcheckbox")){if(isNaN(parseInt(b[c[d]])))throw"Cannot parsing TIMER interrupt value!";e.InterruptEnable=parseInt(b[c[d]])}else if(-1!==id_string.indexOf("freqinteger")&&-1===id_string.indexOf("pwm")){if(isNaN(parseInt(b[c[d]])))throw"Cannot parsing TIMER frequency value!";e.TimerFreq=parseInt(b[c[d]])}else if(-1!==id_string.indexOf("prescaleinteger")&&-1!==id_string.indexOf("timer")){if(isNaN(parseInt(b[c[d]])))throw"Cannot parsing TIMER prescale value!";
e.TimerPrescale=parseInt(b[c[d]])}}}else if(-1!==d.indexOf("UART"))for(d=0;d<c.length;d+=1){if(id_string=c[d].toLowerCase(),-1!==id_string.indexOf("baudrateinteger")){if(isNaN(parseInt(b[c[d]])))throw"Cannot parsing UART baud rate value!";e.UartBaudrate=parseInt(b[c[d]]);break}}else if(-1===d.indexOf("BPWM")&&-1!==d.indexOf("PWM"))for(d=0;d<c.length;d+=1)if(id_string=c[d].toLowerCase(),-1!==id_string.indexOf("freqinteger")){if(isNaN(parseInt(b[c[d]])))throw"Cannot parsing PWM frequency value!";e.PwmFreq=
parseInt(b[c[d]])}else if(-1!==id_string.indexOf("prescalerinteger")){if(isNaN(parseInt(b[c[d]])))throw"Cannot parsing PWM prescaler value!";e.PwmPrescale=parseInt(b[c[d]])}else if(-1!==id_string.indexOf("periodinteger")){if(isNaN(parseInt(b[c[d]])))throw"Cannot parsing PWM period value!";e.PwmPeriod=parseInt(b[c[d]])}else if(-1!==id_string.indexOf("clksrcselect")&&-1===id_string.indexOf("dead"))if(g=b[c[d]],-1!==g.indexOf("TIMER0"))e.PwmSrcSelect=1;else if(-1!==g.indexOf("TIMER1"))e.PwmSrcSelect=
2;else if(-1!==g.indexOf("TIMER2"))e.PwmSrcSelect=3;else if(-1!==g.indexOf("TIMER3"))e.PwmSrcSelect=4;else if(-1!==g.indexOf("PWM_CLK"))e.PwmSrcSelect=0;else return!1;else{if(-1!==id_string.indexOf("cnttypeselect"))if(g=b[c[d]],-1!==g.indexOf("UP_DOWN"))e.PwmCountType=2;else if(-1!==g.indexOf("DOWN"))e.PwmCountType=1;else if(-1!==g.indexOf("UP"))e.PwmCountType=0;else return!1}else return!1;return!0}function t(b,e,d,c,g,a,ka){b.beginPath();b.moveTo(e-c/2,d);b.lineTo(e-c/2+10,d-g/2);b.lineTo(e+c/2-
10,d-g/2);b.lineTo(e+c/2,d);b.lineTo(e+c/2-10,d+g/2);b.lineTo(e-c/2+10,d+g/2);b.strokeStyle=a;b.fillStyle=a;b.stroke();b.fill();b.fillStyle="white";b.font="14px Arial";b.textAlign="center";b.textBaseline="middle";b.fillText(ka,e,d)}function E(b,e,d,c,g,a,ka){ka?(rect_color="rgba(135, 206, 250, 1)",text_color="blue"):(rect_color="rgba(135, 206, 250, 0.1)",text_color="grey");b.font="14px Arial";b.textAlign="center";b.textBaseline="middle";c=b.measureText(a).width+10;b.fillStyle=rect_color;b.fillRect(e,
d,c,g);b.fillStyle=text_color;b.fillText(a,e+c/2,d+g/2);b.strokeRect(e,d,c,g);return c}function T(b,e,d){b.fillStyle="black";b.font="14px Arial";b.textAlign="center";b.textBaseline="middle";b.fillText(" >>> ",e,d)}NUTOOL_PER.drawCanvas=function(b,e,d,c){var g=document.getElementById(b);if(g.getContext){var a=g.getContext("2d");start_pos_x=330;start_pos_y=50;pin_width=35;pin_height=70;canvas_width=g.width;headerfilepath="PeripheralConfigure/"+e+"/psio.h";pin_enable_count=i=0;peripheral_setting=[];
peripheral_clock=0;a.clearRect(0,0,g.width,g.height);peripheral_setting=d.peripheral;a:{var ka=d.clock,V=c,ta,Aa=[];V=V.toLowerCase();-1!==V.indexOf("timer")?V=V.replace("timer","tmr"):-1!==V.indexOf("pwm")&&(V=V.slicePriorToX("_").trim());Aa=k(ka);for(ta=0;ta<Aa.length;ta+=1){var qb=Aa[ta].toLowerCase();if(qb===V){peripheral_clock=ka[Aa[ta]];break a}}peripheral_clock=0}try{var ca=d.peripheralAllIds,w=0,La=["wdt_timeoutselect","wdt_resetdelayselect","wdt_resetenableradio","wdt_intenablecheckbox",
"wdt_wakeupenablecheckbox"],Ma=["timer[0-3]moderadio","timer[0-3]intcheckbox","timer[0-3]cmphextext"],Na="slotctl[0-3]en slotctl[0-3]initslot slotctl[0-3]endslot slotctl[0-3]loopcount slotctl[0-3]triggertype slotctl[0-3]repeatmode slotctl[0-3]slot[0-15]count pin[0-7]en pin[0-7]slotcontrollerselect[0-3] pin[0-7]iomode pin[0-7]initstate pin[0-7]intervalstate pin[0-7]cp[0-7]slt pin[0-7]cp[0-7]act".split(" "),ua=["baudrateinteger"],rb=["freqinteger","prescalerinteger","periodinteger","clksrcselect","cnttypeselect"];
ca=ca.toLowerCase();if("WDT"===c)for(w=0;w<La.length;w+=1){if(-1===ca.indexOf(":"+La[w]+"/"))throw"Cannot draw diagram. '"+La[w]+"' tag id not found!";}else if(-1!==c.indexOf("TIMER"))for(w=0;w<Ma.length;w+=1){var da=":"+Ma[w]+"/";if(-1===ca.search(da))throw"Cannot draw diagram. '"+Ma[w]+"' tag id not found!";}else if(-1!==c.indexOf("PSIO"))for(w=0;w<Na.length;w+=1){if(da=":"+Na[w]+"/",-1===ca.search(da))throw"Cannot draw diagram. '"+Na[w]+"' tag id not found!";}else if(-1!==c.indexOf("UART"))for(w=
0;w<ua.length;w+=1){if(da=ua[w]+"/",-1===ca.search(da))throw"Cannot draw diagram. '"+ua[w]+"' tag id not found!";}else if(-1===c.indexOf("BPWM")&&-1!==c.indexOf("PWM"))for(w=0;w<ua.length;w+=1)if(da=rb[w]+"/",-1===ca.search(da))throw"Cannot draw diagram. '"+ua[w]+"' tag id not found!";if("PSIO"===c){var p=[{SlotEnable:0,slot_count:[0,0,0,0,0,0,0,0],init_slot:0,end_slot:0,loop_count:0,trg_src:0,repeat_mode:0},{SlotEnable:0,slot_count:[0,0,0,0,0,0,0,0],init_slot:0,end_slot:0,loop_count:0,trg_src:0,
repeat_mode:0},{SlotEnable:0,slot_count:[0,0,0,0,0,0,0,0],init_slot:0,end_slot:0,loop_count:0,trg_src:0,repeat_mode:0},{SlotEnable:0,slot_count:[0,0,0,0,0,0,0,0],init_slot:0,end_slot:0,loop_count:0,trg_src:0,repeat_mode:0}],h=[{PinEnable:0,SlotCtlSel:0,interval:0,initial:0,io_mode:0,CPSLOT:[0,0,0,0,0,0,0,0],CPACT:[0,0,0,0,0,0,0,0]},{PinEnable:0,SlotCtlSel:0,interval:0,initial:0,io_mode:0,CPSLOT:[0,0,0,0,0,0,0,0],CPACT:[0,0,0,0,0,0,0,0]},{PinEnable:0,SlotCtlSel:0,interval:0,initial:0,io_mode:0,CPSLOT:[0,
0,0,0,0,0,0,0],CPACT:[0,0,0,0,0,0,0,0]},{PinEnable:0,SlotCtlSel:0,interval:0,initial:0,io_mode:0,CPSLOT:[0,0,0,0,0,0,0,0],CPACT:[0,0,0,0,0,0,0,0]},{PinEnable:0,SlotCtlSel:0,interval:0,initial:0,io_mode:0,CPSLOT:[0,0,0,0,0,0,0,0],CPACT:[0,0,0,0,0,0,0,0]},{PinEnable:0,SlotCtlSel:0,interval:0,initial:0,io_mode:0,CPSLOT:[0,0,0,0,0,0,0,0],CPACT:[0,0,0,0,0,0,0,0]},{PinEnable:0,SlotCtlSel:0,interval:0,initial:0,io_mode:0,CPSLOT:[0,0,0,0,0,0,0,0],CPACT:[0,0,0,0,0,0,0,0]},{PinEnable:0,SlotCtlSel:0,interval:0,
initial:0,io_mode:0,CPSLOT:[0,0,0,0,0,0,0,0],CPACT:[0,0,0,0,0,0,0,0]}],Ba=peripheral_setting,la,va,Oa=[],Xa=[];try{var Ca=$.ajax({url:headerfilepath,async:!1}).responseText.replace(/\r/g,"")}catch(Ya){throw"Cannot draw diagram. PSIO header file not found!";}for(;-1!==Ca.indexOf("\n");){var ma=Ca.slicePriorToX("\n").trim();if(-1!==ma.indexOf("#define")&&-1!==ma.indexOf("UL")){ma=ma.sliceBetweenXandX("#define","UL").replace("(","");var Da=ma.slicePriorToX("0x").trim();Oa.push(Da);Da="0x"+ma.sliceAfterX("0x").trim();
if(isNaN(parseInt(Da)))throw"Cannot parsing define macro of PSIO header file!";Xa.push(parseInt(Da))}Ca=Ca.sliceAfterX("\n")}PSIOProperties=k(Ba);for(la=0;la<PSIOProperties.length;la+=1)for(va=0;va<Oa.length;va+=1)isNaN(Ba[PSIOProperties[la]])&&Ba[PSIOProperties[la]]===Oa[va]&&(Ba[PSIOProperties[la]]=Xa[va]);var J=peripheral_setting,C,O,ea,wa,P,F=[];bFounded=!1;F=k(J);for(C=0;C<F.length;C+=1){var G=F[C].toLowerCase();for(O=0;O<p.length;O+=1){if(-1!==G.indexOf("slotctl"+O))if(-1!==G.indexOf("init"))p[O].init_slot=
J[F[C]],bFounded=!0;else if(-1!==G.indexOf("end"))p[O].end_slot=J[F[C]],bFounded=!0;else if(-1!==G.indexOf("loop"))p[O].loop_count=J[F[C]],bFounded=!0;else if(-1!==G.indexOf("trig"))p[O].trg_src=J[F[C]],bFounded=!0;else if(-1!==G.indexOf("repeat"))p[O].repeat_mode=J[F[C]],bFounded=!0;else if(-1!==G.indexOf("slotctl"+O+"en"))p[O].SlotEnable=J[F[C]],bFounded=!0;else for(wa=0;wa<p[O].slot_count.length;wa+=1)if(-1!==G.indexOf("slot"+wa+"count")){p[O].slot_count[wa]=J[F[C]];bFounded=!0;break}if(bFounded)break}if(!bFounded)for(P=
0;P<h.length;P+=1)if(-1!==G.indexOf("pin"+P))if(-1!==G.indexOf("slot")&&-1!==G.indexOf("select"))h[P].SlotCtlSel=J[F[C]];else if(-1!==G.indexOf("iomode"))h[P].io_mode=J[F[C]];else if(-1!==G.indexOf("init"))h[P].initial=J[F[C]];else if(-1!==G.indexOf("interval"))h[P].interval=J[F[C]];else if(-1!==G.indexOf("pin"+P+"en"))h[P].PinEnable=J[F[C]];else for(ea=0;ea<h[P].CPSLOT.length;ea+=1)if(-1!==G.indexOf("cp"+ea+"slt")){h[P].CPSLOT[ea]=J[F[C]];break}else if(-1!==G.indexOf("cp"+ea+"act")){h[P].CPACT[ea]=
J[F[C]];break}bFounded=!1}for(i=0;i<h.length;i+=1)h[i].PinEnable&&(pin_enable_count+=1);g.setAttribute("height",start_pos_y+250+80*pin_enable_count);var N=pin_height/2,Za=peripheral_clock,D=start_pos_y-N/2-8,Ea;a.beginPath();a.font="14px Arial";a.textAlign="left";a.textBaseline="middle";for(Ea=0;9>Ea;Ea+=1){a.fillStyle="black";switch(Ea){case 0:a.fillStyle="black";0!==Za?a.fillText("PSIO clock : "+Za,15,D):(a.font="20px Arial",a.fillText("PSIO clock not enable!",15,D),a.font="14px Arial");break;case 1:a.fillStyle=
"rgba(100, 149, 237, 1)";a.fillRect(13,D-N/4,64,N/2);a.fillStyle="black";a.fillText("INSTSUP : Input status record and update",15,D);break;case 2:a.fillStyle="rgba(100, 149, 237, 1)";a.fillRect(13,D-N/4,46,N/2);a.fillStyle="black";a.fillText("INSTS : Input status",15,D);break;case 3:a.fillStyle="rgba(100, 149, 237, 1)";a.fillRect(13,D-N/4,19,N/2);a.fillStyle="black";a.fillText("DI : Input data buffer",15,D);break;case 4:a.fillStyle="rgba(205, 85, 85, 1)";a.fillRect(13,D-N/4,26,N/2);a.fillStyle="black";
a.fillText("DO : Output from data buffer",15,D);break;case 5:a.fillStyle="rgba(205, 85, 85, 1)";a.fillRect(13,D-N/4,24,N/2);a.fillStyle="black";a.fillText("TO : Output toggle",15,D);break;case 6:a.fillStyle="rgba(50, 205, 50, 1)";a.fillRect(13,D-N/4,24,N/2);a.fillStyle="black";a.fillText("      : Checkpoint",15,D);break;case 7:a.fillText("H: High level        T: Toggle",15,D);break;case 8:a.fillText("L: Low level         O: Last output",15,D)}D=D+N/2+8}var sb=start_pos_x,tb=2*canvas_width,$a=pin_height/
2,Pa=start_pos_y+10,Qa;for(Qa=0;4>Qa;Qa+=1)a.fillStyle="rgba(0, 200, 0, 0.1)",a.fillRect(sb,Pa,tb,$a),Pa=Pa+$a+10;var ub=start_pos_x,vb=2*canvas_width,ab=pin_height,Ra=start_pos_y+250,Fa;for(Fa=0;8>Fa;Fa+=1)h[Fa].PinEnable&&(a.fillStyle="rgba(0, 0, 200, 0.1)",a.fillRect(ub,Ra,vb,ab),Ra=Ra+ab+10);var fa=start_pos_x,ha=start_pos_y,na=pin_width,bb=pin_height/2,cb=(canvas_width-start_pos_x)/pin_width,wb=pin_enable_count,R;a.fillStyle="black";a.beginPath();a.moveTo(fa,ha);for(R=1;R<=2*cb;R+=2)a.lineTo(fa+
R*na,ha),a.lineTo(fa+R*na,ha-bb),a.lineTo(fa+(R+1)*na,ha-bb),a.lineTo(fa+(R+1)*na,ha);a.stroke();a.beginPath();a.setLineDash([5,8]);for(R=1;R<=2*cb;R+=2)a.moveTo(fa+(R+1)*na,ha+250),a.lineTo(fa+(R+1)*na,ha+250+80*wb);a.stroke();a.setLineDash([]);var Ga=start_pos_x,db=pin_width,oa=pin_height/2,ia=Ga,W=start_pos_y+10,I,X,Sa;a.fillStyle="black";a.beginPath();a.font="20px Arial";a.textBaseline="middle";for(I=0;I<p.length;I+=1){if(p[I].SlotEnable){a.textAlign="left";a.fillText("SC"+I,Ga-50,W+oa/2);if(0==
p[I].init_slot||0==p[I].end_slot)var Ta=0;else{var xb=p[I].init_slot-1;var yb=p[I].end_slot-1;Ta=p[I].loop_count}var zb=p[I].repeat_mode?50:1;for(Sa=0;Sa<zb;Sa+=1)for(X=0;X<p[I].slot_count.length&&0!=p[I].slot_count[X];X+=1)a.moveTo(ia,W),a.lineTo(ia,W+oa),a.textAlign="center",a.fillText("Slot"+X,ia+p[I].slot_count[X]*db,W+oa/2),ia+=p[I].slot_count[X]*db*2,0<Ta&&X==yb&&(X=xb-1,--Ta);a.moveTo(ia,W);a.lineTo(ia,W+oa)}else a.textAlign="left",a.fillText("SC"+I+"  Disable",Ga-50,W+oa/2);ia=Ga;W=W+oa+10}a.stroke();
var eb=start_pos_x-100,aa=pin_height,U,ba=eb,Y=start_pos_y+250;a.fillStyle="black";a.font="20px Arial";a.textAlign="center";a.textBaseline="middle";a.fillText("Pin",ba-200,Y-aa/2);a.fillText("Select",ba-150,Y-aa/2);a.fillText("Initial",ba-70,Y-aa/2);a.fillText("Interval",ba+30,Y-aa/2);for(U=0;U<h.length;U+=1)if(h[U].PinEnable){a.font="20px Arial";a.fillStyle="black";a.fillText(U,ba-200,Y+aa/2);a.fillText("SC"+h[U].SlotCtlSel,ba-150,Y+aa/2);var K=void 0,q=a,L=ba-110,u=Y+aa/4,Ab=h[U].initial,Bb=h[U].interval,
Cb=p[h[U].SlotCtlSel].trg_src,Db=h[U].io_mode;q.fillStyle="Black";q.font="14px Arial";q.textAlign="center";q.textBaseline="middle";q.fillText("L",L+10,u-10);q.strokeRect(L,u,20,20);q.fillText("H",L+30,u-10);q.strokeRect(L+20,u,20,20);q.fillText("O",L+50,u-10);q.strokeRect(L+40,u,20,20);q.fillText("T",L+70,u-10);q.strokeRect(L+60,u,20,20);q.fillRect(L+80*Ab/4,u,20,20);switch(Cb){case 0:q.fillText("SW",L+40,u+30);break;case 1:q.fillText("\\/",L+40,u+30);break;case 2:q.fillText("/\\",L+40,u+30);break;
case 3:q.fillText("/\\  \\/",L+40,u+30)}q.strokeRect(L,u+20,80,20);K=L+100;q.fillText("L",K+10,u-10);q.strokeRect(K,u,20,20);q.fillText("H",K+30,u-10);q.strokeRect(K+20,u,20,20);q.fillText("O",K+50,u-10);q.strokeRect(K+40,u,20,20);q.fillText("T",K+70,u-10);q.strokeRect(K+60,u,20,20);q.fillRect(K+80*Bb/4,u,20,20);switch(Db){case 0:q.fillText("Input",K+40,u+30);break;case 1:q.fillText("Output",K+40,u+30);break;case 2:q.fillText("OpenDrain",K+40,u+30);break;case 3:q.fillText("Quasi",K+40,u+30)}q.strokeRect(K,
u+20,80,20);ba=eb;Y=Y+aa+10}var fb=start_pos_x,Eb=2*pin_width,z=pin_height,gb=canvas_width,v,l,S,pa=[0,0,0,0,0,0,0,0],Ha=[0,0,0,0,0,0,0,0];var x=fb;var B=start_pos_y+250;for(v=0;v<h.length;v+=1){for(l=0;8>l;l+=1)pa[l]=h[v].initial,Ha[l]=0;if(p[h[v].SlotCtlSel].SlotEnable&&h[v].PinEnable&&0!=h[v].io_mode){for(l=0;8>l;l+=1)if(0==h[v].CPSLOT[l])for(S=l;8>S;)h[v].CPSLOT[S]=0,h[v].CPACT[S]=0,S+=1;for(l=7;0<=l;--l)if(0!=h[v].CPSLOT[l])for(S=l;0<S;){if(h[v].CPSLOT[S]>h[v].CPSLOT[l]){h[v].CPSLOT[l]=0;break}--S}for(l=
7;0<=l;--l)if(0!=h[v].CPSLOT[l]){var hb=h[v].CPSLOT[l]-1;pa[hb]=h[v].CPACT[l];Ha[hb]=1}if(0==p[h[v].SlotCtlSel].init_slot||0==p[h[v].SlotCtlSel].end_slot)var Ua=0;else{var Fb=p[h[v].SlotCtlSel].init_slot-1;var Gb=p[h[v].SlotCtlSel].end_slot-1;Ua=p[h[v].SlotCtlSel].loop_count}var Hb=p[h[v].SlotCtlSel].repeat_mode?50:1;for(S=0;S<Hb;S+=1)for(l=0;8>l&&0!=p[h[v].SlotCtlSel].slot_count[l];l+=1){0==Ha[l]&&0!=l&&(pa[l]=ib);var Q=p[h[v].SlotCtlSel].slot_count[l]*Eb;Ha[l]&&(a.strokeStyle="rgba(50, 205, 50, 1)",
a.lineWidth=5,a.beginPath(),a.moveTo(x,B),a.lineTo(x,B+z),a.stroke(),a.lineWidth=1);switch(pa[l]){case 0:a.strokeStyle="black";a.lineWidth=5;a.beginPath();a.moveTo(x,B+z);a.lineTo(x+Q,B+z);a.stroke();a.lineWidth=1;break;case 1:a.strokeStyle="black";a.lineWidth=5;a.beginPath();a.moveTo(x,B);a.lineTo(x+Q,B);a.stroke();a.lineWidth=1;break;case 2:t(a,x+Q/2,B+z/2,Q,z,"rgba(205, 85, 85, 1)","DO");break;case 3:t(a,x+Q/2,B+z/2,Q,z,"rgba(205, 85, 85, 1)","TO");break;case 4:t(a,x+Q/2,B+z/2,Q,z,"rgba(100, 149, 237, 1)",
"DI");break;case 5:t(a,x+Q/2,B+z/2,Q,z,"rgba(100, 149, 237, 1)","INSTS");break;case 6:t(a,x+Q/2,B+z/2,Q,z,"rgba(100, 149, 237, 1)","INSTSUP")}x+=Q;var ib=pa[l];0<Ua&&l==Gb&&(l=Fb-1,--Ua,ib=pa[l])}if(0==p[h[v].SlotCtlSel].repeat_mode&&gb>x){var qa=gb-x;switch(h[v].interval){case 0:a.strokeStyle="black";a.lineWidth=5;a.beginPath();a.moveTo(x,B+z);a.lineTo(x+qa,B+z);a.stroke();a.lineWidth=1;break;case 1:a.strokeStyle="black";a.lineWidth=5;a.beginPath();a.moveTo(x,B);a.lineTo(x+qa,B);a.stroke();a.lineWidth=
1;break;case 2:t(a,x+qa/2,B+z/2,qa,z,"rgba(205, 85, 85, 1)","DO");break;case 3:t(a,x+qa/2,B+z/2,qa,z,"rgba(205, 85, 85, 1)","TO")}}}x=fb;h[v].PinEnable&&(B=B+z+10)}return!0}if("WDT"===c){var A=30,ra={Timeout:0,ResetDelay:0,ResetEnable:0,InterruptEnable:0,WakeupEnable:0};if(!1===m(peripheral_setting,ra,c))return!1;start_pos_x=10;start_pos_y=30;g.setAttribute("height",start_pos_y+A+10);if(0===peripheral_clock)f(a,c+" clock not enable!",15,20,0);else{var n=E(a,start_pos_x,start_pos_y,n,A,"Reset Counter",
!0);start_pos_x=start_pos_x+n+10;T(a,start_pos_x+10,start_pos_y+15);start_pos_x+=30;i=ra.Timeout/peripheral_clock.toFloat();i=parseFloat(i.toFixed(6));n=E(a,start_pos_x,start_pos_y,n,A,i+" seconds",!0);start_pos_x=start_pos_x+n+10;T(a,start_pos_x+10,start_pos_y+15);start_pos_x+=30;n=E(a,start_pos_x,start_pos_y,n,A,"WatchDog Interrupt",ra.InterruptEnable);start_pos_x=start_pos_x+n+10;n=E(a,start_pos_x,start_pos_y,n,A,"Wakeup CPU",ra.WakeupEnable);start_pos_x=start_pos_x+n+10;T(a,start_pos_x+10,start_pos_y+
15);start_pos_x+=30;i=ra.ResetDelay/peripheral_clock.toFloat();i=parseFloat(i.toFixed(6));n=E(a,start_pos_x,start_pos_y,n,A,i+" seconds",!0);start_pos_x=start_pos_x+n+10;T(a,start_pos_x+10,start_pos_y+15);start_pos_x+=30;n=E(a,start_pos_x,start_pos_y,n,A,"WatchDog Reset CPU",ra.ResetEnable)}return!0}if(-1!==c.indexOf("TIMER")){var jb=0,M=0;A=30;var y={FuncSel:0,TimerFreq:0,TimerCmp:0,TimerPrescale:0,TimerMode:0,InterruptEnable:0,TimerChannel:0};if(!1===m(peripheral_setting,y,c)||1!==y.FuncSel)return!1;
start_pos_y=start_pos_x=10;g.setAttribute("height",A+110);if(0===peripheral_clock)f(a,c+" clock not enable!",start_pos_x,start_pos_y+50,0);else{if(0<y.TimerFreq&&0==y.TimerCmp){var Z=peripheral_clock.toFloat(),xa=0,Ia=0,Va=0,kb=0,lb=y.TimerFreq;kb=Z;lb>Z/2?xa=2:(64E6<Z?(Ia=7,Z>>=3):32E6<Z?(Ia=3,Z>>=2):16E6<Z&&(Ia=1,Z>>=1),xa=Math.floor(Z/lb));0<xa?(Va=kb/(xa*(Ia+1)),y.TimerCmp=xa):(Va=0,y.TimerCmp=0);M=Math.floor(Va)}else M=peripheral_clock.toFloat()/(y.TimerPrescale+1)/y.TimerCmp;if(1>M)return f(a,
"TIMER incorrect setting!",start_pos_x,start_pos_y+50,0),!0;i=y.TimerCmp/M;var Ib=y.TimerCmp+" ticks = "+r(i);f(a,Ib,start_pos_x,start_pos_y+50,1);f(a,"Timer working frequency = "+M.toHzString(),start_pos_x,start_pos_y+80,1);f(a,"Clock source frequency = "+peripheral_clock,start_pos_x,start_pos_y+110,1);n=E(a,start_pos_x,start_pos_y,n,A,"Counter 0 -> "+y.TimerCmp,!0);start_pos_x=start_pos_x+n+10;T(a,start_pos_x+10,start_pos_y+15);start_pos_x+=30;n=E(a,start_pos_x,start_pos_y,n,A,"Interrupt",y.InterruptEnable);
0!==y.TimerMode&&(start_pos_x=start_pos_x+n+10,T(a,start_pos_x+10,start_pos_y+15),start_pos_x+=30,3===y.TimerMode?(jb=y.TimerCmp+1,n=E(a,start_pos_x,start_pos_y,n,A,"Counter "+jb+" -> TIMER Max value (overflow)",!0)):n=E(a,start_pos_x,start_pos_y,n,A,"Reset Counter",!0),1===y.TimerMode||2===y.TimerMode)&&(start_pos_x=start_pos_x+n+10,T(a,start_pos_x+10,start_pos_y+15),start_pos_x+=30,2===y.TimerMode?n=E(a,start_pos_x,start_pos_y,n,A,"Toggle Output T"+y.TimerChannel,!0):(n=E(a,start_pos_x,start_pos_y,
n,A,"Restart Counter 0 -> "+y.TimerCmp,!0),start_pos_x=start_pos_x+n+10,n=E(a,start_pos_x,start_pos_y,n,A,"...",!0)))}return!0}if(-1!==c.indexOf("UART")){A=30;var ya=0,mb={UartBaudrate:0};if(!1===m(peripheral_setting,mb,c))return!1;start_pos_y=start_pos_x=10;g.setAttribute("height",A+30);if(0===peripheral_clock)f(a,c+" clock not enable!",start_pos_x,start_pos_y+10,0);else{a:{var Ja=peripheral_clock.toFloat(),nb=mb.UartBaudrate,ja=0,Wa=0;ja=Math.round(Ja/nb-2);if(0>ja)ya=0;else{if(65535<ja){ja=Math.round(Ja/
nb/16-2);if(0>ja){ya=0;break a}Wa=Ja/(16*(ja+2))}else Wa=Ja/(ja+2);ya=Math.round(Wa)}}0<ya?f(a,"Uart working baud rate = "+ya+" bps",start_pos_x,start_pos_y+10,1):f(a,"Uart baud rate incorrect setting!",start_pos_x,start_pos_y+10,1);f(a,"Clock source frequency = "+peripheral_clock,start_pos_x,start_pos_y+30,1)}return!0}if(-1!==c.indexOf("BPWM"))return!1;if(-1!==c.indexOf("PWM")){A=30;var Ka=M=0,H={PwmSrcSelect:0,PwmFreq:0,PwmCountType:0,PwmPrescale:0,PwmPeriod:0};if(!1===m(peripheral_setting,H,c)||
0!==H.PwmSrcSelect)return!1;start_pos_y=start_pos_x=10;g.setAttribute("height",A+50);if(0===peripheral_clock)f(a,c+" clock not enable!",start_pos_x,start_pos_y+10,0);else if(f(a,"Clock source frequency = "+peripheral_clock,start_pos_x,start_pos_y+10,1),0!=H.PwmFreq||0!=H.PwmPeriod&&0!=H.PwmPrescale)if(H.PwmFreq>peripheral_clock.toFloat())a.fillText("Incorrect setting! PWM frequency is greater then clock source frequency.",start_pos_x,start_pos_y+30);else if(0<H.PwmFreq){var ob=peripheral_clock.toFloat(),
pb=H.PwmFreq,sa=0,za=1;if(0<pb){for(za=1;4095>za&&!(sa=ob/pb/za,sa=Math.floor(sa),65536>=sa);za+=1);M=0<sa?Math.floor(ob/(za*sa)):0}else M=0;a.fillText("PWM working frequency = "+M.toHzString(),start_pos_x,start_pos_y+30)}else{2==H.PwmCountType?(M=peripheral_clock.toFloat()/(2*H.PwmPeriod*(H.PwmPrescale+1)),Ka=2*H.PwmPeriod*(H.PwmPrescale+1)/peripheral_clock.toFloat()):(M=peripheral_clock.toFloat()/((H.PwmPeriod+1)*(H.PwmPrescale+1)),Ka=(H.PwmPeriod+1)*(H.PwmPrescale+1)/peripheral_clock.toFloat());
if(0==M||0==Ka)return a.fillText("PWM incorrect setting! PWM frequency or PWM period value is 0.",start_pos_x,start_pos_y+30),!0;M=Math.floor(M);a.fillText("PWM working frequency = "+M.toHzString(),start_pos_x,start_pos_y+30);a.fillText("PWM period time = "+r(Ka),start_pos_x,start_pos_y+50)}else return!1;return!0}return!1}catch(Ya){return g.setAttribute("height",40),f(a,Ya,15,20,0),!0}}}})(NUTOOL_PER,this);
