OSDN Git Service

memoryにwrite32を追加
authornyatla <nyatla@47198e57-cb75-475f-84c4-a814cd6f29e0>
Fri, 25 Nov 2011 03:21:21 +0000 (03:21 +0000)
committernyatla <nyatla@47198e57-cb75-475f-84c4-a814cd6f29e0>
Fri, 25 Nov 2011 03:21:21 +0000 (03:21 +0000)
git-svn-id: http://svn.osdn.jp/svnroot/mimic/trunk@108 47198e57-cb75-475f-84c4-a814cd6f29e0

misc/MiMicVM/api.js/LPCXPresso1769.All-mini.js
misc/MiMicVM/api.js/LPCXPresso1769.All.js
misc/MiMicVM/api.js/LPCXpresso1769.Memory.js
misc/MiMicVM/api.js/demo/memory_access.html [new file with mode: 0644]
misc/MiMicVM/api.js/demo/pwm_port.html [new file with mode: 0644]

index a2ca016..a4c6b40 100644 (file)
@@ -1 +1 @@
-var LPCXpresso1769;(function(){var g=MiMicLib.isUndef;var a={_EE:function(n){return{NG:[n|0,"Unknown exception in LPCXpresso1769"],INVALID_ARG:[n|1,"Invalid argument"],INVALID_PIN:[n|2,"Invalid pin"],INVALID_CFG:[n|3,"Invalid configulation"],VM_RUNTIME:[n|4,"MVM runtime error"],}}(MiMicError.NG[0]|MiMicError.MID_MiMic|MiMicError.CAID_LPCXPresso1769),_BCF:{setBit:function m(p,r,o,q,n){try{n.push(p);n.push(~(r<<q));n.push((r&o)<<q);return"EA00EA01EA02DB0700AA0701AE0702DF0700"}catch(s){throw new MiMicException(s)}},setMem:function b(p,o,n){try{n.push(p);n.push(o);return"EA00EA01DF0100"}catch(q){throw new MiMicException(q)}},getMem:function i(o,n){try{n.push(o);return"EA00DB0000EE00"}catch(p){throw new MiMicException(p)}},READMEM:"EA00DB0000EE00",END:"ZZ.E"},FUNC_NAME:["GPIO","AD","DA","PWM"],PHL_NAME:["GPIO","ADC","DAC","PWM"],PHL:{WDT:[0,0,null],TIMER0:[0,2,1],TIMER1:[0,4,2],UART0:[0,6,3],UART1:[0,8,4],PWM1:[0,12,6],I2C0:[0,14,7],SPI:[0,16,8],RTC:[null,null,9],SSPI1:[0,20,10],DAC:[0,22,null],ADC:[0,24,12],CAN1:[0,26,13],CAN2:[0,28,14],ACF:[0,30,null],QEI:[1,0,18],GPIOINT:[1,2,15],PCB:[1,4,null],I2C1:[1,6,19],SSP0:[1,10,21],TIMER2:[1,12,22],TIMER3:[1,14,23],UART2:[1,16,24],UART3:[1,18,25],I2C2:[1,20,26],I2S:[1,22,27],RIT:[1,26,16],SYSCON:[1,28,null],PWM_MC:[1,30,17],GPDMA:[null,null,29],ENET:[null,null,30],USB:[null,null,31]},P0:[[0,0,0,0,["GPIO0.0","RD1","TXD3","SDA1"]],[0,0,0,1,["GPIO0.1","TD1","RXD3","SCL1"]],[0,0,0,2,["GPIO0.2","TXD0","AD0.7",null]],[0,0,0,3,["GPIO0.3","RXD0","AD0.6",null]],[0,0,0,4,["GPIO0.4","I2SRX_CLK","RD2","CAP2.0"]],[0,0,0,5,["GPIO0.5","I2SRX_WS","TD2","CAP2.1"]],[0,0,0,6,["GPIO0.6","I2SRX_SDA","SSEL1","MAT2.0"]],[0,0,0,7,["GPIO0.7","I2STX_CLK","SCK1","MAT2.1"]],[0,0,0,8,["GPIO0.8","I2STX_WS","MISO1","MAT2.2"]],[0,0,0,9,["GPIO0.9","I2STX_SDA","MOSI1","MAT2.3"]],[0,0,0,10,["GPIO0.10","TXD2","SDA2","MAT3.0"]],[0,0,0,11,["GPIO0.11","RXD2","SCL2","MAT3.1"]],null,null,null,[0,0,0,15,["GPIO0.15","TXD1","SCK0","SCK"]],[1,1,0,16,["GPIO0.16","RXD1","SSEL0","SSEL"]],[1,1,0,17,["GPIO0.17","CTS1","MISO0","MISO"]],[1,1,0,18,["GPIO0.18","DCD1","MOSI0","MOSI"]],[1,1,0,19,["GPIO0.19","DSR1",null,"SDA1"]],[1,1,0,20,["GPIO0.20","DTR1",null,"SCL1"]],[1,1,0,21,["GPIO0.21","RI1",null,"RD1"]],[1,1,0,22,["GPIO0.22","RTS1",null,"TD1"]],[1,1,0,23,["GPIO0.23","AD0.0","I2SRX_CLK","CAP3.0"]],[1,1,0,24,["GPIO0.24","AD0.1","I2SRX_WS","CAP3.1"]],[1,1,0,25,["GPIO0.25","AD0.2","I2SRX_SDA","TXD3"]],[1,1,0,26,["GPIO0.26","AD0.3","AOUT","RXD3"]],[1,null,null,22,["GPIO0.27","SDA0","USB_SDA",null]],[1,null,null,24,["GPIO0.28","SCL0","USB_SCL",null]],[1,null,0,29,["GPIO0.29","USB_D+",null,null]],[1,null,0,30,["GPIO0.30","USB_D-",null,null]],],P1:[[2,2,1,0,["GPIO1.0","ENET_TXD0",null,null]],[2,2,1,1,["GPIO1.1","ENET_TXD1",null,null]],null,null,[2,2,1,4,["GPIO1.4","ENET_TX_EN",null,null]],null,null,null,[2,2,1,8,["GPIO1.8","ENET_CRS",null,null]],[2,2,1,9,["GPIO1.9","ENET_RXD0",null,null]],[2,2,1,10,["GPIO1.10","ENET_RXD1",null,null]],null,null,null,[2,2,1,14,["GPIO1.14","ENET_RX_ER",null,null]],[2,2,1,15,["GPIO1.15","ENET_REF_CLK",null,null]],[3,3,1,16,["GPIO1.16","ENET_MDC",null,null]],[3,3,1,17,["GPIO1.17","ENET_MDIO",null,null]],[3,3,1,18,["GPIO1.18","USB_UP_LED","PWM1.1","CAP1.0"]],[3,3,1,19,["GPIO1.19","MCOA0","USB_PPWR","CAP1.1"]],[3,3,1,20,["GPIO1.20","MCI0","PWM1.2","SCK0"]],[3,3,1,21,["GPIO1.21","MCABORT","PWM1.3","SSEL0"]],[3,3,1,22,["GPIO1.22","MCOB0","USB_PWRD","MAT1.0"]],[3,3,1,23,["GPIO1.23","MCI1","PWM1.4","MISO0"]],[3,3,1,24,["GPIO1.24","MCI2","PWM1.5","MOSI0"]],[3,3,1,25,["GPIO1.25","MCOA1",null,"MAT1.1"]],[3,3,1,26,["GPIO1.26","MCOB1","PWM1.6","CAP0.0"]],[3,3,1,27,["GPIO1.27","CLKOUT","USB_OVRCR","CAP0.1"]],[3,3,1,28,["GPIO1.28","MCOA2","PCAP1.0","MAT0.0"]],[3,3,1,29,["GPIO1.29","MCOB2","PCAP1.1","MAT0.1"]],[3,3,1,30,["GPIO1.30",null,"VBUS","AD0.4"]],[3,3,1,31,["GPIO1.31",null,"SCK1","AD0.5"]],],P2:[[4,4,2,0,["GPIO2.0","PWM1.1","TXD1",null]],[4,4,2,1,["GPIO2.1","PWM1.2","RXD1",null]],[4,4,2,2,["GPIO2.2","PWM1.3","CTS1",null]],[4,4,2,3,["GPIO2.3","PWM1.4","DCD1",null]],[4,4,2,4,["GPIO2.4","PWM1.5","DSR1",null]],[4,4,2,5,["GPIO2.5","PWM1.6","DTR1",null]],[4,4,2,6,["GPIO2.6","PCAP1.0","RI1",null]],[4,4,2,7,["GPIO2.7","RD2","RTS1",null]],[4,4,2,8,["GPIO2.8","TD2","TXD2","ENET_MDC"]],[4,4,2,9,["GPIO2.9","USB_CONNECT","RXD2","ENET_MDIO"]],[4,4,2,10,["GPIO2.10","EINT0","NMI",null]],[4,4,2,11,["GPIO2.11","EINT1",null,"I2STX_CLK"]],[4,4,2,12,["GPIO2.12","EINT2",null,"I2STX_WS"]],[4,4,2,13,["GPIO2.13","EINT3",null,"I2STX_SDA"]],],P3:[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[7,7,3,25,["GPIO3.25",null,"MAT0.0","PWM1.2"]],[7,7,3,26,["GPIO3.26","STCLK","MAT0.1","PWM1.3"]],],P4:[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[9,9,4,28,["GPIO4.28","RX_MCLK","MAT2.0","TXD3"]],[9,9,4,29,["GPIO4.29","TX_MCLK","MAT2.1","RXD3"]]],completePinFunctionName:function j(p,o){try{for(var n=0;n<p[4].length;n++){if(p[4][n].indexOf(o)==0){return p[4][n]}}throw new MiMicException("The function name '"+o+"' is not unknown.")}catch(q){throw new MiMicException(q)}},getPinRegInfo:function d(n){try{return{s:n[0],m:n[1],o:n[2],smb:(n[3]%16)*2,ob:n[3]}}catch(o){throw new MiMicException(o)}},getPinSelByFunctionName:function h(o,q){try{for(var n=0;n<o[4].length;n++){if(o[4][n]==q){return n}}throw new MiMicException("The function name '"+q+"' has not function.")}catch(p){throw new MiMicException(p)}},hasPinFunctionName:function l(n,o){return n[4].indexOf(o)>=0}};a.I2c=function c(){throw new MiMicException("Not imprement.")};a.Dma=function k(){throw new MiMicException("Not imprement.")};a.Uart=function f(){throw new MiMicException("Not imprement.")};a.Usb=function e(){throw new MiMicException("Not imprement.")};LPCXpresso1769=a}());(function(){var f=LPCXpresso1769;var p=f._BCF;var a=f._EE;var e=MiMicLib.isUndef;function b(t){try{var v="";for(var s=0;s<t.length;s++){v+=MiMicLib.hexout(t[s],8)}return v}catch(u){throw new MiMicException(u)}}function h(w){try{function x(A,z){for(var y=0;y<A.length;y++){if(A[y]==null){continue}if(f.hasPinFunctionName(A[y],z)){return A[y]}}return null}var v=[f.P0,f.P1,f.P2,f.P3,f.P4];for(var t=0;t<v.length;t++){var s=x(v[t],w);if(s!=null){return s}}throw new MiMicException("pin function '"+w+"' not found")}catch(u){throw new MiMicException(u)}}function n(v){try{var t={GPIO:"GPIO",AD:"ADC",DA:"DAC"};for(var s in t){if(v.indexOf(s)==0){return t[s]}}throw new MiMicException("Peripheral for "+i_pinfunction+" not found.")}catch(u){throw new MiMicException(u)}}f.Mcu=function o(v,t){try{this.events={onActivateChanged:null};this._phl_holder=[];this._mif=new MiMicRemoteMcuInterface(v);var s=e(t)?true:t;if(s){this.activate()}}catch(u){throw new MiMicException(u)}};f.Mcu.prototype={_mif:null,isActive:function m(){try{return this._mif.isConnected()}catch(s){throw new MiMicException(s)}},events:null,_phl_holder:null,getClockInfo:function g(){return{cclk:100*1000*1000}},activate:function d(){try{var s=this;if(this.isActive()){throw new MiMicException("Already activated!")}this._mif.connect(function(u){if(!u){if(s.events.onActivateChanged!=null){s.events.onActivateChanged(false)}}});if(this.events.onActivateChanged!=null){this.events.onActivateChanged(true)}}catch(t){throw new MiMicException(t)}},deactivate:function c(){try{if(!this.isActive()){throw new MiMicException("Already activated!")}this._mif.disconnect();if(this.events.onActivateChanged!=null){this.events.onActivateChanged(false)}}catch(s){throw new MiMicException(s)}},callMiMic:function l(){try{var t;switch(arguments.length){case 1:t=arguments[0];break;case 2:t=arguments[0]+b(arguments[1]);break;default:throw new MiMicException(s)}return this._mif.execBc(t)}catch(s){throw new MiMicException(s)}},callMiMicWithCheck:function k(){try{var s=this.callMiMic.apply(this,arguments);if(s.result!=0){throw new MiMicException(a.VM_RUNTIME,"Result="+s.toString())}return s}catch(t){throw new MiMicException(t)}},getPin:function q(){switch(arguments.length){case 1:var s=h(arguments[0]);var t=n(arguments[0]);return this.getPeripheral(t).getPin(s);case 2:var t=n(arguments[1]);return this.getPeripheral(t).getPin(arguments[0]);default:throw new MiMicException()}},getPort:function r(s,u){switch(arguments.length){case 2:var t=n(u);return this.getPeripheral(t).getPort(s);default:throw new MiMicException()}},getPeripheral:function i(s,t){if(e(this._phl_holder[s])){switch(s){case"GPIO":new f.Gpio(this,t);break;case"ADC":new f.Adc(this,t);break;case"PWM":new f.Pwm(this,t);break;default:throw new MiMicException("Unknown peripheral symbol "+s)}}else{if(!e(t)){throw new MiMicException()}}return this._phl_holder[s]},registerPhl:function j(t,s){try{if(!e(this._phl_holder[s])){throw new MiMicException("Peripheral symbol "+s+" is already exist on mcu.")}this._phl_holder[s]=t}catch(u){throw new MiMicException(u)}}}}());(function(){var f=LPCXpresso1769;var d=f._BCF;var a=f._EE;var b=MiMicLib.isUndef;f.Memory=function e(g,h){if(!b(h)){this._base=h}this._mcu=g};f.Memory.prototype={_base:0,_mcu:null,read32:function c(){try{function o(i){if(i%4!=0){throw new MiMicException(a.INVALID_ARG,"An alignment is not 32bit unit.")}}var n="";var h=new Array();var p=arguments[0];switch(arguments.length){case 1:if(!isNaN(p)){o(p);n=d.READMEM;h.push(this._base+p)}else{for(var k=0;k<p.length;k++){o(p[k]);n+=d.getMem(this._base+p[k],h)}}break;case 2:o(p);o(arguments[1]);var g=arguments[1]/4;for(var k=0;k<g;k++){n+=d.READMEM;h.push(this._base+p+k*4)}break;default:break}var j=this._mcu.callMiMicWithCheck(n+d.END,h).stream;return j.length==1?j[0]:j}catch(m){throw new MiMicException(m)}}}}());(function(){var g=LPCXpresso1769;var f=g._BCF;var c=g._EE;var e=MiMicLib.isUndef;g.Peripheral=function(h,i,k){try{if(e(i)){throw new MiMicException(c.INVALID_PHL)}this._mcu=h;this._phl=i;if(!e(k)){this.setOpt(k)}}catch(j){throw new MiMicException(j)}};g.Peripheral.prototype={_PCLKSEL:[1074774440,1074774444],_PCONP:1074774212,_phl:null,_mcu:null,_cache:{pclk:0},BCF_setOpt:function a(k,h){try{var j="";if(!e(k.power)){if(this._phl[2]==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PCONP.")}j+=f.setBit(this._PCONP,1,k.power,this._phl[2],h)}if(!e(k.clock)){if(this._phl[0]==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PCLKSEL.")}this._cache.pclk=k.clock;j+=f.setBit(this._PCLKSEL[this._phl[0]],3,k.clock,this._phl[1],h)}return j}catch(i){throw new MiMicException(i)}},setOpt:function b(k){try{var h=new Array();var j=this.BCF_setOpt(k,h);if(j.length==0){throw new MiMicException("i_opt is empty or invalid.")}this._mcu.callMiMicWithCheck(j+f.END,h)}catch(i){throw new MiMicException(i)}return},getPCLK:function d(){try{var h=[4,1,2,0];var i=h[this._cache.pclk];var j;if(i==0){if(this._phl===g.PHL.CAN1||this._phl===g.PHL.CAN2){j=this._mcu.getClockInfo().cclk/6}else{j=this._mcu.getClockInfo().cclk/8}}else{j=this._mcu.getClockInfo().cclk/i}return Math.round(j)}catch(k){throw new MiMicException(k)}}}}());(function(){var a=LPCXpresso1769;var i=a._BCF;var j=a._EE;var d=MiMicLib.isUndef;var h={_PINSEL:[1073922048,1073922052,1073922056,1073922060,1073922064,null,null,1073922240,null,1073922084,1073922088],_PINMODE:[1073922112,1073922116,1073922120,1073922124,1073922128,1073922132,1073922136,1073922140,null,1073922148],_PINMODE_OD:[1073922152,1073922156,1073922160,1073922164,1073922168],};a.Port=function f(l,m,k){try{this._mcu=l;this._pininfo=new Array();for(var n=0;n<m.length;n++){this._pininfo.push(a.getPinRegInfo(m[n]))}if(!d(k)){this.setOpts(k)}}catch(o){throw new MiMicException(o)}};a.Port.prototype={_mcu:null,BCF_setOpts:function c(l,k){try{var r={selr:[0,0,0,0,0,0,0,0,0,0],selr_mask:[0,0,0,0,0,0,0,0,0,0],modr:[0,0,0,0,0,0,0,0,0,0],modr_mask:[0,0,0,0,0,0,0,0,0,0],odr:[0,0,0,0,0],odr_mask:[0,0,0,0,0]};if(this._pininfo.length!=l.length){throw new MiMicException()}for(var n=0;n<l.length;n++){var q=this._pininfo[n];var m=l[n];if(!d(m.sel)){r.selr[q.s]|=(m.sel<<q.smb);r.selr_mask[q.s]|=(3<<q.smb)}if(!d(m.mode)){r.modr[q.m]|=(m.mode<<q.smb);r.modr_mask[q.m]|=(3<<q.smb)}if(!d(m.od)){r.odr[q.o]|=(m.od<<q.ob);r.odr_mask[q.o]|=(1<<q.ob)}}var p="";for(var n=0;n<10;n++){if(r.selr_mask[n]!=0){p+=i.setBit(h._PINSEL[n],r.selr_mask[n],r.selr[n],0,k)}if(r.modr_mask[n]!=0){p+=i.setBit(h._PINMODE[n],r.modr_mask[n],r.modr[n],0,k)}}for(var n=0;n<5;n++){if(r.odr_mask[n]!=0){p+=i.setBit(h._PINMODE_OD[n],r.odr_mask[n],r.odr[n],0,k)}}return p}catch(o){throw new MiMicException(o)}},setOpts:function g(k){try{var l=new Array();var n=this.BCF_setOpts(k,l);if(n.length==0){throw new MiMicException("i_opt is empty or invalid.")}this._mcu.callMiMicWithCheck(n+i.END,l)}catch(m){throw new MiMicException(m)}return}};a.Pin=function b(k,l,n){try{if(d(l)){throw new MiMicException(j.INVALID_PIN)}this._port=new a.Port(k,[l],d(n)?undefined:[n])}catch(m){throw new MiMicException(m)}};a.Pin.prototype={_port:null,setOpt:function e(l){try{this._port.setOpts([l])}catch(k){throw new MiMicException(k)}return}}}());(function(){var a=LPCXpresso1769;var p=a._BCF;var q=a._EE;var d=MiMicLib.isUndef;var k=MiMicLib.cloneAssoc;a.Adc=function b(r,w){try{this._mcu=r;this._phl=new a.Peripheral(r,a.PHL.ADC);var t=d(w)?{phl:{}}:{phl:d(w.phl)?{}:k(w.phl),};if(d(t.phl.power)){t.phl.power=1}var v="";var s=new Array();v+=this.BCF_setOpt(t,s);v+=p.setMem(this._AD0CR,2098176,s);v+=p.setMem(this._AD0CR,2163712,s);this._mcu.callMiMicWithCheck(v+p.END,s);this._mcu.registerPhl(this,"ADC")}catch(u){throw new MiMicException(u)}};a.Adc.prototype={_PHL_DEF:{power:1},_AD0CR:1073954816,_AD0DR:[1073954832,1073954836,1073954840,1073954844,1073954848,1073954852,1073954856,1073954860],_phl:null,_mcu:null,BCF_setOpt:function m(u,r){try{var t="";if(!d(u.phl)){t+=this._phl.BCF_setOpt(u.phl,r)}return t}catch(s){throw new MiMicException(s)}},BCF_setSels:function j(t,s,r){try{return p.setBit(this._AD0CR,t,s*t,0,r)}catch(u){throw new MiMicException(u)}},BCF_getAD0DR:function l(s,r){try{return p.getMem(this._AD0DR[s],r)}catch(t){throw new MiMicException(t)}},setOpt:function h(u){try{var r=new Array();var t=this.BCF_setOpt(u,r);this._mcu.callMiMicWithCheck(t+p.END,r)}catch(s){throw new MiMicException(s)}},getPin:function n(r,t){try{return new a.AdcPin(this,r,t)}catch(s){throw new MiMicException(s)}},getPort:function c(r,t){try{return new a.AdcPort(this,r,t)}catch(s){throw new MiMicException(s)}}};function e(v){try{var t=a.completePinFunctionName(v,"AD");var s=t.substring(2).split(".");var u={port:0,ch:parseInt(s[1]),pin_sel:a.getPinSelByFunctionName(v,t)};if(!isNaN(u.ch)){return u}throw new MiMicException(q.INVALID_CFG,"The pin has not AD fuction.")}catch(w){throw new MiMicException(w)}}a.AdcPort=function o(s,r,x){try{this._adc=s;this._pins=new Array();for(var u=0;u<r.length;u++){this._pins.push(e(r[u]))}var w=this._pins[0].port;for(var u=1;u<this._pins.length;u++){if(w!=this._pins[1].port){throw new MiMicException("Invalid pin combination.")}}this._port=new a.Port(s._mcu,r);this._port_no=w;this._adcr_mask=0;for(var u=0;u<this._pins.length;u++){this._adcr_mask|=(1<<this._pins[u].ch)}var t=k(x);t.sel=1;if(d(t.pin)){t.pin={}}if(d(t.pin.sel)){t.pin.sel=this._PINSEL_AUTO_DETECT}this.setOpt(t)}catch(v){throw new MiMicException(v)}};a.AdcPort.prototype={_PINSEL_AUTO_DETECT:268435455,_adc:null,_pins:null,_port_no:0,_port:null,_adcr_mask:0,setOpt:function h(y){try{var r=new Array();var x="";if(!d(y.pin)){var v=new Array();for(var t=0;t<this._pins.length;t++){var u=(y.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[t].pin_sel:y.pin.sel;v.push({sel:u,mode:y.pin.mode,od:y.pin.od})}}x+=this._port.BCF_setOpts(v,r);x+=this._adc.BCF_setSels(this._adcr_mask,y.sel,r);this._adc._mcu.callMiMicWithCheck(x+p.END,r);return}catch(w){throw new MiMicException(w)}},getValues:function i(){try{var s=new Array();var x="";for(var u=0;u<this._pins.length;u++){x+=this._adc.BCF_getAD0DR(this._pins[u].ch,s)}var t=this._adc._mcu.callMiMicWithCheck(x+p.END,s);var v=new Array();for(var u=0;u<this._pins.length;u++){v.push((t.stream[u]>>4)&4095)}return v}catch(w){throw new MiMicException(w)}}};a.AdcPin=function f(r,s,u){try{this._aport=new a.AdcPort(r,[s],u)}catch(t){throw new MiMicException(t)}};a.AdcPin.prototype={_aport:null,getValue:function g(){try{return this._aport.getValues()[0]}catch(r){throw new MiMicException(r)}},setOpt:function h(s){try{this._aport.setOpt(s)}catch(r){throw new MiMicException(r)}}}}());(function(){var g=LPCXpresso1769;var o=g._BCF;var a=g._EE;var f=MiMicLib.isUndef;var m=MiMicLib.cloneAssoc;g.Gpio=function q(s,u){try{this._mcu=s;s.registerPhl(this,"GPIO")}catch(t){throw new MiMicException(t)}};g.Gpio.prototype={_FIO_DIR:[537509888,537509920,537509952,537509984,537510016],_FIO_PIN:[537509908,537509940,537509972,537510004,537510036],_FIO_SET:[537509912,537509944,537509976,537510008,537510040],_FIO_CLR:[537509916,537509948,537509980,537510012,537510044],_FIO_MASK:[537509904,537509936,537509968,537510000,537510032],_mcu:null,BCF_getValues:function k(t,u,s){try{s.push(this._FIO_PIN[t],this._FIO_MASK[t],~u);return"EA00EA01EA02DF0201DB0300EE03"}catch(v){throw new MiMicException(v)}},BCF_setValues:function h(u,v,t,s){try{s.push(this._FIO_PIN[u],this._FIO_MASK[u],~v,t);return"EA00EA01EA02EA03DF0201DF0300"}catch(w){throw new MiMicException(w)}},BCF_setDirs:function e(t,u,v,s){try{return o.setBit(this._FIO_DIR[t],u,u*v,0,s)}catch(w){throw new MiMicException(w)}},getPin:function p(s,u){try{return new g.GpioPin(this,s,u)}catch(t){throw new MiMicException(t)}},getPort:function r(s,u){try{return new g.GpioPort(this,s,u)}catch(t){throw new MiMicException(t)}}};function j(v){try{var t=g.completePinFunctionName(v,"GPIO");var s=t.substring(4).split(".");var u={port:parseInt(s[0]),bit:parseInt(s[1]),pin_sel:g.getPinSelByFunctionName(v,t)};if(!isNaN(u.port)&&!isNaN(u.bit)){return u}throw new MiMicException(a.INVALID_CFG,"The pin has not GPIO fuction.")}catch(w){throw new MiMicException(w)}}g.GpioPort=function n(v,s,y){try{this._gpio=v;this._pins=new Array();for(var u=0;u<s.length;u++){this._pins.push(j(s[u]))}var x=this._pins[0].port;for(var u=1;u<this._pins.length;u++){if(x!=this._pins[1].port){throw new MiMicException("Invalid pin combination.")}}this._port=new g.Port(v._mcu,s);this._port_no=x;this._mask=0;for(var u=0;u<this._pins.length;u++){this._mask|=(1<<this._pins[u].bit)}var t=m(y);if(f(t.pin)){t.pin={}}if(f(t.pin.sel)){t.pin.sel=this._PINSEL_AUTO_DETECT}this.setOpt(t)}catch(w){throw new MiMicException(w)}};g.GpioPort.prototype={_PINSEL_AUTO_DETECT:268435455,_pins:null,_gpio:null,_port_no:0,_port:null,_mask:0,setOpt:function b(z){try{var t=new Array();var y="";if(!f(z.dir)){y+=this._gpio.BCF_setDirs(this._port_no,this._mask,z.dir,t)}if(!f(z.pin)){var w=new Array();for(var u=0;u<this._pins.length;u++){var v=(z.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[u].pin_sel:z.pin.sel;w.push({sel:v,mode:z.pin.mode,od:z.pin.od})}}y+=this._port.BCF_setOpts(w,t);this._gpio._mcu.callMiMicWithCheck(y+o.END,t);return}catch(x){throw new MiMicException(x)}},setValue:function c(x){try{var w=0;var t=this._pins.length;for(var y=0;y<t;y++){var s=((x>>y)&1);w|=(s<<this._pins[y].bit)}var u=new Array();var A=this._gpio.BCF_setValues(this._port_no,this._mask,w,u);this._gpio._mcu.callMiMicWithCheck(A+o.END,u)}catch(z){throw new MiMicException(z)}},getValue:function d(){try{var w=new Array();var z=this._gpio.BCF_getValues(this._port_no,this._mask,w);var t=this._gpio._mcu.callMiMicWithCheck(z+o.END,w).stream[0];var u=0;for(var x=this._pins.length-1;x>=0;x--){var s=((t>>this._pins[x].bit)&1);u=(u<<1)|s}return u}catch(y){throw new MiMicException(y)}},outPatt:function i(w){try{var B=new Array();var y="";for(var s=0;s<w.length;s++){var z=0;var t=this._pins.length;for(var u=0;u<t;u++){var A=((w[s]>>u)&1);z|=(A<<this._pins[u].bit)}y+=this._gpio.BCF_setValues(this._port_no,this._mask,z,B)}this._gpio._mcu.callMiMicWithCheck(y+o.END,B)}catch(x){throw new MiMicException(x)}}};g.GpioPin=function l(s,t,v){try{this._gport=new g.GpioPort(s,[t],v)}catch(u){throw new MiMicException(u)}};g.GpioPin.prototype={_gport:null,setOpt:function b(t){try{this._gport.setOpt(t)}catch(s){throw new MiMicException(s)}},setValue:function c(s){try{this._gport.setValue(s)}catch(t){throw new MiMicException(t)}},getValue:function d(){try{return this._gport.getValue()}catch(s){throw new MiMicException(s)}},outPatt:function i(s){try{this._gport.outPatt(s)}catch(t){throw new MiMicException(t)}},}}());(function(){var f=LPCXpresso1769;var p=f._BCF;var a=f._EE;var d=MiMicLib.isUndef;var n=MiMicLib.cloneAssoc;f.Pwm=function j(u,z){try{this._mcu=u;this._phl=new f.Peripheral(u,f.PHL.PWM1);var w=d(z)?{phl:{}}:{phl:d(z.phl)?{}:n(z.phl),freq:z.freq};if(d(w.phl.power)){w.phl.power=1}if(d(w.phl.clock)){w.phl.clock=0}if(d(w.freq)){w.freq=100}var y="";var v=new Array();y+=this.BCF_setOpt(w,v);y+=p.setMem(this._PC,0,v);y+=p.setMem(this._PCR,0,v);y+=p.setMem(this._CTCR,0,v);y+=p.setMem(this._TCR,0,v);y+=p.setMem(this._TC,0,v);y+=p.setMem(this._TCR,9,v);this._mcu.callMiMicWithCheck(y+p.END,v);this._mcu.registerPhl(this,"PWM")}catch(x){throw new MiMicException(x)}};f.Pwm.prototype={_cache:{mr0:0},_TCR:1073840132,_TC:1073840136,_PR:1073840140,_PC:1073840144,_MCR:1073840152,_PCR:1073840204,_LER:1073840208,_CTCR:1073840240,_MRn:[1073840152,1073840156,1073840160,1073840164,1073840192,1073840196,1073840200],_phl:null,_mcu:null,BCF_setOpt:function m(z,u){try{var y="";var w;var v;if(!d(z.phl)){y+=this._phl.BCF_setOpt(z.phl,u)}if(!d(z.freq)){v=Math.round(this._phl.getPCLK()/z.freq);if(v<=0){throw new MiMicException("The peripheral clock too small.")}y+=this.BCF_setMRn(0,v,u);y+=this.BCF_setLER(0,u);this._cache.mr0=v}return y}catch(x){throw new MiMicException(x)}},BCF_setLER:function b(v,u){try{return p.setBit(this._LER,1,1,v,u)}catch(w){throw new MiMicException(w)}},BCF_setLERs:function l(w,v,u){try{return p.setBit(this._LER,w,v*w,0,u)}catch(x){throw new MiMicException(x)}},BCF_setMRn:function i(w,v,u){try{return p.setMem(this._MRn[w],v,u)}catch(x){throw new MiMicException(x)}},BCF_setMRnByDuty:function e(v,w,u){try{return this.BCF_setMRn(v,Math.round(w*this._cache.mr0),u)}catch(x){throw new MiMicException(x)}},BCF_setPCRbits:function g(B,x,y,w){try{var u,z;u=z=0;if(!d(x)){var A=255&B;z|=x*A;u|=A}if(!d(y)){var A=65280&B;z|=(y*A);u|=A}return p.setBit(this._PCR,u,z,0,w)}catch(C){throw new MiMicException(C)}},setOpt:function c(x){try{var u=new Array();var w=this.BCF_setOpt(x,u);this._mcu.callMiMicWithCheck(w+p.END,u)}catch(v){throw new MiMicException(v)}},getPin:function q(u,w){try{return new f.PwmPin(this,u,w)}catch(v){throw new MiMicException(v)}},getPort:function s(u,w){try{return new f.PwmPort(this,u,w)}catch(v){throw new MiMicException(v)}}};function h(x){try{var v=f.completePinFunctionName(x,"PWM");var u=v.substring(2).split(".");var w={port:0,ch:parseInt(u[1]),pin_sel:f.getPinSelByFunctionName(x,v)};if(!isNaN(w.ch)){return w}throw new MiMicException(a.INVALID_CFG,"The pin has not PWM fuction.")}catch(y){throw new MiMicException(y)}}f.PwmPort=function r(v,u,A){try{this._pwm=v;this._pins=new Array();for(var x=0;x<u.length;x++){this._pins.push(h(u[x]))}var z=this._pins[0].port;for(var x=1;x<this._pins.length;x++){if(z!=this._pins[1].port){throw new MiMicException("Invalid pin combination.")}}this._port=new f.Port(v._mcu,u);this._port_no=z;this._ler_mask=0;this._pcr_mask=0;for(var x=0;x<this._pins.length;x++){this._ler_mask|=(1<<this._pins[x].ch);this._pcr_mask|=(257<<this._pins[x].ch)}var w=d(A)?{pin:{}}:{pin:d(A.pin)?{}:n(A.pin),duty:A.duty,enable:A.enable};if(d(w.pin.sel)){w.pin.sel=this._PINSEL_AUTO_DETECT}if(d(w.duty)){w.duty=0}if(d(w.enable)){w.enable=1}this.setOpt(w)}catch(y){throw new MiMicException(y)}};f.PwmPort.prototype={_PINSEL_AUTO_DETECT:268435455,_pwm:null,_pins:null,_port_no:0,_port:null,_pcr_mask:0,_ler_mask:0,setOpt:function c(A){try{var u=new Array();var z="";if(!d(A.pin)){var x=new Array();for(var v=0;v<this._pins.length;v++){var w=(A.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[v].pin_sel:A.pin.sel;x.push({sel:w,mode:A.pin.mode,od:A.pin.od})}}z+=this._port.BCF_setOpts(x,u);if(!d(A.enable)){z+=this._pwm.BCF_setPCRbits(this._pcr_mask,0,A.enable,u)}if(!d(A.duty)){for(var v=0;v<this._pins.length;v++){z+=this._pwm.BCF_setMRnByDuty(this._pins[v].ch,A.duty,u)}z+=this._pwm.BCF_setLERs(this._ler_mask,1,u)}this._pwm._mcu.callMiMicWithCheck(z+p.END,u);return}catch(y){throw new MiMicException(y)}},setDutys:function k(y){try{if(y.length!=this._pins.length){throw new MiMicException(w)}var x="";var u=new Array();for(var v=0;v<this._pins.length;v++){if(!d(y[v])){x+=this._pwm.BCF_setMRnByDuty(this._pins[v].ch,y[v],u)}}x+=this._pwm.BCF_setLERs(this._ler_mask,1,u);this._pwm._mcu.callMiMicWithCheck(x+p.END,u)}catch(w){throw new MiMicException(w)}}};f.PwmPin=function t(u,v,x){try{this._pport=new f.PwmPort(u,[v],x)}catch(w){throw new MiMicException(w)}};f.PwmPin.prototype={_pport:null,setOpt:function c(v){try{this._pport.setOpt(v)}catch(u){throw new MiMicException(u)}},setDuty:function o(u){try{this._pport.setDuty([u])}catch(v){throw new MiMicException(v)}}}}());(function(){var f=LPCXpresso1769;var e=f._BCF;var a=f._EE;var d=MiMicLib.isUndef;f.Ni=function c(g){try{this._mcu=g}catch(h){throw new MiMicException(h)}};f.Ni.prototype={call:function b(j,q,p){var n="";var r=new Array();if(!d(q)){for(var l=0;l<8;l++){var k="wm"+l;if(!d(q[k])){n+="FB"+MiMicLib.hexout(l,2)+MiMicLib.hexout(q[k],8)}}if(!d(q.stream)){for(var l=0;l<q.stream.length;l++){r.push(q.stream[l])}}}n+="ZF"+MiMicLib.hexout(j,8);var g=0;if(!d(p)){for(var l=0;l<8;l++){if(!d(p["wm"+l])){n+="EE"+MiMicLib.hexout(l,2);g++}}}var m=this._mcu.callMiMic(n+e.END,r);if(m.result!=0){return false}var o=0;if(!d(p)){var h=m.stream.length-g;for(var l=0;l<8;l++){var k="wm"+l;if(!d(p[k])){p[k]=m.stream[h];h++}}if(!d(p.stream)){p.stream=m.stream.slice(0,m.stream.length-g)}}return false}}}());
\ No newline at end of file
+var LPCXpresso1769;(function(){var g=MiMicLib.isUndef;var a={_EE:function(n){return{NG:[n|0,"Unknown exception in LPCXpresso1769"],INVALID_ARG:[n|1,"Invalid argument"],INVALID_PIN:[n|2,"Invalid pin"],INVALID_CFG:[n|3,"Invalid configulation"],VM_RUNTIME:[n|4,"MVM runtime error"],}}(MiMicError.NG[0]|MiMicError.MID_MiMic|MiMicError.CAID_LPCXPresso1769),_BCF:{setBit:function m(p,r,o,q,n){try{n.push(p);n.push(~(r<<q));n.push((r&o)<<q);return"EA00EA01EA02DB0700AA0701AE0702DF0700"}catch(s){throw new MiMicException(s)}},setMem:function b(p,o,n){try{n.push(p);n.push(o);return"EA00EA01DF0100"}catch(q){throw new MiMicException(q)}},getMem:function i(o,n){try{n.push(o);return"EA00DB0000EE00"}catch(p){throw new MiMicException(p)}},READMEM:"EA00DB0000EE00",END:"ZZ.E"},FUNC_NAME:["GPIO","AD","DA","PWM"],PHL_NAME:["GPIO","ADC","DAC","PWM"],PHL:{WDT:[0,0,null],TIMER0:[0,2,1],TIMER1:[0,4,2],UART0:[0,6,3],UART1:[0,8,4],PWM1:[0,12,6],I2C0:[0,14,7],SPI:[0,16,8],RTC:[null,null,9],SSPI1:[0,20,10],DAC:[0,22,null],ADC:[0,24,12],CAN1:[0,26,13],CAN2:[0,28,14],ACF:[0,30,null],QEI:[1,0,18],GPIOINT:[1,2,15],PCB:[1,4,null],I2C1:[1,6,19],SSP0:[1,10,21],TIMER2:[1,12,22],TIMER3:[1,14,23],UART2:[1,16,24],UART3:[1,18,25],I2C2:[1,20,26],I2S:[1,22,27],RIT:[1,26,16],SYSCON:[1,28,null],PWM_MC:[1,30,17],GPDMA:[null,null,29],ENET:[null,null,30],USB:[null,null,31]},P0:[[0,0,0,0,["GPIO0.0","RD1","TXD3","SDA1"]],[0,0,0,1,["GPIO0.1","TD1","RXD3","SCL1"]],[0,0,0,2,["GPIO0.2","TXD0","AD0.7",null]],[0,0,0,3,["GPIO0.3","RXD0","AD0.6",null]],[0,0,0,4,["GPIO0.4","I2SRX_CLK","RD2","CAP2.0"]],[0,0,0,5,["GPIO0.5","I2SRX_WS","TD2","CAP2.1"]],[0,0,0,6,["GPIO0.6","I2SRX_SDA","SSEL1","MAT2.0"]],[0,0,0,7,["GPIO0.7","I2STX_CLK","SCK1","MAT2.1"]],[0,0,0,8,["GPIO0.8","I2STX_WS","MISO1","MAT2.2"]],[0,0,0,9,["GPIO0.9","I2STX_SDA","MOSI1","MAT2.3"]],[0,0,0,10,["GPIO0.10","TXD2","SDA2","MAT3.0"]],[0,0,0,11,["GPIO0.11","RXD2","SCL2","MAT3.1"]],null,null,null,[0,0,0,15,["GPIO0.15","TXD1","SCK0","SCK"]],[1,1,0,16,["GPIO0.16","RXD1","SSEL0","SSEL"]],[1,1,0,17,["GPIO0.17","CTS1","MISO0","MISO"]],[1,1,0,18,["GPIO0.18","DCD1","MOSI0","MOSI"]],[1,1,0,19,["GPIO0.19","DSR1",null,"SDA1"]],[1,1,0,20,["GPIO0.20","DTR1",null,"SCL1"]],[1,1,0,21,["GPIO0.21","RI1",null,"RD1"]],[1,1,0,22,["GPIO0.22","RTS1",null,"TD1"]],[1,1,0,23,["GPIO0.23","AD0.0","I2SRX_CLK","CAP3.0"]],[1,1,0,24,["GPIO0.24","AD0.1","I2SRX_WS","CAP3.1"]],[1,1,0,25,["GPIO0.25","AD0.2","I2SRX_SDA","TXD3"]],[1,1,0,26,["GPIO0.26","AD0.3","AOUT","RXD3"]],[1,null,null,22,["GPIO0.27","SDA0","USB_SDA",null]],[1,null,null,24,["GPIO0.28","SCL0","USB_SCL",null]],[1,null,0,29,["GPIO0.29","USB_D+",null,null]],[1,null,0,30,["GPIO0.30","USB_D-",null,null]],],P1:[[2,2,1,0,["GPIO1.0","ENET_TXD0",null,null]],[2,2,1,1,["GPIO1.1","ENET_TXD1",null,null]],null,null,[2,2,1,4,["GPIO1.4","ENET_TX_EN",null,null]],null,null,null,[2,2,1,8,["GPIO1.8","ENET_CRS",null,null]],[2,2,1,9,["GPIO1.9","ENET_RXD0",null,null]],[2,2,1,10,["GPIO1.10","ENET_RXD1",null,null]],null,null,null,[2,2,1,14,["GPIO1.14","ENET_RX_ER",null,null]],[2,2,1,15,["GPIO1.15","ENET_REF_CLK",null,null]],[3,3,1,16,["GPIO1.16","ENET_MDC",null,null]],[3,3,1,17,["GPIO1.17","ENET_MDIO",null,null]],[3,3,1,18,["GPIO1.18","USB_UP_LED","PWM1.1","CAP1.0"]],[3,3,1,19,["GPIO1.19","MCOA0","USB_PPWR","CAP1.1"]],[3,3,1,20,["GPIO1.20","MCI0","PWM1.2","SCK0"]],[3,3,1,21,["GPIO1.21","MCABORT","PWM1.3","SSEL0"]],[3,3,1,22,["GPIO1.22","MCOB0","USB_PWRD","MAT1.0"]],[3,3,1,23,["GPIO1.23","MCI1","PWM1.4","MISO0"]],[3,3,1,24,["GPIO1.24","MCI2","PWM1.5","MOSI0"]],[3,3,1,25,["GPIO1.25","MCOA1",null,"MAT1.1"]],[3,3,1,26,["GPIO1.26","MCOB1","PWM1.6","CAP0.0"]],[3,3,1,27,["GPIO1.27","CLKOUT","USB_OVRCR","CAP0.1"]],[3,3,1,28,["GPIO1.28","MCOA2","PCAP1.0","MAT0.0"]],[3,3,1,29,["GPIO1.29","MCOB2","PCAP1.1","MAT0.1"]],[3,3,1,30,["GPIO1.30",null,"VBUS","AD0.4"]],[3,3,1,31,["GPIO1.31",null,"SCK1","AD0.5"]],],P2:[[4,4,2,0,["GPIO2.0","PWM1.1","TXD1",null]],[4,4,2,1,["GPIO2.1","PWM1.2","RXD1",null]],[4,4,2,2,["GPIO2.2","PWM1.3","CTS1",null]],[4,4,2,3,["GPIO2.3","PWM1.4","DCD1",null]],[4,4,2,4,["GPIO2.4","PWM1.5","DSR1",null]],[4,4,2,5,["GPIO2.5","PWM1.6","DTR1",null]],[4,4,2,6,["GPIO2.6","PCAP1.0","RI1",null]],[4,4,2,7,["GPIO2.7","RD2","RTS1",null]],[4,4,2,8,["GPIO2.8","TD2","TXD2","ENET_MDC"]],[4,4,2,9,["GPIO2.9","USB_CONNECT","RXD2","ENET_MDIO"]],[4,4,2,10,["GPIO2.10","EINT0","NMI",null]],[4,4,2,11,["GPIO2.11","EINT1",null,"I2STX_CLK"]],[4,4,2,12,["GPIO2.12","EINT2",null,"I2STX_WS"]],[4,4,2,13,["GPIO2.13","EINT3",null,"I2STX_SDA"]],],P3:[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[7,7,3,25,["GPIO3.25",null,"MAT0.0","PWM1.2"]],[7,7,3,26,["GPIO3.26","STCLK","MAT0.1","PWM1.3"]],],P4:[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[9,9,4,28,["GPIO4.28","RX_MCLK","MAT2.0","TXD3"]],[9,9,4,29,["GPIO4.29","TX_MCLK","MAT2.1","RXD3"]]],completePinFunctionName:function j(p,o){try{for(var n=0;n<p[4].length;n++){if(p[4][n].indexOf(o)==0){return p[4][n]}}throw new MiMicException("The function name '"+o+"' is not unknown.")}catch(q){throw new MiMicException(q)}},getPinRegInfo:function d(n){try{return{s:n[0],m:n[1],o:n[2],smb:(n[3]%16)*2,ob:n[3]}}catch(o){throw new MiMicException(o)}},getPinSelByFunctionName:function h(o,q){try{for(var n=0;n<o[4].length;n++){if(o[4][n]==q){return n}}throw new MiMicException("The function name '"+q+"' has not function.")}catch(p){throw new MiMicException(p)}},hasPinFunctionName:function l(n,o){return n[4].indexOf(o)>=0}};a.I2c=function c(){throw new MiMicException("Not imprement.")};a.Dma=function k(){throw new MiMicException("Not imprement.")};a.Uart=function f(){throw new MiMicException("Not imprement.")};a.Usb=function e(){throw new MiMicException("Not imprement.")};LPCXpresso1769=a}());(function(){var f=LPCXpresso1769;var p=f._BCF;var a=f._EE;var e=MiMicLib.isUndef;function b(t){try{var v="";for(var s=0;s<t.length;s++){v+=MiMicLib.hexout(t[s],8)}return v}catch(u){throw new MiMicException(u)}}function h(w){try{function x(A,z){for(var y=0;y<A.length;y++){if(A[y]==null){continue}if(f.hasPinFunctionName(A[y],z)){return A[y]}}return null}var v=[f.P0,f.P1,f.P2,f.P3,f.P4];for(var t=0;t<v.length;t++){var s=x(v[t],w);if(s!=null){return s}}throw new MiMicException("pin function '"+w+"' not found")}catch(u){throw new MiMicException(u)}}function n(v){try{var t={GPIO:"GPIO",AD:"ADC",DA:"DAC"};for(var s in t){if(v.indexOf(s)==0){return t[s]}}throw new MiMicException("Peripheral for "+i_pinfunction+" not found.")}catch(u){throw new MiMicException(u)}}f.Mcu=function o(v,t){try{this.events={onActivateChanged:null};this._phl_holder=[];this._mif=new MiMicRemoteMcuInterface(v);var s=e(t)?true:t;if(s){this.activate()}}catch(u){throw new MiMicException(u)}};f.Mcu.prototype={_mif:null,isActive:function m(){try{return this._mif.isConnected()}catch(s){throw new MiMicException(s)}},events:null,_phl_holder:null,getClockInfo:function g(){return{cclk:100*1000*1000}},activate:function d(){try{var s=this;if(this.isActive()){throw new MiMicException("Already activated!")}this._mif.connect(function(u){if(!u){if(s.events.onActivateChanged!=null){s.events.onActivateChanged(false)}}});if(this.events.onActivateChanged!=null){this.events.onActivateChanged(true)}}catch(t){throw new MiMicException(t)}},deactivate:function c(){try{if(!this.isActive()){throw new MiMicException("Already activated!")}this._mif.disconnect();if(this.events.onActivateChanged!=null){this.events.onActivateChanged(false)}}catch(s){throw new MiMicException(s)}},callMiMic:function l(){try{var t;switch(arguments.length){case 1:t=arguments[0];break;case 2:t=arguments[0]+b(arguments[1]);break;default:throw new MiMicException(s)}return this._mif.execBc(t)}catch(s){throw new MiMicException(s)}},callMiMicWithCheck:function k(){try{var s=this.callMiMic.apply(this,arguments);if(s.result!=0){throw new MiMicException(a.VM_RUNTIME,"Result="+s.toString())}return s}catch(t){throw new MiMicException(t)}},getPin:function q(){switch(arguments.length){case 1:var s=h(arguments[0]);var t=n(arguments[0]);return this.getPeripheral(t).getPin(s);case 2:var t=n(arguments[1]);return this.getPeripheral(t).getPin(arguments[0]);default:throw new MiMicException()}},getPort:function r(s,u){switch(arguments.length){case 2:var t=n(u);return this.getPeripheral(t).getPort(s);default:throw new MiMicException()}},getPeripheral:function i(s,t){if(e(this._phl_holder[s])){switch(s){case"GPIO":new f.Gpio(this,t);break;case"ADC":new f.Adc(this,t);break;case"PWM":new f.Pwm(this,t);break;default:throw new MiMicException("Unknown peripheral symbol "+s)}}else{if(!e(t)){throw new MiMicException()}}return this._phl_holder[s]},registerPhl:function j(t,s){try{if(!e(this._phl_holder[s])){throw new MiMicException("Peripheral symbol "+s+" is already exist on mcu.")}this._phl_holder[s]=t}catch(u){throw new MiMicException(u)}}}}());(function(){var h=LPCXpresso1769;var e=h._BCF;var a=h._EE;var b=MiMicLib.isUndef;function d(i){if(i%4!=0){throw new MiMicException(a.INVALID_ARG,"An alignment is not 32bit unit.")}}h.Memory=function f(i,j){if(!b(j)){this._base=j}this._mcu=i};h.Memory.prototype={_base:0,_mcu:null,read32:function c(){try{var p="";var k=new Array();var q=arguments[0];switch(arguments.length){case 1:if(!isNaN(q)){d(q);p=e.READMEM;k.push(this._base+q)}else{for(var n=0;n<q.length;n++){d(q[n]);p+=e.getMem(this._base+q[n],k)}}break;case 2:d(q);d(arguments[1]);var j=arguments[1]/4;for(var n=0;n<j;n++){p+=e.READMEM;k.push(this._base+q+n*4)}break;default:break}var m=this._mcu.callMiMicWithCheck(p+e.END,k).stream;return m.length==1?m[0]:m}catch(o){throw new MiMicException(o)}},write32:function g(){try{var o="";var k=new Array();var p=arguments[0];switch(arguments.length){case 2:if((!isNaN(p))){if(!isNaN(arguments[1])){d(p);o+=e.setMem(this._base+p,arguments[1],k)}else{if(arguments[1].length>0){d(p);var j=arguments[1].length;for(var m=0;m<j;m++){o+=e.setMem(this._base+p+m*4,arguments[1][m],k)}}else{throw new MiMicException()}}}else{if(p.length==arguments[1].length){for(var m=0;m<p.length;m++){d(p[m]);o+=e.setMem(this._base+p[m],arguments[1][m],k)}}else{throw new MiMicException()}}break;default:break}this._mcu.callMiMicWithCheck(o+e.END,k).stream;return}catch(n){throw new MiMicException(n)}}}}());(function(){var g=LPCXpresso1769;var f=g._BCF;var c=g._EE;var e=MiMicLib.isUndef;g.Peripheral=function(h,i,k){try{if(e(i)){throw new MiMicException(c.INVALID_PHL)}this._mcu=h;this._phl=i;if(!e(k)){this.setOpt(k)}}catch(j){throw new MiMicException(j)}};g.Peripheral.prototype={_PCLKSEL:[1074774440,1074774444],_PCONP:1074774212,_phl:null,_mcu:null,_cache:{pclk:0},BCF_setOpt:function a(k,h){try{var j="";if(!e(k.power)){if(this._phl[2]==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PCONP.")}j+=f.setBit(this._PCONP,1,k.power,this._phl[2],h)}if(!e(k.clock)){if(this._phl[0]==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PCLKSEL.")}this._cache.pclk=k.clock;j+=f.setBit(this._PCLKSEL[this._phl[0]],3,k.clock,this._phl[1],h)}return j}catch(i){throw new MiMicException(i)}},setOpt:function b(k){try{var h=new Array();var j=this.BCF_setOpt(k,h);if(j.length==0){throw new MiMicException("i_opt is empty or invalid.")}this._mcu.callMiMicWithCheck(j+f.END,h)}catch(i){throw new MiMicException(i)}return},getPCLK:function d(){try{var h=[4,1,2,0];var i=h[this._cache.pclk];var j;if(i==0){if(this._phl===g.PHL.CAN1||this._phl===g.PHL.CAN2){j=this._mcu.getClockInfo().cclk/6}else{j=this._mcu.getClockInfo().cclk/8}}else{j=this._mcu.getClockInfo().cclk/i}return Math.round(j)}catch(k){throw new MiMicException(k)}}}}());(function(){var a=LPCXpresso1769;var i=a._BCF;var j=a._EE;var d=MiMicLib.isUndef;var h={_PINSEL:[1073922048,1073922052,1073922056,1073922060,1073922064,null,null,1073922240,null,1073922084,1073922088],_PINMODE:[1073922112,1073922116,1073922120,1073922124,1073922128,1073922132,1073922136,1073922140,null,1073922148],_PINMODE_OD:[1073922152,1073922156,1073922160,1073922164,1073922168],};a.Port=function f(l,m,k){try{this._mcu=l;this._pininfo=new Array();for(var n=0;n<m.length;n++){this._pininfo.push(a.getPinRegInfo(m[n]))}if(!d(k)){this.setOpts(k)}}catch(o){throw new MiMicException(o)}};a.Port.prototype={_mcu:null,BCF_setOpts:function c(l,k){try{var r={selr:[0,0,0,0,0,0,0,0,0,0],selr_mask:[0,0,0,0,0,0,0,0,0,0],modr:[0,0,0,0,0,0,0,0,0,0],modr_mask:[0,0,0,0,0,0,0,0,0,0],odr:[0,0,0,0,0],odr_mask:[0,0,0,0,0]};if(this._pininfo.length!=l.length){throw new MiMicException()}for(var n=0;n<l.length;n++){var q=this._pininfo[n];var m=l[n];if(!d(m.sel)){r.selr[q.s]|=(m.sel<<q.smb);r.selr_mask[q.s]|=(3<<q.smb)}if(!d(m.mode)){r.modr[q.m]|=(m.mode<<q.smb);r.modr_mask[q.m]|=(3<<q.smb)}if(!d(m.od)){r.odr[q.o]|=(m.od<<q.ob);r.odr_mask[q.o]|=(1<<q.ob)}}var p="";for(var n=0;n<10;n++){if(r.selr_mask[n]!=0){p+=i.setBit(h._PINSEL[n],r.selr_mask[n],r.selr[n],0,k)}if(r.modr_mask[n]!=0){p+=i.setBit(h._PINMODE[n],r.modr_mask[n],r.modr[n],0,k)}}for(var n=0;n<5;n++){if(r.odr_mask[n]!=0){p+=i.setBit(h._PINMODE_OD[n],r.odr_mask[n],r.odr[n],0,k)}}return p}catch(o){throw new MiMicException(o)}},setOpts:function g(k){try{var l=new Array();var n=this.BCF_setOpts(k,l);if(n.length==0){throw new MiMicException("i_opt is empty or invalid.")}this._mcu.callMiMicWithCheck(n+i.END,l)}catch(m){throw new MiMicException(m)}return}};a.Pin=function b(k,l,n){try{if(d(l)){throw new MiMicException(j.INVALID_PIN)}this._port=new a.Port(k,[l],d(n)?undefined:[n])}catch(m){throw new MiMicException(m)}};a.Pin.prototype={_port:null,setOpt:function e(l){try{this._port.setOpts([l])}catch(k){throw new MiMicException(k)}return}}}());(function(){var a=LPCXpresso1769;var p=a._BCF;var q=a._EE;var d=MiMicLib.isUndef;var k=MiMicLib.cloneAssoc;a.Adc=function b(r,w){try{this._mcu=r;this._phl=new a.Peripheral(r,a.PHL.ADC);var t=d(w)?{phl:{}}:{phl:d(w.phl)?{}:k(w.phl),};if(d(t.phl.power)){t.phl.power=1}var v="";var s=new Array();v+=this.BCF_setOpt(t,s);v+=p.setMem(this._AD0CR,2098176,s);v+=p.setMem(this._AD0CR,2163712,s);this._mcu.callMiMicWithCheck(v+p.END,s);this._mcu.registerPhl(this,"ADC")}catch(u){throw new MiMicException(u)}};a.Adc.prototype={_PHL_DEF:{power:1},_AD0CR:1073954816,_AD0DR:[1073954832,1073954836,1073954840,1073954844,1073954848,1073954852,1073954856,1073954860],_phl:null,_mcu:null,BCF_setOpt:function m(u,r){try{var t="";if(!d(u.phl)){t+=this._phl.BCF_setOpt(u.phl,r)}return t}catch(s){throw new MiMicException(s)}},BCF_setSels:function j(t,s,r){try{return p.setBit(this._AD0CR,t,s*t,0,r)}catch(u){throw new MiMicException(u)}},BCF_getAD0DR:function l(s,r){try{return p.getMem(this._AD0DR[s],r)}catch(t){throw new MiMicException(t)}},setOpt:function h(u){try{var r=new Array();var t=this.BCF_setOpt(u,r);this._mcu.callMiMicWithCheck(t+p.END,r)}catch(s){throw new MiMicException(s)}},getPin:function n(r,t){try{return new a.AdcPin(this,r,t)}catch(s){throw new MiMicException(s)}},getPort:function c(r,t){try{return new a.AdcPort(this,r,t)}catch(s){throw new MiMicException(s)}}};function e(v){try{var t=a.completePinFunctionName(v,"AD");var s=t.substring(2).split(".");var u={port:0,ch:parseInt(s[1]),pin_sel:a.getPinSelByFunctionName(v,t)};if(!isNaN(u.ch)){return u}throw new MiMicException(q.INVALID_CFG,"The pin has not AD fuction.")}catch(w){throw new MiMicException(w)}}a.AdcPort=function o(s,r,x){try{this._adc=s;this._pins=new Array();for(var u=0;u<r.length;u++){this._pins.push(e(r[u]))}var w=this._pins[0].port;for(var u=1;u<this._pins.length;u++){if(w!=this._pins[1].port){throw new MiMicException("Invalid pin combination.")}}this._port=new a.Port(s._mcu,r);this._port_no=w;this._adcr_mask=0;for(var u=0;u<this._pins.length;u++){this._adcr_mask|=(1<<this._pins[u].ch)}var t=k(x);t.sel=1;if(d(t.pin)){t.pin={}}if(d(t.pin.sel)){t.pin.sel=this._PINSEL_AUTO_DETECT}this.setOpt(t)}catch(v){throw new MiMicException(v)}};a.AdcPort.prototype={_PINSEL_AUTO_DETECT:268435455,_adc:null,_pins:null,_port_no:0,_port:null,_adcr_mask:0,setOpt:function h(y){try{var r=new Array();var x="";if(!d(y.pin)){var v=new Array();for(var t=0;t<this._pins.length;t++){var u=(y.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[t].pin_sel:y.pin.sel;v.push({sel:u,mode:y.pin.mode,od:y.pin.od})}}x+=this._port.BCF_setOpts(v,r);x+=this._adc.BCF_setSels(this._adcr_mask,y.sel,r);this._adc._mcu.callMiMicWithCheck(x+p.END,r);return}catch(w){throw new MiMicException(w)}},getValues:function i(){try{var s=new Array();var x="";for(var u=0;u<this._pins.length;u++){x+=this._adc.BCF_getAD0DR(this._pins[u].ch,s)}var t=this._adc._mcu.callMiMicWithCheck(x+p.END,s);var v=new Array();for(var u=0;u<this._pins.length;u++){v.push((t.stream[u]>>4)&4095)}return v}catch(w){throw new MiMicException(w)}}};a.AdcPin=function f(r,s,u){try{this._aport=new a.AdcPort(r,[s],u)}catch(t){throw new MiMicException(t)}};a.AdcPin.prototype={_aport:null,getValue:function g(){try{return this._aport.getValues()[0]}catch(r){throw new MiMicException(r)}},setOpt:function h(s){try{this._aport.setOpt(s)}catch(r){throw new MiMicException(r)}}}}());(function(){var g=LPCXpresso1769;var o=g._BCF;var a=g._EE;var f=MiMicLib.isUndef;var m=MiMicLib.cloneAssoc;g.Gpio=function q(s,u){try{this._mcu=s;s.registerPhl(this,"GPIO")}catch(t){throw new MiMicException(t)}};g.Gpio.prototype={_FIO_DIR:[537509888,537509920,537509952,537509984,537510016],_FIO_PIN:[537509908,537509940,537509972,537510004,537510036],_FIO_SET:[537509912,537509944,537509976,537510008,537510040],_FIO_CLR:[537509916,537509948,537509980,537510012,537510044],_FIO_MASK:[537509904,537509936,537509968,537510000,537510032],_mcu:null,BCF_getValues:function k(t,u,s){try{s.push(this._FIO_PIN[t],this._FIO_MASK[t],~u);return"EA00EA01EA02DF0201DB0300EE03"}catch(v){throw new MiMicException(v)}},BCF_setValues:function h(u,v,t,s){try{s.push(this._FIO_PIN[u],this._FIO_MASK[u],~v,t);return"EA00EA01EA02EA03DF0201DF0300"}catch(w){throw new MiMicException(w)}},BCF_setDirs:function e(t,u,v,s){try{return o.setBit(this._FIO_DIR[t],u,u*v,0,s)}catch(w){throw new MiMicException(w)}},getPin:function p(s,u){try{return new g.GpioPin(this,s,u)}catch(t){throw new MiMicException(t)}},getPort:function r(s,u){try{return new g.GpioPort(this,s,u)}catch(t){throw new MiMicException(t)}}};function j(v){try{var t=g.completePinFunctionName(v,"GPIO");var s=t.substring(4).split(".");var u={port:parseInt(s[0]),bit:parseInt(s[1]),pin_sel:g.getPinSelByFunctionName(v,t)};if(!isNaN(u.port)&&!isNaN(u.bit)){return u}throw new MiMicException(a.INVALID_CFG,"The pin has not GPIO fuction.")}catch(w){throw new MiMicException(w)}}g.GpioPort=function n(v,s,y){try{this._gpio=v;this._pins=new Array();for(var u=0;u<s.length;u++){this._pins.push(j(s[u]))}var x=this._pins[0].port;for(var u=1;u<this._pins.length;u++){if(x!=this._pins[1].port){throw new MiMicException("Invalid pin combination.")}}this._port=new g.Port(v._mcu,s);this._port_no=x;this._mask=0;for(var u=0;u<this._pins.length;u++){this._mask|=(1<<this._pins[u].bit)}var t=m(y);if(f(t.pin)){t.pin={}}if(f(t.pin.sel)){t.pin.sel=this._PINSEL_AUTO_DETECT}this.setOpt(t)}catch(w){throw new MiMicException(w)}};g.GpioPort.prototype={_PINSEL_AUTO_DETECT:268435455,_pins:null,_gpio:null,_port_no:0,_port:null,_mask:0,setOpt:function b(z){try{var t=new Array();var y="";if(!f(z.dir)){y+=this._gpio.BCF_setDirs(this._port_no,this._mask,z.dir,t)}if(!f(z.pin)){var w=new Array();for(var u=0;u<this._pins.length;u++){var v=(z.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[u].pin_sel:z.pin.sel;w.push({sel:v,mode:z.pin.mode,od:z.pin.od})}}y+=this._port.BCF_setOpts(w,t);this._gpio._mcu.callMiMicWithCheck(y+o.END,t);return}catch(x){throw new MiMicException(x)}},setValue:function c(x){try{var w=0;var t=this._pins.length;for(var y=0;y<t;y++){var s=((x>>y)&1);w|=(s<<this._pins[y].bit)}var u=new Array();var A=this._gpio.BCF_setValues(this._port_no,this._mask,w,u);this._gpio._mcu.callMiMicWithCheck(A+o.END,u)}catch(z){throw new MiMicException(z)}},getValue:function d(){try{var w=new Array();var z=this._gpio.BCF_getValues(this._port_no,this._mask,w);var t=this._gpio._mcu.callMiMicWithCheck(z+o.END,w).stream[0];var u=0;for(var x=this._pins.length-1;x>=0;x--){var s=((t>>this._pins[x].bit)&1);u=(u<<1)|s}return u}catch(y){throw new MiMicException(y)}},outPatt:function i(w){try{var B=new Array();var y="";for(var s=0;s<w.length;s++){var z=0;var t=this._pins.length;for(var u=0;u<t;u++){var A=((w[s]>>u)&1);z|=(A<<this._pins[u].bit)}y+=this._gpio.BCF_setValues(this._port_no,this._mask,z,B)}this._gpio._mcu.callMiMicWithCheck(y+o.END,B)}catch(x){throw new MiMicException(x)}}};g.GpioPin=function l(s,t,v){try{this._gport=new g.GpioPort(s,[t],v)}catch(u){throw new MiMicException(u)}};g.GpioPin.prototype={_gport:null,setOpt:function b(t){try{this._gport.setOpt(t)}catch(s){throw new MiMicException(s)}},setValue:function c(s){try{this._gport.setValue(s)}catch(t){throw new MiMicException(t)}},getValue:function d(){try{return this._gport.getValue()}catch(s){throw new MiMicException(s)}},outPatt:function i(s){try{this._gport.outPatt(s)}catch(t){throw new MiMicException(t)}},}}());(function(){var f=LPCXpresso1769;var p=f._BCF;var a=f._EE;var d=MiMicLib.isUndef;var n=MiMicLib.cloneAssoc;f.Pwm=function j(u,z){try{this._mcu=u;this._phl=new f.Peripheral(u,f.PHL.PWM1);var w=d(z)?{phl:{}}:{phl:d(z.phl)?{}:n(z.phl),freq:z.freq};if(d(w.phl.power)){w.phl.power=1}if(d(w.phl.clock)){w.phl.clock=0}if(d(w.freq)){w.freq=100}var y="";var v=new Array();y+=this.BCF_setOpt(w,v);y+=p.setMem(this._PC,0,v);y+=p.setMem(this._PCR,0,v);y+=p.setMem(this._CTCR,0,v);y+=p.setMem(this._TCR,0,v);y+=p.setMem(this._TC,0,v);y+=p.setMem(this._TCR,9,v);this._mcu.callMiMicWithCheck(y+p.END,v);this._mcu.registerPhl(this,"PWM")}catch(x){throw new MiMicException(x)}};f.Pwm.prototype={_cache:{mr0:0},_TCR:1073840132,_TC:1073840136,_PR:1073840140,_PC:1073840144,_MCR:1073840152,_PCR:1073840204,_LER:1073840208,_CTCR:1073840240,_MRn:[1073840152,1073840156,1073840160,1073840164,1073840192,1073840196,1073840200],_phl:null,_mcu:null,BCF_setOpt:function m(z,u){try{var y="";var w;var v;if(!d(z.phl)){y+=this._phl.BCF_setOpt(z.phl,u)}if(!d(z.freq)){v=Math.round(this._phl.getPCLK()/z.freq);if(v<=0){throw new MiMicException("The peripheral clock too small.")}y+=this.BCF_setMRn(0,v,u);y+=this.BCF_setLER(0,u);this._cache.mr0=v}return y}catch(x){throw new MiMicException(x)}},BCF_setLER:function b(v,u){try{return p.setBit(this._LER,1,1,v,u)}catch(w){throw new MiMicException(w)}},BCF_setLERs:function l(w,v,u){try{return p.setBit(this._LER,w,v*w,0,u)}catch(x){throw new MiMicException(x)}},BCF_setMRn:function i(w,v,u){try{return p.setMem(this._MRn[w],v,u)}catch(x){throw new MiMicException(x)}},BCF_setMRnByDuty:function e(v,w,u){try{return this.BCF_setMRn(v,Math.round(w*this._cache.mr0),u)}catch(x){throw new MiMicException(x)}},BCF_setPCRbits:function g(B,x,y,w){try{var u,z;u=z=0;if(!d(x)){var A=255&B;z|=x*A;u|=A}if(!d(y)){var A=65280&B;z|=(y*A);u|=A}return p.setBit(this._PCR,u,z,0,w)}catch(C){throw new MiMicException(C)}},setOpt:function c(x){try{var u=new Array();var w=this.BCF_setOpt(x,u);this._mcu.callMiMicWithCheck(w+p.END,u)}catch(v){throw new MiMicException(v)}},getPin:function q(u,w){try{return new f.PwmPin(this,u,w)}catch(v){throw new MiMicException(v)}},getPort:function s(u,w){try{return new f.PwmPort(this,u,w)}catch(v){throw new MiMicException(v)}}};function h(x){try{var v=f.completePinFunctionName(x,"PWM");var u=v.substring(2).split(".");var w={port:0,ch:parseInt(u[1]),pin_sel:f.getPinSelByFunctionName(x,v)};if(!isNaN(w.ch)){return w}throw new MiMicException(a.INVALID_CFG,"The pin has not PWM fuction.")}catch(y){throw new MiMicException(y)}}f.PwmPort=function r(v,u,A){try{this._pwm=v;this._pins=new Array();for(var x=0;x<u.length;x++){this._pins.push(h(u[x]))}var z=this._pins[0].port;for(var x=1;x<this._pins.length;x++){if(z!=this._pins[1].port){throw new MiMicException("Invalid pin combination.")}}this._port=new f.Port(v._mcu,u);this._port_no=z;this._ler_mask=0;this._pcr_mask=0;for(var x=0;x<this._pins.length;x++){this._ler_mask|=(1<<this._pins[x].ch);this._pcr_mask|=(257<<this._pins[x].ch)}var w=d(A)?{pin:{}}:{pin:d(A.pin)?{}:n(A.pin),duty:A.duty,enable:A.enable};if(d(w.pin.sel)){w.pin.sel=this._PINSEL_AUTO_DETECT}if(d(w.duty)){w.duty=0}if(d(w.enable)){w.enable=1}this.setOpt(w)}catch(y){throw new MiMicException(y)}};f.PwmPort.prototype={_PINSEL_AUTO_DETECT:268435455,_pwm:null,_pins:null,_port_no:0,_port:null,_pcr_mask:0,_ler_mask:0,setOpt:function c(A){try{var u=new Array();var z="";if(!d(A.pin)){var x=new Array();for(var v=0;v<this._pins.length;v++){var w=(A.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[v].pin_sel:A.pin.sel;x.push({sel:w,mode:A.pin.mode,od:A.pin.od})}}z+=this._port.BCF_setOpts(x,u);if(!d(A.enable)){z+=this._pwm.BCF_setPCRbits(this._pcr_mask,0,A.enable,u)}if(!d(A.duty)){for(var v=0;v<this._pins.length;v++){z+=this._pwm.BCF_setMRnByDuty(this._pins[v].ch,A.duty,u)}z+=this._pwm.BCF_setLERs(this._ler_mask,1,u)}this._pwm._mcu.callMiMicWithCheck(z+p.END,u);return}catch(y){throw new MiMicException(y)}},setDutys:function k(y){try{if(y.length!=this._pins.length){throw new MiMicException(w)}var x="";var u=new Array();for(var v=0;v<this._pins.length;v++){if(!d(y[v])){x+=this._pwm.BCF_setMRnByDuty(this._pins[v].ch,y[v],u)}}x+=this._pwm.BCF_setLERs(this._ler_mask,1,u);this._pwm._mcu.callMiMicWithCheck(x+p.END,u)}catch(w){throw new MiMicException(w)}}};f.PwmPin=function t(u,v,x){try{this._pport=new f.PwmPort(u,[v],x)}catch(w){throw new MiMicException(w)}};f.PwmPin.prototype={_pport:null,setOpt:function c(v){try{this._pport.setOpt(v)}catch(u){throw new MiMicException(u)}},setDuty:function o(u){try{this._pport.setDuty([u])}catch(v){throw new MiMicException(v)}}}}());(function(){var f=LPCXpresso1769;var e=f._BCF;var a=f._EE;var d=MiMicLib.isUndef;f.Ni=function c(g){try{this._mcu=g}catch(h){throw new MiMicException(h)}};f.Ni.prototype={call:function b(j,q,p){var n="";var r=new Array();if(!d(q)){for(var l=0;l<8;l++){var k="wm"+l;if(!d(q[k])){n+="FB"+MiMicLib.hexout(l,2)+MiMicLib.hexout(q[k],8)}}if(!d(q.stream)){for(var l=0;l<q.stream.length;l++){r.push(q.stream[l])}}}n+="ZF"+MiMicLib.hexout(j,8);var g=0;if(!d(p)){for(var l=0;l<8;l++){if(!d(p["wm"+l])){n+="EE"+MiMicLib.hexout(l,2);g++}}}var m=this._mcu.callMiMic(n+e.END,r);if(m.result!=0){return false}var o=0;if(!d(p)){var h=m.stream.length-g;for(var l=0;l<8;l++){var k="wm"+l;if(!d(p[k])){p[k]=m.stream[h];h++}}if(!d(p.stream)){p.stream=m.stream.slice(0,m.stream.length-g)}}return false}}}());
\ No newline at end of file
index 8f40b7a..5182412 100644 (file)
@@ -958,6 +958,13 @@ var DEV=LPCXpresso1769;
 var BCF=DEV._BCF;\r
 var EE=DEV._EE;\r
 var isUndef=MiMicLib.isUndef;\r
+\r
+function checkAlign(v){\r
+       if(v%4!=0){\r
+               throw new MiMicException(EE.INVALID_ARG,"An alignment is not 32bit unit.");\r
+       }\r
+}\r
+\r
 /**\r
  * LPCXPresso1769.Memory (Memory)クラスのコンストラクタ。\r
  * Memoryクラスは、MCUのメモリ空間へアクセスする手段を提供する。\r
@@ -1040,11 +1047,6 @@ DEV.Memory.prototype=
        read32:function read32(/*arguments*/)\r
        {\r
                try{\r
-                       function checkAlign(v){\r
-                               if(v%4!=0){\r
-                                       throw new MiMicException(EE.INVALID_ARG,"An alignment is not 32bit unit.");\r
-                               }\r
-                       }\r
                        var bc="";\r
                        var ar=new Array();\r
                        var offset=arguments[0];\r
@@ -1081,7 +1083,50 @@ DEV.Memory.prototype=
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
-       }\r
+       },\r
+       write32:function write32(/*arguments*/)\r
+       {\r
+               try{\r
+                       var bc="";\r
+                       var ar=new Array();\r
+                       var offset=arguments[0];\r
+                       switch(arguments.length){\r
+                       case 2:\r
+                               if((!isNaN(offset))){\r
+                                       if(!isNaN(arguments[1])){\r
+                                               //write32(i_offset:int,i_value:int)\r
+                                               checkAlign(offset);\r
+                                               bc+=BCF.setMem(this._base+offset,arguments[1],ar);\r
+                                       }else if(arguments[1].length>0){\r
+                                               //read32(i_offset:int,i_value:array)\r
+                                               checkAlign(offset);\r
+                                               var l=arguments[1].length;\r
+                                               for(var i=0;i<l;i++){\r
+                                                       bc+=BCF.setMem(this._base+offset+i*4,arguments[1][i],ar);\r
+                                               }\r
+                                       }else{\r
+                                               throw new MiMicException();\r
+                                       }\r
+                               }else if(offset.length==arguments[1].length){\r
+                                       //write32(i_offsets:array,i_value:array)\r
+                                       for(var i=0;i<offset.length;i++){\r
+                                               checkAlign(offset[i]);\r
+                                               bc+=BCF.setMem(this._base+offset[i],arguments[1][i],ar);\r
+                                               \r
+                                       }\r
+                               }else{\r
+                                       throw new MiMicException();\r
+                               }\r
+                               break;\r
+                       default:\r
+                               break;\r
+                       }\r
+                       this._mcu.callMiMicWithCheck(bc+BCF.END,ar).stream;\r
+                       return;\r
+               }catch(e){\r
+                       throw new MiMicException(e);\r
+               }\r
+       }       \r
 }\r
 \r
 }());/**\r
index b5cccbd..1922adb 100644 (file)
@@ -7,6 +7,13 @@ var DEV=LPCXpresso1769;
 var BCF=DEV._BCF;\r
 var EE=DEV._EE;\r
 var isUndef=MiMicLib.isUndef;\r
+\r
+function checkAlign(v){\r
+       if(v%4!=0){\r
+               throw new MiMicException(EE.INVALID_ARG,"An alignment is not 32bit unit.");\r
+       }\r
+}\r
+\r
 /**\r
  * LPCXPresso1769.Memory (Memory)クラスのコンストラクタ。\r
  * Memoryクラスは、MCUのメモリ空間へアクセスする手段を提供する。\r
@@ -77,7 +84,7 @@ DEV.Memory.prototype=
         */\r
        /**\r
         * メモリから値を読み出して、値セットの配列、又は値を返す。\r
-        * 関数はバイト単位のアライメントでメモリにアクセスする。メモリアドレス、取得サイズは4バイト境界に一致させなければならない。\r
+        * 関数は4バイト単位のアライメントでメモリにアクセスする。メモリアドレス、取得サイズは4バイト境界に一致させなければならない。\r
         * 引数の違いにより、数種類の呼び出し方がある。\r
         * @name LPCXpresso1769.Memory#read32^1\r
         * @function\r
@@ -89,11 +96,6 @@ DEV.Memory.prototype=
        read32:function read32(/*arguments*/)\r
        {\r
                try{\r
-                       function checkAlign(v){\r
-                               if(v%4!=0){\r
-                                       throw new MiMicException(EE.INVALID_ARG,"An alignment is not 32bit unit.");\r
-                               }\r
-                       }\r
                        var bc="";\r
                        var ar=new Array();\r
                        var offset=arguments[0];\r
@@ -130,7 +132,99 @@ DEV.Memory.prototype=
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
-       }\r
+       },\r
+       /**\r
+        * 指定したアドレスに32ビット値を書き込む。\r
+        * @name LPCXpresso1769.Memory#write32^2\r
+        * @function\r
+        * @param {int} i_offset\r
+        * コンストラクタで指定したアドレスからのオフセット位置を指定する。4バイト境界でなければならない。\r
+        * @param {int} i_value\r
+        * 1個のint値。\r
+        * @example\r
+        * var mcu=new LPCXpresso1769.Mcu("192.168.0.39");\r
+        * var mem=new LPCXpresso1769.Memory(mcu); //create instance\r
+        * mem.write32(0x20080000,139);\r
+        */\r
+       /**\r
+        * 指定したオフセットから、n個の32bit値を書き込む。シーケンシャルアクセスに使用する。\r
+        * @name LPCXpresso1769.Memory#write32^3\r
+        * @function\r
+        * @param {int} i_offset\r
+        * コンストラクタで指定したアドレスからのオフセット位置を指定する。4バイト境界でなければならない。\r
+        * @param {array[int]} i_values\r
+        * 書きこむバイト数を指定する。4バイト単位でなければならない。      \r
+        * @example\r
+        * var mcu=new LPCXpresso1769.Mcu("192.168.0.39");\r
+        * var mem=new LPCXpresso1769.Memory(mcu); //create instance\r
+        * mem.write32(0x20080008,[439,539,639]);\r
+        */\r
+       /**\r
+        * オフセットの配列要素に対応した値を、それぞれ32ビット単位で書きこむ。\r
+        * ランダムアクセスに使用する。\r
+        * @name LPCXpresso1769.Memory#write32^4\r
+        * @function\r
+        * @param {array[int]} i_offsets\r
+        * オフセットアドレスの配列。それぞれ4バイト境界でなければならない。\r
+        * @param {array[int]} i_values\r
+        * セットする値。個数は、i_offsetsと一致していなければならない。\r
+        * @example\r
+        * var mcu=new LPCXpresso1769.Mcu("192.168.0.39");\r
+        * var mem=new LPCXpresso1769.Memory(mcu); //create instance\r
+        * mem.write32([0x20080020,0x20080024],[239,339]);\r
+        */\r
+       /**\r
+        * メモリアドレスを指定して、値を書き込む。
+        * 関数は4バイト単位のアライメントでメモリにアクセスする。メモリアドレス、取得サイズは4バイト境界に一致させなければならない。\r
+        * 引数の違いにより、数種類の呼び出し方がある。\r
+        * @name LPCXpresso1769.Memory#write32^1\r
+        * @function\r
+        * @param ...\r
+        * 詳細は、write32^nを参照。\r
+        */\r
+       write32:function write32(/*arguments*/)\r
+       {\r
+               try{\r
+                       var bc="";\r
+                       var ar=new Array();\r
+                       var offset=arguments[0];\r
+                       switch(arguments.length){\r
+                       case 2:\r
+                               if((!isNaN(offset))){\r
+                                       if(!isNaN(arguments[1])){\r
+                                               //write32(i_offset:int,i_value:int)\r
+                                               checkAlign(offset);\r
+                                               bc+=BCF.setMem(this._base+offset,arguments[1],ar);\r
+                                       }else if(arguments[1].length>0){\r
+                                               //read32(i_offset:int,i_value:array)\r
+                                               checkAlign(offset);\r
+                                               var l=arguments[1].length;\r
+                                               for(var i=0;i<l;i++){\r
+                                                       bc+=BCF.setMem(this._base+offset+i*4,arguments[1][i],ar);\r
+                                               }\r
+                                       }else{\r
+                                               throw new MiMicException();\r
+                                       }\r
+                               }else if(offset.length==arguments[1].length){\r
+                                       //write32(i_offsets:array,i_value:array)\r
+                                       for(var i=0;i<offset.length;i++){\r
+                                               checkAlign(offset[i]);\r
+                                               bc+=BCF.setMem(this._base+offset[i],arguments[1][i],ar);\r
+                                               \r
+                                       }\r
+                               }else{\r
+                                       throw new MiMicException();\r
+                               }\r
+                               break;\r
+                       default:\r
+                               break;\r
+                       }\r
+                       this._mcu.callMiMicWithCheck(bc+BCF.END,ar).stream;\r
+                       return;\r
+               }catch(e){\r
+                       throw new MiMicException(e);\r
+               }\r
+       }       \r
 }\r
 \r
 }());
