OSDN Git Service

git-svn-id: http://svn.osdn.jp/svnroot/mimic/trunk@100 47198e57-cb75-475f-84c4-a814cd...
authornyatla <nyatla@47198e57-cb75-475f-84c4-a814cd6f29e0>
Tue, 15 Nov 2011 10:59:15 +0000 (10:59 +0000)
committernyatla <nyatla@47198e57-cb75-475f-84c4-a814cd6f29e0>
Tue, 15 Nov 2011 10:59:15 +0000 (10:59 +0000)
misc/MiMicVM/api.js/LPCXPresso1769.All-mini.js
misc/MiMicVM/api.js/LPCXPresso1769.All.js
misc/MiMicVM/api.js/LPCXpresso1769.Mcu.js
misc/MiMicVM/api.js/LPCXpresso1769.Ni.js [new file with mode: 0644]
misc/MiMicVM/api.js/MiMicCore.js
misc/MiMicVM/api.js/demo/naitive_call.html [new file with mode: 0644]
misc/MiMicVM/api.js/make_LPCXpresso1769_all.bat
misc/MiMicVM/api.js/test.html

index 3f38a5b..e86b815 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(w){try{var y=["0000000","000000","00000","0000","000","00","0",""];var A="";for(var u=0;u<w.length;u++){var t=(w[u]>>>0);var x=t.toString(16).toLowerCase();if(x.length<1||x.length>8){throw new MiMicException(a.NG)}A+=y[x.length-1]+x}return A}catch(z){throw new MiMicException(z)}}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){throw new MiMicException("Not implemented.")},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 g=LPCXpresso1769;var e=g._BCF;var c=g._EE;var d=MiMicLib.isUndef;g.Pin=function f(h,i,k){try{if(d(i)){throw new MiMicException(c.INVALID_PIN)}this._mcu=h;this._pininfo=g.getPinRegInfo(i);if(!d(k)){this.setOpt(k)}}catch(j){throw new MiMicException(j)}};g.Pin.prototype={_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],_pininfo:null,_mcu:null,BCF_setOpt:function a(k,h){try{var j="";if(!d(k.sel)){j+=e.setBit(this._PINSEL[this._pininfo.s],3,k.sel,this._pininfo.smb,h)}if(!d(k.mode)){if(this._pininfo.m==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PINMODE. pininfo.")}j+=e.setBit(this._PINMODE[this._pininfo.m],3,k.mode,this._pininfo.smb,h)}if(!d(k.od)){if(this._pininfo.o==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PINMODE_OD. pininfo.")}j+=e.setBit(this._PINMODE_OD[this._pininfo.o],1,k.od,this._pininfo.ob,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+e.END,h)}catch(i){throw new MiMicException(i)}return}}}());(function(){var a=LPCXpresso1769;var k=a._BCF;var l=a._EE;var c=MiMicLib.isUndef;a.Adc=function b(m,r){try{this._mcu=m;this._phl=new a.Peripheral(m,a.PHL.ADC);var o=c(r)?{phl:{}}:{phl:c(r.phl)?{}:cloneAssoc(r.phl),};if(c(o.phl.power)){o.phl.power=1}var q="";var n=new Array();q+=this.BCF_setOpt(o,n);q+=k.setMem(this._AD0CR,2098176,n);q+=k.setMem(this._AD0CR,2163712,n);this._mcu.callMiMicWithCheck(q+k.END,n);this._mcu.registerPhl(this,"ADC")}catch(p){throw new MiMicException(p)}};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 h(p,m){try{var o="";if(!c(p.phl)){o+=this._phl.BCF_setOpt(p.phl,m)}return o}catch(n){throw new MiMicException(n)}},BCF_setSel:function i(o,n,m){try{return k.setBit(this._AD0CR,1,n,o,m)}catch(p){throw new MiMicException(p)}},BCF_getAD0DR:function g(n,m){try{return k.getMem(this._AD0DR[n],m)}catch(o){throw new MiMicException(o)}},setOpt:function f(p){try{var m=new Array();var o=this.BCF_setOpt(p,m);this._mcu.callMiMicWithCheck(o+k.END,m)}catch(n){throw new MiMicException(n)}},getPin:function j(m,o){try{return new a.AdcPin(this,m,o)}catch(n){throw new MiMicException(n)}}};a.AdcPin=function d(m,o,q){try{this._adc=m;this._pin=new a.Pin(m._mcu,o);this._adinfo=function(v){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(l.INVALID_CFG,"The pin has not AD fuction.")}(o);var n=c(q)?{pin:{}}:{pin:c(q.pin)?{}:cloneAssoc(q.pin)};n.sel=1;if(c(n.pin.sel)){n.pin.sel=this._adinfo.pin_sel}this.setOpt(n)}catch(p){throw new MiMicException(p)}};a.AdcPin.prototype={_adc:null,_pin:null,_adinfo:null,getValue:function e(){try{var m=new Array();var p=this._adc.BCF_getAD0DR(this._adinfo.ch,m);var n=this._adc._mcu.callMiMicWithCheck(p+k.END,m);return(n.stream[0]>>4)&4095}catch(o){throw new MiMicException(o)}},setOpt:function f(p){try{var o="";var m=new Array();if(!c(p.pin)){o+=this._pin.BCF_setOpt(p.pin,m)}if(!c(p.sel)){o+=this._adc.BCF_setSel(this._adinfo.ch,p.sel,m)}this._adc._mcu.callMiMicWithCheck(o+k.END,m);return}catch(n){throw new MiMicException(n)}}}}());(function(){var a=LPCXpresso1769;var n=a._BCF;var o=a._EE;var c=MiMicLib.isUndef;var h=MiMicLib.cloneAssoc;a.Gpio=function i(p,r){try{this._mcu=p;p.registerPhl(this,"GPIO")}catch(q){throw new MiMicException(q)}};a.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_setDir:function k(r,q,s,p){try{return n.setBit(this._FIO_DIR[r],1,s,q,p)}catch(t){throw new MiMicException(t)}},BCF_setValue:function b(s,r,q,p){try{if(q){p.push(this._FIO_SET[s],this._FIO_MASK[s],~(1<<r))}else{p.push(this._FIO_CLR[s],this._FIO_MASK[s],~(1<<r))}return"EA00EA01EA02DF0201FB02ffffffffDF0200"}catch(t){throw new MiMicException(t)}},BCF_getValue:function d(r,q,p){try{p.push(this._FIO_PIN[r],this._FIO_MASK[r],~(1<<q));return"EA00EA01EA02DF0201DB0300EE03"}catch(s){throw new MiMicException(s)}},getPin:function j(p,r){try{return new a.GpioPin(this,p,r)}catch(q){throw new MiMicException(q)}}};a.GpioPin=function l(q,r,t){try{this._gpio=q;this._pin=new a.Pin(q._mcu,r);this._gpioinfo=function(x){var v=a.completePinFunctionName(x,"GPIO");var u=v.substring(4).split(".");var w={port:parseInt(u[0]),bit:parseInt(u[1]),pin_sel:a.getPinSelByFunctionName(x,v)};if(!isNaN(w.port)&&!isNaN(w.bit)){return w}throw new MiMicException(o.INVALID_CFG,"The pin has not GPIO fuction.")}(r);var p=c(t)?{pin:{}}:{dir:t.dir,pin:c(t.pin)?{}:h(t.pin)};if(c(p.pin.sel)){p.pin.sel=this._gpioinfo.pin_sel}this.setOpt(p)}catch(s){throw new MiMicException(s)}};a.GpioPin.prototype={_gpio:null,_pin:null,_gpioinfo:null,setOpt:function g(s){try{var r="";var p=new Array();if(!c(s.dir)){r+=this._gpio.BCF_setDir(this._gpioinfo.port,this._gpioinfo.bit,s.dir,p)}if(!c(s.pin)){r+=this._pin.BCF_setOpt(s.pin,p)}this._gpio._mcu.callMiMicWithCheck(r+n.END,p)}catch(q){throw new MiMicException(q)}},setValue:function e(q){try{var s="";var p=new Array();s+=this._gpio.BCF_setValue(this._gpioinfo.port,this._gpioinfo.bit,q,p);this._gpio._mcu.callMiMicWithCheck(s+n.END,p)}catch(r){throw new MiMicException(r)}},getValue:function f(){try{var s="";var p=new Array();s+=this._gpio.BCF_getValue(this._gpioinfo.port,this._gpioinfo.bit,p);var q=this._gpio._mcu.callMiMicWithCheck(s+n.END,p);return(q.stream[0]>>this._gpioinfo.bit)&1}catch(r){throw new MiMicException(r)}},outPatt:function m(q){try{var t="";var p=new Array();for(var r=0;r<q.length;r++){t+=this._gpio.BCF_setValue(this._gpioinfo.port,this._gpioinfo.bit,q[r],p)}this._gpio._mcu.callMiMicWithCheck(t+n.END,p)}catch(s){throw new MiMicException(s)}},}}());(function(){var a=LPCXpresso1769;var n=a._BCF;var o=a._EE;var b=MiMicLib.isUndef;var g=MiMicLib.cloneAssoc;a.Pwm=function d(p,u){try{this._mcu=p;this._phl=new a.Peripheral(p,a.PHL.PWM1);var r=b(u)?{phl:{}}:{phl:b(u.phl)?{}:g(u.phl),freq:u.freq};if(b(r.phl.power)){r.phl.power=1}if(b(r.phl.clock)){r.phl.clock=0}if(b(r.freq)){r.freq=100}var t="";var q=new Array();t+=this.BCF_setOpt(r,q);t+=n.setMem(this._PC,0,q);t+=n.setMem(this._PCR,0,q);t+=n.setMem(this._CTCR,0,q);t+=n.setMem(this._TCR,0,q);t+=n.setMem(this._TC,0,q);t+=n.setMem(this._TCR,9,q);this._mcu.callMiMicWithCheck(t+n.END,q);this._mcu.registerPhl(this,"PWM")}catch(s){throw new MiMicException(s)}};a.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 h(u,p){try{var t="";var r;var q;if(!b(u.phl)){t+=this._phl.BCF_setOpt(u.phl,p)}if(!b(u.freq)){q=Math.round(this._phl.getPCLK()/u.freq);if(q<=0){throw new MiMicException("The peripheral clock too small.")}t+=this.BCF_setMRn(0,q,p);t+=this.BCF_setLER(0,p);this._cache.mr0=q}return t}catch(s){throw new MiMicException(s)}},BCF_setLER:function e(q,p){return n.setBit(this._LER,1,1,q,p)},BCF_setMRn:function j(r,q,p){try{return n.setMem(this._MRn[r],q,p)}catch(s){throw new MiMicException(s)}},BCF_setMRnByDuty:function m(q,r,p){try{return this.BCF_setMRn(q,Math.round(r*this._cache.mr0),p)}catch(s){throw new MiMicException(s)}},BCF_setPCRbit:function l(u,r,s,q){try{var p,t;p=t=0;if(!b(r)){t|=r;p|=1}if(!b(s)){t|=(s<<8);p|=256}return n.setBit(this._PCR,p,t,u,q)}catch(w){throw new MiMicException(w)}},setOpt:function f(s){try{var p=new Array();var r=this.BCF_setOpt(s,p);this._mcu.callMiMicWithCheck(r+n.END,p)}catch(q){throw new MiMicException(q)}},getPin:function i(p,r){try{return new a.PwmPin(this,p,r)}catch(q){throw new MiMicException(q)}}};a.PwmPin=function k(p,r,t){try{this._pwm=p;this._pin=new a.Pin(p._mcu,r);this._pwminfo=function(x){var v=a.completePinFunctionName(x,"PWM");var u=v.substring(2).split(".");var w={port:0,ch:parseInt(u[1]),pin_sel:a.getPinSelByFunctionName(x,v)};if(!isNaN(w.ch)){return w}throw new MiMicException(o.INVALID_CFG,"The pin has not PWM fuction.")}(r);var q=b(t)?{pin:{}}:{pin:b(t.pin)?{}:g(t.pin),duty:t.duty,enable:t.enable};if(b(q.pin.sel)){q.pin.sel=this._pwminfo.pin_sel}if(b(q.duty)){q.duty=0}if(b(q.enable)){q.enable=1}this.setOpt(q)}catch(s){throw new MiMicException(s)}};a.PwmPin.prototype={_pwm:null,_pin:null,_pwminfo:null,BCF_setOpt:function h(s,p){try{var r="";if(!b(s.pin)){r+=this._pin.BCF_setOpt(s.pin,p)}if(!b(s.enable)){r+=this._pwm.BCF_setPCRbit(this._pwminfo.ch,0,s.enable,p)}if(!b(s.duty)){r+=this._pwm.BCF_setMRnByDuty(this._pwminfo.ch,s.duty,p);r+=this._pwm.BCF_setLER(this._pwminfo.ch,p)}return r}catch(q){throw new MiMicException(q)}},setOpt:function f(s){try{var p=new Array();var r=this.BCF_setOpt(s,p);this._pwm._mcu.callMiMicWithCheck(r+n.END,p)}catch(q){throw new MiMicException(q)}},setDuty:function c(p){try{this.setOpt({duty:p})}catch(q){throw new MiMicException(q)}}}}());
\ 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){throw new MiMicException("Not implemented.")},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 g=LPCXpresso1769;var e=g._BCF;var c=g._EE;var d=MiMicLib.isUndef;g.Pin=function f(h,i,k){try{if(d(i)){throw new MiMicException(c.INVALID_PIN)}this._mcu=h;this._pininfo=g.getPinRegInfo(i);if(!d(k)){this.setOpt(k)}}catch(j){throw new MiMicException(j)}};g.Pin.prototype={_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],_pininfo:null,_mcu:null,BCF_setOpt:function a(k,h){try{var j="";if(!d(k.sel)){j+=e.setBit(this._PINSEL[this._pininfo.s],3,k.sel,this._pininfo.smb,h)}if(!d(k.mode)){if(this._pininfo.m==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PINMODE. pininfo.")}j+=e.setBit(this._PINMODE[this._pininfo.m],3,k.mode,this._pininfo.smb,h)}if(!d(k.od)){if(this._pininfo.o==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PINMODE_OD. pininfo.")}j+=e.setBit(this._PINMODE_OD[this._pininfo.o],1,k.od,this._pininfo.ob,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+e.END,h)}catch(i){throw new MiMicException(i)}return}}}());(function(){var a=LPCXpresso1769;var k=a._BCF;var l=a._EE;var c=MiMicLib.isUndef;a.Adc=function b(m,r){try{this._mcu=m;this._phl=new a.Peripheral(m,a.PHL.ADC);var o=c(r)?{phl:{}}:{phl:c(r.phl)?{}:cloneAssoc(r.phl),};if(c(o.phl.power)){o.phl.power=1}var q="";var n=new Array();q+=this.BCF_setOpt(o,n);q+=k.setMem(this._AD0CR,2098176,n);q+=k.setMem(this._AD0CR,2163712,n);this._mcu.callMiMicWithCheck(q+k.END,n);this._mcu.registerPhl(this,"ADC")}catch(p){throw new MiMicException(p)}};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 h(p,m){try{var o="";if(!c(p.phl)){o+=this._phl.BCF_setOpt(p.phl,m)}return o}catch(n){throw new MiMicException(n)}},BCF_setSel:function i(o,n,m){try{return k.setBit(this._AD0CR,1,n,o,m)}catch(p){throw new MiMicException(p)}},BCF_getAD0DR:function g(n,m){try{return k.getMem(this._AD0DR[n],m)}catch(o){throw new MiMicException(o)}},setOpt:function f(p){try{var m=new Array();var o=this.BCF_setOpt(p,m);this._mcu.callMiMicWithCheck(o+k.END,m)}catch(n){throw new MiMicException(n)}},getPin:function j(m,o){try{return new a.AdcPin(this,m,o)}catch(n){throw new MiMicException(n)}}};a.AdcPin=function d(m,o,q){try{this._adc=m;this._pin=new a.Pin(m._mcu,o);this._adinfo=function(v){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(l.INVALID_CFG,"The pin has not AD fuction.")}(o);var n=c(q)?{pin:{}}:{pin:c(q.pin)?{}:cloneAssoc(q.pin)};n.sel=1;if(c(n.pin.sel)){n.pin.sel=this._adinfo.pin_sel}this.setOpt(n)}catch(p){throw new MiMicException(p)}};a.AdcPin.prototype={_adc:null,_pin:null,_adinfo:null,getValue:function e(){try{var m=new Array();var p=this._adc.BCF_getAD0DR(this._adinfo.ch,m);var n=this._adc._mcu.callMiMicWithCheck(p+k.END,m);return(n.stream[0]>>4)&4095}catch(o){throw new MiMicException(o)}},setOpt:function f(p){try{var o="";var m=new Array();if(!c(p.pin)){o+=this._pin.BCF_setOpt(p.pin,m)}if(!c(p.sel)){o+=this._adc.BCF_setSel(this._adinfo.ch,p.sel,m)}this._adc._mcu.callMiMicWithCheck(o+k.END,m);return}catch(n){throw new MiMicException(n)}}}}());(function(){var a=LPCXpresso1769;var n=a._BCF;var o=a._EE;var c=MiMicLib.isUndef;var h=MiMicLib.cloneAssoc;a.Gpio=function i(p,r){try{this._mcu=p;p.registerPhl(this,"GPIO")}catch(q){throw new MiMicException(q)}};a.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_setDir:function k(r,q,s,p){try{return n.setBit(this._FIO_DIR[r],1,s,q,p)}catch(t){throw new MiMicException(t)}},BCF_setValue:function b(s,r,q,p){try{if(q){p.push(this._FIO_SET[s],this._FIO_MASK[s],~(1<<r))}else{p.push(this._FIO_CLR[s],this._FIO_MASK[s],~(1<<r))}return"EA00EA01EA02DF0201FB02ffffffffDF0200"}catch(t){throw new MiMicException(t)}},BCF_getValue:function d(r,q,p){try{p.push(this._FIO_PIN[r],this._FIO_MASK[r],~(1<<q));return"EA00EA01EA02DF0201DB0300EE03"}catch(s){throw new MiMicException(s)}},getPin:function j(p,r){try{return new a.GpioPin(this,p,r)}catch(q){throw new MiMicException(q)}}};a.GpioPin=function l(q,r,t){try{this._gpio=q;this._pin=new a.Pin(q._mcu,r);this._gpioinfo=function(x){var v=a.completePinFunctionName(x,"GPIO");var u=v.substring(4).split(".");var w={port:parseInt(u[0]),bit:parseInt(u[1]),pin_sel:a.getPinSelByFunctionName(x,v)};if(!isNaN(w.port)&&!isNaN(w.bit)){return w}throw new MiMicException(o.INVALID_CFG,"The pin has not GPIO fuction.")}(r);var p=c(t)?{pin:{}}:{dir:t.dir,pin:c(t.pin)?{}:h(t.pin)};if(c(p.pin.sel)){p.pin.sel=this._gpioinfo.pin_sel}this.setOpt(p)}catch(s){throw new MiMicException(s)}};a.GpioPin.prototype={_gpio:null,_pin:null,_gpioinfo:null,setOpt:function g(s){try{var r="";var p=new Array();if(!c(s.dir)){r+=this._gpio.BCF_setDir(this._gpioinfo.port,this._gpioinfo.bit,s.dir,p)}if(!c(s.pin)){r+=this._pin.BCF_setOpt(s.pin,p)}this._gpio._mcu.callMiMicWithCheck(r+n.END,p)}catch(q){throw new MiMicException(q)}},setValue:function e(q){try{var s="";var p=new Array();s+=this._gpio.BCF_setValue(this._gpioinfo.port,this._gpioinfo.bit,q,p);this._gpio._mcu.callMiMicWithCheck(s+n.END,p)}catch(r){throw new MiMicException(r)}},getValue:function f(){try{var s="";var p=new Array();s+=this._gpio.BCF_getValue(this._gpioinfo.port,this._gpioinfo.bit,p);var q=this._gpio._mcu.callMiMicWithCheck(s+n.END,p);return(q.stream[0]>>this._gpioinfo.bit)&1}catch(r){throw new MiMicException(r)}},outPatt:function m(q){try{var t="";var p=new Array();for(var r=0;r<q.length;r++){t+=this._gpio.BCF_setValue(this._gpioinfo.port,this._gpioinfo.bit,q[r],p)}this._gpio._mcu.callMiMicWithCheck(t+n.END,p)}catch(s){throw new MiMicException(s)}},}}());(function(){var a=LPCXpresso1769;var n=a._BCF;var o=a._EE;var b=MiMicLib.isUndef;var g=MiMicLib.cloneAssoc;a.Pwm=function d(p,u){try{this._mcu=p;this._phl=new a.Peripheral(p,a.PHL.PWM1);var r=b(u)?{phl:{}}:{phl:b(u.phl)?{}:g(u.phl),freq:u.freq};if(b(r.phl.power)){r.phl.power=1}if(b(r.phl.clock)){r.phl.clock=0}if(b(r.freq)){r.freq=100}var t="";var q=new Array();t+=this.BCF_setOpt(r,q);t+=n.setMem(this._PC,0,q);t+=n.setMem(this._PCR,0,q);t+=n.setMem(this._CTCR,0,q);t+=n.setMem(this._TCR,0,q);t+=n.setMem(this._TC,0,q);t+=n.setMem(this._TCR,9,q);this._mcu.callMiMicWithCheck(t+n.END,q);this._mcu.registerPhl(this,"PWM")}catch(s){throw new MiMicException(s)}};a.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 h(u,p){try{var t="";var r;var q;if(!b(u.phl)){t+=this._phl.BCF_setOpt(u.phl,p)}if(!b(u.freq)){q=Math.round(this._phl.getPCLK()/u.freq);if(q<=0){throw new MiMicException("The peripheral clock too small.")}t+=this.BCF_setMRn(0,q,p);t+=this.BCF_setLER(0,p);this._cache.mr0=q}return t}catch(s){throw new MiMicException(s)}},BCF_setLER:function e(q,p){return n.setBit(this._LER,1,1,q,p)},BCF_setMRn:function j(r,q,p){try{return n.setMem(this._MRn[r],q,p)}catch(s){throw new MiMicException(s)}},BCF_setMRnByDuty:function m(q,r,p){try{return this.BCF_setMRn(q,Math.round(r*this._cache.mr0),p)}catch(s){throw new MiMicException(s)}},BCF_setPCRbit:function l(u,r,s,q){try{var p,t;p=t=0;if(!b(r)){t|=r;p|=1}if(!b(s)){t|=(s<<8);p|=256}return n.setBit(this._PCR,p,t,u,q)}catch(w){throw new MiMicException(w)}},setOpt:function f(s){try{var p=new Array();var r=this.BCF_setOpt(s,p);this._mcu.callMiMicWithCheck(r+n.END,p)}catch(q){throw new MiMicException(q)}},getPin:function i(p,r){try{return new a.PwmPin(this,p,r)}catch(q){throw new MiMicException(q)}}};a.PwmPin=function k(p,r,t){try{this._pwm=p;this._pin=new a.Pin(p._mcu,r);this._pwminfo=function(x){var v=a.completePinFunctionName(x,"PWM");var u=v.substring(2).split(".");var w={port:0,ch:parseInt(u[1]),pin_sel:a.getPinSelByFunctionName(x,v)};if(!isNaN(w.ch)){return w}throw new MiMicException(o.INVALID_CFG,"The pin has not PWM fuction.")}(r);var q=b(t)?{pin:{}}:{pin:b(t.pin)?{}:g(t.pin),duty:t.duty,enable:t.enable};if(b(q.pin.sel)){q.pin.sel=this._pwminfo.pin_sel}if(b(q.duty)){q.duty=0}if(b(q.enable)){q.enable=1}this.setOpt(q)}catch(s){throw new MiMicException(s)}};a.PwmPin.prototype={_pwm:null,_pin:null,_pwminfo:null,BCF_setOpt:function h(s,p){try{var r="";if(!b(s.pin)){r+=this._pin.BCF_setOpt(s.pin,p)}if(!b(s.enable)){r+=this._pwm.BCF_setPCRbit(this._pwminfo.ch,0,s.enable,p)}if(!b(s.duty)){r+=this._pwm.BCF_setMRnByDuty(this._pwminfo.ch,s.duty,p);r+=this._pwm.BCF_setLER(this._pwminfo.ch,p)}return r}catch(q){throw new MiMicException(q)}},setOpt:function f(s){try{var p=new Array();var r=this.BCF_setOpt(s,p);this._pwm._mcu.callMiMicWithCheck(r+n.END,p)}catch(q){throw new MiMicException(q)}},setDuty:function c(p){try{this.setOpt({duty:p})}catch(q){throw new MiMicException(q)}}}}());(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 05e39a3..d102dc5 100644 (file)
@@ -462,15 +462,9 @@ LPCXpresso1769=DEV;
        function array2MimicDb(i_array)\r
        {\r
                try{\r
-                       var dt=["0000000","000000","00000","0000","000","00","0",""];\r
                        var p="";\r
                        for(var i=0;i<i_array.length;i++){\r
-                               var v=(i_array[i]>>>0);\r
-                               var s=v.toString(16).toLowerCase();\r
-                               if(s.length<1 || s.length>8){\r
-                                       throw new MiMicException(EE.NG);\r
-                               }\r
-                               p+=dt[s.length-1]+s;\r
+                               p+=MiMicLib.hexout(i_array[i],8);\r
                        }\r
                        return p;\r
                }catch(e){\r
@@ -2328,3 +2322,164 @@ DEV.PwmPin.prototype=
 \r
 \r
 }());\r
+/**\r
+ * @fileOverview LPCXpresso1769における、ネイティブ関数コールインタフェイスを定義する。\r
+  */\r
+(function(){\r
+var DEV=LPCXpresso1769;\r
+var BCF=DEV._BCF;\r
+var EE=DEV._EE;\r
+var isUndef=MiMicLib.isUndef;\r
+\r
+\r
+\r
+/**\r
+ * LPCXPresso1769.Ni (NativeInterface)クラスのコンストラクタ。\r
+ * MCUに関連付けしたネイティブインタフェイスを生成する。\r
+ * クラスは、MiMicVMのCALL命令を使用した、ネイティブ関数コール機能を提供する。\r
+ * @constructor\r
+ * @name LPCXpresso1769.Ni\r
+ * @param {object as LPCXpresso1769.Mcu} i_mcu\r
+ * インスタンスを結びつけるMcuオブジェクト。\r
+ * @example\r
+ */\r
+DEV.Ni=function Ni(i_mcu)\r
+{\r
+       try{\r
+               this._mcu=i_mcu;\r
+       }catch(e){\r
+               throw new MiMicException(e);\r
+       }\r
+\r
+}\r
+DEV.Ni.prototype=\r
+{\r
+       /**\r
+        * この関数は、CALLインストラクションを使ったネイティブファンクションコールを実行する。\r
+        * MiMicRemoteMCUに定義されているネイティブ関数から、ファンクションIDに一致するものを検索して、実行する。\r
+        * ネイティブ関数は、native_function.cのnaitive_function_tableに定義されている。\r
+        * 引き渡すパラメータは、SPUTによるストリーム値と、VMのレジスタ(WM)値である。得られる返却値は、ネイティブ関数実行後のVMレジスタ(WM)と、ストリームである。\r
+        * @name LPCXpresso1769.Ni#call\r
+        * @function\r
+        * @param {int} i_id\r
+        * ファンクションID。ファンクションIDは、呼び出す関数を識別するidである。\r
+        * @param {object as associative array} i_in\r
+        * 入力パラメータである。必要な値を格納した連想配列で指定する。省略が可能である。\r
+        * 連想配列のメンバは以下の通り。\r
+        * <pre>{wm?:int,stream:array[int]}</pre>\r
+        *\r
+        * <ul>\r
+        * <li>wm? - WMレジスタにセットする値である。wm0~wm7まで、最大8個の値を指定できる。</li>\r
+        * <li>stream - ストリームに出力する値である。長さに制限は無いが、100個程度が上限である。</li>\r
+        * </ul>\r
+        * @param {object as associative array} o_out\r
+        * 出力パラメータを受け取る変数である。戻り値として取得したい値を格納した連想配列を指定する。省略が可能である。\r
+        * 各メンバ変数は関数が割り当てるので、nullを設定しておくこと。\r
+        * 連想配列のメンバは以下の通り。\r
+        * <pre>{wm?:null,stream:null}</pre>\r
+        * <ul>\r
+        * <li>wm? - 取得するWMレジスタのプレースホルダ。戻り値としてwmレジスタの値を取得する時に指定する。取得したいWMを指定する。</li>\r
+        * <li>stream - 取得するストリームのプレースホルダ。戻り値としてネイティブ関数が出力したストリームを取得する時に指定する。純粋な返却streamから、wmの返却分を差し引いたint array値である。</li>\r
+        * </ul>\r
+        * @return {boolean}\r
+        * 関数コールが成功するとtrueである。\r
+        * @example\r
+        * var mcu=new LPCXpresso1769.Mcu("192.168.128.39",true);\r
+        * var ni=new LPCXpresso1769.Ni(mcu);\r
+        * //This function calls the function number 1. wm1=1,wm2=3 are set to WM before calling. And puts [12] to input stream.\r
+        * //Out values are consist of wm4,wm5 and output stream values.\r
+        * var r1={wm4:null,wm5:null};\r
+        * nativeCall(0,{wm1:1,wm2:3,stream:[12]},r1);\r
+        *\r
+        * //sample2 no parameter, returns.\r
+        * nativeCall(0);\r
+        * \r
+        * //sample 3 stream only.\r
+        * var r2={stream:null};\r
+        * nativeCall(0,{stream:[]},r2);\r
+        *\r
+        * //call sample echo back native function.\r
+        * var r3={stream:null};\r
+        * nativeCall(0x39000000,{stream:[0x2525]},r3);\r
+        * alert(r3[0]);\r
+        *\r
+        * // set/get all work register and stream.\r
+        * var r4={stream:null,wm0:null,wm1:null,wm2:null,wm3:null,wm4:null,wm5:null,wm6:null,wm7:null};\r
+        * ni.call(0x39000000,{stream:[0x39],wm0:7,wm1:6,wm2:5,wm3:4,wm4:3,wm5:2,wm6:1,wm7:0},r4);\r
+        *\r
+        */\r
+       call:function call(i_id,i_in,o_out)\r
+       {\r
+               /*\r
+                * .DBは、WM設定値(あれば),idx番号,stream値の順で格納。\r
+                * 命令は、\r
+                * WM初期化部(LD配列)\r
+                * LD #0;WM初期化(あれば)\r
+                * :\r
+                * SGET 
+                */\r
+               var bc="";\r
+               var db=new Array();\r
+               //WM初期化命令\r
+               if(!isUndef(i_in)){\r
+                       //wmがあれば、初期化命令を追加。\r
+                       //LD命令を直書き\r
+                       for(var i=0;i<8;i++){\r
+                               var hash="wm"+i;\r
+                               if(!isUndef(i_in[hash])){\r
+                                       bc+="FB"+MiMicLib.hexout(i,2)+MiMicLib.hexout(i_in[hash],8);\r
+                               }\r
+                       }\r
+                       //streamをセット\r
+                       if(!isUndef(i_in.stream)){\r
+                               for(var i=0;i<i_in.stream.length;i++){\r
+                                       db.push(i_in.stream[i]);\r
+                               }\r
+                       }\r
+               }\r
+               //CALL命令を直書き\r
+               bc+="ZF"+MiMicLib.hexout(i_id,8);\r
+               //\r
+               var num_of_wm=0;\r
+               if(!isUndef(o_out)){\r
+                       //o_out.wmxがあれば、回収用命令を追記\r
+                       //SGET命令を直書き\r
+                       for(var i=0;i<8;i++){\r
+                               if(!isUndef(o_out["wm"+i])){\r
+                                       bc+="EE"+MiMicLib.hexout(i,2);\r
+                                       num_of_wm++;\r
+                               }\r
+                       }\r
+               }\r
+               //実行\r
+               var ret=this._mcu.callMiMic(bc+BCF.END,db);\r
+               if(ret.result!=0x00){\r
+                       //失敗.理由はresultの内容。\r
+                       return false;\r
+               }\r
+               //streamから値を回収\r
+               //streamは、関数の返したストリーム+WMの返却値\r
+               var c=0;\r
+               if(!isUndef(o_out)){\r
+                       //WM回収のためにSGET命令を直書き\r
+                       var offset=ret.stream.length-num_of_wm;\r
+                       for(var i=0;i<8;i++){\r
+                               var hash="wm"+i;\r
+                               if(!isUndef(o_out[hash])){\r
+                                       o_out[hash]=ret.stream[offset];\r
+                                       offset++;\r
+                               }\r
+                       }\r
+                       //o_out.streamがあれば、値を回収。\r
+                       if(!isUndef(o_out.stream)){\r
+                               o_out.stream=ret.stream.slice(0,ret.stream.length-num_of_wm);\r
+                       }\r
+               }\r
+               return false;\r
+       }\r
+}\r
+\r
+\r
+\r
+\r
+}());\r
index 25e2295..c9e0294 100644 (file)
        function array2MimicDb(i_array)\r
        {\r
                try{\r
-                       var dt=["0000000","000000","00000","0000","000","00","0",""];\r
                        var p="";\r
                        for(var i=0;i<i_array.length;i++){\r
-                               var v=(i_array[i]>>>0);\r
-                               var s=v.toString(16).toLowerCase();\r
-                               if(s.length<1 || s.length>8){\r
-                                       throw new MiMicException(EE.NG);\r
-                               }\r
-                               p+=dt[s.length-1]+s;\r
+                               p+=MiMicLib.hexout(i_array[i],8);\r
                        }\r
                        return p;\r
                }catch(e){\r
diff --git a/misc/MiMicVM/api.js/LPCXpresso1769.Ni.js b/misc/MiMicVM/api.js/LPCXpresso1769.Ni.js
new file mode 100644 (file)
index 0000000..e568020
--- /dev/null
@@ -0,0 +1,161 @@
+/**\r
+ * @fileOverview LPCXpresso1769における、ネイティブ関数コールインタフェイスを定義する。\r
+  */\r
+(function(){\r
+var DEV=LPCXpresso1769;\r
+var BCF=DEV._BCF;\r
+var EE=DEV._EE;\r
+var isUndef=MiMicLib.isUndef;\r
+\r
+\r
+\r
+/**\r
+ * LPCXPresso1769.Ni (NativeInterface)クラスのコンストラクタ。\r
+ * MCUに関連付けしたネイティブインタフェイスを生成する。\r
+ * クラスは、MiMicVMのCALL命令を使用した、ネイティブ関数コール機能を提供する。\r
+ * @constructor\r
+ * @name LPCXpresso1769.Ni\r
+ * @param {object as LPCXpresso1769.Mcu} i_mcu\r
+ * インスタンスを結びつけるMcuオブジェクト。\r
+ * @example\r
+ */\r
+DEV.Ni=function Ni(i_mcu)\r
+{\r
+       try{\r
+               this._mcu=i_mcu;\r
+       }catch(e){\r
+               throw new MiMicException(e);\r
+       }\r
+\r
+}\r
+DEV.Ni.prototype=\r
+{\r
+       /**\r
+        * この関数は、CALLインストラクションを使ったネイティブファンクションコールを実行する。\r
+        * MiMicRemoteMCUに定義されているネイティブ関数から、ファンクションIDに一致するものを検索して、実行する。\r
+        * ネイティブ関数は、native_function.cのnaitive_function_tableに定義されている。\r
+        * 引き渡すパラメータは、SPUTによるストリーム値と、VMのレジスタ(WM)値である。得られる返却値は、ネイティブ関数実行後のVMレジスタ(WM)と、ストリームである。\r
+        * @name LPCXpresso1769.Ni#call\r
+        * @function\r
+        * @param {int} i_id\r
+        * ファンクションID。ファンクションIDは、呼び出す関数を識別するidである。\r
+        * @param {object as associative array} i_in\r
+        * 入力パラメータである。必要な値を格納した連想配列で指定する。省略が可能である。\r
+        * 連想配列のメンバは以下の通り。\r
+        * <pre>{wm?:int,stream:array[int]}</pre>\r
+        *\r
+        * <ul>\r
+        * <li>wm? - WMレジスタにセットする値である。wm0~wm7まで、最大8個の値を指定できる。</li>\r
+        * <li>stream - ストリームに出力する値である。長さに制限は無いが、100個程度が上限である。</li>\r
+        * </ul>\r
+        * @param {object as associative array} o_out\r
+        * 出力パラメータを受け取る変数である。戻り値として取得したい値を格納した連想配列を指定する。省略が可能である。\r
+        * 各メンバ変数は関数が割り当てるので、nullを設定しておくこと。\r
+        * 連想配列のメンバは以下の通り。\r
+        * <pre>{wm?:null,stream:null}</pre>\r
+        * <ul>\r
+        * <li>wm? - 取得するWMレジスタのプレースホルダ。戻り値としてwmレジスタの値を取得する時に指定する。取得したいWMを指定する。</li>\r
+        * <li>stream - 取得するストリームのプレースホルダ。戻り値としてネイティブ関数が出力したストリームを取得する時に指定する。純粋な返却streamから、wmの返却分を差し引いたint array値である。</li>\r
+        * </ul>\r
+        * @return {boolean}\r
+        * 関数コールが成功するとtrueである。\r
+        * @example\r
+        * var mcu=new LPCXpresso1769.Mcu("192.168.128.39",true);\r
+        * var ni=new LPCXpresso1769.Ni(mcu);\r
+        * //This function calls the function number 1. wm1=1,wm2=3 are set to WM before calling. And puts [12] to input stream.\r
+        * //Out values are consist of wm4,wm5 and output stream values.\r
+        * var r1={wm4:null,wm5:null};\r
+        * nativeCall(0,{wm1:1,wm2:3,stream:[12]},r1);\r
+        *\r
+        * //sample2 no parameter, returns.\r
+        * nativeCall(0);\r
+        * \r
+        * //sample 3 stream only.\r
+        * var r2={stream:null};\r
+        * nativeCall(0,{stream:[]},r2);\r
+        *\r
+        * //call sample echo back native function.\r
+        * var r3={stream:null};\r
+        * nativeCall(0x39000000,{stream:[0x2525]},r3);\r
+        * alert(r3[0]);\r
+        *\r
+        * // set/get all work register and stream.\r
+        * var r4={stream:null,wm0:null,wm1:null,wm2:null,wm3:null,wm4:null,wm5:null,wm6:null,wm7:null};\r
+        * ni.call(0x39000000,{stream:[0x39],wm0:7,wm1:6,wm2:5,wm3:4,wm4:3,wm5:2,wm6:1,wm7:0},r4);\r
+        *\r
+        */\r
+       call:function call(i_id,i_in,o_out)\r
+       {\r
+               /*\r
+                * .DBは、WM設定値(あれば),idx番号,stream値の順で格納。\r
+                * 命令は、\r
+                * WM初期化部(LD配列)\r
+                * LD #0;WM初期化(あれば)\r
+                * :\r
+                * SGET 
+                */\r
+               var bc="";\r
+               var db=new Array();\r
+               //WM初期化命令\r
+               if(!isUndef(i_in)){\r
+                       //wmがあれば、初期化命令を追加。\r
+                       //LD命令を直書き\r
+                       for(var i=0;i<8;i++){\r
+                               var hash="wm"+i;\r
+                               if(!isUndef(i_in[hash])){\r
+                                       bc+="FB"+MiMicLib.hexout(i,2)+MiMicLib.hexout(i_in[hash],8);\r
+                               }\r
+                       }\r
+                       //streamをセット\r
+                       if(!isUndef(i_in.stream)){\r
+                               for(var i=0;i<i_in.stream.length;i++){\r
+                                       db.push(i_in.stream[i]);\r
+                               }\r
+                       }\r
+               }\r
+               //CALL命令を直書き\r
+               bc+="ZF"+MiMicLib.hexout(i_id,8);\r
+               //\r
+               var num_of_wm=0;\r
+               if(!isUndef(o_out)){\r
+                       //o_out.wmxがあれば、回収用命令を追記\r
+                       //SGET命令を直書き\r
+                       for(var i=0;i<8;i++){\r
+                               if(!isUndef(o_out["wm"+i])){\r
+                                       bc+="EE"+MiMicLib.hexout(i,2);\r
+                                       num_of_wm++;\r
+                               }\r
+                       }\r
+               }\r
+               //実行\r
+               var ret=this._mcu.callMiMic(bc+BCF.END,db);\r
+               if(ret.result!=0x00){\r
+                       //失敗.理由はresultの内容。\r
+                       return false;\r
+               }\r
+               //streamから値を回収\r
+               //streamは、関数の返したストリーム+WMの返却値\r
+               var c=0;\r
+               if(!isUndef(o_out)){\r
+                       //WM回収のためにSGET命令を直書き\r
+                       var offset=ret.stream.length-num_of_wm;\r
+                       for(var i=0;i<8;i++){\r
+                               var hash="wm"+i;\r
+                               if(!isUndef(o_out[hash])){\r
+                                       o_out[hash]=ret.stream[offset];\r
+                                       offset++;\r
+                               }\r
+                       }\r
+                       //o_out.streamがあれば、値を回収。\r
+                       if(!isUndef(o_out.stream)){\r
+                               o_out.stream=ret.stream.slice(0,ret.stream.length-num_of_wm);\r
+                       }\r
+               }\r
+               return false;\r
+       }\r
+}\r
+\r
+\r
+\r
+\r
+}());\r
index 462be9f..30b76bb 100644 (file)
@@ -34,7 +34,32 @@ var MiMicLib=
                        r[i]=a[i];\r
                }\r
                return r;\r
+       },\r
+       /**\r
+        * 桁数を指定して、int値を16進数に変換する。\r
+        * @param {int} i_val\r
+        * 変換する値\r
+        * @param {int} i_digit\r
+        * 桁数\r
+        * @return {string}\r
+        * 文字列形式の値\r
+        */\r
+       hexout:function hexout(i_val,i_digit)\r
+       {\r
+               try{\r
+                       var dt=["","0","00","000","0000","00000","000000","0000000"];\r
+                       var s=(i_val>>>0).toString(16).toLowerCase();\r
+                       if(s.length>i_digit){\r
+                               //マイナスだともれなくエラー\r
+                               throw new MiMicException(EE.NG);\r
+                       }\r
+                       var l=i_digit-s.length;\r
+                       return dt[l]+s;\r
+               }catch(e){\r
+                       throw new MiMicException(e);\r
+               }\r
        }\r
+       \r
 }\r
 \r
 /**\r
diff --git a/misc/MiMicVM/api.js/demo/naitive_call.html b/misc/MiMicVM/api.js/demo/naitive_call.html
new file mode 100644 (file)
index 0000000..7506584
--- /dev/null
@@ -0,0 +1,28 @@
+<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
+function init(){\r
+       var mcu=new LPCXpresso1769.Mcu("192.168.128.39");\r
+       //create native call interface.\r
+       var ni=new LPCXpresso1769.Ni(mcu);\r
+       //create result value holder.\r
+       var ret={stream:null};\r
+       //call the native function #0x39000000(echo back). 1 input stream,1output result. \r
+       ni.call(0x39000000,{stream:[31319]},ret);\r
+       //show result\r
+       alert(ret.stream[0]);\r
+}      \r
+</script>\r
+</head>\r
+<body onload="init();">\r
+<h1>MiMic for LPCXpressso1769 + native function call</h1>\r
+<div>\r
+This sample program calls the native function via MiMicRemoteMCU.\r
+The called native function is implemented in firmware. <br/>\r
+You can add your original function to firmware. See native_function.c in MiMicRemoteMCU source code.\r
+Before running the program, opening this source code, set IP address to your Mimic address. \r
+</div>\r
+</body>\r
index 5324dc7..4c44d5f 100644 (file)
@@ -7,6 +7,7 @@ copy /b ^
 +"LPCXpresso1769.Adc.js" ^\r
 +"LPCXPresso1769.Gpio.js" ^\r
 +"LPCXPresso1769.Pwm.js" ^\r
++"LPCXPresso1769.Ni.js" ^\r
  "LPCXPresso1769.All.js"\r
 \r
 java -jar D:\application.files\yuicompressor-2.4.6\build\yuicompressor-2.4.6.jar -o LPCXPresso1769.All-mini.js "LPCXPresso1769.All.js\r
index 0c42e7a..88a43c8 100644 (file)
@@ -11,6 +11,7 @@
 <script src="LPCXpresso1769.Peripheral.js"></script>   \r
 <script src="LPCXpresso1769.Adc.js"></script>  \r
 <script src="LPCXpresso1769.Pwm.js"></script>  \r
+<script src="LPCXpresso1769.NativeInterface.js"></script>      \r
 <script type="text/javascript">\r
 function init(){\r
 try{\r
@@ -64,10 +65,13 @@ try{
 //             var pwm=mcu.getPeripheral("PWM",{freq:100});\r
 //             var pwmpin=pwm.getPin(LPCXpresso1769.P2[0],{duty:0.5});\r
                \r
-               var pwm=new LPCXpresso1769.Pwm(mcu,{freq:100});\r
-               \r
-               pwmpin=new LPCXpresso1769.PwmPin(pwm,LPCXpresso1769.P2[0],{duty:0.0});\r
+//             var pwm=new LPCXpresso1769.Pwm(mcu,{freq:100});\r
                \r
+//             pwmpin=new LPCXpresso1769.PwmPin(pwm,LPCXpresso1769.P2[0],{duty:0.0});\r
+       var ni=new LPCXpresso1769.Ni(mcu);\r
+       var ret={stream:null,wm0:null,wm1:null,wm2:null,wm3:null,wm4:null,wm5:null,wm6:null,wm7:null};\r
+       ni.call(0x39000000,{stream:[0x39],wm0:7,wm1:6,wm2:5,wm3:4,wm4:3,wm5:2,wm6:1,wm7:0},ret);\r
+       alert(ret.stream[0]+","+ret.wm0+","+ret.wm1+","+ret.wm2+","+ret.wm3+","+ret.wm4+","+ret.wm5+","+ret.wm6+","+ret.wm7);\r
        }\r
        test();\r
        /*\r