\ No newline at end of file
diff --git a/misc/MiMicVM/api.js/demo/memory_access.html b/misc/MiMicVM/api.js/demo/memory_access.html
new file mode 100644 (file)
index 0000000..5431581
--- /dev/null
@@ -0,0 +1,23 @@
+<head>\r
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
+<script src="../MiMicCore.js"></script>        \r
+<script src="../LPCXPresso1769.All.js"></script>       \r
+<script type="text/javascript">\r
+function init(){\r
+       var mcu=new LPCXpresso1769.Mcu("192.168.128.39");\r
+       var ma=new LPCXpresso1769.Memory(mcu);\r
+       ma.write32(0x20080000,139);\r
+       ma.write32([0x20080020,0x20080024],[239,339]);\r
+       ma.write32(0x20080008,[439,539,639]);\r
+       alert(ma.read32(0x20080000));\r
+       alert(ma.read32(0x20080020,8));\r
+       alert(ma.read32([0x20080008,0x20080010,0x2008000c]));\r
+}      \r
+</script>\r
+</head>\r
+<body onload="init();">\r
+<h1>Memory read/write</h1>\r
+<div>\r
+       This program is sample program for reading/writing the memory(0x20080000). Please edit IP address of this program before test.\r
+</div>\r
+</body>\r
diff --git a/misc/MiMicVM/api.js/demo/pwm_port.html b/misc/MiMicVM/api.js/demo/pwm_port.html
new file mode 100644 (file)
index 0000000..ee69745
--- /dev/null
@@ -0,0 +1,32 @@
+<head>\r
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
+<script src="../MiMicCore.js"></script>        \r
+<script src="../LPCXPresso1769.All.js"></script>       \r
+<script type="text/javascript">\r
+\r
+\r
+function init(){\r
+       var mcu=new LPCXpresso1769.Mcu("192.168.128.39");\r
+       var port=mcu.getPeripheral("PWM").getPort(\r
+               [LPCXpresso1769.P2[0],LPCXpresso1769.P2[1]]\r
+               );\r
+       var i=0;\r
+       setInterval(function(){\r
+               i++;\r
+               var r=(Math.sin(i/30*3.14)+1)/8+0.05;//0.05-0.30\r
+               var r2=(Math.sin((i+90)/30*3.14)+1)/8+0.05;//0.05-0.30\r
+               document.getElementById("gage").innerHTML=r;\r
+               v=port.setDutys([r,r2]);\r
+       },50);\r
+}      \r
+</script>\r
+</head>\r
+<body id="body" onload="init();">\r
+<h1>MiMic PWM sample</h1>\r
+<hr/>\r
+This sample controls two PWM pins (P2[0],P2[1]) at 100Hz.\r
+<div id="gage">-</div>\r
+MiMic Copyright (C) 2011 nyatla.jp All Rights Reserved.<br/>\r
+<a href="http://nyatla.jp/mimic/wp">http://nyatla.jp/mimic/wp</a>\r
+</div>\r
+</body>
\ No newline at end of file