OSDN Git Service

update 1.3.2(候補)
authornyatla <nyatla@47198e57-cb75-475f-84c4-a814cd6f29e0>
Fri, 20 Jul 2012 06:44:38 +0000 (06:44 +0000)
committernyatla <nyatla@47198e57-cb75-475f-84c4-a814cd6f29e0>
Fri, 20 Jul 2012 06:44:38 +0000 (06:44 +0000)
git-svn-id: http://svn.osdn.jp/svnroot/mimic/trunk@176 47198e57-cb75-475f-84c4-a814cd6f29e0

18 files changed:
misc/MiMicVM/api.js/LPC1769.Adc.js
misc/MiMicVM/api.js/LPC1769.All-mini.js
misc/MiMicVM/api.js/LPC1769.All.js
misc/MiMicVM/api.js/LPC1769.Dac.js
misc/MiMicVM/api.js/LPC1769.Gpio.js
misc/MiMicVM/api.js/LPC1769.Mcu.js
misc/MiMicVM/api.js/LPC1769.Memory.js
misc/MiMicVM/api.js/LPC1769.Port.js
misc/MiMicVM/api.js/LPC1769.Pwm.js
misc/MiMicVM/api.js/LPCXPresso1769.All-mini.js
misc/MiMicVM/api.js/LPCXPresso1769.All.js
misc/MiMicVM/api.js/MbedM3.All-mini.js
misc/MiMicVM/api.js/MbedM3.All.js
misc/MiMicVM/api.js/demo/da.html
misc/MiMicVM/api.js/demo/led_blink.html
misc/MiMicVM/tool/C0test.html [new file with mode: 0644]
misc/MiMicVM/tool/adView.html [new file with mode: 0644]
misc/MiMicVM/tool/memDump.html [new file with mode: 0644]

index 7bf34c3..e829c28 100644 (file)
@@ -19,7 +19,7 @@ var cloneAssoc=MiMicLib.cloneAssoc;
  * @name LPC1769.Adc\r
  * @param {object as LPC1769.Mcu} i_mcu\r
  * インスタンスを結びつけるMcuオブジェクト。\r
- * @param {object as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * インスタンス生成と同時にsetOpt関数で設定する値。省略時は、{phl:{power:1}}とみなす。\r
  * 詳細はsetOpt関数を参照。 \r
  * @example\r
@@ -106,10 +106,10 @@ DEV.Adc.prototype=
         * ADCペリフェラルに、i_optのオプション値を設定する。\r
         * @name LPC1769.Adc#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
+        * @param {associative array} i_opt\r
         * ADCペリフェラルのコンフィグレーションパラメタである。必要な値を格納した連想配列で指定する。\r
         * 全ての値を省略することは出来ない。連想配列のメンバは以下の通り。\r
-        * <pre>{phl:object as associative array}</pre>\r
+        * <pre>{phl:associative array}</pre>\r
         * <ul>\r
         * <li>phl - LPC1769.Peripheral#setOpt関数のi_optに渡すパラメタである。</li>\r
         * </ul>\r
@@ -139,8 +139,8 @@ DEV.Adc.prototype=
         * @function\r
         * @param {object as ピン識別子} i_pin\r
         * AD機能を割り当てるPINの識別子である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * AdcPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPin.setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * AdcPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPinを参照。\r
         * @return {object as LPC1769.AdcPin}\r
         * LPC1769.AdcPinクラスのオブジェクトである。\r
         * @example\r
@@ -166,8 +166,8 @@ DEV.Adc.prototype=
         * @function\r
         * @param {array[ピン識別子]} i_pin\r
         * AD機能を割り当てるPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPort.setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPortを参照。\r
         * @return {object as LPC1769.AdcPort}\r
         * LPC1769.AdcPortクラスのオブジェクトである。\r
         * @example\r
@@ -191,24 +191,27 @@ DEV.Adc.prototype=
  * AD pinからADInfoを取得\r
  * @private\r
  */\r
-function pin2AdcPinInfo(i_pin)\r
+function makeAdcPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var func_name=DEV.completePinFunctionName(i_pin,"AD");\r
-               //portとbitを得る(AD0だけしか管理しないよ)\r
-               var a=func_name.substring(2).split(".");\r
-               var r={port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pin,func_name)};\r
-               if(!isNaN(r.ch)){\r
-                       return r;\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var func_name=DEV.completePinFunctionName(i_pins[i],"AD");\r
+                       //portとbitを得る(AD0だけしか管理しないよ)\r
+                       var a=func_name.substring(2).split(".");\r
+                       if(isNaN(a[1])){\r
+                               throw new MiMicException(EE.INVALID_CFG);\r
+                       }\r
+                       ret.push({port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pins[i],func_name)});\r
                }\r
-               throw new MiMicException(EE.INVALID_CFG,"The pin has not AD fuction.");\r
+               return ret;\r
        }catch(e){\r
-               throw new MiMicException(e);    \r
+               throw new MiMicException(e);\r
        }\r
 }\r
 /**\r
- * LPC1769.AdcPort (AdcPort)クラスのコンストラクタ。複数のADピンから一括で値を取得するときに使用する。\r
+ * LPC1769.AdcPort (AdcPort)クラスのコンストラクタ。複数のADcPinから一括で値を取得するときに使用する。\r
  * Adcペリフェラルオブジェクトにピン識別子の配列で指定されたピン集合を関連付けて、AD機能を持つポートを生成する。\r
  * 関数は、ピン識別子を元に、そのピンがAD機能に接続できるかを調べる。全てのピンにAD機能を割り当てられない場合、例外が発生する。どのピンにAD機能が割り当てられるかは、MCUのスペックシートを参照すること。\r
  * @constructor\r
@@ -217,9 +220,9 @@ function pin2AdcPinInfo(i_pin)
  * インスタンスを結びつけるAdcオブジェクト。\r
  * @param {array[pin識別子]} i_pins\r
  * ピン識別子の配列。指定できるのは、LPC1769.P?[?]である。順番は、このインスタンスの返す値の順序に影響する。\r
- * @param {object as associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto}}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * @param {array[associative array] | associative array} i_opt\r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined}}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create [AD0.0,AD0.1]\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -231,15 +234,11 @@ DEV.AdcPort=function AdcPort(i_adc,i_pins,i_opt)
        try{\r
                this._adc=i_adc;\r
                //ピンセットを取得\r
-               this._pins=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       this._pins.push(pin2AdcPinInfo(i_pins[i]));\r
-               }\r
+               var pininfo=makeAdcPinInfoArray(i_pins);\r
                //pinが全て同じポートに所属しているか確認\r
-               var p=this._pins[0].port;\r
-               for(var i=1;i<this._pins.length;i++){\r
-                       if(p!=this._pins[i].port){\r
+               var p=pininfo[0].port;\r
+               for(var i=1;i<pininfo.length;i++){\r
+                       if(p!=pininfo[i].port){\r
                                throw new MiMicException("Invalid pin combination.");\r
                        }\r
                }\r
@@ -248,15 +247,26 @@ DEV.AdcPort=function AdcPort(i_adc,i_pins,i_opt)
                this._port_no=p;\r
                //AD0CR用のマスクを生成。\r
                this._adcr_mask=0;\r
-               for(var i=0;i<this._pins.length;i++){\r
-                       this._adcr_mask|=(0x1<<this._pins[i].ch);\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       this._adcr_mask|=(0x1<<pininfo[i].ch);\r
                }\r
+\r
                //ピンオプションの生成\r
-               var opt=isUndef(i_opt)?{}:cloneAssoc(i_opt);\r
-               opt.sel=1;//ADxCRの値\r
-               opt.pin=isUndef(opt.pin)?{}:cloneAssoc(opt.pin);\r
-               //設定が無ければ、ピンセレクタを自動に設定\r
-               if(isUndef(opt.pin.sel)){opt.pin.sel=this._PINSEL_AUTO_DETECT;}\r
+               var opt={};\r
+               if(isUndef(i_opt)){\r
+                       opt.pin=this._port.clonePinOptAssoc({});\r
+                       opt.sel=1;//ADxCRの値\r
+               }else{\r
+                       opt.pin=this._port.clonePinOptAssoc(isUndef(i_opt.pin)?{}:i_opt.pin);\r
+                       opt.sel=1;//ADxCRの値\r
+               };\r
+               //pinselの自動設定\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       if(isUndef(opt.pin[i].sel)){\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
+                       }\r
+               }\r
+               this._pininfo=pininfo;\r
                //ピンオプションの設定\r
                this.setOpt(opt);\r
        }catch(e){\r
@@ -265,9 +275,8 @@ DEV.AdcPort=function AdcPort(i_adc,i_pins,i_opt)
 }\r
 DEV.AdcPort.prototype=\r
 {\r
-       _PINSEL_AUTO_DETECT:0x0fffffff,\r
        _adc:null,\r
-       _pins:null,\r
+       _pininfo:null,\r
        _port_no:0,\r
        _port:null,\r
        _adcr_mask:0,\r
@@ -277,8 +286,19 @@ DEV.AdcPort.prototype=
         * 設定可能な値は、LPC1769.AdcPin#setOptと同じである。\r
         * @name LPC1769.AdcPort#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
-        * LPC1769.AdcPin#setOptを参照。\r
+        * @param {associative array | array[associative array]} i_opt\r
+        * ADピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
+        * 全てのピンに同じパラメータを指定する場合は、連装配列で指定する。個別に設定する場合は、連装配列を配列にして指定する。\r
+        * <pre>{i_opt:associative array}</pre>\r
+        * <ul>\r
+        * <li>pin(option)</li>\r
+        * </ul>\r
+        * パラメータの詳細は、LPC1769.AdcPin#setOptを参照。\r
+        * @example\r
+        * //ポートを構成する全てのピンに同じパラメータを設定する場合\r
+        * setOpt({pin:{v1}});\r
+        * //ポートを構成するピンに個々にパラメータを設定する場合\r
+        * setOpt({pin:[{v1},{v2}]});\r
         */     \r
        setOpt:function setOpt(i_opt)\r
        {\r
@@ -288,14 +308,7 @@ DEV.AdcPort.prototype=
                        var bc="";\r
                        //i_optの展開\r
                        if(!isUndef(i_opt.pin)){\r
-                               var optset=new Array();\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       //pinselが_PINSEL_AUTO_DETECTならばauto。そうでなければundefinedも含めて設定\r
-                                       var s=(i_opt.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[i].pin_sel:i_opt.pin.sel;\r
-                                       optset.push({sel:s,mode:i_opt.pin.mode,od:i_opt.pin.od});\r
-                               }\r
-                               //portの設定\r
-                               bc+=this._port.BCF_setOpts(optset,db);\r
+                               bc+=this._port.BCF_setOpts(i_opt.pin,db);\r
                        }\r
                        //隠し。ADxCR\r
                        if(!isUndef(i_opt.sel)){\r
@@ -326,13 +339,13 @@ DEV.AdcPort.prototype=
                        //メモリから値取得\r
                        var db=new Array();\r
                        var bc="";\r
-                       for(var i=0;i<this._pins.length;i++){\r
-                               bc+=this._adc.BCF_getAD0DR(this._pins[i].ch,db);\r
+                       for(var i=0;i<this._port.pins.length;i++){\r
+                               bc+=this._adc.BCF_getAD0DR(this._pininfo[i].ch,db);\r
                        }\r
                        var ret=this._adc._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                        //値の整形\r
                        var r=new Array();\r
-                       for(var i=0;i<this._pins.length;i++){\r
+                       for(var i=0;i<this._port.pins.length;i++){\r
                                r.push((ret.stream[i]>>4)&0x00000fff);\r
                        }\r
                        return r;\r
@@ -352,8 +365,8 @@ DEV.AdcPort.prototype=
  * @param {object as pin識別子} i_pin\r
  * ピン識別子。指定できるのは、LPCXpresso1796.P?[?]である。\r
  * @param {object as associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto}}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined}}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create AD0.0\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -396,10 +409,10 @@ DEV.AdcPin.prototype=
         * ADピンにオプション値を設定する。\r
         * @name LPC1769.AdcPin#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
+        * @param {associative array} i_opt\r
         * ADピンのコンフィグレーションパラメタである。必要な値を格納した連想配列で指定する。\r
         * 全ての値を省略することは出来ない。連想配列のメンバは以下の通り。\r
-        * <pre>{pin:object as associative array}</pre>\r
+        * <pre>{pin:associative array}</pre>\r
         * <ul>\r
         * <li>pin - LPC1769.Pin#setOpt関数のi_optに渡すパラメタである。</li>\r
         * </ul>\r
index 7e06596..22119d8 100644 (file)
@@ -1 +1 @@
-var LPC1769;(function(){var g=MiMicLib.isUndef;var a={_EE:function(n){return{NG:[n|0,"Unknown exception in LPC1769"],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.")};LPC1769=a}());(function(){var f=LPC1769;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",PWM:"PWM"};for(var s in t){if(v==s){return t[s]}}throw new MiMicException("Peripheral for "+v+" 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;case"DAC":new f.Dac(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=LPC1769;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=LPC1769;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=LPC1769;var j=a._BCF;var k=a._EE;var c=MiMicLib.isUndef;var d=MiMicLib.cloneAssoc;var e=MiMicLib.isArray;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 g(m,n,l){try{this._mcu=m;this.pins=new Array();for(var o=0;o<n.length;o++){this.pins.push({pin:n[o],reginfo:a.getPinRegInfo(n[o])})}if(!c(l)){this.setOpts(l)}}catch(p){throw new MiMicException(p)}};a.Port.prototype={_mcu:null,pins:null,BCF_setOpts:function b(t,n){try{var s={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]};var l=e(t)?t:this.clonePinOptAssoc(t);for(var o=0;o<this.pins.length;o++){var p=this.pins[o].reginfo;var m=l[o];if(!c(m.sel)){s.selr[p.s]|=(m.sel<<p.smb);s.selr_mask[p.s]|=(3<<p.smb)}if(!c(m.mode)){s.modr[p.m]|=(m.mode<<p.smb);s.modr_mask[p.m]|=(3<<p.smb)}if(!c(m.od)){s.odr[p.o]|=(m.od<<p.ob);s.odr_mask[p.o]|=(1<<p.ob)}}var r="";for(var o=0;o<10;o++){if(s.selr_mask[o]!=0){r+=j.setBit(h._PINSEL[o],s.selr_mask[o],s.selr[o],0,n)}if(s.modr_mask[o]!=0){r+=j.setBit(h._PINMODE[o],s.modr_mask[o],s.modr[o],0,n)}}for(var o=0;o<5;o++){if(s.odr_mask[o]!=0){r+=j.setBit(h._PINMODE_OD[o],s.odr_mask[o],s.odr[o],0,n)}}return r}catch(q){throw new MiMicException(q)}},setOpts:function f(l){try{var m=new Array();var o=this.BCF_setOpts(l,m);if(o.length>0){this._mcu.callMiMicWithCheck(o+j.END,m)}}catch(n){throw new MiMicException(n)}return},clonePinOptAssoc:function i(l){var m=new Array();if(e(l)){if(l.length!=this.pins.length){throw new MiMicException()}for(var n=0;n<this.pins.length;n++){m.push(d(l[n]))}}else{for(var n=0;n<this.pins.length;n++){m.push(d(l))}}return m}}}());(function(){var f=LPC1769;var d=f._BCF;var b=f._EE;var c=MiMicLib.isUndef;f.Pin=function e(g,h,j){try{if(c(h)){throw new MiMicException(b.INVALID_PIN)}this._port=new f.Port(g,[h],c(j)?undefined:[j])}catch(i){throw new MiMicException(i)}};f.Pin.prototype={_port:null,setOpt:function a(h){try{this._port.setOpts([h])}catch(g){throw new MiMicException(g)}return}}}());(function(){var a=LPC1769;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={_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[u].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=d(x)?{}:k(x);t.sel=1;t.pin=d(t.pin)?{}:k(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)}if(!d(y.sel)){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=LPC1769;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[u].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);t.pin=f(t.pin)?{}:m(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=LPC1769;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(y,u){try{var x="";var v;if(!d(y.phl)){x+=this._phl.BCF_setOpt(y.phl,u)}if(!d(y.freq)){v=Math.round(this._phl.getPCLK()/y.freq);if(v<=0){throw new MiMicException("The peripheral clock too small.")}x+=this.BCF_setMRn(0,v,u);x+=this.BCF_setLER(0,u);this._cache.mr0=v}return x}catch(w){throw new MiMicException(w)}},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[x].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()}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.setDutys([u])}catch(v){throw new MiMicException(v)}}}}());(function(){var f=LPC1769;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,p,o){var n="";var q=new Array();if(!d(p)){for(var l=0;l<8;l++){var k="wm"+l;if(!d(p[k])){n+="FB"+MiMicLib.hexout(l,2)+MiMicLib.hexout(p[k],8)}}if(!d(p.stream)){for(var l=0;l<p.stream.length;l++){q.push(p.stream[l])}}}n+="ZF"+MiMicLib.hexout(j,8);var g=0;if(!d(o)){for(var l=0;l<8;l++){if(!d(o["wm"+l])){n+="EE"+MiMicLib.hexout(l,2);g++}}}var m=this._mcu.callMiMic(n+e.END,q);if(m.result!=0){return false}if(!d(o)){var h=m.stream.length-g;for(var l=0;l<8;l++){var k="wm"+l;if(!d(o[k])){o[k]=m.stream[h];h++}}if(!d(o.stream)){o.stream=m.stream.slice(0,m.stream.length-g)}}return false}}}());(function(){var g=LPC1769;var n=g._BCF;var a=g._EE;var f=MiMicLib.isUndef;var h=MiMicLib.isArray;var k=MiMicLib.cloneAssoc;g.Dac=function i(s,x){try{this._mcu=s;this._phl=new g.Peripheral(s,g.PHL.DAC);var u=f(x)?{phl:{}}:{phl:f(x.phl)?{}:k(x.phl),};if(f(u.phl.clock)){u.phl.clock=0}var w="";var t=new Array();w+=this.BCF_setOpt(u,t);this._mcu.callMiMicWithCheck(w+n.END,t);this._mcu.registerPhl(this,"DAC")}catch(v){throw new MiMicException(v)}};g.Dac.prototype={_DACR:1074315264,_DACCTRL:1074315268,_DACCNTVAL:1074315272,_phl:null,_mcu:null,BCF_setOpt:function j(v,s){try{var u="";if(!f(v.phl)){u+=this._phl.BCF_setOpt(v.phl,s)}return u}catch(t){throw new MiMicException(t)}},setOpt:function c(v){try{var s=new Array();var u=this.BCF_setOpt(v,s);this._mcu.callMiMicWithCheck(u+n.END,s)}catch(t){throw new MiMicException(t)}},getPin:function o(s,u){try{return new g.DacPin(this,s,u)}catch(t){throw new MiMicException(t)}},getPort:function r(s,u){try{return new g.DacPort(this,s,u)}catch(t){throw new MiMicException(t)}},BCF_setBias:function b(u,t,s){try{return n.setBit(this._DACR,u,t*u,0,s)}catch(v){throw new MiMicException(v)}},BCF_setValue:function l(t,s){return n.setBit(this._DACR,1023,t,6,s)}};function p(t){try{var s=g.completePinFunctionName(t,"AOUT");return{port:0,pin_sel:g.getPinSelByFunctionName(t,s)}}catch(u){throw new MiMicException(u)}}g.DacPort=function e(t,s,y){try{this._dac=t;var x=new Array();for(var v=0;v<s.length;v++){x.push(p(s[v]))}this._port=new g.Port(t._mcu,s);var u={};if(f(y)){u.pin=this._port.clonePinOptAssoc({});u.bias=0}else{u.pin=this._port.clonePinOptAssoc(f(y.pin)?{}:y.pin);u.bias=f(y.bias)?0:y.bias}for(var v=0;v<this._port.pins.length;v++){if(f(u.pin[v].sel)){u.pin[v].sel=x[v].pin_sel}}this.setOpt(u)}catch(w){throw new MiMicException(w)}};g.DacPort.prototype={_dac:null,_port:null,setOpt:function c(v){try{var s=new Array();var u="";if(!f(v.pin)){u+=this._port.BCF_setOpts(v.pin,s)}if(!f(v.bias)){if(h(v.pin)){u+=this._dac.BCF_setBias(65536,v.bias[0],s)}else{u+=this._dac.BCF_setBias(65536,v.bias,s)}}this._dac._mcu.callMiMicWithCheck(u+n.END,s);return}catch(t){throw new MiMicException(t)}},setValues:function m(s){try{var t=new Array();var w="";for(var u=0;u<this._port.pins.length;u++){w+=this._dac.BCF_setValue(s[u],t)}this._dac._mcu.callMiMicWithCheck(w+n.END,t);return}catch(v){throw new MiMicException(v)}}};g.DacPin=function q(s,t,v){try{this._port=new g.DacPort(s,[t],v)}catch(u){throw new MiMicException(u)}};g.DacPin.prototype={_port:null,setValue:function d(s){try{this._port.setValues([s])}catch(t){throw new MiMicException(t)}},setOpt:function c(t){try{this._port.setOpt(t)}catch(s){throw new MiMicException(s)}}}}());
\ No newline at end of file
+var LPC1769;(function(){var g=MiMicLib.isUndef;var a={_EE:function(n){return{NG:[n|0,"Unknown exception in LPC1769"],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.")};LPC1769=a}());(function(){var f=LPC1769;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",PWM:"PWM"};for(var s in t){if(v==s){return t[s]}}throw new MiMicException("Peripheral for "+v+" 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;case"DAC":new f.Dac(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=LPC1769;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 r=true;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);r=false}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 r?m:m[0]}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=LPC1769;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=LPC1769;var j=a._BCF;var k=a._EE;var c=MiMicLib.isUndef;var d=MiMicLib.cloneAssoc;var e=MiMicLib.isArray;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 g(m,n,l){try{this._mcu=m;this.pins=new Array();for(var o=0;o<n.length;o++){this.pins.push({pin:n[o],reginfo:a.getPinRegInfo(n[o])})}if(!c(l)){this.setOpts(l)}}catch(p){throw new MiMicException(p)}};a.Port.prototype={_mcu:null,pins:null,BCF_setOpts:function b(t,n){try{var s={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]};var l=e(t)?t:this.clonePinOptAssoc(t);for(var o=0;o<this.pins.length;o++){var p=this.pins[o].reginfo;var m=l[o];if(!c(m.sel)){s.selr[p.s]|=(m.sel<<p.smb);s.selr_mask[p.s]|=(3<<p.smb)}if(!c(m.mode)){s.modr[p.m]|=(m.mode<<p.smb);s.modr_mask[p.m]|=(3<<p.smb)}if(!c(m.od)){s.odr[p.o]|=(m.od<<p.ob);s.odr_mask[p.o]|=(1<<p.ob)}}var r="";for(var o=0;o<10;o++){if(s.selr_mask[o]!=0){r+=j.setBit(h._PINSEL[o],s.selr_mask[o],s.selr[o],0,n)}if(s.modr_mask[o]!=0){r+=j.setBit(h._PINMODE[o],s.modr_mask[o],s.modr[o],0,n)}}for(var o=0;o<5;o++){if(s.odr_mask[o]!=0){r+=j.setBit(h._PINMODE_OD[o],s.odr_mask[o],s.odr[o],0,n)}}return r}catch(q){throw new MiMicException(q)}},setOpts:function f(l){try{var m=new Array();var o=this.BCF_setOpts(l,m);if(o.length>0){this._mcu.callMiMicWithCheck(o+j.END,m)}}catch(n){throw new MiMicException(n)}return},clonePinOptAssoc:function i(l){var m=new Array();if(e(l)){if(l.length!=this.pins.length){throw new MiMicException()}for(var n=0;n<this.pins.length;n++){m.push(d(l[n]))}}else{for(var n=0;n<this.pins.length;n++){m.push(d(l))}}return m}}}());(function(){var f=LPC1769;var d=f._BCF;var b=f._EE;var c=MiMicLib.isUndef;f.Pin=function e(g,h,j){try{if(c(h)){throw new MiMicException(b.INVALID_PIN)}this._port=new f.Port(g,[h],c(j)?undefined:[j])}catch(i){throw new MiMicException(i)}};f.Pin.prototype={_port:null,setOpt:function a(h){try{this._port.setOpts([h])}catch(g){throw new MiMicException(g)}return}}}());(function(){var a=LPC1769;var p=a._BCF;var q=a._EE;var d=MiMicLib.isUndef;var j=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)?{}:j(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={_AD0CR:1073954816,_AD0DR:[1073954832,1073954836,1073954840,1073954844,1073954848,1073954852,1073954856,1073954860],_phl:null,_mcu:null,BCF_setOpt:function l(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 i(t,s,r){try{return p.setBit(this._AD0CR,t,s*t,0,r)}catch(u){throw new MiMicException(u)}},BCF_getAD0DR:function k(s,r){try{return p.getMem(this._AD0DR[s],r)}catch(t){throw new MiMicException(t)}},setOpt:function g(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 m(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 n(t){try{var u=new Array();for(var v=0;v<t.length;v++){var s=a.completePinFunctionName(t[v],"AD");var r=s.substring(2).split(".");if(isNaN(r[1])){throw new MiMicException(q.INVALID_CFG)}u.push({port:0,ch:parseInt(r[1]),pin_sel:a.getPinSelByFunctionName(t[v],s)})}return u}catch(w){throw new MiMicException(w)}}a.AdcPort=function o(t,s,y){try{this._adc=t;var r=n(s);var x=r[0].port;for(var v=1;v<r.length;v++){if(x!=r[v].port){throw new MiMicException("Invalid pin combination.")}}this._port=new a.Port(t._mcu,s);this._port_no=x;this._adcr_mask=0;for(var v=0;v<r.length;v++){this._adcr_mask|=(1<<r[v].ch)}var u={};if(d(y)){u.pin=this._port.clonePinOptAssoc({});u.sel=1}else{u.pin=this._port.clonePinOptAssoc(d(y.pin)?{}:y.pin);u.sel=1}for(var v=0;v<r.length;v++){if(d(u.pin[v].sel)){u.pin[v].sel=r[v].pin_sel}}this._pininfo=r;this.setOpt(u)}catch(w){throw new MiMicException(w)}};a.AdcPort.prototype={_adc:null,_pininfo:null,_port_no:0,_port:null,_adcr_mask:0,setOpt:function g(u){try{var r=new Array();var t="";if(!d(u.pin)){t+=this._port.BCF_setOpts(u.pin,r)}if(!d(u.sel)){t+=this._adc.BCF_setSels(this._adcr_mask,u.sel,r)}this._adc._mcu.callMiMicWithCheck(t+p.END,r);return}catch(s){throw new MiMicException(s)}},getValues:function h(){try{var s=new Array();var x="";for(var u=0;u<this._port.pins.length;u++){x+=this._adc.BCF_getAD0DR(this._pininfo[u].ch,s)}var t=this._adc._mcu.callMiMicWithCheck(x+p.END,s);var v=new Array();for(var u=0;u<this._port.pins.length;u++){v.push((t.stream[u]>>4)&4095)}return v}catch(w){throw new MiMicException(w)}}};a.AdcPin=function e(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 f(){try{return this._aport.getValues()[0]}catch(r){throw new MiMicException(r)}},setOpt:function g(s){try{this._aport.setOpt(s)}catch(r){throw new MiMicException(r)}}}}());(function(){var g=LPC1769;var p=g._BCF;var a=g._EE;var f=MiMicLib.isUndef;var n=MiMicLib.cloneAssoc;var j=MiMicLib.isArray;g.Gpio=function r(t,v){try{this._mcu=t;t.registerPhl(this,"GPIO")}catch(u){throw new MiMicException(u)}};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 l(u,v,t){try{t.push(this._FIO_PIN[u],this._FIO_MASK[u],~v);return"EA00EA01EA02DF0201DB0300EE03"}catch(w){throw new MiMicException(w)}},BCF_setValues:function h(v,w,u,t){try{t.push(this._FIO_PIN[v],this._FIO_MASK[v],~w,u);return"EA00EA01EA02EA03DF0201DF0300"}catch(x){throw new MiMicException(x)}},BCF_setDirs:function e(u,v,w,t){try{return p.setBit(this._FIO_DIR[u],v,w,0,t)}catch(x){throw new MiMicException(x)}},getPin:function q(t,v){try{return new g.GpioPin(this,t,v)}catch(u){throw new MiMicException(u)}},getPort:function s(t,v){try{return new g.GpioPort(this,t,v)}catch(u){throw new MiMicException(u)}}};function k(u){try{var v=new Array();for(var w=0;w<u.length;w++){var x=g.completePinFunctionName(u[w],"GPIO");var t=x.substring(4).split(".");if(isNaN(t[0])||isNaN(t[1])){throw new MiMicException(a.INVALID_CFG)}v.push({port:parseInt(t[0]),bit:parseInt(t[1]),pin_sel:g.getPinSelByFunctionName(u[w],x)})}return v}catch(y){throw new MiMicException(y)}}g.GpioPort=function o(x,u,A){try{this._gpio=x;var t=k(u);var z=t[0].port;for(var w=1;w<t.length;w++){if(z!=t[w].port){throw new MiMicException("Invalid pin combination.")}}this._port=new g.Port(x._mcu,u);this._port_no=z;this._mask=0;for(var w=0;w<t.length;w++){this._mask|=(1<<t[w].bit)}var v={};if(f(A)){v.pin=this._port.clonePinOptAssoc({})}else{v.pin=this._port.clonePinOptAssoc(f(A.pin)?{}:A.pin)}for(var w=0;w<t.length;w++){if(f(v.pin[w].sel)){v.pin[w].sel=t[w].pin_sel}}this._pininfo=t;this.setOpt(v)}catch(y){throw new MiMicException(y)}};g.GpioPort.prototype={_pininfo:null,_gpio:null,_port_no:0,_port:null,_mask:0,setOpt:function b(z){try{var t=this._pininfo;var u=new Array();var y="";if(!f(z.pin)){y+=this._port.BCF_setOpts(z.pin,u)}if(!f(z.dir)){var A=0;var w=0;if(j(z.dir)){for(var v=0;v<t.length;v++){if(f(z.dir[v])){continue}w|=(1<<t[v].bit);A|=(z.dir[v]<<t[v].bit)}}else{A=this._mask*z.dir;w=this._mask}y+=this._gpio.BCF_setDirs(this._port_no,w,A,u)}this._gpio._mcu.callMiMicWithCheck(y+p.END,u);return}catch(x){throw new MiMicException(x)}},setValue:function c(x){try{var w=0;for(var y=0;y<this._pininfo.length;y++){var t=((x>>y)&1);w|=(t<<this._pininfo[y].bit)}var u=new Array();var A=this._gpio.BCF_setValues(this._port_no,this._mask,w,u);this._gpio._mcu.callMiMicWithCheck(A+p.END,u)}catch(z){throw new MiMicException(z)}},getValue:function d(){try{var x=new Array();var A=this._gpio.BCF_getValues(this._port_no,this._mask,x);var u=this._gpio._mcu.callMiMicWithCheck(A+p.END,x).stream[0];var w=0;for(var y=this._pininfo.length-1;y>=0;y--){var t=((u>>this._pininfo[y].bit)&1);w=(w<<1)|t}return w}catch(z){throw new MiMicException(z)}},outPatt:function i(x){try{var w=new Array();var B="";for(var z=0;z<x.length;z++){var u=0;for(var y=0;y<this._pininfo.length;y++){var t=((x[z]>>y)&1);u|=(t<<this._pininfo[y].bit)}B+=this._gpio.BCF_setValues(this._port_no,this._mask,u,w)}this._gpio._mcu.callMiMicWithCheck(B+p.END,w)}catch(A){throw new MiMicException(A)}}};g.GpioPin=function m(t,u,w){try{this._gport=new g.GpioPort(t,[u],w)}catch(v){throw new MiMicException(v)}};g.GpioPin.prototype={_gport:null,setOpt:function b(u){try{this._gport.setOpt(u)}catch(t){throw new MiMicException(t)}},setValue:function c(t){try{this._gport.setValue(t)}catch(u){throw new MiMicException(u)}},getValue:function d(){try{return this._gport.getValue()}catch(t){throw new MiMicException(t)}},outPatt:function i(t){try{this._gport.outPatt(t)}catch(u){throw new MiMicException(u)}},}}());(function(){var f=LPC1769;var q=f._BCF;var a=f._EE;var d=MiMicLib.isUndef;var l=MiMicLib.isArray;var o=MiMicLib.cloneAssoc;f.Pwm=function j(v,A){try{this._mcu=v;this._phl=new f.Peripheral(v,f.PHL.PWM1);var x=d(A)?{phl:{}}:{phl:d(A.phl)?{}:o(A.phl),freq:A.freq};if(d(x.phl.power)){x.phl.power=1}if(d(x.phl.clock)){x.phl.clock=0}if(d(x.freq)){x.freq=100}var z="";var w=new Array();z+=this.BCF_setOpt(x,w);z+=q.setMem(this._PC,0,w);z+=q.setMem(this._PCR,0,w);z+=q.setMem(this._CTCR,0,w);z+=q.setMem(this._TCR,0,w);z+=q.setMem(this._TC,0,w);z+=q.setMem(this._TCR,9,w);this._mcu.callMiMicWithCheck(z+q.END,w);this._mcu.registerPhl(this,"PWM")}catch(y){throw new MiMicException(y)}};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 n(z,v){try{var y="";var w;if(!d(z.phl)){y+=this._phl.BCF_setOpt(z.phl,v)}if(!d(z.freq)){w=Math.round(this._phl.getPCLK()/z.freq);if(w<=0){throw new MiMicException("The peripheral clock too small.")}y+=this.BCF_setMRn(0,w,v);y+=this.BCF_setLER(0,v);this._cache.mr0=w}return y}catch(x){throw new MiMicException(x)}},BCF_setLER:function b(w,v){try{return q.setBit(this._LER,1,1,w,v)}catch(x){throw new MiMicException(x)}},BCF_setLERs:function m(x,w,v){try{return q.setBit(this._LER,x,w,0,v)}catch(y){throw new MiMicException(y)}},BCF_setMRn:function i(x,w,v){try{return q.setMem(this._MRn[x],w,v)}catch(y){throw new MiMicException(y)}},BCF_setMRnByDuty:function e(w,x,v){try{return this.BCF_setMRn(w,Math.round(x*this._cache.mr0),v)}catch(y){throw new MiMicException(y)}},BCF_setPCRbits:function g(C,y,z,x){try{var w,A;w=A=0;if(!d(y)){var B=255&C;A|=y*B;w|=B}if(!d(z)){var B=65280&C;A|=(z*B);w|=B}return q.setBit(this._PCR,w,A,0,x)}catch(D){throw new MiMicException(D)}},setOpt:function c(y){try{var v=new Array();var x=this.BCF_setOpt(y,v);this._mcu.callMiMicWithCheck(x+q.END,v)}catch(w){throw new MiMicException(w)}},getPin:function r(v,x){try{return new f.PwmPin(this,v,x)}catch(w){throw new MiMicException(w)}},getPort:function t(v,x){try{return new f.PwmPort(this,v,x)}catch(w){throw new MiMicException(w)}}};function h(w){try{var x=new Array();for(var y=0;y<w.length;y++){var z=f.completePinFunctionName(w[y],"PWM");var v=z.substring(2).split(".");if(isNaN(v[1])){throw new MiMicException(a.INVALID_CFG)}x.push({port:0,ch:parseInt(v[1]),pin_sel:f.getPinSelByFunctionName(w[y],z)})}return x}catch(A){throw new MiMicException(A)}}f.PwmPort=function s(x,w,C){try{this._pwm=x;var v=h(w);var B=v[0].port;for(var z=1;z<v.length;z++){if(B!=v[z].port){throw new MiMicException("Invalid pin combination.")}}this._port=new f.Port(x._mcu,w);this._port_no=B;var y={};if(d(C)){y.pin=this._port.clonePinOptAssoc({});y.duty=0;y.enable=1}else{y.pin=this._port.clonePinOptAssoc(d(C.pin)?{}:C.pin);y.duty=d(C.duty)?0:C.duty;y.enable=d(C.enable)?0:C.enable}for(var z=0;z<v.length;z++){if(d(y.pin[z].sel)){y.pin[z].sel=v[z].pin_sel}}this._pininfo=v;this.setOpt(y)}catch(A){throw new MiMicException(A)}};f.PwmPort.prototype={_pwm:null,_pininfo:null,_port_no:0,_port:null,setOpt:function c(v){try{var A=this._pininfo;var D=new Array();var C="";if(!d(v.pin)){C+=this._port.BCF_setOpts(v.pin,D)}if(!d(v.enable)){var w=0;var x=0;if(l(v.enable)){for(var z=0;z<A.length;z++){if(d(v.enable[z])){continue}x|=((257*v.enable[z])<<A[z].ch);w|=(257<<A[z].ch)}}else{for(var z=0;z<A.length;z++){w|=(257<<A[z].ch)}x=w*v.enable}C+=this._pwm.BCF_setPCRbits(w,0,x,D)}if(!d(v.duty)){var y=0;if(l(v.duty)){for(var z=0;z<A.length;z++){if(d(v.duty[z])){continue}C+=this._pwm.BCF_setMRnByDuty(A[z].ch,v.duty[z],D);y|=(1<<A[z].ch)}}else{for(var z=0;z<A.length;z++){C+=this._pwm.BCF_setMRnByDuty(A[z].ch,v.duty,D);y|=(1<<A[z].ch)}}C+=this._pwm.BCF_setLERs(y,y,D)}this._pwm._mcu.callMiMicWithCheck(C+q.END,D);return}catch(B){throw new MiMicException(B)}},setDutys:function k(w){try{this.setOpt({duty:w})}catch(v){throw new MiMicException(v)}}};f.PwmPin=function u(v,w,y){try{this._pport=new f.PwmPort(v,[w],y)}catch(x){throw new MiMicException(x)}};f.PwmPin.prototype={_pport:null,setOpt:function c(w){try{this._pport.setOpt(w)}catch(v){throw new MiMicException(v)}},setDuty:function p(v){try{this._pport.setDutys([v])}catch(w){throw new MiMicException(w)}}}}());(function(){var f=LPC1769;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,p,o){var n="";var q=new Array();if(!d(p)){for(var l=0;l<8;l++){var k="wm"+l;if(!d(p[k])){n+="FB"+MiMicLib.hexout(l,2)+MiMicLib.hexout(p[k],8)}}if(!d(p.stream)){for(var l=0;l<p.stream.length;l++){q.push(p.stream[l])}}}n+="ZF"+MiMicLib.hexout(j,8);var g=0;if(!d(o)){for(var l=0;l<8;l++){if(!d(o["wm"+l])){n+="EE"+MiMicLib.hexout(l,2);g++}}}var m=this._mcu.callMiMic(n+e.END,q);if(m.result!=0){return false}if(!d(o)){var h=m.stream.length-g;for(var l=0;l<8;l++){var k="wm"+l;if(!d(o[k])){o[k]=m.stream[h];h++}}if(!d(o.stream)){o.stream=m.stream.slice(0,m.stream.length-g)}}return false}}}());(function(){var g=LPC1769;var n=g._BCF;var a=g._EE;var f=MiMicLib.isUndef;var h=MiMicLib.isArray;var k=MiMicLib.cloneAssoc;g.Dac=function i(s,x){try{this._mcu=s;this._phl=new g.Peripheral(s,g.PHL.DAC);var u=f(x)?{phl:{}}:{phl:f(x.phl)?{}:k(x.phl),};if(f(u.phl.clock)){u.phl.clock=0}var w="";var t=new Array();w+=this.BCF_setOpt(u,t);this._mcu.callMiMicWithCheck(w+n.END,t);this._mcu.registerPhl(this,"DAC")}catch(v){throw new MiMicException(v)}};g.Dac.prototype={_DACR:1074315264,_DACCTRL:1074315268,_DACCNTVAL:1074315272,_phl:null,_mcu:null,BCF_setOpt:function j(v,s){try{var u="";if(!f(v.phl)){u+=this._phl.BCF_setOpt(v.phl,s)}return u}catch(t){throw new MiMicException(t)}},setOpt:function c(v){try{var s=new Array();var u=this.BCF_setOpt(v,s);this._mcu.callMiMicWithCheck(u+n.END,s)}catch(t){throw new MiMicException(t)}},getPin:function o(s,u){try{return new g.DacPin(this,s,u)}catch(t){throw new MiMicException(t)}},getPort:function r(s,u){try{return new g.DacPort(this,s,u)}catch(t){throw new MiMicException(t)}},BCF_setBias:function b(u,t,s){try{return n.setBit(this._DACR,u,t*u,0,s)}catch(v){throw new MiMicException(v)}},BCF_setValue:function l(t,s){return n.setBit(this._DACR,1023,t,6,s)}};function p(t){try{var u=new Array();for(var v=0;v<t.length;v++){var s=g.completePinFunctionName(t[v],"AOUT");u.push({port:0,pin_sel:g.getPinSelByFunctionName(t[v],s)})}return u}catch(w){throw new MiMicException(w)}}g.DacPort=function e(u,t,y){try{this._dac=u;var s=p(t);this._port=new g.Port(u._mcu,t);var w={};if(f(y)){w.pin=this._port.clonePinOptAssoc({});w.bias=0}else{w.pin=this._port.clonePinOptAssoc(f(y.pin)?{}:y.pin);w.bias=f(y.bias)?0:y.bias}for(var v=0;v<s.length;v++){if(f(w.pin[v].sel)){w.pin[v].sel=s[v].pin_sel}}this.setOpt(w)}catch(x){throw new MiMicException(x)}};g.DacPort.prototype={_dac:null,_port:null,setOpt:function c(v){try{var s=new Array();var u="";if(!f(v.pin)){u+=this._port.BCF_setOpts(v.pin,s)}if(!f(v.bias)){if(h(v.pin)){u+=this._dac.BCF_setBias(65536,v.bias[0],s)}else{u+=this._dac.BCF_setBias(65536,v.bias,s)}}this._dac._mcu.callMiMicWithCheck(u+n.END,s);return}catch(t){throw new MiMicException(t)}},setValues:function m(s){try{var t=new Array();var w="";for(var u=0;u<this._port.pins.length;u++){w+=this._dac.BCF_setValue(s[u],t)}this._dac._mcu.callMiMicWithCheck(w+n.END,t);return}catch(v){throw new MiMicException(v)}}};g.DacPin=function q(s,t,v){try{this._port=new g.DacPort(s,[t],v)}catch(u){throw new MiMicException(u)}};g.DacPin.prototype={_port:null,setValue:function d(s){try{this._port.setValues([s])}catch(t){throw new MiMicException(t)}},setOpt:function c(t){try{this._port.setOpt(t)}catch(s){throw new MiMicException(s)}}}}());
\ No newline at end of file
index aad458f..e26bcdf 100644 (file)
@@ -842,6 +842,7 @@ LPC1769=DEV;
                 * <li>GPIO - LPC1769.GpioPin</li>\r
                 * <li>AD - LPC1769.AdcPin</li>\r
                 * <li>PWM - LPC1769.PwmPin</li>\r
+                * <li>DA - LPC1769.DacPin</li>\r
                 * </ul>\r
                 */\r
                getPin:function getPin(/*...*/)\r
@@ -875,10 +876,10 @@ LPC1769=DEV;
                 * @return {object as PortObject}\r
                 * 返却されるインスタンスのクラスは、機能により異なる。機能とインスタンスのクラスの対応は、以下の通りである。\r
                 * <ul>\r
-                * <li>GPIO - LPC1769.GpioPin</li>\r
-                * <li>AD - LPC1769.AdcPin</li>\r
-                * <li>PWM - LPC1769.PwmPin</li>\r
-                * <li>DAC - LPC1769.DacPin</li>\r
+                * <li>GPIO - LPC1769.GpioPort</li>\r
+                * <li>AD - LPC1769.AdcPort</li>\r
+                * <li>PWM - LPC1769.PwmPort</li>\r
+                * <li>DA - LPC1769.DacPort</li>\r
                 * </ul>                 \r
                 */\r
                getPort:function getPort(i_pins,i_function_name)\r
@@ -1016,8 +1017,8 @@ DEV.Memory.prototype=
         * コンストラクタで指定したアドレスからのオフセット位置を指定する。4バイト境界でなければならない。\r
         * @param {int} i_size\r
         * 取得するバイト数を指定する。4バイト単位でなければならない。      \r
-        * @return {int or Array[int]}\r
-        * 取得する値の個数は、i_size/4個である。個数により、戻り値の型が異なるので注意すること。\r
+        * @return {Array[int]}\r
+        * 取得する値の個数は、i_size/4個である。\r
         * @example\r
         * var mcu=new LPC1769.Mcu("192.168.0.39");\r
         * var mem=new LPC1769.Memory(mcu); //create instance\r
@@ -1031,7 +1032,7 @@ DEV.Memory.prototype=
         * @param {array[int]} i_offsets\r
         * オフセットアドレスの配列。それぞれ4バイト境界でなければならない。\r
         * @return {int or Array[int]}\r
-        * 返却される値の個数は、i_offsetの長さと同じになる。個数により、戻り値の型が異なるので注意すること。\r
+        * 返却される値の個数は、i_offsetの長さと同じになる。\r
         * @example\r
         * var mcu=new LPC1769.Mcu("192.168.0.39");\r
         * var mem=new LPC1769.Memory(mcu); //create instance\r
@@ -1051,6 +1052,7 @@ DEV.Memory.prototype=
        read32:function read32(/*arguments*/)\r
        {\r
                try{\r
+                       var is_ret_array=true;\r
                        var bc="";\r
                        var ar=new Array();\r
                        var offset=arguments[0];\r
@@ -1061,6 +1063,7 @@ DEV.Memory.prototype=
                                        checkAlign(offset);\r
                                        bc=BCF.READMEM;\r
                                        ar.push(this._base+offset);\r
+                                       is_ret_array=false;\r
                                }else{\r
                                        //read32(i_offsets:array)\r
                                        for(var i=0;i<offset.length;i++){\r
@@ -1083,7 +1086,7 @@ DEV.Memory.prototype=
                                break;\r
                        }\r
                        var ret=this._mcu.callMiMicWithCheck(bc+BCF.END,ar).stream;\r
-                       return ret.length==1?ret[0]:ret;\r
+                       return is_ret_array?ret:ret[0];\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -1419,7 +1422,7 @@ DEV.Port.prototype=
         * 複数のピン設定をレジスタごとにまとめたBCを生成する。\r
         * @private\r
         * @param {array[associative array]| associative array} i_opts\r
-        * ã\83\94ã\83³è¨­å®\9aæ\83\85å ±ã\81®é\80£è£\85é\85\8då\88\97ã\81®é\85\8då\88\97ã\80\82é\85\8då\88\97ã\81®è¦\81ç´ æ\95°ã\81¯ã\80\81Portを構成するPinと同じ数である必要がある。\r
+        * ã\83\94ã\83³è¨­å®\9aæ\83\85å ±ã\81®é\80£è£\85é\85\8då\88\97ã\81\8bã\80\81ã\81\9dã\81®é\85\8då\88\97ã\80\82é\85\8då\88\97ã\81®æ\99\82ã\81¯Portを構成するPinと同じ数である必要がある。\r
         * 単一のassociative arrayを指定した場合は、全てのピンに同じパラメータを設定する。\r
         * <pre>associative array</>\r
         * ピン設定連装配列 {sel:int,mode:int,od:int}\r
@@ -1479,14 +1482,12 @@ DEV.Port.prototype=
                }\r
        },\r
        /**\r
-        * ポートにオプションパラメータをセットする。\r
-        * 関数は、ポートを構成するピンに、ピンオプション配列の値を個別に設定する。\r
+        * Portを構成するPinにオプション値を設定する。\r
         * @name LPC1769.Port#setOpts\r
         * @function\r
-        * @param {array[associative array]} i_opts\r
-        * ã\83\94ã\83³ã\82³ã\83³ã\83\95ã\82£ã\82°ã\83¬ã\83¼ã\82·ã\83§ã\83³ã\81®é\80£è£\85é\85\8då\88\97ã\81®配列である。\r
+        * @param {array[associative array] | associative array} i_opts\r
+        * ã\83\94ã\83³ã\82³ã\83³ã\83\95ã\82£ã\82°ã\83¬ã\83¼ã\82·ã\83§ã\83³ã\81®é\80£è£\85é\85\8då\88\97ã\80\81ã\81¾ã\81\9fã\81¯配列である。\r
         * ピンオプションの連装配列は、Pin#setOptを参照。\r
-        * 配列の要素数は、ポートを構成するピンの数と同じでなければならない。\r
         * @example\r
         * //set GPIO,mode=1,open drain=0\r
         * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -1638,7 +1639,7 @@ var cloneAssoc=MiMicLib.cloneAssoc;
  * @name LPC1769.Adc\r
  * @param {object as LPC1769.Mcu} i_mcu\r
  * インスタンスを結びつけるMcuオブジェクト。\r
- * @param {object as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * インスタンス生成と同時にsetOpt関数で設定する値。省略時は、{phl:{power:1}}とみなす。\r
  * 詳細はsetOpt関数を参照。 \r
  * @example\r
@@ -1725,10 +1726,10 @@ DEV.Adc.prototype=
         * ADCペリフェラルに、i_optのオプション値を設定する。\r
         * @name LPC1769.Adc#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
+        * @param {associative array} i_opt\r
         * ADCペリフェラルのコンフィグレーションパラメタである。必要な値を格納した連想配列で指定する。\r
         * 全ての値を省略することは出来ない。連想配列のメンバは以下の通り。\r
-        * <pre>{phl:object as associative array}</pre>\r
+        * <pre>{phl:associative array}</pre>\r
         * <ul>\r
         * <li>phl - LPC1769.Peripheral#setOpt関数のi_optに渡すパラメタである。</li>\r
         * </ul>\r
@@ -1758,8 +1759,8 @@ DEV.Adc.prototype=
         * @function\r
         * @param {object as ピン識別子} i_pin\r
         * AD機能を割り当てるPINの識別子である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * AdcPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPin.setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * AdcPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPinを参照。\r
         * @return {object as LPC1769.AdcPin}\r
         * LPC1769.AdcPinクラスのオブジェクトである。\r
         * @example\r
@@ -1785,8 +1786,8 @@ DEV.Adc.prototype=
         * @function\r
         * @param {array[ピン識別子]} i_pin\r
         * AD機能を割り当てるPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPort.setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPortを参照。\r
         * @return {object as LPC1769.AdcPort}\r
         * LPC1769.AdcPortクラスのオブジェクトである。\r
         * @example\r
@@ -1810,24 +1811,27 @@ DEV.Adc.prototype=
  * AD pinからADInfoを取得\r
  * @private\r
  */\r
-function pin2AdcPinInfo(i_pin)\r
+function makeAdcPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var func_name=DEV.completePinFunctionName(i_pin,"AD");\r
-               //portとbitを得る(AD0だけしか管理しないよ)\r
-               var a=func_name.substring(2).split(".");\r
-               var r={port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pin,func_name)};\r
-               if(!isNaN(r.ch)){\r
-                       return r;\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var func_name=DEV.completePinFunctionName(i_pins[i],"AD");\r
+                       //portとbitを得る(AD0だけしか管理しないよ)\r
+                       var a=func_name.substring(2).split(".");\r
+                       if(isNaN(a[1])){\r
+                               throw new MiMicException(EE.INVALID_CFG);\r
+                       }\r
+                       ret.push({port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pins[i],func_name)});\r
                }\r
-               throw new MiMicException(EE.INVALID_CFG,"The pin has not AD fuction.");\r
+               return ret;\r
        }catch(e){\r
-               throw new MiMicException(e);    \r
+               throw new MiMicException(e);\r
        }\r
 }\r
 /**\r
- * LPC1769.AdcPort (AdcPort)クラスのコンストラクタ。複数のADピンから一括で値を取得するときに使用する。\r
+ * LPC1769.AdcPort (AdcPort)クラスのコンストラクタ。複数のADcPinから一括で値を取得するときに使用する。\r
  * Adcペリフェラルオブジェクトにピン識別子の配列で指定されたピン集合を関連付けて、AD機能を持つポートを生成する。\r
  * 関数は、ピン識別子を元に、そのピンがAD機能に接続できるかを調べる。全てのピンにAD機能を割り当てられない場合、例外が発生する。どのピンにAD機能が割り当てられるかは、MCUのスペックシートを参照すること。\r
  * @constructor\r
@@ -1836,9 +1840,9 @@ function pin2AdcPinInfo(i_pin)
  * インスタンスを結びつけるAdcオブジェクト。\r
  * @param {array[pin識別子]} i_pins\r
  * ピン識別子の配列。指定できるのは、LPC1769.P?[?]である。順番は、このインスタンスの返す値の順序に影響する。\r
- * @param {object as associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto}}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * @param {array[associative array] | associative array} i_opt\r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined}}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create [AD0.0,AD0.1]\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -1850,15 +1854,11 @@ DEV.AdcPort=function AdcPort(i_adc,i_pins,i_opt)
        try{\r
                this._adc=i_adc;\r
                //ピンセットを取得\r
-               this._pins=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       this._pins.push(pin2AdcPinInfo(i_pins[i]));\r
-               }\r
+               var pininfo=makeAdcPinInfoArray(i_pins);\r
                //pinが全て同じポートに所属しているか確認\r
-               var p=this._pins[0].port;\r
-               for(var i=1;i<this._pins.length;i++){\r
-                       if(p!=this._pins[i].port){\r
+               var p=pininfo[0].port;\r
+               for(var i=1;i<pininfo.length;i++){\r
+                       if(p!=pininfo[i].port){\r
                                throw new MiMicException("Invalid pin combination.");\r
                        }\r
                }\r
@@ -1867,15 +1867,26 @@ DEV.AdcPort=function AdcPort(i_adc,i_pins,i_opt)
                this._port_no=p;\r
                //AD0CR用のマスクを生成。\r
                this._adcr_mask=0;\r
-               for(var i=0;i<this._pins.length;i++){\r
-                       this._adcr_mask|=(0x1<<this._pins[i].ch);\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       this._adcr_mask|=(0x1<<pininfo[i].ch);\r
                }\r
+\r
                //ピンオプションの生成\r
-               var opt=isUndef(i_opt)?{}:cloneAssoc(i_opt);\r
-               opt.sel=1;//ADxCRの値\r
-               opt.pin=isUndef(opt.pin)?{}:cloneAssoc(opt.pin);\r
-               //設定が無ければ、ピンセレクタを自動に設定\r
-               if(isUndef(opt.pin.sel)){opt.pin.sel=this._PINSEL_AUTO_DETECT;}\r
+               var opt={};\r
+               if(isUndef(i_opt)){\r
+                       opt.pin=this._port.clonePinOptAssoc({});\r
+                       opt.sel=1;//ADxCRの値\r
+               }else{\r
+                       opt.pin=this._port.clonePinOptAssoc(isUndef(i_opt.pin)?{}:i_opt.pin);\r
+                       opt.sel=1;//ADxCRの値\r
+               };\r
+               //pinselの自動設定\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       if(isUndef(opt.pin[i].sel)){\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
+                       }\r
+               }\r
+               this._pininfo=pininfo;\r
                //ピンオプションの設定\r
                this.setOpt(opt);\r
        }catch(e){\r
@@ -1884,9 +1895,8 @@ DEV.AdcPort=function AdcPort(i_adc,i_pins,i_opt)
 }\r
 DEV.AdcPort.prototype=\r
 {\r
-       _PINSEL_AUTO_DETECT:0x0fffffff,\r
        _adc:null,\r
-       _pins:null,\r
+       _pininfo:null,\r
        _port_no:0,\r
        _port:null,\r
        _adcr_mask:0,\r
@@ -1896,8 +1906,19 @@ DEV.AdcPort.prototype=
         * 設定可能な値は、LPC1769.AdcPin#setOptと同じである。\r
         * @name LPC1769.AdcPort#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
-        * LPC1769.AdcPin#setOptを参照。\r
+        * @param {associative array | array[associative array]} i_opt\r
+        * ADピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
+        * 全てのピンに同じパラメータを指定する場合は、連装配列で指定する。個別に設定する場合は、連装配列を配列にして指定する。\r
+        * <pre>{i_opt:associative array}</pre>\r
+        * <ul>\r
+        * <li>pin(option)</li>\r
+        * </ul>\r
+        * パラメータの詳細は、LPC1769.AdcPin#setOptを参照。\r
+        * @example\r
+        * //ポートを構成する全てのピンに同じパラメータを設定する場合\r
+        * setOpt({pin:{v1}});\r
+        * //ポートを構成するピンに個々にパラメータを設定する場合\r
+        * setOpt({pin:[{v1},{v2}]});\r
         */     \r
        setOpt:function setOpt(i_opt)\r
        {\r
@@ -1907,14 +1928,7 @@ DEV.AdcPort.prototype=
                        var bc="";\r
                        //i_optの展開\r
                        if(!isUndef(i_opt.pin)){\r
-                               var optset=new Array();\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       //pinselが_PINSEL_AUTO_DETECTならばauto。そうでなければundefinedも含めて設定\r
-                                       var s=(i_opt.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[i].pin_sel:i_opt.pin.sel;\r
-                                       optset.push({sel:s,mode:i_opt.pin.mode,od:i_opt.pin.od});\r
-                               }\r
-                               //portの設定\r
-                               bc+=this._port.BCF_setOpts(optset,db);\r
+                               bc+=this._port.BCF_setOpts(i_opt.pin,db);\r
                        }\r
                        //隠し。ADxCR\r
                        if(!isUndef(i_opt.sel)){\r
@@ -1945,13 +1959,13 @@ DEV.AdcPort.prototype=
                        //メモリから値取得\r
                        var db=new Array();\r
                        var bc="";\r
-                       for(var i=0;i<this._pins.length;i++){\r
-                               bc+=this._adc.BCF_getAD0DR(this._pins[i].ch,db);\r
+                       for(var i=0;i<this._port.pins.length;i++){\r
+                               bc+=this._adc.BCF_getAD0DR(this._pininfo[i].ch,db);\r
                        }\r
                        var ret=this._adc._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                        //値の整形\r
                        var r=new Array();\r
-                       for(var i=0;i<this._pins.length;i++){\r
+                       for(var i=0;i<this._port.pins.length;i++){\r
                                r.push((ret.stream[i]>>4)&0x00000fff);\r
                        }\r
                        return r;\r
@@ -1971,8 +1985,8 @@ DEV.AdcPort.prototype=
  * @param {object as pin識別子} i_pin\r
  * ピン識別子。指定できるのは、LPCXpresso1796.P?[?]である。\r
  * @param {object as associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto}}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined}}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create AD0.0\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -2015,10 +2029,10 @@ DEV.AdcPin.prototype=
         * ADピンにオプション値を設定する。\r
         * @name LPC1769.AdcPin#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
+        * @param {associative array} i_opt\r
         * ADピンのコンフィグレーションパラメタである。必要な値を格納した連想配列で指定する。\r
         * 全ての値を省略することは出来ない。連想配列のメンバは以下の通り。\r
-        * <pre>{pin:object as associative array}</pre>\r
+        * <pre>{pin:associative array}</pre>\r
         * <ul>\r
         * <li>pin - LPC1769.Pin#setOpt関数のi_optに渡すパラメタである。</li>\r
         * </ul>\r
@@ -2046,7 +2060,7 @@ var BCF=DEV._BCF;
 var EE=DEV._EE;\r
 var isUndef=MiMicLib.isUndef;\r
 var cloneAssoc=MiMicLib.cloneAssoc;\r
-\r
+var isArray=MiMicLib.isArray;\r
 /**\r
  * LPCXPresso1769.Gpio (Gpio)クラスのコンストラクタ。\r
  * MCUに関連付けしたGpioペリフェラルを生成する。\r
@@ -2055,7 +2069,7 @@ var cloneAssoc=MiMicLib.cloneAssoc;
  * @constructor\r
  * @param {object as LPC1769.Mcu} i_mcu\r
  * インスタンスを結びつけるMcuオブジェクト。\r
- * @param {oject as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * 常に無視する。省略すること。\r
  * @example\r
  * //create GPIO (logical)pheripheral\r
@@ -2117,13 +2131,14 @@ DEV.Gpio.prototype=
        },\r
        /**\r
         * \r
-        @param i_dir 1 or 0\r
-        @private
+        * @param {int} i_dir\r
+        * i_maskに合致したビットイメージ\r
+        * @private
         */\r
        BCF_setDirs:function BCF_setDirs(i_ch,i_mask,i_dir,i_db)\r
        {\r
                try{\r
-                       return BCF.setBit(this._FIO_DIR[i_ch],i_mask,i_mask*i_dir,0,i_db);\r
+                       return BCF.setBit(this._FIO_DIR[i_ch],i_mask,i_dir,0,i_db);\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -2137,8 +2152,8 @@ DEV.Gpio.prototype=
         * @function\r
         * @param {object as ピン識別子} i_pin\r
         * GPIO機能を割り当てるPINの識別子である。\r
-        * @param {object as associative array} i_opt\r
-        * GpioPinのコンストラクタに渡すオプション値を指定する。省略可能。省略時はundefinedとみなす。詳細はGpioPinのコンストラクタを参照。\r
+        * @param {associative array} i_opt\r
+        * GpioPinのコンストラクタに渡すオプション値を指定する。省略時はundefinedである。詳細はLPC1769.GpioPinを参照。\r
         * @return {object as GpioPin}\r
         * GpioPinクラスのオブジェクトである。\r
         * @example\r
@@ -2164,8 +2179,8 @@ DEV.Gpio.prototype=
         * @function\r
         * @param {array[ピン識別子]} i_pin\r
         * Gpioポートを構成するPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * GpioPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.GpioPort.setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * GpioPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.GpioPortを参照。\r
         * @return {object as LPC1769.GpioPort}\r
         * LPC1769.GpioPortクラスのオブジェクトである。\r
         * @example\r
@@ -2188,21 +2203,24 @@ DEV.Gpio.prototype=
  * GPIO pinからGPIOInfoを取得
  * @private
  */\r
-function pin2GpioPinInfo(i_pin)\r
+function makeGpioPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var fn=DEV.completePinFunctionName(i_pin,"GPIO");\r
-               //pin名からポートとビットを得る。\r
-               var a=fn.substring(4).split(".");\r
-               //pin情報を構成。\r
-               var r={port:parseInt(a[0]),bit:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pin,fn)};\r
-               if(!isNaN(r.port) && !isNaN(r.bit)){\r
-                       return r;\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var fn=DEV.completePinFunctionName(i_pins[i],"GPIO");\r
+                       //pin名からポートとビットを得る。\r
+                       var a=fn.substring(4).split(".");\r
+                       if(isNaN(a[0]) || isNaN(a[1])){\r
+                               throw new MiMicException(EE.INVALID_CFG);\r
+                       }\r
+                       //pin情報を構成。\r
+                       ret.push({port:parseInt(a[0]),bit:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pins[i],fn)});\r
                }\r
-               throw new MiMicException(EE.INVALID_CFG,"The pin has not GPIO fuction.");\r
+               return ret;\r
        }catch(e){\r
-               throw new MiMicException(e);    \r
+               throw new MiMicException(e);\r
        }\r
 }\r
 \r
@@ -2218,11 +2236,11 @@ function pin2GpioPinInfo(i_pin)
  * ピン識別子の配列。指定できるのは、LPCXpresso1796.P?[?]である。順番は、このインスタンスの返す値の順序に影響する。\r
  * 0番目のピンはビット0に対応する。同様に、1番目のピンはビット1に対応する。\r
  * 組み合わせるピンは、同じ物理ポートに所属している必要がある。例えば、GPIO0.0とGPIO0.1は組み合わせられるが、GPIO0.0とGPIO1.1は組み合わせることが出来ない。\r
- * @param {object as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto}}を設定する。\r
  * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
  * @example\r
- * //create [AD0.0,AD0.1]\r
+ * //create [LPC1769.P0[0],LPC1769.P0[1]]\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
  * var gpio=new LPC1769.Gpio(mcu);\r
  * var port=new LPC1769.GpioPort(adc,[LPC1769.P0[0],LPC1769.P0[1]]); \r
@@ -2232,15 +2250,11 @@ DEV.GpioPort=function GpioPort(i_gpio,i_pins,i_opt)
        try{\r
                this._gpio=i_gpio;\r
                //ピンセットを取得\r
-               this._pins=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       this._pins.push(pin2GpioPinInfo(i_pins[i]));\r
-               }\r
+               var pininfo=makeGpioPinInfoArray(i_pins);\r
                //pinが全て同じポートに所属しているか確認\r
-               var p=this._pins[0].port;\r
-               for(var i=1;i<this._pins.length;i++){\r
-                       if(p!=this._pins[i].port){\r
+               var p=pininfo[0].port;\r
+               for(var i=1;i<pininfo.length;i++){\r
+                       if(p!=pininfo[i].port){\r
                                throw new MiMicException("Invalid pin combination.");\r
                        }\r
                }\r
@@ -2249,15 +2263,24 @@ DEV.GpioPort=function GpioPort(i_gpio,i_pins,i_opt)
                this._port_no=p;\r
                //GPIO用のマスクを生成。\r
                this._mask=0;\r
-               for(var i=0;i<this._pins.length;i++){\r
-                       this._mask|=(0x1<<this._pins[i].bit);\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       this._mask|=(0x1<<pininfo[i].bit);\r
                }\r
+\r
                //ピンオプションの生成\r
-               var opt=cloneAssoc(i_opt);\r
-               //ピンプロパティの複製\r
-               opt.pin=isUndef(opt.pin)?{}:cloneAssoc(opt.pin);\r
-               //設定が無ければ、ピンセレクタを自動に設定\r
-               if(isUndef(opt.pin.sel)){opt.pin.sel=this._PINSEL_AUTO_DETECT;}\r
+               var opt={};\r
+               if(isUndef(i_opt)){\r
+                       opt.pin=this._port.clonePinOptAssoc({});\r
+               }else{\r
+                       opt.pin=this._port.clonePinOptAssoc(isUndef(i_opt.pin)?{}:i_opt.pin);\r
+               };\r
+               //pinselの自動設定\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       if(isUndef(opt.pin[i].sel)){\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
+                       }\r
+               }\r
+               this._pininfo=pininfo;\r
                //ピンオプションの設定\r
                this.setOpt(opt);\r
        }catch(e){\r
@@ -2266,8 +2289,7 @@ DEV.GpioPort=function GpioPort(i_gpio,i_pins,i_opt)
 }\r
 DEV.GpioPort.prototype=\r
 {\r
-       _PINSEL_AUTO_DETECT:0x0fffffff,//setoptに自動を伝えるときに使う\r
-       _pins:null,\r
+       _pininfo:null,\r
        _gpio:null,\r
        _port_no:0,\r
        _port:null,\r
@@ -2275,32 +2297,52 @@ DEV.GpioPort.prototype=
        /**\r
         * Gpioポートにオプション値を設定する。\r
         * 関数は、ポートを構成する全てのピンに、同一なオプション値を設定する。\r
-        * 設定可能な値は、LPC1769.GpioPin#setOptと同じである。\r
+        * 設定可能な値は、LPC1769.GpioPin#setOptと同じである。   \r
         * @name LPC1769.GpioPort#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
-        * LPC1769.GpioPin#setOptを参照。\r
+        * @param {associative array | array[associative array]} i_opt\r
+        * GPIOピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
+        * 全てのピンに同じパラメータを指定する場合は、連装配列で指定する。個別に設定する場合は、連装配列を配列にして指定する。\r
+        * <pre>{i_opt:associative array}</pre>\r
+        * <ul>\r
+        * <li>pin(option) - array[{PIN_OPTION}] | {PIN_OPTION}</li>\r
+        * <li>dir(option) - array[{1bit int}] | {1bit int}</li>\r
+        * </ul>\r
+        * パラメータの詳細は、LPC1769.GpioPin#setOptを参照。\r
+        * @example\r
+        * //ポートを構成する全てのピンに同じパラメータを設定する場合\r
+        * setOpt({pin:{v1},dir:1});\r
+        * //ポートを構成するピンに個々にパラメータを設定する場合\r
+        * setOpt({pin:[{v1},{v2}],dir:[1,1]});\r
         */     \r
        setOpt:function setOpt(i_opt)\r
        {\r
                try{\r
+                       var pininfo=this._pininfo;\r
                        var db=new Array();\r
                        //BCの生成\r
                        var bc="";\r
+                       //pinの設定\r
+                       if(!isUndef(i_opt.pin)){\r
+                               bc+=this._port.BCF_setOpts(i_opt.pin,db);\r
+                       }\r
                        //dir設定\r
                        if(!isUndef(i_opt.dir)){\r
-                               bc+=this._gpio.BCF_setDirs(this._port_no,this._mask,i_opt.dir,db);\r
-                       }\r
-                       //i_optの展開\r
-                       if(!isUndef(i_opt.pin)){\r
-                               var optset=new Array();\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       //pinselが_PINSEL_AUTO_DETECTならばauto。そうでなければundefinedも含めて設定\r
-                                       var s=(i_opt.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[i].pin_sel:i_opt.pin.sel;\r
-                                       optset.push({sel:s,mode:i_opt.pin.mode,od:i_opt.pin.od});\r
+                               var dir_bits=0x0;\r
+                               var dir_mask=0x0;\r
+                               if(isArray(i_opt.dir)){\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               if(isUndef(i_opt.dir[i])){\r
+                                                       continue;\r
+                                               }\r
+                                               dir_mask|=(0x1<<pininfo[i].bit);\r
+                                               dir_bits|=(i_opt.dir[i]<<pininfo[i].bit);\r
+                                       }\r
+                               }else{\r
+                                       dir_bits=this._mask*i_opt.dir;\r
+                                       dir_mask=this._mask;\r
                                }\r
-                               //portの設定\r
-                               bc+=this._port.BCF_setOpts(optset,db);\r
+                               bc+=this._gpio.BCF_setDirs(this._port_no,dir_mask,dir_bits,db);\r
                        }\r
                        this._gpio._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                        return;\r
@@ -2327,12 +2369,11 @@ DEV.GpioPort.prototype=
        {\r
                try{\r
                        var v=0;\r
-                       var l=this._pins.length;\r
-                       for(var i=0;i<l;i++){\r
+                       for(var i=0;i<this._pininfo.length;i++){\r
                                //セットするbit値を得る。\r
                                var sv=((i_val>>i)&0x01);\r
                                //値のセット\r
-                               v|=(sv<<this._pins[i].bit);\r
+                               v|=(sv<<this._pininfo[i].bit);\r
                        }\r
                        //値をセット\r
                        var db=new Array();\r
@@ -2365,9 +2406,9 @@ DEV.GpioPort.prototype=
                        var retval=this._gpio._mcu.callMiMicWithCheck(bc+BCF.END,db).stream[0];\r
                        //値の再構成\r
                        var v=0;\r
-                       for(var i=this._pins.length-1;i>=0;i--){\r
+                       for(var i=this._pininfo.length-1;i>=0;i--){\r
                                //セットするbit値を得る。\r
-                               var sv=((retval>>this._pins[i].bit)&0x1);\r
+                               var sv=((retval>>this._pininfo[i].bit)&0x1);\r
                                //値のセット(pinArrayの並びとビット並びが同じになるようにする)\r
                                v=(v<<1)|sv;\r
                        }\r
@@ -2400,12 +2441,11 @@ DEV.GpioPort.prototype=
                        var bc="";\r
                        for(var i2=0;i2<i_val_array.length;i2++){\r
                                var v=0;\r
-                               var l=this._pins.length;\r
-                               for(var i=0;i<l;i++){\r
+                               for(var i=0;i<this._pininfo.length;i++){\r
                                        //セットするbit値を得る。\r
                                        var sv=((i_val_array[i2]>>i)&0x01);\r
                                        //値のセット(pinArrayの並びと最下位ビットの位置が同じになるように反転)\r
-                                       v|=(sv<<this._pins[i].bit);\r
+                                       v|=(sv<<this._pininfo[i].bit);\r
                                }\r
                                //値をセット\r
                                bc+=this._gpio.BCF_setValues(this._port_no,this._mask,v,db);\r
@@ -2452,7 +2492,7 @@ DEV.GpioPin.prototype=
 {\r
        _gport:null,\r
        /**\r
-        * ADピンにオプション値を設定する。\r
+        * GPIOピンにオプション値を設定する。\r
         * @name LPC1769.GpioPin#setOpt\r
         * @function\r
         * @param {object as associative array} i_opt\r
@@ -2559,6 +2599,7 @@ var DEV=LPC1769;
 var BCF=DEV._BCF;\r
 var EE=DEV._EE;\r
 var isUndef=MiMicLib.isUndef;\r
+var isArray=MiMicLib.isArray;\r
 var cloneAssoc=MiMicLib.cloneAssoc;\r
 \r
 \r
@@ -2572,7 +2613,7 @@ var cloneAssoc=MiMicLib.cloneAssoc;
  * @constructor\r
  * @param {object as LPC1769.Mcu} i_mcu\r
  * インスタンスを結びつけるMcuオブジェクト。\r
- * @param {aobject as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * インスタンス生成と同時にsetOpt関数でセットする値を指定する。省略時は、{freq:100,phl:{power:1,clock:0}}である。\r
  * 詳細は、setOpt関数を参照。 \r
  * @example\r
@@ -2680,7 +2721,7 @@ DEV.Pwm.prototype=
        {\r
                try{\r
                        //LERにビットをセット\r
-                       return BCF.setBit(this._LER,i_mask,i_value*i_mask,0,i_db);\r
+                       return BCF.setBit(this._LER,i_mask,i_value,0,i_db);\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -2708,7 +2749,6 @@ DEV.Pwm.prototype=
        },\r
        /**\r
         * PCRに値を設定するBC\r
-        i_ch=1の場合、エッジモードは無視します。\r
         @private\r
         @param i_mask\r
         @param i_edge\r
@@ -2743,10 +2783,10 @@ DEV.Pwm.prototype=
         * 設定する値は、全てのPWMチャンネル(PIN)に共通な項目である。\r
         * @name LPC1769.Pwm#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
+        * @param {associative array} i_opt\r
         * GPIOピンのコンフィグレーションパラメタである。必要な値を格納した連想配列で指定する。\r
         * 全ての値を省略することは出来ない。連想配列のメンバは以下の通り。\r
-        * <pre>{freq:int,phl:object as associative array}</pre>\r
+        * <pre>{freq:int,phl:associative array}</pre>\r
         * <ul>\r
         * <li>freq - PWMの基本周波数(Hz)である。この値は、全てのPWMチャンネルで共通である。</li>\r
         * <li>phl - ペリフェラルの共通パラメタである。LPC1769.Peripheral.setOpt関数のi_optに渡すパラメタである。詳細はLPC1769.Peripheral#setOptを参照。</li>\r
@@ -2776,8 +2816,8 @@ DEV.Pwm.prototype=
         * @function\r
         * @param {object as ピン識別子} i_pin\r
         * PWM機能を割り当てるPINの識別子である。\r
-        * @param {object as associative array} i_opt\r
-        * PemPinのコンストラクタに渡すオプション値。省略時は{duty:0,enable:1,pin:{sel:auto}}である\r
+        * @param {associative array} i_opt\r
+        * PwmPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.PwmPinを参照\r
         * @return {object as LPC1769.PwmPin}\r
         * LPC1769.PwmPinクラスのオブジェクトである。\r
         * @example\r
@@ -2803,8 +2843,8 @@ DEV.Pwm.prototype=
         * @function\r
         * @param {array[ピン識別子]} i_pin\r
         * Pwm機能を割り当てるPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.PwmPort#setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * PwmPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.PwmPortを参照。\r
         * @return {object as LPC1769.PwmPort}\r
         * LPC1769.PwmPortクラスのオブジェクトである。\r
         * @example\r
@@ -2827,20 +2867,23 @@ DEV.Pwm.prototype=
  * Pwm pinからPwmInfoを取得\r
  * @private\r
  */\r
-function pin2PwmPinInfo(i_pin)\r
+function makePwmPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var fn=DEV.completePinFunctionName(i_pin,"PWM");\r
-               //portとbitを得る(AD0だけしか管理しないよ)\r
-               var a=fn.substring(2).split(".");\r
-               var r={port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pin,fn)};\r
-               if(!isNaN(r.ch)){\r
-                       return r;\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var fn=DEV.completePinFunctionName(i_pins[i],"PWM");\r
+                       //portとbitを得る\r
+                       var a=fn.substring(2).split(".");\r
+                       if(isNaN(a[1])){\r
+                               throw new MiMicException(EE.INVALID_CFG);\r
+                       }\r
+                       ret.push({port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pins[i],fn)});\r
                }\r
-               throw new MiMicException(EE.INVALID_CFG,"The pin has not PWM fuction.");\r
+               return ret;\r
        }catch(e){\r
-               throw new MiMicException(e);    \r
+               throw new MiMicException(e);\r
        }\r
 }\r
 /**\r
@@ -2870,15 +2913,12 @@ DEV.PwmPort=function PwmPort(i_pwm,i_pins,i_opt)
        try{\r
                this._pwm=i_pwm;\r
                //ピンセットを取得\r
-               this._pins=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       this._pins.push(pin2PwmPinInfo(i_pins[i]));\r
-               }\r
+               var pininfo=makePwmPinInfoArray(i_pins);\r
+\r
                //pinが全て同じポートに所属しているか確認\r
-               var p=this._pins[0].port;\r
-               for(var i=1;i<this._pins.length;i++){\r
-                       if(p!=this._pins[i].port){\r
+               var p=pininfo[0].port;\r
+               for(var i=1;i<pininfo.length;i++){\r
+                       if(p!=pininfo[i].port){\r
                                throw new MiMicException("Invalid pin combination.");\r
                        }\r
                }\r
@@ -2886,22 +2926,25 @@ DEV.PwmPort=function PwmPort(i_pwm,i_pins,i_opt)
                this._port=new DEV.Port(i_pwm._mcu,i_pins);\r
                this._port_no=p;\r
                \r
-               this._ler_mask=0;\r
-               this._pcr_mask=0;\r
-               for(var i=0;i<this._pins.length;i++){\r
-                       this._ler_mask|=(0x1<<this._pins[i].ch);\r
-                       this._pcr_mask|=(0x101<<this._pins[i].ch);\r
-               }               \r
-               var opt=isUndef(i_opt)?{pin:{}}:\r
-               {\r
-                       pin:isUndef(i_opt.pin)?{}:cloneAssoc(i_opt.pin),\r
-                       duty:i_opt.duty,\r
-                       enable:i_opt.enable\r
+\r
+               //ピンオプションの生成\r
+               var opt={};\r
+               if(isUndef(i_opt)){\r
+                       opt.pin=this._port.clonePinOptAssoc({});\r
+                       opt.duty=0;\r
+                       opt.enable=1;\r
+               }else{\r
+                       opt.pin=this._port.clonePinOptAssoc(isUndef(i_opt.pin)?{}:i_opt.pin);\r
+                       opt.duty=isUndef(i_opt.duty)?0:i_opt.duty;\r
+                       opt.enable=isUndef(i_opt.enable)?0:i_opt.enable;\r
                };\r
-               //デフォルト値のロード\r
-               if(isUndef(opt.pin.sel)){opt.pin.sel=this._PINSEL_AUTO_DETECT;}\r
-               if(isUndef(opt.duty)){opt.duty=0;}\r
-               if(isUndef(opt.enable)){opt.enable=1;}\r
+               //pinselの自動設定\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       if(isUndef(opt.pin[i].sel)){\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
+                       }\r
+               }\r
+               this._pininfo=pininfo;\r
                this.setOpt(opt);\r
        }catch(e){\r
                throw new MiMicException(e);\r
@@ -2909,21 +2952,24 @@ DEV.PwmPort=function PwmPort(i_pwm,i_pins,i_opt)
 }\r
 DEV.PwmPort.prototype=\r
 {\r
-       _PINSEL_AUTO_DETECT:0x0fffffff,\r
        _pwm:null,\r
-       _pins:null,\r
+       _pininfo:null,\r
        _port_no:0,\r
        _port:null,\r
-       _pcr_mask:0,\r
-       _ler_mask:0,\r
        /**\r
         * PWMポートにオプション値を設定する。\r
-        * 関数は、ポートを構成する全てのピンに、同じ値を設定する。\r
         * 設定可能な値は、LPC1769.PwmPin#setOptと同じである。    \r
         * @name LPC1769.PwmPort#setOpt\r
         * @function\r
         * @param {object as associative array} i_opt\r
-        * LPC1769.PwmPin#setOptを参照。\r
+        * PWMピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
+        * 全てのピンに同じパラメータを指定する場合は、連装配列で指定する。個別に設定する場合は、連装配列を配列にして指定する。\r
+        * <pre>{i_opt:associative array}</pre>\r
+        * <ul>\r
+        * <li>pin(option) - array[{PIN_OPTION}] | {PIN_OPTION}</li>\r
+        * <li>enable(option) - array[{1bit int}] | {1bit int}</li>\r
+        * <li>duty(option) - array[{1bit int}] | {1bit int}</li>\r
+        * </ul>\r
         * @example\r
         * var mcu=new LPC1769.Mcu("192.168.128.39",true);\r
         * var pwm=mcu.getPeripheral("PWM",{freq:100});\r
@@ -2933,32 +2979,53 @@ DEV.PwmPort.prototype=
        setOpt:function setOpt(i_opt)\r
        {\r
                try{\r
+                       var pininfo=this._pininfo;\r
                        var db=new Array();\r
                        //BCの生成\r
                        var bc="";\r
-                       //i_optの展開\r
+                       //pinの設定\r
                        if(!isUndef(i_opt.pin)){\r
-                               var optset=new Array();\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       //pinselが_PINSEL_AUTO_DETECTならばauto。そうでなければundefinedも含めて設定\r
-                                       var s=(i_opt.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[i].pin_sel:i_opt.pin.sel;\r
-                                       optset.push({sel:s,mode:i_opt.pin.mode,od:i_opt.pin.od});\r
-                               }\r
-                               //portの設定\r
-                               bc+=this._port.BCF_setOpts(optset,db);\r
+                               bc+=this._port.BCF_setOpts(i_opt.pin,db);\r
                        }\r
-                       //PCRに値設定\r
+                       //enable設定\r
                        if(!isUndef(i_opt.enable)){\r
-                               bc+=this._pwm.BCF_setPCRbits(this._pcr_mask,0,i_opt.enable,db);\r
+                               var pcr_mask=0x0;\r
+                               var enable_bits=0x0;\r
+                               if(isArray(i_opt.enable)){\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               if(isUndef(i_opt.enable[i])){\r
+                                                       continue;\r
+                                               }\r
+                                               enable_bits|=((0x101*i_opt.enable[i])<<pininfo[i].ch);\r
+                                               pcr_mask|=(0x101<<pininfo[i].ch);\r
+                                       }\r
+                               }else{\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               pcr_mask|=(0x101<<pininfo[i].ch);\r
+                                       }\r
+                                       enable_bits=pcr_mask*i_opt.enable;\r
+                               }\r
+                               //edgeは固定でゼロ、enableはビット配列。\r
+                               bc+=this._pwm.BCF_setPCRbits(pcr_mask,0,enable_bits,db);\r
                        }\r
-                       //デューティ比を\r
+                       //dutyの設定\r
                        if(!isUndef(i_opt.duty)){\r
-                               //デューティ比を設定\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       bc+=this._pwm.BCF_setMRnByDuty(this._pins[i].ch,i_opt.duty,db);\r
+                               var ler_value=0;\r
+                               if(isArray(i_opt.duty)){\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               if(isUndef(i_opt.duty[i])){\r
+                                                       continue;\r
+                                               }\r
+                                               bc+=this._pwm.BCF_setMRnByDuty(pininfo[i].ch,i_opt.duty[i],db);\r
+                                               ler_value|=(0x1<<pininfo[i].ch);\r
+                                       }\r
+                               }else{\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               bc+=this._pwm.BCF_setMRnByDuty(pininfo[i].ch,i_opt.duty,db);\r
+                                               ler_value|=(0x1<<pininfo[i].ch);\r
+                                       }\r
                                }\r
-                               //LERにセット\r
-                               bc+=this._pwm.BCF_setLERs(this._ler_mask,1,db);\r
+                               bc+=this._pwm.BCF_setLERs(ler_value,ler_value,db);\r
                        }\r
                        this._pwm._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                        return;\r
@@ -2967,12 +3034,13 @@ DEV.PwmPort.prototype=
                }\r
        },\r
        /**\r
-        * PWMポートのデューティ比をまとめて変更する。\r
+        * PWMポートのデューティ比を変更する。\r
+        * この関数は、LPC1769.PwmPort#setOpt関数へのショートカットである。\r
         * @name LPC1769.PwmPort#setDutys\r
         * @function\r
         * @param {array[double]} i_duty_array\r
         * デューティ比の配列である。0.0<=n<=1.0のdouble値を指定する。\r
-        * ã\83\9dã\83¼ã\83\88ã\82\92æ§\8bæ\88\90ã\81\99ã\82\8bã\83\94ã\83³ã\81®æ\95°ã\81 ã\81\91æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å¤\89æ\9b´ã\81\97ã\81ªã\81\84ã\83\94ã\83³ã\81«ã\81¯ã\80\81undefinedã\82\92æ\8c\87å®\9aã\81\99ã\82\8bã\81\93ã\81¨\r
+        * ã\83\9dã\83¼ã\83\88ã\82\92æ§\8bæ\88\90ã\81\99ã\82\8bã\83\94ã\83³ã\81®æ\95°ã\81 ã\81\91æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å¤\89æ\9b´ã\81\97ã\81ªã\81\84ã\83\94ã\83³ã\81«ã\81¯ã\80\81undefinedã\82\92æ\8c\87å®\9aã\81§ã\81\8dã\82\8b\r
         * @example\r
         * varmcu=new LPC1769.Mcu("192.168.128.39",true);\r
         * var pwm=mcu.getPeripheral("PWM",{freq:100});\r
@@ -2983,20 +3051,7 @@ DEV.PwmPort.prototype=
        setDutys:function setDutys(i_duty_array)\r
        {\r
                try{\r
-                       if(i_duty_array.length!=this._pins.length){\r
-                               throw new MiMicException();\r
-                       }\r
-                       var bc="";\r
-                       var db=new Array();\r
-                       //デューティ比をまとめてセット\r
-                       for(var i=0;i<this._pins.length;i++){\r
-                               if(!isUndef(i_duty_array[i])){\r
-                                       bc+=this._pwm.BCF_setMRnByDuty(this._pins[i].ch,i_duty_array[i],db);\r
-                               }\r
-                       }\r
-                       //LERにセット\r
-                       bc+=this._pwm.BCF_setLERs(this._ler_mask,1,db);\r
-                       this._pwm._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
+                       this.setOpt({duty:i_duty_array});\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -3013,9 +3068,9 @@ DEV.PwmPort.prototype=
  * インスタンスを結びつけるAdcオブジェクト。\r
  * @param {object as pin識別子} i_pin\r
  * ピン識別子。指定できるのは、LPC1769.P?[?]である。\r
- * @param {object as associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{duty:100,enable:1,pin{sel:auto}}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * @param {associative array} i_opt\r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{duty:100,enable:1,pin{sel:undefined}}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create PWM1.0\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -3353,15 +3408,15 @@ DEV.Dac.prototype=
        },      \r
        /**\r
         * DA機能を持つピンを取得する。\r
-        * ピン識別子で指定されるピンをDAペリフェラルと結合して、DaPinを生成する。\r
-        * 関数は、DacPinオブジェクトのコンストラクタをコールして、DaPinを生成する。失敗すると、例外をスローする。\r
+        * ピン識別子で指定されるピンをDAペリフェラルと結合して、DacPinを生成する。\r
+        * 関数は、DacPinオブジェクトのコンストラクタをコールして、DacPinを生成する。失敗すると、例外をスローする。\r
         * 生成ルールについての詳細は、DacPinを参照。\r
         * @name LPC1769.Dac#getPin\r
         * @function\r
         * @param {object as ピン識別子} i_pin\r
-        * Da機能を割り当てるPINの識別子である。値は、LPC1769.Pn[m]のメンバ変数である。\r
+        * Dac機能を割り当てるPINの識別子である。値は、LPC1769.Pn[m]のメンバ変数である。\r
         * @param {associative array} i_opt\r
-        * AdcPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.DacPin.setOptを参照。\r
+        * DacPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.DacPinを参照。\r
         * @return {object as LPC1769.AdcPin}\r
         * LPC1769.DacPinクラスのオブジェクトである。\r
         * @example\r
@@ -3389,7 +3444,7 @@ DEV.Dac.prototype=
         * @param {array[ピン識別子]} i_pin\r
         * AD機能を割り当てるPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
         * @param {associative array} i_opt\r
-        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.DacPort.setOptを参照。\r
+        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.DacPortを参照。\r
         * @return {object as LPC1769.DacPort}\r
         * LPC1769.DacPortクラスのオブジェクトである。\r
         * @example\r
@@ -3435,16 +3490,20 @@ DEV.Dac.prototype=
  * DA pinからDAInfoを取得\r
  * @private\r
  */\r
-function pin2DacPinInfo(i_pin)\r
+function makeDacPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var func_name=DEV.completePinFunctionName(i_pin,"AOUT");\r
-               //portとbitを得る(AD0だけしか管理しないよ)\r
-               return {\r
-                       port:0,\r
-                       pin_sel:DEV.getPinSelByFunctionName(i_pin,func_name)\r
-               };//DAPinは1ピンのみなので、特に識別パラメータはない。\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var func_name=DEV.completePinFunctionName(i_pins[i],"AOUT");\r
+                       //portとbitを得る(AD0だけしか管理しないよ)\r
+                       ret.push({\r
+                               port:0,\r
+                               pin_sel:DEV.getPinSelByFunctionName(i_pins[i],func_name)\r
+                       });\r
+               };\r
+               return ret;\r
        }catch(e){\r
                throw new MiMicException(e);    \r
        }\r
@@ -3461,8 +3520,8 @@ function pin2DacPinInfo(i_pin)
  * @param {array[pin識別子]} i_pins\r
  * ピン識別子の配列。指定できるのは、LPC1769.P?[?]である。順番は、このインスタンスの返す値の順序に影響する。\r
  * @param {associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略時は{pin:{sel:%AUTO%},bias:0}を設定する。\r
- * 詳細はsetOpt関数を参照。 %AUTO%は関数がPin情報から自動的に決定する。(指定は出来ない。)\r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined},bias:0}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create [AOUT]\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -3473,12 +3532,8 @@ DEV.DacPort=function DacPort(i_adc,i_pins,i_opt)
 {\r
        try{\r
                this._dac=i_adc;\r
-               //ピンセットを取得\r
-               var pininf=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       pininf.push(pin2DacPinInfo(i_pins[i]));\r
-               }\r
+               //Pin情報配列を生成\r
+               var pininfo=makeDacPinInfoArray(i_pins);\r
                //ポートの生成\r
                this._port=new DEV.Port(i_adc._mcu,i_pins);\r
                //ピンオプションの生成\r
@@ -3491,9 +3546,9 @@ DEV.DacPort=function DacPort(i_adc,i_pins,i_opt)
                        opt.bias=isUndef(i_opt.bias)?0:i_opt.bias;\r
                };\r
                //pinselの自動設定\r
-               for(var i=0;i<this._port.pins.length;i++){\r
+               for(var i=0;i<pininfo.length;i++){\r
                        if(isUndef(opt.pin[i].sel)){\r
-                               opt.pin[i].sel=pininf[i].pin_sel;\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
                        }\r
                }\r
                //ピンオプションの設定\r
@@ -3508,24 +3563,23 @@ DEV.DacPort.prototype=
        _port:null,\r
        /**\r
         * ポートにオプション値を設定する。\r
-        * 関数は、ポートを構成する全てのピンに、同一なオプション値を設定する。\r
         * 設定可能な値は、LPC1769.DacPin#setOptと同じである。\r
         * @name LPC1769.DacPort#setOpt\r
         * @function\r
-        * @param {associative array| array[associative array]} i_opt\r
-        * DAã\83\94ã\83³ã\81®ã\82³ã\83³ã\83\95ã\82£ã\82°ã\83¬ã\83¼ã\82·ã\83§ã\83³ã\83\91ã\83©ã\83¡ã\82¿ã\81§ã\81\82ã\82\8bã\80\82å¿\85è¦\81ã\81ªå\80¤ã\82\92æ ¼ç´\8dã\81\97ã\81\9fé\80£æ\83³é\85\8då\88\97ã\81§指定する。\r
-        * å\85¨ã\81¦ã\81®ã\83\94ã\83³ã\81«å\90\8cã\81\98ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\82\92æ\8c\87å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\81§æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å\80\8bå\88¥ã\81«è¨­å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\81«é\85\8då\88\97ã\82\92å\85¥ã\82\8cå­\90ã\81§指定する。\r
+        * @param {associative array | array[associative array]} i_opt\r
+        * DAã\83\94ã\83³ã\81®ã\82³ã\83³ã\83\95ã\82£ã\82°ã\83¬ã\83¼ã\82·ã\83§ã\83³ã\83\91ã\83©ã\83¡ã\82¿ã\81§ã\81\82ã\82\8bã\80\82å¿\85è¦\81ã\81ªå\80¤ã\82\92æ ¼ç´\8dã\81\97ã\81\9fé\80£æ\83³é\85\8då\88\97ã\80\81ã\81¾ã\81\9fã\81¯ã\81\9dã\81®é\85\8då\88\97ã\82\92指定する。\r
+        * å\85¨ã\81¦ã\81®ã\83\94ã\83³ã\81«å\90\8cã\81\98ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\82\92æ\8c\87å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\81§æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å\80\8bå\88¥ã\81«è¨­å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\82\92é\85\8då\88\97ã\81«ã\81\97ã\81¦指定する。\r
         * <pre>{i_opt:associative array}</pre>\r
         * <ul>\r
         * <li>pin(option)</li>\r
         * <li>bias(option)</li>\r
         * </ul>\r
-        * パラメータの詳細は、DacPin#setOptを参照。\r
+        * パラメータの詳細は、LPC1769.DacPin#setOptを参照。\r
         * @example\r
         * //ポートを構成する全てのピンに同じパラメータを設定する場合\r
-        * setOpt(pin:v1,bias:v1);\r
+        * setOpt({pin:{v1},bias:v1});\r
         * //ポートを構成するピンに個々にパラメータを設定する場合\r
-        * setOpt(pin:[{v1},{v2}],bias:[v1,v2...]);\r
+        * setOpt({pin:[{v1},{v2}],bias:[v1,v2...]});\r
         */     \r
        setOpt:function setOpt(i_opt)\r
        {\r
@@ -3593,8 +3647,8 @@ DEV.DacPort.prototype=
  * @param {object as pin識別子} i_pin\r
  * ピン識別子。指定できるのは、LPCXpresso1796.P?[?]である。\r
  * @param {associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto},bias:0}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined},bias:0}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create AOUT\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -3614,16 +3668,16 @@ DEV.DacPin.prototype=
 {\r
        _port:null,\r
        /**\r
-        * æ\95°å\80¤ã\82\92DAå¤\89æ\8f\9bã\81\97ã\81¦ã\83\94ã\83³ã\81«å\87ºå\8a\9bã\81\97ã\81¾ã\81\99\r
+        * æ\95°å\80¤ã\82\92DAå¤\89æ\8f\9bã\81\97ã\81¦ã\83\94ã\83³ã\81«å\87ºå\8a\9bã\81\99ã\82\8b\r
         * @name LPC1769.DacPin#setValue\r
         * @function\r
         * @return {int}\r
-        * 10bitã\81®ADå¤\89æ\8f\9bå\80¤ã\82\92è¿\94ã\81\99ã\80\82å\80¤ã\81®æ\84\8få\91³ã\81¯ã\80\81UM10360 Chapter 30: LPC17xx Digital-to-Analog Converter (DAC)ã\82\92å\8f\82ç\85§ã\80\82\r
+        * 10bitのAD変換値。値の意味は、UM10360 Chapter 30: LPC17xx Digital-to-Analog Converter (DAC)を参照。\r
         * @example\r
         * //set value of DA0 pin\r
         * var mcu=new LPC1769.Mcu("192.168.0.39");\r
         * var pin=mcu.getPin("AOUT");\r
-        * pin.setValue(3939);\r
+        * pin.setValue(100);\r
         */\r
        setValue:function setValue(i_value)\r
        {\r
index b1e89cf..3b4dfcc 100644 (file)
@@ -103,15 +103,15 @@ DEV.Dac.prototype=
        },      \r
        /**\r
         * DA機能を持つピンを取得する。\r
-        * ピン識別子で指定されるピンをDAペリフェラルと結合して、DaPinを生成する。\r
-        * 関数は、DacPinオブジェクトのコンストラクタをコールして、DaPinを生成する。失敗すると、例外をスローする。\r
+        * ピン識別子で指定されるピンをDAペリフェラルと結合して、DacPinを生成する。\r
+        * 関数は、DacPinオブジェクトのコンストラクタをコールして、DacPinを生成する。失敗すると、例外をスローする。\r
         * 生成ルールについての詳細は、DacPinを参照。\r
         * @name LPC1769.Dac#getPin\r
         * @function\r
         * @param {object as ピン識別子} i_pin\r
-        * Da機能を割り当てるPINの識別子である。値は、LPC1769.Pn[m]のメンバ変数である。\r
+        * Dac機能を割り当てるPINの識別子である。値は、LPC1769.Pn[m]のメンバ変数である。\r
         * @param {associative array} i_opt\r
-        * AdcPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.DacPin.setOptを参照。\r
+        * DacPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.DacPinを参照。\r
         * @return {object as LPC1769.AdcPin}\r
         * LPC1769.DacPinクラスのオブジェクトである。\r
         * @example\r
@@ -139,7 +139,7 @@ DEV.Dac.prototype=
         * @param {array[ピン識別子]} i_pin\r
         * AD機能を割り当てるPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
         * @param {associative array} i_opt\r
-        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.DacPort.setOptを参照。\r
+        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.DacPortを参照。\r
         * @return {object as LPC1769.DacPort}\r
         * LPC1769.DacPortクラスのオブジェクトである。\r
         * @example\r
@@ -185,16 +185,20 @@ DEV.Dac.prototype=
  * DA pinからDAInfoを取得\r
  * @private\r
  */\r
-function pin2DacPinInfo(i_pin)\r
+function makeDacPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var func_name=DEV.completePinFunctionName(i_pin,"AOUT");\r
-               //portとbitを得る(AD0だけしか管理しないよ)\r
-               return {\r
-                       port:0,\r
-                       pin_sel:DEV.getPinSelByFunctionName(i_pin,func_name)\r
-               };//DAPinは1ピンのみなので、特に識別パラメータはない。\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var func_name=DEV.completePinFunctionName(i_pins[i],"AOUT");\r
+                       //portとbitを得る(AD0だけしか管理しないよ)\r
+                       ret.push({\r
+                               port:0,\r
+                               pin_sel:DEV.getPinSelByFunctionName(i_pins[i],func_name)\r
+                       });\r
+               };\r
+               return ret;\r
        }catch(e){\r
                throw new MiMicException(e);    \r
        }\r
@@ -211,8 +215,8 @@ function pin2DacPinInfo(i_pin)
  * @param {array[pin識別子]} i_pins\r
  * ピン識別子の配列。指定できるのは、LPC1769.P?[?]である。順番は、このインスタンスの返す値の順序に影響する。\r
  * @param {associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略時は{pin:{sel:%AUTO%},bias:0}を設定する。\r
- * 詳細はsetOpt関数を参照。 %AUTO%は関数がPin情報から自動的に決定する事を意味する。(指定は出来ない。)\r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined},bias:0}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create [AOUT]\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -223,12 +227,8 @@ DEV.DacPort=function DacPort(i_adc,i_pins,i_opt)
 {\r
        try{\r
                this._dac=i_adc;\r
-               //ピンセットを取得\r
-               var pininf=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       pininf.push(pin2DacPinInfo(i_pins[i]));\r
-               }\r
+               //Pin情報配列を生成\r
+               var pininfo=makeDacPinInfoArray(i_pins);\r
                //ポートの生成\r
                this._port=new DEV.Port(i_adc._mcu,i_pins);\r
                //ピンオプションの生成\r
@@ -241,9 +241,9 @@ DEV.DacPort=function DacPort(i_adc,i_pins,i_opt)
                        opt.bias=isUndef(i_opt.bias)?0:i_opt.bias;\r
                };\r
                //pinselの自動設定\r
-               for(var i=0;i<this._port.pins.length;i++){\r
+               for(var i=0;i<pininfo.length;i++){\r
                        if(isUndef(opt.pin[i].sel)){\r
-                               opt.pin[i].sel=pininf[i].pin_sel;\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
                        }\r
                }\r
                //ピンオプションの設定\r
@@ -263,18 +263,18 @@ DEV.DacPort.prototype=
         * @function\r
         * @param {associative array | array[associative array]} i_opt\r
         * DAピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
-        * å\85¨ã\81¦ã\81®ã\83\94ã\83³ã\81«å\90\8cã\81\98ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\82\92æ\8c\87å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\81§æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å\80\8bå\88¥ã\81«è¨­å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\81«é\85\8då\88\97ã\82\92å\85¥ã\82\8cå­\90ã\81§指定する。\r
+        * å\85¨ã\81¦ã\81®ã\83\94ã\83³ã\81«å\90\8cã\81\98ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\82\92æ\8c\87å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\81§æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å\80\8bå\88¥ã\81«è¨­å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\82\92é\85\8då\88\97ã\81«ã\81\97ã\81¦指定する。\r
         * <pre>{i_opt:associative array}</pre>\r
         * <ul>\r
         * <li>pin(option)</li>\r
         * <li>bias(option)</li>\r
         * </ul>\r
-        * パラメータの詳細は、DacPin#setOptを参照。\r
+        * パラメータの詳細は、LPC1769.DacPin#setOptを参照。\r
         * @example\r
         * //ポートを構成する全てのピンに同じパラメータを設定する場合\r
-        * setOpt(pin:v1,bias:v1);\r
+        * setOpt({pin:{v1},bias:v1});\r
         * //ポートを構成するピンに個々にパラメータを設定する場合\r
-        * setOpt(pin:[{v1},{v2}],bias:[v1,v2...]);\r
+        * setOpt({pin:[{v1},{v2}],bias:[v1,v2...]});\r
         */     \r
        setOpt:function setOpt(i_opt)\r
        {\r
@@ -289,7 +289,10 @@ DEV.DacPort.prototype=
                        //DACR:bit16\r
                        if(!isUndef(i_opt.bias)){\r
                                //DAは1ポートだけなので、固定値\r
-                               if(isArray(i_opt.pin)){\r
+                               if(isArray(i_opt.bias)){\r
+                                       if(this._port.pins.length!=i_opt.bias.length){\r
+                                               throw new MiMicException(DEV._EE.INVALID_ARG);\r
+                                       }\r
                                        bc+=this._dac.BCF_setBias(0x00010000,i_opt.bias[0],db);\r
                                }else{\r
                                        bc+=this._dac.BCF_setBias(0x00010000,i_opt.bias,db);\r
@@ -317,6 +320,9 @@ DEV.DacPort.prototype=
        setValues:function setValues(i_values)\r
        {\r
                try{\r
+                       if(this._port.pins.length!=i_values.length){\r
+                               throw new MiMicException("Invalid number of values.");\r
+                       }\r
                        //メモリへ値設定\r
                        var db=new Array();\r
                        var bc="";\r
@@ -342,8 +348,8 @@ DEV.DacPort.prototype=
  * @param {object as pin識別子} i_pin\r
  * ピン識別子。指定できるのは、LPCXpresso1796.P?[?]である。\r
  * @param {associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto},bias:0}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined},bias:0}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create AOUT\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
index 4b4cc5e..94e3679 100644 (file)
@@ -8,7 +8,7 @@ var BCF=DEV._BCF;
 var EE=DEV._EE;\r
 var isUndef=MiMicLib.isUndef;\r
 var cloneAssoc=MiMicLib.cloneAssoc;\r
-\r
+var isArray=MiMicLib.isArray;\r
 /**\r
  * LPCXPresso1769.Gpio (Gpio)クラスのコンストラクタ。\r
  * MCUに関連付けしたGpioペリフェラルを生成する。\r
@@ -17,7 +17,7 @@ var cloneAssoc=MiMicLib.cloneAssoc;
  * @constructor\r
  * @param {object as LPC1769.Mcu} i_mcu\r
  * インスタンスを結びつけるMcuオブジェクト。\r
- * @param {oject as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * 常に無視する。省略すること。\r
  * @example\r
  * //create GPIO (logical)pheripheral\r
@@ -79,13 +79,14 @@ DEV.Gpio.prototype=
        },\r
        /**\r
         * \r
-        @param i_dir 1 or 0\r
-        @private
+        * @param {int} i_dir\r
+        * i_maskに合致したビットイメージ\r
+        * @private
         */\r
        BCF_setDirs:function BCF_setDirs(i_ch,i_mask,i_dir,i_db)\r
        {\r
                try{\r
-                       return BCF.setBit(this._FIO_DIR[i_ch],i_mask,i_mask*i_dir,0,i_db);\r
+                       return BCF.setBit(this._FIO_DIR[i_ch],i_mask,i_dir,0,i_db);\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -99,8 +100,8 @@ DEV.Gpio.prototype=
         * @function\r
         * @param {object as ピン識別子} i_pin\r
         * GPIO機能を割り当てるPINの識別子である。\r
-        * @param {object as associative array} i_opt\r
-        * GpioPinのコンストラクタに渡すオプション値を指定する。省略可能。省略時はundefinedとみなす。詳細はGpioPinのコンストラクタを参照。\r
+        * @param {associative array} i_opt\r
+        * GpioPinのコンストラクタに渡すオプション値を指定する。省略時はundefinedである。詳細はLPC1769.GpioPinを参照。\r
         * @return {object as GpioPin}\r
         * GpioPinクラスのオブジェクトである。\r
         * @example\r
@@ -126,8 +127,8 @@ DEV.Gpio.prototype=
         * @function\r
         * @param {array[ピン識別子]} i_pin\r
         * Gpioポートを構成するPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * GpioPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.GpioPort.setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * GpioPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.GpioPortを参照。\r
         * @return {object as LPC1769.GpioPort}\r
         * LPC1769.GpioPortクラスのオブジェクトである。\r
         * @example\r
@@ -150,21 +151,24 @@ DEV.Gpio.prototype=
  * GPIO pinからGPIOInfoを取得
  * @private
  */\r
-function pin2GpioPinInfo(i_pin)\r
+function makeGpioPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var fn=DEV.completePinFunctionName(i_pin,"GPIO");\r
-               //pin名からポートとビットを得る。\r
-               var a=fn.substring(4).split(".");\r
-               //pin情報を構成。\r
-               var r={port:parseInt(a[0]),bit:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pin,fn)};\r
-               if(!isNaN(r.port) && !isNaN(r.bit)){\r
-                       return r;\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var fn=DEV.completePinFunctionName(i_pins[i],"GPIO");\r
+                       //pin名からポートとビットを得る。\r
+                       var a=fn.substring(4).split(".");\r
+                       if(isNaN(a[0]) || isNaN(a[1])){\r
+                               throw new MiMicException(EE.INVALID_CFG);\r
+                       }\r
+                       //pin情報を構成。\r
+                       ret.push({port:parseInt(a[0]),bit:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pins[i],fn)});\r
                }\r
-               throw new MiMicException(EE.INVALID_CFG,"The pin has not GPIO fuction.");\r
+               return ret;\r
        }catch(e){\r
-               throw new MiMicException(e);    \r
+               throw new MiMicException(e);\r
        }\r
 }\r
 \r
@@ -180,11 +184,11 @@ function pin2GpioPinInfo(i_pin)
  * ピン識別子の配列。指定できるのは、LPCXpresso1796.P?[?]である。順番は、このインスタンスの返す値の順序に影響する。\r
  * 0番目のピンはビット0に対応する。同様に、1番目のピンはビット1に対応する。\r
  * 組み合わせるピンは、同じ物理ポートに所属している必要がある。例えば、GPIO0.0とGPIO0.1は組み合わせられるが、GPIO0.0とGPIO1.1は組み合わせることが出来ない。\r
- * @param {object as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto}}を設定する。\r
  * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
  * @example\r
- * //create [AD0.0,AD0.1]\r
+ * //create [LPC1769.P0[0],LPC1769.P0[1]]\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
  * var gpio=new LPC1769.Gpio(mcu);\r
  * var port=new LPC1769.GpioPort(adc,[LPC1769.P0[0],LPC1769.P0[1]]); \r
@@ -194,15 +198,11 @@ DEV.GpioPort=function GpioPort(i_gpio,i_pins,i_opt)
        try{\r
                this._gpio=i_gpio;\r
                //ピンセットを取得\r
-               this._pins=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       this._pins.push(pin2GpioPinInfo(i_pins[i]));\r
-               }\r
+               var pininfo=makeGpioPinInfoArray(i_pins);\r
                //pinが全て同じポートに所属しているか確認\r
-               var p=this._pins[0].port;\r
-               for(var i=1;i<this._pins.length;i++){\r
-                       if(p!=this._pins[i].port){\r
+               var p=pininfo[0].port;\r
+               for(var i=1;i<pininfo.length;i++){\r
+                       if(p!=pininfo[i].port){\r
                                throw new MiMicException("Invalid pin combination.");\r
                        }\r
                }\r
@@ -211,15 +211,24 @@ DEV.GpioPort=function GpioPort(i_gpio,i_pins,i_opt)
                this._port_no=p;\r
                //GPIO用のマスクを生成。\r
                this._mask=0;\r
-               for(var i=0;i<this._pins.length;i++){\r
-                       this._mask|=(0x1<<this._pins[i].bit);\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       this._mask|=(0x1<<pininfo[i].bit);\r
                }\r
+\r
                //ピンオプションの生成\r
-               var opt=cloneAssoc(i_opt);\r
-               //ピンプロパティの複製\r
-               opt.pin=isUndef(opt.pin)?{}:cloneAssoc(opt.pin);\r
-               //設定が無ければ、ピンセレクタを自動に設定\r
-               if(isUndef(opt.pin.sel)){opt.pin.sel=this._PINSEL_AUTO_DETECT;}\r
+               var opt={};\r
+               if(isUndef(i_opt)){\r
+                       opt.pin=this._port.clonePinOptAssoc({});\r
+               }else{\r
+                       opt.pin=this._port.clonePinOptAssoc(isUndef(i_opt.pin)?{}:i_opt.pin);\r
+               };\r
+               //pinselの自動設定\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       if(isUndef(opt.pin[i].sel)){\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
+                       }\r
+               }\r
+               this._pininfo=pininfo;\r
                //ピンオプションの設定\r
                this.setOpt(opt);\r
        }catch(e){\r
@@ -228,8 +237,7 @@ DEV.GpioPort=function GpioPort(i_gpio,i_pins,i_opt)
 }\r
 DEV.GpioPort.prototype=\r
 {\r
-       _PINSEL_AUTO_DETECT:0x0fffffff,//setoptに自動を伝えるときに使う\r
-       _pins:null,\r
+       _pininfo:null,\r
        _gpio:null,\r
        _port_no:0,\r
        _port:null,\r
@@ -237,32 +245,55 @@ DEV.GpioPort.prototype=
        /**\r
         * Gpioポートにオプション値を設定する。\r
         * 関数は、ポートを構成する全てのピンに、同一なオプション値を設定する。\r
-        * 設定可能な値は、LPC1769.GpioPin#setOptと同じである。\r
+        * 設定可能な値は、LPC1769.GpioPin#setOptと同じである。   \r
         * @name LPC1769.GpioPort#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
-        * LPC1769.GpioPin#setOptを参照。\r
+        * @param {associative array | array[associative array]} i_opt\r
+        * GPIOピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
+        * 全てのピンに同じパラメータを指定する場合は、連装配列で指定する。個別に設定する場合は、連装配列を配列にして指定する。\r
+        * <pre>{i_opt:associative array}</pre>\r
+        * <ul>\r
+        * <li>pin(option) - array[{PIN_OPTION}] | {PIN_OPTION}</li>\r
+        * <li>dir(option) - array[{1bit int}] | {1bit int}</li>\r
+        * </ul>\r
+        * パラメータの詳細は、LPC1769.GpioPin#setOptを参照。\r
+        * @example\r
+        * //ポートを構成する全てのピンに同じパラメータを設定する場合\r
+        * setOpt({pin:{v1},dir:1});\r
+        * //ポートを構成するピンに個々にパラメータを設定する場合\r
+        * setOpt({pin:[{v1},{v2}],dir:[1,1]});\r
         */     \r
        setOpt:function setOpt(i_opt)\r
        {\r
                try{\r
+                       var pininfo=this._pininfo;\r
                        var db=new Array();\r
                        //BCの生成\r
                        var bc="";\r
+                       //pinの設定\r
+                       if(!isUndef(i_opt.pin)){\r
+                               bc+=this._port.BCF_setOpts(i_opt.pin,db);\r
+                       }\r
                        //dir設定\r
                        if(!isUndef(i_opt.dir)){\r
-                               bc+=this._gpio.BCF_setDirs(this._port_no,this._mask,i_opt.dir,db);\r
-                       }\r
-                       //i_optの展開\r
-                       if(!isUndef(i_opt.pin)){\r
-                               var optset=new Array();\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       //pinselが_PINSEL_AUTO_DETECTならばauto。そうでなければundefinedも含めて設定\r
-                                       var s=(i_opt.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[i].pin_sel:i_opt.pin.sel;\r
-                                       optset.push({sel:s,mode:i_opt.pin.mode,od:i_opt.pin.od});\r
+                               var dir_bits=0x0;\r
+                               var dir_mask=0x0;\r
+                               if(isArray(i_opt.dir)){\r
+                                       if(this._port.pins.length!=i_opt.dir.length){\r
+                                               throw new MiMicException(DEV._EE.INVALID_ARG);\r
+                                       }                                       \r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               if(isUndef(i_opt.dir[i])){\r
+                                                       continue;\r
+                                               }\r
+                                               dir_mask|=(0x1<<pininfo[i].bit);\r
+                                               dir_bits|=(i_opt.dir[i]<<pininfo[i].bit);\r
+                                       }\r
+                               }else{\r
+                                       dir_bits=this._mask*i_opt.dir;\r
+                                       dir_mask=this._mask;\r
                                }\r
-                               //portの設定\r
-                               bc+=this._port.BCF_setOpts(optset,db);\r
+                               bc+=this._gpio.BCF_setDirs(this._port_no,dir_mask,dir_bits,db);\r
                        }\r
                        this._gpio._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                        return;\r
@@ -289,12 +320,11 @@ DEV.GpioPort.prototype=
        {\r
                try{\r
                        var v=0;\r
-                       var l=this._pins.length;\r
-                       for(var i=0;i<l;i++){\r
+                       for(var i=0;i<this._pininfo.length;i++){\r
                                //セットするbit値を得る。\r
                                var sv=((i_val>>i)&0x01);\r
                                //値のセット\r
-                               v|=(sv<<this._pins[i].bit);\r
+                               v|=(sv<<this._pininfo[i].bit);\r
                        }\r
                        //値をセット\r
                        var db=new Array();\r
@@ -327,9 +357,9 @@ DEV.GpioPort.prototype=
                        var retval=this._gpio._mcu.callMiMicWithCheck(bc+BCF.END,db).stream[0];\r
                        //値の再構成\r
                        var v=0;\r
-                       for(var i=this._pins.length-1;i>=0;i--){\r
+                       for(var i=this._pininfo.length-1;i>=0;i--){\r
                                //セットするbit値を得る。\r
-                               var sv=((retval>>this._pins[i].bit)&0x1);\r
+                               var sv=((retval>>this._pininfo[i].bit)&0x1);\r
                                //値のセット(pinArrayの並びとビット並びが同じになるようにする)\r
                                v=(v<<1)|sv;\r
                        }\r
@@ -362,12 +392,11 @@ DEV.GpioPort.prototype=
                        var bc="";\r
                        for(var i2=0;i2<i_val_array.length;i2++){\r
                                var v=0;\r
-                               var l=this._pins.length;\r
-                               for(var i=0;i<l;i++){\r
+                               for(var i=0;i<this._pininfo.length;i++){\r
                                        //セットするbit値を得る。\r
                                        var sv=((i_val_array[i2]>>i)&0x01);\r
                                        //値のセット(pinArrayの並びと最下位ビットの位置が同じになるように反転)\r
-                                       v|=(sv<<this._pins[i].bit);\r
+                                       v|=(sv<<this._pininfo[i].bit);\r
                                }\r
                                //値をセット\r
                                bc+=this._gpio.BCF_setValues(this._port_no,this._mask,v,db);\r
@@ -414,7 +443,7 @@ DEV.GpioPin.prototype=
 {\r
        _gport:null,\r
        /**\r
-        * ADピンにオプション値を設定する。\r
+        * GPIOピンにオプション値を設定する。\r
         * @name LPC1769.GpioPin#setOpt\r
         * @function\r
         * @param {object as associative array} i_opt\r
index bb7c831..e8cfc61 100644 (file)
                 * <li>GPIO - LPC1769.GpioPin</li>\r
                 * <li>AD - LPC1769.AdcPin</li>\r
                 * <li>PWM - LPC1769.PwmPin</li>\r
+                * <li>DA - LPC1769.DacPin</li>\r
                 * </ul>\r
                 */\r
                getPin:function getPin(/*...*/)\r
                 * @return {object as PortObject}\r
                 * 返却されるインスタンスのクラスは、機能により異なる。機能とインスタンスのクラスの対応は、以下の通りである。\r
                 * <ul>\r
-                * <li>GPIO - LPC1769.GpioPin</li>\r
-                * <li>AD - LPC1769.AdcPin</li>\r
-                * <li>PWM - LPC1769.PwmPin</li>\r
-                * <li>DAC - LPC1769.DacPin</li>\r
+                * <li>GPIO - LPC1769.GpioPort</li>\r
+                * <li>AD - LPC1769.AdcPort</li>\r
+                * <li>PWM - LPC1769.PwmPort</li>\r
+                * <li>DA - LPC1769.DacPort</li>\r
                 * </ul>                 \r
                 */\r
                getPort:function getPort(i_pins,i_function_name)\r
index dacce32..de0bc90 100644 (file)
@@ -61,8 +61,8 @@ DEV.Memory.prototype=
         * コンストラクタで指定したアドレスからのオフセット位置を指定する。4バイト境界でなければならない。\r
         * @param {int} i_size\r
         * 取得するバイト数を指定する。4バイト単位でなければならない。      \r
-        * @return {int or Array[int]}\r
-        * 取得する値の個数は、i_size/4個である。個数により、戻り値の型が異なるので注意すること。\r
+        * @return {Array[int]}\r
+        * 取得する値の個数は、i_size/4個である。\r
         * @example\r
         * var mcu=new LPC1769.Mcu("192.168.0.39");\r
         * var mem=new LPC1769.Memory(mcu); //create instance\r
@@ -76,7 +76,7 @@ DEV.Memory.prototype=
         * @param {array[int]} i_offsets\r
         * オフセットアドレスの配列。それぞれ4バイト境界でなければならない。\r
         * @return {int or Array[int]}\r
-        * 返却される値の個数は、i_offsetの長さと同じになる。個数により、戻り値の型が異なるので注意すること。\r
+        * 返却される値の個数は、i_offsetの長さと同じになる。\r
         * @example\r
         * var mcu=new LPC1769.Mcu("192.168.0.39");\r
         * var mem=new LPC1769.Memory(mcu); //create instance\r
@@ -96,6 +96,7 @@ DEV.Memory.prototype=
        read32:function read32(/*arguments*/)\r
        {\r
                try{\r
+                       var is_ret_array=true;\r
                        var bc="";\r
                        var ar=new Array();\r
                        var offset=arguments[0];\r
@@ -106,6 +107,7 @@ DEV.Memory.prototype=
                                        checkAlign(offset);\r
                                        bc=BCF.READMEM;\r
                                        ar.push(this._base+offset);\r
+                                       is_ret_array=false;\r
                                }else{\r
                                        //read32(i_offsets:array)\r
                                        for(var i=0;i<offset.length;i++){\r
@@ -128,7 +130,7 @@ DEV.Memory.prototype=
                                break;\r
                        }\r
                        var ret=this._mcu.callMiMicWithCheck(bc+BCF.END,ar).stream;\r
-                       return ret.length==1?ret[0]:ret;\r
+                       return is_ret_array?ret:ret[0];\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
index a5b5927..890bd41 100644 (file)
@@ -64,7 +64,8 @@ DEV.Port.prototype=
 {\r
        _mcu:null,\r
        /**\r
-        * {array[object as ピン識別子]} Portを構成するピンの配列。Portコンストラクタのi_pinsetのコピー。
+        * {array[object as ピン識別子]} Portを構成するピンの配列。Portコンストラクタのi_pinsetのコピー。\r
+        * @name LPC1769.Port#pins\r
         */\r
        pins:null,\r
        /**\r
index a9cbc2f..aefe339 100644 (file)
@@ -6,6 +6,7 @@ var DEV=LPC1769;
 var BCF=DEV._BCF;\r
 var EE=DEV._EE;\r
 var isUndef=MiMicLib.isUndef;\r
+var isArray=MiMicLib.isArray;\r
 var cloneAssoc=MiMicLib.cloneAssoc;\r
 \r
 \r
@@ -19,7 +20,7 @@ var cloneAssoc=MiMicLib.cloneAssoc;
  * @constructor\r
  * @param {object as LPC1769.Mcu} i_mcu\r
  * インスタンスを結びつけるMcuオブジェクト。\r
- * @param {aobject as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * インスタンス生成と同時にsetOpt関数でセットする値を指定する。省略時は、{freq:100,phl:{power:1,clock:0}}である。\r
  * 詳細は、setOpt関数を参照。 \r
  * @example\r
@@ -127,7 +128,7 @@ DEV.Pwm.prototype=
        {\r
                try{\r
                        //LERにビットをセット\r
-                       return BCF.setBit(this._LER,i_mask,i_value*i_mask,0,i_db);\r
+                       return BCF.setBit(this._LER,i_mask,i_value,0,i_db);\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -155,7 +156,6 @@ DEV.Pwm.prototype=
        },\r
        /**\r
         * PCRに値を設定するBC\r
-        i_ch=1の場合、エッジモードは無視します。\r
         @private\r
         @param i_mask\r
         @param i_edge\r
@@ -163,23 +163,11 @@ DEV.Pwm.prototype=
         @param i_en\r
        有効/無効の選択\r
         */\r
-       BCF_setPCRbits:function BCF_setPCRbits(i_mask,i_edge,i_en,i_db)\r
+       BCF_setPCRbits:function BCF_setPCRbits(i_mask,i_value,i_db)\r
        {\r
                try{\r
-                       var m,v;\r
-                       m=v=0;\r
-                       if(!isUndef(i_edge)){\r
-                               var t=0xff&i_mask;\r
-                               v|=i_edge*t;\r
-                               m|=t;\r
-                       }\r
-                       if(!isUndef(i_en)){\r
-                               var t=0xff00&i_mask;\r
-                               v|=(i_en*t);\r
-                               m|=t;\r
-                       }\r
                        //ビットの設定\r
-                       return BCF.setBit(this._PCR,m,v,0,i_db);\r
+                       return BCF.setBit(this._PCR,i_mask,i_value,0,i_db);\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -190,10 +178,10 @@ DEV.Pwm.prototype=
         * 設定する値は、全てのPWMチャンネル(PIN)に共通な項目である。\r
         * @name LPC1769.Pwm#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
+        * @param {associative array} i_opt\r
         * GPIOピンのコンフィグレーションパラメタである。必要な値を格納した連想配列で指定する。\r
         * 全ての値を省略することは出来ない。連想配列のメンバは以下の通り。\r
-        * <pre>{freq:int,phl:object as associative array}</pre>\r
+        * <pre>{freq:int,phl:associative array}</pre>\r
         * <ul>\r
         * <li>freq - PWMの基本周波数(Hz)である。この値は、全てのPWMチャンネルで共通である。</li>\r
         * <li>phl - ペリフェラルの共通パラメタである。LPC1769.Peripheral.setOpt関数のi_optに渡すパラメタである。詳細はLPC1769.Peripheral#setOptを参照。</li>\r
@@ -223,8 +211,8 @@ DEV.Pwm.prototype=
         * @function\r
         * @param {object as ピン識別子} i_pin\r
         * PWM機能を割り当てるPINの識別子である。\r
-        * @param {object as associative array} i_opt\r
-        * PemPinのコンストラクタに渡すオプション値。省略時は{duty:0,enable:1,pin:{sel:auto}}である\r
+        * @param {associative array} i_opt\r
+        * PwmPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.PwmPinを参照\r
         * @return {object as LPC1769.PwmPin}\r
         * LPC1769.PwmPinクラスのオブジェクトである。\r
         * @example\r
@@ -250,8 +238,8 @@ DEV.Pwm.prototype=
         * @function\r
         * @param {array[ピン識別子]} i_pin\r
         * Pwm機能を割り当てるPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.PwmPort#setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * PwmPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.PwmPortを参照。\r
         * @return {object as LPC1769.PwmPort}\r
         * LPC1769.PwmPortクラスのオブジェクトである。\r
         * @example\r
@@ -274,20 +262,23 @@ DEV.Pwm.prototype=
  * Pwm pinからPwmInfoを取得\r
  * @private\r
  */\r
-function pin2PwmPinInfo(i_pin)\r
+function makePwmPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var fn=DEV.completePinFunctionName(i_pin,"PWM");\r
-               //portとbitを得る(AD0だけしか管理しないよ)\r
-               var a=fn.substring(2).split(".");\r
-               var r={port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pin,fn)};\r
-               if(!isNaN(r.ch)){\r
-                       return r;\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var fn=DEV.completePinFunctionName(i_pins[i],"PWM");\r
+                       //portとbitを得る\r
+                       var a=fn.substring(2).split(".");\r
+                       if(isNaN(a[1])){\r
+                               throw new MiMicException(EE.INVALID_CFG);\r
+                       }\r
+                       ret.push({port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pins[i],fn)});\r
                }\r
-               throw new MiMicException(EE.INVALID_CFG,"The pin has not PWM fuction.");\r
+               return ret;\r
        }catch(e){\r
-               throw new MiMicException(e);    \r
+               throw new MiMicException(e);\r
        }\r
 }\r
 /**\r
@@ -302,7 +293,7 @@ function pin2PwmPinInfo(i_pin)
  * インスタンスを結びつけるPwmオブジェクト。\r
  * @param {array[pin識別子]} i_pins\r
  * ピン識別子の配列。指定できるのは、LPC1769.P?[?]である。\r
- * @param {object as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{duty:100,enable:1,pin{sel:auto}}を設定する。\r
  * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
  * dutyをピン毎に設定する場合は、setDuty関数を使うこと。\r
@@ -317,15 +308,12 @@ DEV.PwmPort=function PwmPort(i_pwm,i_pins,i_opt)
        try{\r
                this._pwm=i_pwm;\r
                //ピンセットを取得\r
-               this._pins=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       this._pins.push(pin2PwmPinInfo(i_pins[i]));\r
-               }\r
+               var pininfo=makePwmPinInfoArray(i_pins);\r
+\r
                //pinが全て同じポートに所属しているか確認\r
-               var p=this._pins[0].port;\r
-               for(var i=1;i<this._pins.length;i++){\r
-                       if(p!=this._pins[i].port){\r
+               var p=pininfo[0].port;\r
+               for(var i=1;i<pininfo.length;i++){\r
+                       if(p!=pininfo[i].port){\r
                                throw new MiMicException("Invalid pin combination.");\r
                        }\r
                }\r
@@ -333,22 +321,25 @@ DEV.PwmPort=function PwmPort(i_pwm,i_pins,i_opt)
                this._port=new DEV.Port(i_pwm._mcu,i_pins);\r
                this._port_no=p;\r
                \r
-               this._ler_mask=0;\r
-               this._pcr_mask=0;\r
-               for(var i=0;i<this._pins.length;i++){\r
-                       this._ler_mask|=(0x1<<this._pins[i].ch);\r
-                       this._pcr_mask|=(0x101<<this._pins[i].ch);\r
-               }               \r
-               var opt=isUndef(i_opt)?{pin:{}}:\r
-               {\r
-                       pin:isUndef(i_opt.pin)?{}:cloneAssoc(i_opt.pin),\r
-                       duty:i_opt.duty,\r
-                       enable:i_opt.enable\r
+\r
+               //ピンオプションの生成\r
+               var opt={};\r
+               if(isUndef(i_opt)){\r
+                       opt.pin=this._port.clonePinOptAssoc({});\r
+                       opt.duty=0;\r
+                       opt.enable=1;\r
+               }else{\r
+                       opt.pin=this._port.clonePinOptAssoc(isUndef(i_opt.pin)?{}:i_opt.pin);\r
+                       opt.duty=isUndef(i_opt.duty)?0:i_opt.duty;\r
+                       opt.enable=isUndef(i_opt.enable)?0:i_opt.enable;\r
                };\r
-               //デフォルト値のロード\r
-               if(isUndef(opt.pin.sel)){opt.pin.sel=this._PINSEL_AUTO_DETECT;}\r
-               if(isUndef(opt.duty)){opt.duty=0;}\r
-               if(isUndef(opt.enable)){opt.enable=1;}\r
+               //pinselの自動設定\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       if(isUndef(opt.pin[i].sel)){\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
+                       }\r
+               }\r
+               this._pininfo=pininfo;\r
                this.setOpt(opt);\r
        }catch(e){\r
                throw new MiMicException(e);\r
@@ -356,21 +347,24 @@ DEV.PwmPort=function PwmPort(i_pwm,i_pins,i_opt)
 }\r
 DEV.PwmPort.prototype=\r
 {\r
-       _PINSEL_AUTO_DETECT:0x0fffffff,\r
        _pwm:null,\r
-       _pins:null,\r
+       _pininfo:null,\r
        _port_no:0,\r
        _port:null,\r
-       _pcr_mask:0,\r
-       _ler_mask:0,\r
        /**\r
         * PWMポートにオプション値を設定する。\r
-        * 関数は、ポートを構成する全てのピンに、同じ値を設定する。\r
         * 設定可能な値は、LPC1769.PwmPin#setOptと同じである。    \r
         * @name LPC1769.PwmPort#setOpt\r
         * @function\r
         * @param {object as associative array} i_opt\r
-        * LPC1769.PwmPin#setOptを参照。\r
+        * PWMピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
+        * 全てのピンに同じパラメータを指定する場合は、連装配列で指定する。個別に設定する場合は、連装配列を配列にして指定する。\r
+        * <pre>{i_opt:associative array}</pre>\r
+        * <ul>\r
+        * <li>pin(option) - array[{PIN_OPTION}] | {PIN_OPTION}</li>\r
+        * <li>enable(option) - array[{1bit int}] | {1bit int}</li>\r
+        * <li>duty(option) - array[{1bit int}] | {1bit int}</li>\r
+        * </ul>\r
         * @example\r
         * var mcu=new LPC1769.Mcu("192.168.128.39",true);\r
         * var pwm=mcu.getPeripheral("PWM",{freq:100});\r
@@ -380,32 +374,60 @@ DEV.PwmPort.prototype=
        setOpt:function setOpt(i_opt)\r
        {\r
                try{\r
+                       var pininfo=this._pininfo;\r
                        var db=new Array();\r
                        //BCの生成\r
                        var bc="";\r
-                       //i_optの展開\r
+                       //pinの設定\r
                        if(!isUndef(i_opt.pin)){\r
-                               var optset=new Array();\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       //pinselが_PINSEL_AUTO_DETECTならばauto。そうでなければundefinedも含めて設定\r
-                                       var s=(i_opt.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[i].pin_sel:i_opt.pin.sel;\r
-                                       optset.push({sel:s,mode:i_opt.pin.mode,od:i_opt.pin.od});\r
-                               }\r
-                               //portの設定\r
-                               bc+=this._port.BCF_setOpts(optset,db);\r
+                               bc+=this._port.BCF_setOpts(i_opt.pin,db);\r
                        }\r
-                       //PCRに値設定\r
+                       //enable設定\r
                        if(!isUndef(i_opt.enable)){\r
-                               bc+=this._pwm.BCF_setPCRbits(this._pcr_mask,0,i_opt.enable,db);\r
+                               var pcr_mask=0x0;\r
+                               var pcr_bits=0x0;\r
+                               if(isArray(i_opt.enable)){\r
+                                       if(this._port.pins.length!=i_opt.enable.length){\r
+                                               throw new MiMicException(DEV._EE.INVALID_ARG);\r
+                                       }                                       \r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               if(isUndef(i_opt.enable[i])){\r
+                                                       continue;\r
+                                               }\r
+                                               pcr_bits|=((0x100*i_opt.enable[i])<<pininfo[i].ch);\r
+                                               pcr_mask|=(0x101<<pininfo[i].ch);\r
+                                               //single edge\r
+                                       }\r
+                               }else{\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               pcr_mask|=(0x101<<pininfo[i].ch);\r
+                                               pcr_bits|=((0x100*i_opt.enable)<<pininfo[i].ch);\r
+                                       }\r
+                               }\r
+                               //edgeは固定でゼロ、enableはビット配列。\r
+                               bc+=this._pwm.BCF_setPCRbits(pcr_mask,pcr_bits,db);\r
                        }\r
-                       //デューティ比を\r
+                       //dutyの設定\r
                        if(!isUndef(i_opt.duty)){\r
-                               //デューティ比を設定\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       bc+=this._pwm.BCF_setMRnByDuty(this._pins[i].ch,i_opt.duty,db);\r
+                               var ler_value=0;\r
+                               if(isArray(i_opt.duty)){\r
+                                       if(this._port.pins.length!=i_opt.duty.length){\r
+                                               throw new MiMicException(DEV._EE.INVALID_ARG);\r
+                                       }                                       \r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               if(isUndef(i_opt.duty[i])){\r
+                                                       continue;\r
+                                               }\r
+                                               bc+=this._pwm.BCF_setMRnByDuty(pininfo[i].ch,i_opt.duty[i],db);\r
+                                               ler_value|=(0x1<<pininfo[i].ch);\r
+                                       }\r
+                               }else{\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               bc+=this._pwm.BCF_setMRnByDuty(pininfo[i].ch,i_opt.duty,db);\r
+                                               ler_value|=(0x1<<pininfo[i].ch);\r
+                                       }\r
                                }\r
-                               //LERにセット\r
-                               bc+=this._pwm.BCF_setLERs(this._ler_mask,1,db);\r
+                               bc+=this._pwm.BCF_setLERs(ler_value,ler_value,db);\r
                        }\r
                        this._pwm._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                        return;\r
@@ -414,12 +436,13 @@ DEV.PwmPort.prototype=
                }\r
        },\r
        /**\r
-        * PWMポートのデューティ比をまとめて変更する。\r
+        * PWMポートのデューティ比を変更する。\r
+        * この関数は、LPC1769.PwmPort#setOpt関数へのショートカットである。\r
         * @name LPC1769.PwmPort#setDutys\r
         * @function\r
         * @param {array[double]} i_duty_array\r
         * デューティ比の配列である。0.0<=n<=1.0のdouble値を指定する。\r
-        * ã\83\9dã\83¼ã\83\88ã\82\92æ§\8bæ\88\90ã\81\99ã\82\8bã\83\94ã\83³ã\81®æ\95°ã\81 ã\81\91æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å¤\89æ\9b´ã\81\97ã\81ªã\81\84ã\83\94ã\83³ã\81«ã\81¯ã\80\81undefinedã\82\92æ\8c\87å®\9aã\81\99ã\82\8bã\81\93ã\81¨\r
+        * ã\83\9dã\83¼ã\83\88ã\82\92æ§\8bæ\88\90ã\81\99ã\82\8bã\83\94ã\83³ã\81®æ\95°ã\81 ã\81\91æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å¤\89æ\9b´ã\81\97ã\81ªã\81\84ã\83\94ã\83³ã\81«ã\81¯ã\80\81undefinedã\82\92æ\8c\87å®\9aã\81§ã\81\8dã\82\8b\r
         * @example\r
         * varmcu=new LPC1769.Mcu("192.168.128.39",true);\r
         * var pwm=mcu.getPeripheral("PWM",{freq:100});\r
@@ -429,21 +452,8 @@ DEV.PwmPort.prototype=
         */     \r
        setDutys:function setDutys(i_duty_array)\r
        {\r
-               try{\r
-                       if(i_duty_array.length!=this._pins.length){\r
-                               throw new MiMicException();\r
-                       }\r
-                       var bc="";\r
-                       var db=new Array();\r
-                       //デューティ比をまとめてセット\r
-                       for(var i=0;i<this._pins.length;i++){\r
-                               if(!isUndef(i_duty_array[i])){\r
-                                       bc+=this._pwm.BCF_setMRnByDuty(this._pins[i].ch,i_duty_array[i],db);\r
-                               }\r
-                       }\r
-                       //LERにセット\r
-                       bc+=this._pwm.BCF_setLERs(this._ler_mask,1,db);\r
-                       this._pwm._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
+               try{                    \r
+                       this.setOpt({duty:i_duty_array});\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -460,9 +470,9 @@ DEV.PwmPort.prototype=
  * インスタンスを結びつけるAdcオブジェクト。\r
  * @param {object as pin識別子} i_pin\r
  * ピン識別子。指定できるのは、LPC1769.P?[?]である。\r
- * @param {object as associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{duty:100,enable:1,pin{sel:auto}}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * @param {associative array} i_opt\r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{duty:100,enable:1,pin{sel:undefined}}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create PWM1.0\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
index 2a6bc72..e627bf2 100644 (file)
@@ -1 +1 @@
-var LPC1769;(function(){var g=MiMicLib.isUndef;var a={_EE:function(n){return{NG:[n|0,"Unknown exception in LPC1769"],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.")};LPC1769=a}());(function(){var f=LPC1769;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",PWM:"PWM"};for(var s in t){if(v==s){return t[s]}}throw new MiMicException("Peripheral for "+v+" 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;case"DAC":new f.Dac(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=LPC1769;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=LPC1769;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=LPC1769;var j=a._BCF;var k=a._EE;var c=MiMicLib.isUndef;var d=MiMicLib.cloneAssoc;var e=MiMicLib.isArray;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 g(m,n,l){try{this._mcu=m;this.pins=new Array();for(var o=0;o<n.length;o++){this.pins.push({pin:n[o],reginfo:a.getPinRegInfo(n[o])})}if(!c(l)){this.setOpts(l)}}catch(p){throw new MiMicException(p)}};a.Port.prototype={_mcu:null,pins:null,BCF_setOpts:function b(t,n){try{var s={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]};var l=e(t)?t:this.clonePinOptAssoc(t);for(var o=0;o<this.pins.length;o++){var p=this.pins[o].reginfo;var m=l[o];if(!c(m.sel)){s.selr[p.s]|=(m.sel<<p.smb);s.selr_mask[p.s]|=(3<<p.smb)}if(!c(m.mode)){s.modr[p.m]|=(m.mode<<p.smb);s.modr_mask[p.m]|=(3<<p.smb)}if(!c(m.od)){s.odr[p.o]|=(m.od<<p.ob);s.odr_mask[p.o]|=(1<<p.ob)}}var r="";for(var o=0;o<10;o++){if(s.selr_mask[o]!=0){r+=j.setBit(h._PINSEL[o],s.selr_mask[o],s.selr[o],0,n)}if(s.modr_mask[o]!=0){r+=j.setBit(h._PINMODE[o],s.modr_mask[o],s.modr[o],0,n)}}for(var o=0;o<5;o++){if(s.odr_mask[o]!=0){r+=j.setBit(h._PINMODE_OD[o],s.odr_mask[o],s.odr[o],0,n)}}return r}catch(q){throw new MiMicException(q)}},setOpts:function f(l){try{var m=new Array();var o=this.BCF_setOpts(l,m);if(o.length>0){this._mcu.callMiMicWithCheck(o+j.END,m)}}catch(n){throw new MiMicException(n)}return},clonePinOptAssoc:function i(l){var m=new Array();if(e(l)){if(l.length!=this.pins.length){throw new MiMicException()}for(var n=0;n<this.pins.length;n++){m.push(d(l[n]))}}else{for(var n=0;n<this.pins.length;n++){m.push(d(l))}}return m}}}());(function(){var f=LPC1769;var d=f._BCF;var b=f._EE;var c=MiMicLib.isUndef;f.Pin=function e(g,h,j){try{if(c(h)){throw new MiMicException(b.INVALID_PIN)}this._port=new f.Port(g,[h],c(j)?undefined:[j])}catch(i){throw new MiMicException(i)}};f.Pin.prototype={_port:null,setOpt:function a(h){try{this._port.setOpts([h])}catch(g){throw new MiMicException(g)}return}}}());(function(){var a=LPC1769;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={_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[u].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=d(x)?{}:k(x);t.sel=1;t.pin=d(t.pin)?{}:k(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)}if(!d(y.sel)){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=LPC1769;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[u].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);t.pin=f(t.pin)?{}:m(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=LPC1769;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(y,u){try{var x="";var v;if(!d(y.phl)){x+=this._phl.BCF_setOpt(y.phl,u)}if(!d(y.freq)){v=Math.round(this._phl.getPCLK()/y.freq);if(v<=0){throw new MiMicException("The peripheral clock too small.")}x+=this.BCF_setMRn(0,v,u);x+=this.BCF_setLER(0,u);this._cache.mr0=v}return x}catch(w){throw new MiMicException(w)}},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[x].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()}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.setDutys([u])}catch(v){throw new MiMicException(v)}}}}());(function(){var f=LPC1769;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,p,o){var n="";var q=new Array();if(!d(p)){for(var l=0;l<8;l++){var k="wm"+l;if(!d(p[k])){n+="FB"+MiMicLib.hexout(l,2)+MiMicLib.hexout(p[k],8)}}if(!d(p.stream)){for(var l=0;l<p.stream.length;l++){q.push(p.stream[l])}}}n+="ZF"+MiMicLib.hexout(j,8);var g=0;if(!d(o)){for(var l=0;l<8;l++){if(!d(o["wm"+l])){n+="EE"+MiMicLib.hexout(l,2);g++}}}var m=this._mcu.callMiMic(n+e.END,q);if(m.result!=0){return false}if(!d(o)){var h=m.stream.length-g;for(var l=0;l<8;l++){var k="wm"+l;if(!d(o[k])){o[k]=m.stream[h];h++}}if(!d(o.stream)){o.stream=m.stream.slice(0,m.stream.length-g)}}return false}}}());(function(){var g=LPC1769;var n=g._BCF;var a=g._EE;var f=MiMicLib.isUndef;var h=MiMicLib.isArray;var k=MiMicLib.cloneAssoc;g.Dac=function i(s,x){try{this._mcu=s;this._phl=new g.Peripheral(s,g.PHL.DAC);var u=f(x)?{phl:{}}:{phl:f(x.phl)?{}:k(x.phl),};if(f(u.phl.clock)){u.phl.clock=0}var w="";var t=new Array();w+=this.BCF_setOpt(u,t);this._mcu.callMiMicWithCheck(w+n.END,t);this._mcu.registerPhl(this,"DAC")}catch(v){throw new MiMicException(v)}};g.Dac.prototype={_DACR:1074315264,_DACCTRL:1074315268,_DACCNTVAL:1074315272,_phl:null,_mcu:null,BCF_setOpt:function j(v,s){try{var u="";if(!f(v.phl)){u+=this._phl.BCF_setOpt(v.phl,s)}return u}catch(t){throw new MiMicException(t)}},setOpt:function c(v){try{var s=new Array();var u=this.BCF_setOpt(v,s);this._mcu.callMiMicWithCheck(u+n.END,s)}catch(t){throw new MiMicException(t)}},getPin:function o(s,u){try{return new g.DacPin(this,s,u)}catch(t){throw new MiMicException(t)}},getPort:function r(s,u){try{return new g.DacPort(this,s,u)}catch(t){throw new MiMicException(t)}},BCF_setBias:function b(u,t,s){try{return n.setBit(this._DACR,u,t*u,0,s)}catch(v){throw new MiMicException(v)}},BCF_setValue:function l(t,s){return n.setBit(this._DACR,1023,t,6,s)}};function p(t){try{var s=g.completePinFunctionName(t,"AOUT");return{port:0,pin_sel:g.getPinSelByFunctionName(t,s)}}catch(u){throw new MiMicException(u)}}g.DacPort=function e(t,s,y){try{this._dac=t;var x=new Array();for(var v=0;v<s.length;v++){x.push(p(s[v]))}this._port=new g.Port(t._mcu,s);var u={};if(f(y)){u.pin=this._port.clonePinOptAssoc({});u.bias=0}else{u.pin=this._port.clonePinOptAssoc(f(y.pin)?{}:y.pin);u.bias=f(y.bias)?0:y.bias}for(var v=0;v<this._port.pins.length;v++){if(f(u.pin[v].sel)){u.pin[v].sel=x[v].pin_sel}}this.setOpt(u)}catch(w){throw new MiMicException(w)}};g.DacPort.prototype={_dac:null,_port:null,setOpt:function c(v){try{var s=new Array();var u="";if(!f(v.pin)){u+=this._port.BCF_setOpts(v.pin,s)}if(!f(v.bias)){if(h(v.pin)){u+=this._dac.BCF_setBias(65536,v.bias[0],s)}else{u+=this._dac.BCF_setBias(65536,v.bias,s)}}this._dac._mcu.callMiMicWithCheck(u+n.END,s);return}catch(t){throw new MiMicException(t)}},setValues:function m(s){try{var t=new Array();var w="";for(var u=0;u<this._port.pins.length;u++){w+=this._dac.BCF_setValue(s[u],t)}this._dac._mcu.callMiMicWithCheck(w+n.END,t);return}catch(v){throw new MiMicException(v)}}};g.DacPin=function q(s,t,v){try{this._port=new g.DacPort(s,[t],v)}catch(u){throw new MiMicException(u)}};g.DacPin.prototype={_port:null,setValue:function d(s){try{this._port.setValues([s])}catch(t){throw new MiMicException(t)}},setOpt:function c(t){try{this._port.setOpt(t)}catch(s){throw new MiMicException(s)}}}}());var LPCXpresso1769;(function(){var b=LPC1769;var a=MiMicLib.isUndef;LPCXpresso1769=MiMicLib.cloneAssoc(b);if(!a(LPCXpresso1769.LED)){alert("invalid override[LED]")}LPCXpresso1769.LED=[b.P0[22]]}());
\ No newline at end of file
+var LPC1769;(function(){var g=MiMicLib.isUndef;var a={_EE:function(n){return{NG:[n|0,"Unknown exception in LPC1769"],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.")};LPC1769=a}());(function(){var f=LPC1769;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",PWM:"PWM"};for(var s in t){if(v==s){return t[s]}}throw new MiMicException("Peripheral for "+v+" 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;case"DAC":new f.Dac(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=LPC1769;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 r=true;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);r=false}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 r?m:m[0]}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=LPC1769;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=LPC1769;var j=a._BCF;var k=a._EE;var c=MiMicLib.isUndef;var d=MiMicLib.cloneAssoc;var e=MiMicLib.isArray;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 g(m,n,l){try{this._mcu=m;this.pins=new Array();for(var o=0;o<n.length;o++){this.pins.push({pin:n[o],reginfo:a.getPinRegInfo(n[o])})}if(!c(l)){this.setOpts(l)}}catch(p){throw new MiMicException(p)}};a.Port.prototype={_mcu:null,pins:null,BCF_setOpts:function b(t,n){try{var s={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]};var l=e(t)?t:this.clonePinOptAssoc(t);for(var o=0;o<this.pins.length;o++){var p=this.pins[o].reginfo;var m=l[o];if(!c(m.sel)){s.selr[p.s]|=(m.sel<<p.smb);s.selr_mask[p.s]|=(3<<p.smb)}if(!c(m.mode)){s.modr[p.m]|=(m.mode<<p.smb);s.modr_mask[p.m]|=(3<<p.smb)}if(!c(m.od)){s.odr[p.o]|=(m.od<<p.ob);s.odr_mask[p.o]|=(1<<p.ob)}}var r="";for(var o=0;o<10;o++){if(s.selr_mask[o]!=0){r+=j.setBit(h._PINSEL[o],s.selr_mask[o],s.selr[o],0,n)}if(s.modr_mask[o]!=0){r+=j.setBit(h._PINMODE[o],s.modr_mask[o],s.modr[o],0,n)}}for(var o=0;o<5;o++){if(s.odr_mask[o]!=0){r+=j.setBit(h._PINMODE_OD[o],s.odr_mask[o],s.odr[o],0,n)}}return r}catch(q){throw new MiMicException(q)}},setOpts:function f(l){try{var m=new Array();var o=this.BCF_setOpts(l,m);if(o.length>0){this._mcu.callMiMicWithCheck(o+j.END,m)}}catch(n){throw new MiMicException(n)}return},clonePinOptAssoc:function i(l){var m=new Array();if(e(l)){if(l.length!=this.pins.length){throw new MiMicException()}for(var n=0;n<this.pins.length;n++){m.push(d(l[n]))}}else{for(var n=0;n<this.pins.length;n++){m.push(d(l))}}return m}}}());(function(){var f=LPC1769;var d=f._BCF;var b=f._EE;var c=MiMicLib.isUndef;f.Pin=function e(g,h,j){try{if(c(h)){throw new MiMicException(b.INVALID_PIN)}this._port=new f.Port(g,[h],c(j)?undefined:[j])}catch(i){throw new MiMicException(i)}};f.Pin.prototype={_port:null,setOpt:function a(h){try{this._port.setOpts([h])}catch(g){throw new MiMicException(g)}return}}}());(function(){var a=LPC1769;var p=a._BCF;var q=a._EE;var d=MiMicLib.isUndef;var j=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)?{}:j(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={_AD0CR:1073954816,_AD0DR:[1073954832,1073954836,1073954840,1073954844,1073954848,1073954852,1073954856,1073954860],_phl:null,_mcu:null,BCF_setOpt:function l(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 i(t,s,r){try{return p.setBit(this._AD0CR,t,s*t,0,r)}catch(u){throw new MiMicException(u)}},BCF_getAD0DR:function k(s,r){try{return p.getMem(this._AD0DR[s],r)}catch(t){throw new MiMicException(t)}},setOpt:function g(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 m(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 n(t){try{var u=new Array();for(var v=0;v<t.length;v++){var s=a.completePinFunctionName(t[v],"AD");var r=s.substring(2).split(".");if(isNaN(r[1])){throw new MiMicException(q.INVALID_CFG)}u.push({port:0,ch:parseInt(r[1]),pin_sel:a.getPinSelByFunctionName(t[v],s)})}return u}catch(w){throw new MiMicException(w)}}a.AdcPort=function o(t,s,y){try{this._adc=t;var r=n(s);var x=r[0].port;for(var v=1;v<r.length;v++){if(x!=r[v].port){throw new MiMicException("Invalid pin combination.")}}this._port=new a.Port(t._mcu,s);this._port_no=x;this._adcr_mask=0;for(var v=0;v<r.length;v++){this._adcr_mask|=(1<<r[v].ch)}var u={};if(d(y)){u.pin=this._port.clonePinOptAssoc({});u.sel=1}else{u.pin=this._port.clonePinOptAssoc(d(y.pin)?{}:y.pin);u.sel=1}for(var v=0;v<r.length;v++){if(d(u.pin[v].sel)){u.pin[v].sel=r[v].pin_sel}}this._pininfo=r;this.setOpt(u)}catch(w){throw new MiMicException(w)}};a.AdcPort.prototype={_adc:null,_pininfo:null,_port_no:0,_port:null,_adcr_mask:0,setOpt:function g(u){try{var r=new Array();var t="";if(!d(u.pin)){t+=this._port.BCF_setOpts(u.pin,r)}if(!d(u.sel)){t+=this._adc.BCF_setSels(this._adcr_mask,u.sel,r)}this._adc._mcu.callMiMicWithCheck(t+p.END,r);return}catch(s){throw new MiMicException(s)}},getValues:function h(){try{var s=new Array();var x="";for(var u=0;u<this._port.pins.length;u++){x+=this._adc.BCF_getAD0DR(this._pininfo[u].ch,s)}var t=this._adc._mcu.callMiMicWithCheck(x+p.END,s);var v=new Array();for(var u=0;u<this._port.pins.length;u++){v.push((t.stream[u]>>4)&4095)}return v}catch(w){throw new MiMicException(w)}}};a.AdcPin=function e(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 f(){try{return this._aport.getValues()[0]}catch(r){throw new MiMicException(r)}},setOpt:function g(s){try{this._aport.setOpt(s)}catch(r){throw new MiMicException(r)}}}}());(function(){var g=LPC1769;var p=g._BCF;var a=g._EE;var f=MiMicLib.isUndef;var n=MiMicLib.cloneAssoc;var j=MiMicLib.isArray;g.Gpio=function r(t,v){try{this._mcu=t;t.registerPhl(this,"GPIO")}catch(u){throw new MiMicException(u)}};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 l(u,v,t){try{t.push(this._FIO_PIN[u],this._FIO_MASK[u],~v);return"EA00EA01EA02DF0201DB0300EE03"}catch(w){throw new MiMicException(w)}},BCF_setValues:function h(v,w,u,t){try{t.push(this._FIO_PIN[v],this._FIO_MASK[v],~w,u);return"EA00EA01EA02EA03DF0201DF0300"}catch(x){throw new MiMicException(x)}},BCF_setDirs:function e(u,v,w,t){try{return p.setBit(this._FIO_DIR[u],v,w,0,t)}catch(x){throw new MiMicException(x)}},getPin:function q(t,v){try{return new g.GpioPin(this,t,v)}catch(u){throw new MiMicException(u)}},getPort:function s(t,v){try{return new g.GpioPort(this,t,v)}catch(u){throw new MiMicException(u)}}};function k(u){try{var v=new Array();for(var w=0;w<u.length;w++){var x=g.completePinFunctionName(u[w],"GPIO");var t=x.substring(4).split(".");if(isNaN(t[0])||isNaN(t[1])){throw new MiMicException(a.INVALID_CFG)}v.push({port:parseInt(t[0]),bit:parseInt(t[1]),pin_sel:g.getPinSelByFunctionName(u[w],x)})}return v}catch(y){throw new MiMicException(y)}}g.GpioPort=function o(x,u,A){try{this._gpio=x;var t=k(u);var z=t[0].port;for(var w=1;w<t.length;w++){if(z!=t[w].port){throw new MiMicException("Invalid pin combination.")}}this._port=new g.Port(x._mcu,u);this._port_no=z;this._mask=0;for(var w=0;w<t.length;w++){this._mask|=(1<<t[w].bit)}var v={};if(f(A)){v.pin=this._port.clonePinOptAssoc({})}else{v.pin=this._port.clonePinOptAssoc(f(A.pin)?{}:A.pin)}for(var w=0;w<t.length;w++){if(f(v.pin[w].sel)){v.pin[w].sel=t[w].pin_sel}}this._pininfo=t;this.setOpt(v)}catch(y){throw new MiMicException(y)}};g.GpioPort.prototype={_pininfo:null,_gpio:null,_port_no:0,_port:null,_mask:0,setOpt:function b(z){try{var t=this._pininfo;var u=new Array();var y="";if(!f(z.pin)){y+=this._port.BCF_setOpts(z.pin,u)}if(!f(z.dir)){var A=0;var w=0;if(j(z.dir)){for(var v=0;v<t.length;v++){if(f(z.dir[v])){continue}w|=(1<<t[v].bit);A|=(z.dir[v]<<t[v].bit)}}else{A=this._mask*z.dir;w=this._mask}y+=this._gpio.BCF_setDirs(this._port_no,w,A,u)}this._gpio._mcu.callMiMicWithCheck(y+p.END,u);return}catch(x){throw new MiMicException(x)}},setValue:function c(x){try{var w=0;for(var y=0;y<this._pininfo.length;y++){var t=((x>>y)&1);w|=(t<<this._pininfo[y].bit)}var u=new Array();var A=this._gpio.BCF_setValues(this._port_no,this._mask,w,u);this._gpio._mcu.callMiMicWithCheck(A+p.END,u)}catch(z){throw new MiMicException(z)}},getValue:function d(){try{var x=new Array();var A=this._gpio.BCF_getValues(this._port_no,this._mask,x);var u=this._gpio._mcu.callMiMicWithCheck(A+p.END,x).stream[0];var w=0;for(var y=this._pininfo.length-1;y>=0;y--){var t=((u>>this._pininfo[y].bit)&1);w=(w<<1)|t}return w}catch(z){throw new MiMicException(z)}},outPatt:function i(x){try{var w=new Array();var B="";for(var z=0;z<x.length;z++){var u=0;for(var y=0;y<this._pininfo.length;y++){var t=((x[z]>>y)&1);u|=(t<<this._pininfo[y].bit)}B+=this._gpio.BCF_setValues(this._port_no,this._mask,u,w)}this._gpio._mcu.callMiMicWithCheck(B+p.END,w)}catch(A){throw new MiMicException(A)}}};g.GpioPin=function m(t,u,w){try{this._gport=new g.GpioPort(t,[u],w)}catch(v){throw new MiMicException(v)}};g.GpioPin.prototype={_gport:null,setOpt:function b(u){try{this._gport.setOpt(u)}catch(t){throw new MiMicException(t)}},setValue:function c(t){try{this._gport.setValue(t)}catch(u){throw new MiMicException(u)}},getValue:function d(){try{return this._gport.getValue()}catch(t){throw new MiMicException(t)}},outPatt:function i(t){try{this._gport.outPatt(t)}catch(u){throw new MiMicException(u)}},}}());(function(){var f=LPC1769;var q=f._BCF;var a=f._EE;var d=MiMicLib.isUndef;var l=MiMicLib.isArray;var o=MiMicLib.cloneAssoc;f.Pwm=function j(v,A){try{this._mcu=v;this._phl=new f.Peripheral(v,f.PHL.PWM1);var x=d(A)?{phl:{}}:{phl:d(A.phl)?{}:o(A.phl),freq:A.freq};if(d(x.phl.power)){x.phl.power=1}if(d(x.phl.clock)){x.phl.clock=0}if(d(x.freq)){x.freq=100}var z="";var w=new Array();z+=this.BCF_setOpt(x,w);z+=q.setMem(this._PC,0,w);z+=q.setMem(this._PCR,0,w);z+=q.setMem(this._CTCR,0,w);z+=q.setMem(this._TCR,0,w);z+=q.setMem(this._TC,0,w);z+=q.setMem(this._TCR,9,w);this._mcu.callMiMicWithCheck(z+q.END,w);this._mcu.registerPhl(this,"PWM")}catch(y){throw new MiMicException(y)}};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 n(z,v){try{var y="";var w;if(!d(z.phl)){y+=this._phl.BCF_setOpt(z.phl,v)}if(!d(z.freq)){w=Math.round(this._phl.getPCLK()/z.freq);if(w<=0){throw new MiMicException("The peripheral clock too small.")}y+=this.BCF_setMRn(0,w,v);y+=this.BCF_setLER(0,v);this._cache.mr0=w}return y}catch(x){throw new MiMicException(x)}},BCF_setLER:function b(w,v){try{return q.setBit(this._LER,1,1,w,v)}catch(x){throw new MiMicException(x)}},BCF_setLERs:function m(x,w,v){try{return q.setBit(this._LER,x,w,0,v)}catch(y){throw new MiMicException(y)}},BCF_setMRn:function i(x,w,v){try{return q.setMem(this._MRn[x],w,v)}catch(y){throw new MiMicException(y)}},BCF_setMRnByDuty:function e(w,x,v){try{return this.BCF_setMRn(w,Math.round(x*this._cache.mr0),v)}catch(y){throw new MiMicException(y)}},BCF_setPCRbits:function g(C,y,z,x){try{var w,A;w=A=0;if(!d(y)){var B=255&C;A|=y*B;w|=B}if(!d(z)){var B=65280&C;A|=(z*B);w|=B}return q.setBit(this._PCR,w,A,0,x)}catch(D){throw new MiMicException(D)}},setOpt:function c(y){try{var v=new Array();var x=this.BCF_setOpt(y,v);this._mcu.callMiMicWithCheck(x+q.END,v)}catch(w){throw new MiMicException(w)}},getPin:function r(v,x){try{return new f.PwmPin(this,v,x)}catch(w){throw new MiMicException(w)}},getPort:function t(v,x){try{return new f.PwmPort(this,v,x)}catch(w){throw new MiMicException(w)}}};function h(w){try{var x=new Array();for(var y=0;y<w.length;y++){var z=f.completePinFunctionName(w[y],"PWM");var v=z.substring(2).split(".");if(isNaN(v[1])){throw new MiMicException(a.INVALID_CFG)}x.push({port:0,ch:parseInt(v[1]),pin_sel:f.getPinSelByFunctionName(w[y],z)})}return x}catch(A){throw new MiMicException(A)}}f.PwmPort=function s(x,w,C){try{this._pwm=x;var v=h(w);var B=v[0].port;for(var z=1;z<v.length;z++){if(B!=v[z].port){throw new MiMicException("Invalid pin combination.")}}this._port=new f.Port(x._mcu,w);this._port_no=B;var y={};if(d(C)){y.pin=this._port.clonePinOptAssoc({});y.duty=0;y.enable=1}else{y.pin=this._port.clonePinOptAssoc(d(C.pin)?{}:C.pin);y.duty=d(C.duty)?0:C.duty;y.enable=d(C.enable)?0:C.enable}for(var z=0;z<v.length;z++){if(d(y.pin[z].sel)){y.pin[z].sel=v[z].pin_sel}}this._pininfo=v;this.setOpt(y)}catch(A){throw new MiMicException(A)}};f.PwmPort.prototype={_pwm:null,_pininfo:null,_port_no:0,_port:null,setOpt:function c(v){try{var A=this._pininfo;var D=new Array();var C="";if(!d(v.pin)){C+=this._port.BCF_setOpts(v.pin,D)}if(!d(v.enable)){var w=0;var x=0;if(l(v.enable)){for(var z=0;z<A.length;z++){if(d(v.enable[z])){continue}x|=((257*v.enable[z])<<A[z].ch);w|=(257<<A[z].ch)}}else{for(var z=0;z<A.length;z++){w|=(257<<A[z].ch)}x=w*v.enable}C+=this._pwm.BCF_setPCRbits(w,0,x,D)}if(!d(v.duty)){var y=0;if(l(v.duty)){for(var z=0;z<A.length;z++){if(d(v.duty[z])){continue}C+=this._pwm.BCF_setMRnByDuty(A[z].ch,v.duty[z],D);y|=(1<<A[z].ch)}}else{for(var z=0;z<A.length;z++){C+=this._pwm.BCF_setMRnByDuty(A[z].ch,v.duty,D);y|=(1<<A[z].ch)}}C+=this._pwm.BCF_setLERs(y,y,D)}this._pwm._mcu.callMiMicWithCheck(C+q.END,D);return}catch(B){throw new MiMicException(B)}},setDutys:function k(w){try{this.setOpt({duty:w})}catch(v){throw new MiMicException(v)}}};f.PwmPin=function u(v,w,y){try{this._pport=new f.PwmPort(v,[w],y)}catch(x){throw new MiMicException(x)}};f.PwmPin.prototype={_pport:null,setOpt:function c(w){try{this._pport.setOpt(w)}catch(v){throw new MiMicException(v)}},setDuty:function p(v){try{this._pport.setDutys([v])}catch(w){throw new MiMicException(w)}}}}());(function(){var f=LPC1769;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,p,o){var n="";var q=new Array();if(!d(p)){for(var l=0;l<8;l++){var k="wm"+l;if(!d(p[k])){n+="FB"+MiMicLib.hexout(l,2)+MiMicLib.hexout(p[k],8)}}if(!d(p.stream)){for(var l=0;l<p.stream.length;l++){q.push(p.stream[l])}}}n+="ZF"+MiMicLib.hexout(j,8);var g=0;if(!d(o)){for(var l=0;l<8;l++){if(!d(o["wm"+l])){n+="EE"+MiMicLib.hexout(l,2);g++}}}var m=this._mcu.callMiMic(n+e.END,q);if(m.result!=0){return false}if(!d(o)){var h=m.stream.length-g;for(var l=0;l<8;l++){var k="wm"+l;if(!d(o[k])){o[k]=m.stream[h];h++}}if(!d(o.stream)){o.stream=m.stream.slice(0,m.stream.length-g)}}return false}}}());(function(){var g=LPC1769;var n=g._BCF;var a=g._EE;var f=MiMicLib.isUndef;var h=MiMicLib.isArray;var k=MiMicLib.cloneAssoc;g.Dac=function i(s,x){try{this._mcu=s;this._phl=new g.Peripheral(s,g.PHL.DAC);var u=f(x)?{phl:{}}:{phl:f(x.phl)?{}:k(x.phl),};if(f(u.phl.clock)){u.phl.clock=0}var w="";var t=new Array();w+=this.BCF_setOpt(u,t);this._mcu.callMiMicWithCheck(w+n.END,t);this._mcu.registerPhl(this,"DAC")}catch(v){throw new MiMicException(v)}};g.Dac.prototype={_DACR:1074315264,_DACCTRL:1074315268,_DACCNTVAL:1074315272,_phl:null,_mcu:null,BCF_setOpt:function j(v,s){try{var u="";if(!f(v.phl)){u+=this._phl.BCF_setOpt(v.phl,s)}return u}catch(t){throw new MiMicException(t)}},setOpt:function c(v){try{var s=new Array();var u=this.BCF_setOpt(v,s);this._mcu.callMiMicWithCheck(u+n.END,s)}catch(t){throw new MiMicException(t)}},getPin:function o(s,u){try{return new g.DacPin(this,s,u)}catch(t){throw new MiMicException(t)}},getPort:function r(s,u){try{return new g.DacPort(this,s,u)}catch(t){throw new MiMicException(t)}},BCF_setBias:function b(u,t,s){try{return n.setBit(this._DACR,u,t*u,0,s)}catch(v){throw new MiMicException(v)}},BCF_setValue:function l(t,s){return n.setBit(this._DACR,1023,t,6,s)}};function p(t){try{var u=new Array();for(var v=0;v<t.length;v++){var s=g.completePinFunctionName(t[v],"AOUT");u.push({port:0,pin_sel:g.getPinSelByFunctionName(t[v],s)})}return u}catch(w){throw new MiMicException(w)}}g.DacPort=function e(u,t,y){try{this._dac=u;var s=p(t);this._port=new g.Port(u._mcu,t);var w={};if(f(y)){w.pin=this._port.clonePinOptAssoc({});w.bias=0}else{w.pin=this._port.clonePinOptAssoc(f(y.pin)?{}:y.pin);w.bias=f(y.bias)?0:y.bias}for(var v=0;v<s.length;v++){if(f(w.pin[v].sel)){w.pin[v].sel=s[v].pin_sel}}this.setOpt(w)}catch(x){throw new MiMicException(x)}};g.DacPort.prototype={_dac:null,_port:null,setOpt:function c(v){try{var s=new Array();var u="";if(!f(v.pin)){u+=this._port.BCF_setOpts(v.pin,s)}if(!f(v.bias)){if(h(v.pin)){u+=this._dac.BCF_setBias(65536,v.bias[0],s)}else{u+=this._dac.BCF_setBias(65536,v.bias,s)}}this._dac._mcu.callMiMicWithCheck(u+n.END,s);return}catch(t){throw new MiMicException(t)}},setValues:function m(s){try{var t=new Array();var w="";for(var u=0;u<this._port.pins.length;u++){w+=this._dac.BCF_setValue(s[u],t)}this._dac._mcu.callMiMicWithCheck(w+n.END,t);return}catch(v){throw new MiMicException(v)}}};g.DacPin=function q(s,t,v){try{this._port=new g.DacPort(s,[t],v)}catch(u){throw new MiMicException(u)}};g.DacPin.prototype={_port:null,setValue:function d(s){try{this._port.setValues([s])}catch(t){throw new MiMicException(t)}},setOpt:function c(t){try{this._port.setOpt(t)}catch(s){throw new MiMicException(s)}}}}());var LPCXpresso1769;(function(){var b=LPC1769;var a=MiMicLib.isUndef;LPCXpresso1769=MiMicLib.cloneAssoc(b);if(!a(LPCXpresso1769.LED)){alert("invalid override[LED]")}LPCXpresso1769.LED=[b.P0[22]]}());
\ No newline at end of file
index 1113efb..a61cbbe 100644 (file)
@@ -842,6 +842,7 @@ LPC1769=DEV;
                 * <li>GPIO - LPC1769.GpioPin</li>\r
                 * <li>AD - LPC1769.AdcPin</li>\r
                 * <li>PWM - LPC1769.PwmPin</li>\r
+                * <li>DA - LPC1769.DacPin</li>\r
                 * </ul>\r
                 */\r
                getPin:function getPin(/*...*/)\r
@@ -875,10 +876,10 @@ LPC1769=DEV;
                 * @return {object as PortObject}\r
                 * 返却されるインスタンスのクラスは、機能により異なる。機能とインスタンスのクラスの対応は、以下の通りである。\r
                 * <ul>\r
-                * <li>GPIO - LPC1769.GpioPin</li>\r
-                * <li>AD - LPC1769.AdcPin</li>\r
-                * <li>PWM - LPC1769.PwmPin</li>\r
-                * <li>DAC - LPC1769.DacPin</li>\r
+                * <li>GPIO - LPC1769.GpioPort</li>\r
+                * <li>AD - LPC1769.AdcPort</li>\r
+                * <li>PWM - LPC1769.PwmPort</li>\r
+                * <li>DA - LPC1769.DacPort</li>\r
                 * </ul>                 \r
                 */\r
                getPort:function getPort(i_pins,i_function_name)\r
@@ -1016,8 +1017,8 @@ DEV.Memory.prototype=
         * コンストラクタで指定したアドレスからのオフセット位置を指定する。4バイト境界でなければならない。\r
         * @param {int} i_size\r
         * 取得するバイト数を指定する。4バイト単位でなければならない。      \r
-        * @return {int or Array[int]}\r
-        * 取得する値の個数は、i_size/4個である。個数により、戻り値の型が異なるので注意すること。\r
+        * @return {Array[int]}\r
+        * 取得する値の個数は、i_size/4個である。\r
         * @example\r
         * var mcu=new LPC1769.Mcu("192.168.0.39");\r
         * var mem=new LPC1769.Memory(mcu); //create instance\r
@@ -1031,7 +1032,7 @@ DEV.Memory.prototype=
         * @param {array[int]} i_offsets\r
         * オフセットアドレスの配列。それぞれ4バイト境界でなければならない。\r
         * @return {int or Array[int]}\r
-        * 返却される値の個数は、i_offsetの長さと同じになる。個数により、戻り値の型が異なるので注意すること。\r
+        * 返却される値の個数は、i_offsetの長さと同じになる。\r
         * @example\r
         * var mcu=new LPC1769.Mcu("192.168.0.39");\r
         * var mem=new LPC1769.Memory(mcu); //create instance\r
@@ -1051,6 +1052,7 @@ DEV.Memory.prototype=
        read32:function read32(/*arguments*/)\r
        {\r
                try{\r
+                       var is_ret_array=true;\r
                        var bc="";\r
                        var ar=new Array();\r
                        var offset=arguments[0];\r
@@ -1061,6 +1063,7 @@ DEV.Memory.prototype=
                                        checkAlign(offset);\r
                                        bc=BCF.READMEM;\r
                                        ar.push(this._base+offset);\r
+                                       is_ret_array=false;\r
                                }else{\r
                                        //read32(i_offsets:array)\r
                                        for(var i=0;i<offset.length;i++){\r
@@ -1083,7 +1086,7 @@ DEV.Memory.prototype=
                                break;\r
                        }\r
                        var ret=this._mcu.callMiMicWithCheck(bc+BCF.END,ar).stream;\r
-                       return ret.length==1?ret[0]:ret;\r
+                       return is_ret_array?ret:ret[0];\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -1419,7 +1422,7 @@ DEV.Port.prototype=
         * 複数のピン設定をレジスタごとにまとめたBCを生成する。\r
         * @private\r
         * @param {array[associative array]| associative array} i_opts\r
-        * ã\83\94ã\83³è¨­å®\9aæ\83\85å ±ã\81®é\80£è£\85é\85\8då\88\97ã\81®é\85\8då\88\97ã\80\82é\85\8då\88\97ã\81®è¦\81ç´ æ\95°ã\81¯ã\80\81Portを構成するPinと同じ数である必要がある。\r
+        * ã\83\94ã\83³è¨­å®\9aæ\83\85å ±ã\81®é\80£è£\85é\85\8då\88\97ã\81\8bã\80\81ã\81\9dã\81®é\85\8då\88\97ã\80\82é\85\8då\88\97ã\81®æ\99\82ã\81¯Portを構成するPinと同じ数である必要がある。\r
         * 単一のassociative arrayを指定した場合は、全てのピンに同じパラメータを設定する。\r
         * <pre>associative array</>\r
         * ピン設定連装配列 {sel:int,mode:int,od:int}\r
@@ -1479,14 +1482,12 @@ DEV.Port.prototype=
                }\r
        },\r
        /**\r
-        * ポートにオプションパラメータをセットする。\r
-        * 関数は、ポートを構成するピンに、ピンオプション配列の値を個別に設定する。\r
+        * Portを構成するPinにオプション値を設定する。\r
         * @name LPC1769.Port#setOpts\r
         * @function\r
-        * @param {array[associative array]} i_opts\r
-        * ã\83\94ã\83³ã\82³ã\83³ã\83\95ã\82£ã\82°ã\83¬ã\83¼ã\82·ã\83§ã\83³ã\81®é\80£è£\85é\85\8då\88\97ã\81®配列である。\r
+        * @param {array[associative array] | associative array} i_opts\r
+        * ã\83\94ã\83³ã\82³ã\83³ã\83\95ã\82£ã\82°ã\83¬ã\83¼ã\82·ã\83§ã\83³ã\81®é\80£è£\85é\85\8då\88\97ã\80\81ã\81¾ã\81\9fã\81¯配列である。\r
         * ピンオプションの連装配列は、Pin#setOptを参照。\r
-        * 配列の要素数は、ポートを構成するピンの数と同じでなければならない。\r
         * @example\r
         * //set GPIO,mode=1,open drain=0\r
         * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -1638,7 +1639,7 @@ var cloneAssoc=MiMicLib.cloneAssoc;
  * @name LPC1769.Adc\r
  * @param {object as LPC1769.Mcu} i_mcu\r
  * インスタンスを結びつけるMcuオブジェクト。\r
- * @param {object as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * インスタンス生成と同時にsetOpt関数で設定する値。省略時は、{phl:{power:1}}とみなす。\r
  * 詳細はsetOpt関数を参照。 \r
  * @example\r
@@ -1725,10 +1726,10 @@ DEV.Adc.prototype=
         * ADCペリフェラルに、i_optのオプション値を設定する。\r
         * @name LPC1769.Adc#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
+        * @param {associative array} i_opt\r
         * ADCペリフェラルのコンフィグレーションパラメタである。必要な値を格納した連想配列で指定する。\r
         * 全ての値を省略することは出来ない。連想配列のメンバは以下の通り。\r
-        * <pre>{phl:object as associative array}</pre>\r
+        * <pre>{phl:associative array}</pre>\r
         * <ul>\r
         * <li>phl - LPC1769.Peripheral#setOpt関数のi_optに渡すパラメタである。</li>\r
         * </ul>\r
@@ -1758,8 +1759,8 @@ DEV.Adc.prototype=
         * @function\r
         * @param {object as ピン識別子} i_pin\r
         * AD機能を割り当てるPINの識別子である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * AdcPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPin.setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * AdcPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPinを参照。\r
         * @return {object as LPC1769.AdcPin}\r
         * LPC1769.AdcPinクラスのオブジェクトである。\r
         * @example\r
@@ -1785,8 +1786,8 @@ DEV.Adc.prototype=
         * @function\r
         * @param {array[ピン識別子]} i_pin\r
         * AD機能を割り当てるPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPort.setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPortを参照。\r
         * @return {object as LPC1769.AdcPort}\r
         * LPC1769.AdcPortクラスのオブジェクトである。\r
         * @example\r
@@ -1810,24 +1811,27 @@ DEV.Adc.prototype=
  * AD pinからADInfoを取得\r
  * @private\r
  */\r
-function pin2AdcPinInfo(i_pin)\r
+function makeAdcPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var func_name=DEV.completePinFunctionName(i_pin,"AD");\r
-               //portとbitを得る(AD0だけしか管理しないよ)\r
-               var a=func_name.substring(2).split(".");\r
-               var r={port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pin,func_name)};\r
-               if(!isNaN(r.ch)){\r
-                       return r;\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var func_name=DEV.completePinFunctionName(i_pins[i],"AD");\r
+                       //portとbitを得る(AD0だけしか管理しないよ)\r
+                       var a=func_name.substring(2).split(".");\r
+                       if(isNaN(a[1])){\r
+                               throw new MiMicException(EE.INVALID_CFG);\r
+                       }\r
+                       ret.push({port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pins[i],func_name)});\r
                }\r
-               throw new MiMicException(EE.INVALID_CFG,"The pin has not AD fuction.");\r
+               return ret;\r
        }catch(e){\r
-               throw new MiMicException(e);    \r
+               throw new MiMicException(e);\r
        }\r
 }\r
 /**\r
- * LPC1769.AdcPort (AdcPort)クラスのコンストラクタ。複数のADピンから一括で値を取得するときに使用する。\r
+ * LPC1769.AdcPort (AdcPort)クラスのコンストラクタ。複数のADcPinから一括で値を取得するときに使用する。\r
  * Adcペリフェラルオブジェクトにピン識別子の配列で指定されたピン集合を関連付けて、AD機能を持つポートを生成する。\r
  * 関数は、ピン識別子を元に、そのピンがAD機能に接続できるかを調べる。全てのピンにAD機能を割り当てられない場合、例外が発生する。どのピンにAD機能が割り当てられるかは、MCUのスペックシートを参照すること。\r
  * @constructor\r
@@ -1836,9 +1840,9 @@ function pin2AdcPinInfo(i_pin)
  * インスタンスを結びつけるAdcオブジェクト。\r
  * @param {array[pin識別子]} i_pins\r
  * ピン識別子の配列。指定できるのは、LPC1769.P?[?]である。順番は、このインスタンスの返す値の順序に影響する。\r
- * @param {object as associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto}}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * @param {array[associative array] | associative array} i_opt\r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined}}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create [AD0.0,AD0.1]\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -1850,15 +1854,11 @@ DEV.AdcPort=function AdcPort(i_adc,i_pins,i_opt)
        try{\r
                this._adc=i_adc;\r
                //ピンセットを取得\r
-               this._pins=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       this._pins.push(pin2AdcPinInfo(i_pins[i]));\r
-               }\r
+               var pininfo=makeAdcPinInfoArray(i_pins);\r
                //pinが全て同じポートに所属しているか確認\r
-               var p=this._pins[0].port;\r
-               for(var i=1;i<this._pins.length;i++){\r
-                       if(p!=this._pins[i].port){\r
+               var p=pininfo[0].port;\r
+               for(var i=1;i<pininfo.length;i++){\r
+                       if(p!=pininfo[i].port){\r
                                throw new MiMicException("Invalid pin combination.");\r
                        }\r
                }\r
@@ -1867,15 +1867,26 @@ DEV.AdcPort=function AdcPort(i_adc,i_pins,i_opt)
                this._port_no=p;\r
                //AD0CR用のマスクを生成。\r
                this._adcr_mask=0;\r
-               for(var i=0;i<this._pins.length;i++){\r
-                       this._adcr_mask|=(0x1<<this._pins[i].ch);\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       this._adcr_mask|=(0x1<<pininfo[i].ch);\r
                }\r
+\r
                //ピンオプションの生成\r
-               var opt=isUndef(i_opt)?{}:cloneAssoc(i_opt);\r
-               opt.sel=1;//ADxCRの値\r
-               opt.pin=isUndef(opt.pin)?{}:cloneAssoc(opt.pin);\r
-               //設定が無ければ、ピンセレクタを自動に設定\r
-               if(isUndef(opt.pin.sel)){opt.pin.sel=this._PINSEL_AUTO_DETECT;}\r
+               var opt={};\r
+               if(isUndef(i_opt)){\r
+                       opt.pin=this._port.clonePinOptAssoc({});\r
+                       opt.sel=1;//ADxCRの値\r
+               }else{\r
+                       opt.pin=this._port.clonePinOptAssoc(isUndef(i_opt.pin)?{}:i_opt.pin);\r
+                       opt.sel=1;//ADxCRの値\r
+               };\r
+               //pinselの自動設定\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       if(isUndef(opt.pin[i].sel)){\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
+                       }\r
+               }\r
+               this._pininfo=pininfo;\r
                //ピンオプションの設定\r
                this.setOpt(opt);\r
        }catch(e){\r
@@ -1884,9 +1895,8 @@ DEV.AdcPort=function AdcPort(i_adc,i_pins,i_opt)
 }\r
 DEV.AdcPort.prototype=\r
 {\r
-       _PINSEL_AUTO_DETECT:0x0fffffff,\r
        _adc:null,\r
-       _pins:null,\r
+       _pininfo:null,\r
        _port_no:0,\r
        _port:null,\r
        _adcr_mask:0,\r
@@ -1896,8 +1906,19 @@ DEV.AdcPort.prototype=
         * 設定可能な値は、LPC1769.AdcPin#setOptと同じである。\r
         * @name LPC1769.AdcPort#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
-        * LPC1769.AdcPin#setOptを参照。\r
+        * @param {associative array | array[associative array]} i_opt\r
+        * ADピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
+        * 全てのピンに同じパラメータを指定する場合は、連装配列で指定する。個別に設定する場合は、連装配列を配列にして指定する。\r
+        * <pre>{i_opt:associative array}</pre>\r
+        * <ul>\r
+        * <li>pin(option)</li>\r
+        * </ul>\r
+        * パラメータの詳細は、LPC1769.AdcPin#setOptを参照。\r
+        * @example\r
+        * //ポートを構成する全てのピンに同じパラメータを設定する場合\r
+        * setOpt({pin:{v1}});\r
+        * //ポートを構成するピンに個々にパラメータを設定する場合\r
+        * setOpt({pin:[{v1},{v2}]});\r
         */     \r
        setOpt:function setOpt(i_opt)\r
        {\r
@@ -1907,14 +1928,7 @@ DEV.AdcPort.prototype=
                        var bc="";\r
                        //i_optの展開\r
                        if(!isUndef(i_opt.pin)){\r
-                               var optset=new Array();\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       //pinselが_PINSEL_AUTO_DETECTならばauto。そうでなければundefinedも含めて設定\r
-                                       var s=(i_opt.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[i].pin_sel:i_opt.pin.sel;\r
-                                       optset.push({sel:s,mode:i_opt.pin.mode,od:i_opt.pin.od});\r
-                               }\r
-                               //portの設定\r
-                               bc+=this._port.BCF_setOpts(optset,db);\r
+                               bc+=this._port.BCF_setOpts(i_opt.pin,db);\r
                        }\r
                        //隠し。ADxCR\r
                        if(!isUndef(i_opt.sel)){\r
@@ -1945,13 +1959,13 @@ DEV.AdcPort.prototype=
                        //メモリから値取得\r
                        var db=new Array();\r
                        var bc="";\r
-                       for(var i=0;i<this._pins.length;i++){\r
-                               bc+=this._adc.BCF_getAD0DR(this._pins[i].ch,db);\r
+                       for(var i=0;i<this._port.pins.length;i++){\r
+                               bc+=this._adc.BCF_getAD0DR(this._pininfo[i].ch,db);\r
                        }\r
                        var ret=this._adc._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                        //値の整形\r
                        var r=new Array();\r
-                       for(var i=0;i<this._pins.length;i++){\r
+                       for(var i=0;i<this._port.pins.length;i++){\r
                                r.push((ret.stream[i]>>4)&0x00000fff);\r
                        }\r
                        return r;\r
@@ -1971,8 +1985,8 @@ DEV.AdcPort.prototype=
  * @param {object as pin識別子} i_pin\r
  * ピン識別子。指定できるのは、LPCXpresso1796.P?[?]である。\r
  * @param {object as associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto}}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined}}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create AD0.0\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -2015,10 +2029,10 @@ DEV.AdcPin.prototype=
         * ADピンにオプション値を設定する。\r
         * @name LPC1769.AdcPin#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
+        * @param {associative array} i_opt\r
         * ADピンのコンフィグレーションパラメタである。必要な値を格納した連想配列で指定する。\r
         * 全ての値を省略することは出来ない。連想配列のメンバは以下の通り。\r
-        * <pre>{pin:object as associative array}</pre>\r
+        * <pre>{pin:associative array}</pre>\r
         * <ul>\r
         * <li>pin - LPC1769.Pin#setOpt関数のi_optに渡すパラメタである。</li>\r
         * </ul>\r
@@ -2046,7 +2060,7 @@ var BCF=DEV._BCF;
 var EE=DEV._EE;\r
 var isUndef=MiMicLib.isUndef;\r
 var cloneAssoc=MiMicLib.cloneAssoc;\r
-\r
+var isArray=MiMicLib.isArray;\r
 /**\r
  * LPCXPresso1769.Gpio (Gpio)クラスのコンストラクタ。\r
  * MCUに関連付けしたGpioペリフェラルを生成する。\r
@@ -2055,7 +2069,7 @@ var cloneAssoc=MiMicLib.cloneAssoc;
  * @constructor\r
  * @param {object as LPC1769.Mcu} i_mcu\r
  * インスタンスを結びつけるMcuオブジェクト。\r
- * @param {oject as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * 常に無視する。省略すること。\r
  * @example\r
  * //create GPIO (logical)pheripheral\r
@@ -2117,13 +2131,14 @@ DEV.Gpio.prototype=
        },\r
        /**\r
         * \r
-        @param i_dir 1 or 0\r
-        @private
+        * @param {int} i_dir\r
+        * i_maskに合致したビットイメージ\r
+        * @private
         */\r
        BCF_setDirs:function BCF_setDirs(i_ch,i_mask,i_dir,i_db)\r
        {\r
                try{\r
-                       return BCF.setBit(this._FIO_DIR[i_ch],i_mask,i_mask*i_dir,0,i_db);\r
+                       return BCF.setBit(this._FIO_DIR[i_ch],i_mask,i_dir,0,i_db);\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -2137,8 +2152,8 @@ DEV.Gpio.prototype=
         * @function\r
         * @param {object as ピン識別子} i_pin\r
         * GPIO機能を割り当てるPINの識別子である。\r
-        * @param {object as associative array} i_opt\r
-        * GpioPinのコンストラクタに渡すオプション値を指定する。省略可能。省略時はundefinedとみなす。詳細はGpioPinのコンストラクタを参照。\r
+        * @param {associative array} i_opt\r
+        * GpioPinのコンストラクタに渡すオプション値を指定する。省略時はundefinedである。詳細はLPC1769.GpioPinを参照。\r
         * @return {object as GpioPin}\r
         * GpioPinクラスのオブジェクトである。\r
         * @example\r
@@ -2164,8 +2179,8 @@ DEV.Gpio.prototype=
         * @function\r
         * @param {array[ピン識別子]} i_pin\r
         * Gpioポートを構成するPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * GpioPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.GpioPort.setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * GpioPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.GpioPortを参照。\r
         * @return {object as LPC1769.GpioPort}\r
         * LPC1769.GpioPortクラスのオブジェクトである。\r
         * @example\r
@@ -2188,21 +2203,24 @@ DEV.Gpio.prototype=
  * GPIO pinからGPIOInfoを取得
  * @private
  */\r
-function pin2GpioPinInfo(i_pin)\r
+function makeGpioPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var fn=DEV.completePinFunctionName(i_pin,"GPIO");\r
-               //pin名からポートとビットを得る。\r
-               var a=fn.substring(4).split(".");\r
-               //pin情報を構成。\r
-               var r={port:parseInt(a[0]),bit:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pin,fn)};\r
-               if(!isNaN(r.port) && !isNaN(r.bit)){\r
-                       return r;\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var fn=DEV.completePinFunctionName(i_pins[i],"GPIO");\r
+                       //pin名からポートとビットを得る。\r
+                       var a=fn.substring(4).split(".");\r
+                       if(isNaN(a[0]) || isNaN(a[1])){\r
+                               throw new MiMicException(EE.INVALID_CFG);\r
+                       }\r
+                       //pin情報を構成。\r
+                       ret.push({port:parseInt(a[0]),bit:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pins[i],fn)});\r
                }\r
-               throw new MiMicException(EE.INVALID_CFG,"The pin has not GPIO fuction.");\r
+               return ret;\r
        }catch(e){\r
-               throw new MiMicException(e);    \r
+               throw new MiMicException(e);\r
        }\r
 }\r
 \r
@@ -2218,11 +2236,11 @@ function pin2GpioPinInfo(i_pin)
  * ピン識別子の配列。指定できるのは、LPCXpresso1796.P?[?]である。順番は、このインスタンスの返す値の順序に影響する。\r
  * 0番目のピンはビット0に対応する。同様に、1番目のピンはビット1に対応する。\r
  * 組み合わせるピンは、同じ物理ポートに所属している必要がある。例えば、GPIO0.0とGPIO0.1は組み合わせられるが、GPIO0.0とGPIO1.1は組み合わせることが出来ない。\r
- * @param {object as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto}}を設定する。\r
  * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
  * @example\r
- * //create [AD0.0,AD0.1]\r
+ * //create [LPC1769.P0[0],LPC1769.P0[1]]\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
  * var gpio=new LPC1769.Gpio(mcu);\r
  * var port=new LPC1769.GpioPort(adc,[LPC1769.P0[0],LPC1769.P0[1]]); \r
@@ -2232,15 +2250,11 @@ DEV.GpioPort=function GpioPort(i_gpio,i_pins,i_opt)
        try{\r
                this._gpio=i_gpio;\r
                //ピンセットを取得\r
-               this._pins=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       this._pins.push(pin2GpioPinInfo(i_pins[i]));\r
-               }\r
+               var pininfo=makeGpioPinInfoArray(i_pins);\r
                //pinが全て同じポートに所属しているか確認\r
-               var p=this._pins[0].port;\r
-               for(var i=1;i<this._pins.length;i++){\r
-                       if(p!=this._pins[i].port){\r
+               var p=pininfo[0].port;\r
+               for(var i=1;i<pininfo.length;i++){\r
+                       if(p!=pininfo[i].port){\r
                                throw new MiMicException("Invalid pin combination.");\r
                        }\r
                }\r
@@ -2249,15 +2263,24 @@ DEV.GpioPort=function GpioPort(i_gpio,i_pins,i_opt)
                this._port_no=p;\r
                //GPIO用のマスクを生成。\r
                this._mask=0;\r
-               for(var i=0;i<this._pins.length;i++){\r
-                       this._mask|=(0x1<<this._pins[i].bit);\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       this._mask|=(0x1<<pininfo[i].bit);\r
                }\r
+\r
                //ピンオプションの生成\r
-               var opt=cloneAssoc(i_opt);\r
-               //ピンプロパティの複製\r
-               opt.pin=isUndef(opt.pin)?{}:cloneAssoc(opt.pin);\r
-               //設定が無ければ、ピンセレクタを自動に設定\r
-               if(isUndef(opt.pin.sel)){opt.pin.sel=this._PINSEL_AUTO_DETECT;}\r
+               var opt={};\r
+               if(isUndef(i_opt)){\r
+                       opt.pin=this._port.clonePinOptAssoc({});\r
+               }else{\r
+                       opt.pin=this._port.clonePinOptAssoc(isUndef(i_opt.pin)?{}:i_opt.pin);\r
+               };\r
+               //pinselの自動設定\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       if(isUndef(opt.pin[i].sel)){\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
+                       }\r
+               }\r
+               this._pininfo=pininfo;\r
                //ピンオプションの設定\r
                this.setOpt(opt);\r
        }catch(e){\r
@@ -2266,8 +2289,7 @@ DEV.GpioPort=function GpioPort(i_gpio,i_pins,i_opt)
 }\r
 DEV.GpioPort.prototype=\r
 {\r
-       _PINSEL_AUTO_DETECT:0x0fffffff,//setoptに自動を伝えるときに使う\r
-       _pins:null,\r
+       _pininfo:null,\r
        _gpio:null,\r
        _port_no:0,\r
        _port:null,\r
@@ -2275,32 +2297,52 @@ DEV.GpioPort.prototype=
        /**\r
         * Gpioポートにオプション値を設定する。\r
         * 関数は、ポートを構成する全てのピンに、同一なオプション値を設定する。\r
-        * 設定可能な値は、LPC1769.GpioPin#setOptと同じである。\r
+        * 設定可能な値は、LPC1769.GpioPin#setOptと同じである。   \r
         * @name LPC1769.GpioPort#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
-        * LPC1769.GpioPin#setOptを参照。\r
+        * @param {associative array | array[associative array]} i_opt\r
+        * GPIOピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
+        * 全てのピンに同じパラメータを指定する場合は、連装配列で指定する。個別に設定する場合は、連装配列を配列にして指定する。\r
+        * <pre>{i_opt:associative array}</pre>\r
+        * <ul>\r
+        * <li>pin(option) - array[{PIN_OPTION}] | {PIN_OPTION}</li>\r
+        * <li>dir(option) - array[{1bit int}] | {1bit int}</li>\r
+        * </ul>\r
+        * パラメータの詳細は、LPC1769.GpioPin#setOptを参照。\r
+        * @example\r
+        * //ポートを構成する全てのピンに同じパラメータを設定する場合\r
+        * setOpt({pin:{v1},dir:1});\r
+        * //ポートを構成するピンに個々にパラメータを設定する場合\r
+        * setOpt({pin:[{v1},{v2}],dir:[1,1]});\r
         */     \r
        setOpt:function setOpt(i_opt)\r
        {\r
                try{\r
+                       var pininfo=this._pininfo;\r
                        var db=new Array();\r
                        //BCの生成\r
                        var bc="";\r
+                       //pinの設定\r
+                       if(!isUndef(i_opt.pin)){\r
+                               bc+=this._port.BCF_setOpts(i_opt.pin,db);\r
+                       }\r
                        //dir設定\r
                        if(!isUndef(i_opt.dir)){\r
-                               bc+=this._gpio.BCF_setDirs(this._port_no,this._mask,i_opt.dir,db);\r
-                       }\r
-                       //i_optの展開\r
-                       if(!isUndef(i_opt.pin)){\r
-                               var optset=new Array();\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       //pinselが_PINSEL_AUTO_DETECTならばauto。そうでなければundefinedも含めて設定\r
-                                       var s=(i_opt.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[i].pin_sel:i_opt.pin.sel;\r
-                                       optset.push({sel:s,mode:i_opt.pin.mode,od:i_opt.pin.od});\r
+                               var dir_bits=0x0;\r
+                               var dir_mask=0x0;\r
+                               if(isArray(i_opt.dir)){\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               if(isUndef(i_opt.dir[i])){\r
+                                                       continue;\r
+                                               }\r
+                                               dir_mask|=(0x1<<pininfo[i].bit);\r
+                                               dir_bits|=(i_opt.dir[i]<<pininfo[i].bit);\r
+                                       }\r
+                               }else{\r
+                                       dir_bits=this._mask*i_opt.dir;\r
+                                       dir_mask=this._mask;\r
                                }\r
-                               //portの設定\r
-                               bc+=this._port.BCF_setOpts(optset,db);\r
+                               bc+=this._gpio.BCF_setDirs(this._port_no,dir_mask,dir_bits,db);\r
                        }\r
                        this._gpio._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                        return;\r
@@ -2327,12 +2369,11 @@ DEV.GpioPort.prototype=
        {\r
                try{\r
                        var v=0;\r
-                       var l=this._pins.length;\r
-                       for(var i=0;i<l;i++){\r
+                       for(var i=0;i<this._pininfo.length;i++){\r
                                //セットするbit値を得る。\r
                                var sv=((i_val>>i)&0x01);\r
                                //値のセット\r
-                               v|=(sv<<this._pins[i].bit);\r
+                               v|=(sv<<this._pininfo[i].bit);\r
                        }\r
                        //値をセット\r
                        var db=new Array();\r
@@ -2365,9 +2406,9 @@ DEV.GpioPort.prototype=
                        var retval=this._gpio._mcu.callMiMicWithCheck(bc+BCF.END,db).stream[0];\r
                        //値の再構成\r
                        var v=0;\r
-                       for(var i=this._pins.length-1;i>=0;i--){\r
+                       for(var i=this._pininfo.length-1;i>=0;i--){\r
                                //セットするbit値を得る。\r
-                               var sv=((retval>>this._pins[i].bit)&0x1);\r
+                               var sv=((retval>>this._pininfo[i].bit)&0x1);\r
                                //値のセット(pinArrayの並びとビット並びが同じになるようにする)\r
                                v=(v<<1)|sv;\r
                        }\r
@@ -2400,12 +2441,11 @@ DEV.GpioPort.prototype=
                        var bc="";\r
                        for(var i2=0;i2<i_val_array.length;i2++){\r
                                var v=0;\r
-                               var l=this._pins.length;\r
-                               for(var i=0;i<l;i++){\r
+                               for(var i=0;i<this._pininfo.length;i++){\r
                                        //セットするbit値を得る。\r
                                        var sv=((i_val_array[i2]>>i)&0x01);\r
                                        //値のセット(pinArrayの並びと最下位ビットの位置が同じになるように反転)\r
-                                       v|=(sv<<this._pins[i].bit);\r
+                                       v|=(sv<<this._pininfo[i].bit);\r
                                }\r
                                //値をセット\r
                                bc+=this._gpio.BCF_setValues(this._port_no,this._mask,v,db);\r
@@ -2452,7 +2492,7 @@ DEV.GpioPin.prototype=
 {\r
        _gport:null,\r
        /**\r
-        * ADピンにオプション値を設定する。\r
+        * GPIOピンにオプション値を設定する。\r
         * @name LPC1769.GpioPin#setOpt\r
         * @function\r
         * @param {object as associative array} i_opt\r
@@ -2559,6 +2599,7 @@ var DEV=LPC1769;
 var BCF=DEV._BCF;\r
 var EE=DEV._EE;\r
 var isUndef=MiMicLib.isUndef;\r
+var isArray=MiMicLib.isArray;\r
 var cloneAssoc=MiMicLib.cloneAssoc;\r
 \r
 \r
@@ -2572,7 +2613,7 @@ var cloneAssoc=MiMicLib.cloneAssoc;
  * @constructor\r
  * @param {object as LPC1769.Mcu} i_mcu\r
  * インスタンスを結びつけるMcuオブジェクト。\r
- * @param {aobject as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * インスタンス生成と同時にsetOpt関数でセットする値を指定する。省略時は、{freq:100,phl:{power:1,clock:0}}である。\r
  * 詳細は、setOpt関数を参照。 \r
  * @example\r
@@ -2680,7 +2721,7 @@ DEV.Pwm.prototype=
        {\r
                try{\r
                        //LERにビットをセット\r
-                       return BCF.setBit(this._LER,i_mask,i_value*i_mask,0,i_db);\r
+                       return BCF.setBit(this._LER,i_mask,i_value,0,i_db);\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -2708,7 +2749,6 @@ DEV.Pwm.prototype=
        },\r
        /**\r
         * PCRに値を設定するBC\r
-        i_ch=1の場合、エッジモードは無視します。\r
         @private\r
         @param i_mask\r
         @param i_edge\r
@@ -2743,10 +2783,10 @@ DEV.Pwm.prototype=
         * 設定する値は、全てのPWMチャンネル(PIN)に共通な項目である。\r
         * @name LPC1769.Pwm#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
+        * @param {associative array} i_opt\r
         * GPIOピンのコンフィグレーションパラメタである。必要な値を格納した連想配列で指定する。\r
         * 全ての値を省略することは出来ない。連想配列のメンバは以下の通り。\r
-        * <pre>{freq:int,phl:object as associative array}</pre>\r
+        * <pre>{freq:int,phl:associative array}</pre>\r
         * <ul>\r
         * <li>freq - PWMの基本周波数(Hz)である。この値は、全てのPWMチャンネルで共通である。</li>\r
         * <li>phl - ペリフェラルの共通パラメタである。LPC1769.Peripheral.setOpt関数のi_optに渡すパラメタである。詳細はLPC1769.Peripheral#setOptを参照。</li>\r
@@ -2776,8 +2816,8 @@ DEV.Pwm.prototype=
         * @function\r
         * @param {object as ピン識別子} i_pin\r
         * PWM機能を割り当てるPINの識別子である。\r
-        * @param {object as associative array} i_opt\r
-        * PemPinのコンストラクタに渡すオプション値。省略時は{duty:0,enable:1,pin:{sel:auto}}である\r
+        * @param {associative array} i_opt\r
+        * PwmPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.PwmPinを参照\r
         * @return {object as LPC1769.PwmPin}\r
         * LPC1769.PwmPinクラスのオブジェクトである。\r
         * @example\r
@@ -2803,8 +2843,8 @@ DEV.Pwm.prototype=
         * @function\r
         * @param {array[ピン識別子]} i_pin\r
         * Pwm機能を割り当てるPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.PwmPort#setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * PwmPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.PwmPortを参照。\r
         * @return {object as LPC1769.PwmPort}\r
         * LPC1769.PwmPortクラスのオブジェクトである。\r
         * @example\r
@@ -2827,20 +2867,23 @@ DEV.Pwm.prototype=
  * Pwm pinからPwmInfoを取得\r
  * @private\r
  */\r
-function pin2PwmPinInfo(i_pin)\r
+function makePwmPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var fn=DEV.completePinFunctionName(i_pin,"PWM");\r
-               //portとbitを得る(AD0だけしか管理しないよ)\r
-               var a=fn.substring(2).split(".");\r
-               var r={port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pin,fn)};\r
-               if(!isNaN(r.ch)){\r
-                       return r;\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var fn=DEV.completePinFunctionName(i_pins[i],"PWM");\r
+                       //portとbitを得る\r
+                       var a=fn.substring(2).split(".");\r
+                       if(isNaN(a[1])){\r
+                               throw new MiMicException(EE.INVALID_CFG);\r
+                       }\r
+                       ret.push({port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pins[i],fn)});\r
                }\r
-               throw new MiMicException(EE.INVALID_CFG,"The pin has not PWM fuction.");\r
+               return ret;\r
        }catch(e){\r
-               throw new MiMicException(e);    \r
+               throw new MiMicException(e);\r
        }\r
 }\r
 /**\r
@@ -2870,15 +2913,12 @@ DEV.PwmPort=function PwmPort(i_pwm,i_pins,i_opt)
        try{\r
                this._pwm=i_pwm;\r
                //ピンセットを取得\r
-               this._pins=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       this._pins.push(pin2PwmPinInfo(i_pins[i]));\r
-               }\r
+               var pininfo=makePwmPinInfoArray(i_pins);\r
+\r
                //pinが全て同じポートに所属しているか確認\r
-               var p=this._pins[0].port;\r
-               for(var i=1;i<this._pins.length;i++){\r
-                       if(p!=this._pins[i].port){\r
+               var p=pininfo[0].port;\r
+               for(var i=1;i<pininfo.length;i++){\r
+                       if(p!=pininfo[i].port){\r
                                throw new MiMicException("Invalid pin combination.");\r
                        }\r
                }\r
@@ -2886,22 +2926,25 @@ DEV.PwmPort=function PwmPort(i_pwm,i_pins,i_opt)
                this._port=new DEV.Port(i_pwm._mcu,i_pins);\r
                this._port_no=p;\r
                \r
-               this._ler_mask=0;\r
-               this._pcr_mask=0;\r
-               for(var i=0;i<this._pins.length;i++){\r
-                       this._ler_mask|=(0x1<<this._pins[i].ch);\r
-                       this._pcr_mask|=(0x101<<this._pins[i].ch);\r
-               }               \r
-               var opt=isUndef(i_opt)?{pin:{}}:\r
-               {\r
-                       pin:isUndef(i_opt.pin)?{}:cloneAssoc(i_opt.pin),\r
-                       duty:i_opt.duty,\r
-                       enable:i_opt.enable\r
+\r
+               //ピンオプションの生成\r
+               var opt={};\r
+               if(isUndef(i_opt)){\r
+                       opt.pin=this._port.clonePinOptAssoc({});\r
+                       opt.duty=0;\r
+                       opt.enable=1;\r
+               }else{\r
+                       opt.pin=this._port.clonePinOptAssoc(isUndef(i_opt.pin)?{}:i_opt.pin);\r
+                       opt.duty=isUndef(i_opt.duty)?0:i_opt.duty;\r
+                       opt.enable=isUndef(i_opt.enable)?0:i_opt.enable;\r
                };\r
-               //デフォルト値のロード\r
-               if(isUndef(opt.pin.sel)){opt.pin.sel=this._PINSEL_AUTO_DETECT;}\r
-               if(isUndef(opt.duty)){opt.duty=0;}\r
-               if(isUndef(opt.enable)){opt.enable=1;}\r
+               //pinselの自動設定\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       if(isUndef(opt.pin[i].sel)){\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
+                       }\r
+               }\r
+               this._pininfo=pininfo;\r
                this.setOpt(opt);\r
        }catch(e){\r
                throw new MiMicException(e);\r
@@ -2909,21 +2952,24 @@ DEV.PwmPort=function PwmPort(i_pwm,i_pins,i_opt)
 }\r
 DEV.PwmPort.prototype=\r
 {\r
-       _PINSEL_AUTO_DETECT:0x0fffffff,\r
        _pwm:null,\r
-       _pins:null,\r
+       _pininfo:null,\r
        _port_no:0,\r
        _port:null,\r
-       _pcr_mask:0,\r
-       _ler_mask:0,\r
        /**\r
         * PWMポートにオプション値を設定する。\r
-        * 関数は、ポートを構成する全てのピンに、同じ値を設定する。\r
         * 設定可能な値は、LPC1769.PwmPin#setOptと同じである。    \r
         * @name LPC1769.PwmPort#setOpt\r
         * @function\r
         * @param {object as associative array} i_opt\r
-        * LPC1769.PwmPin#setOptを参照。\r
+        * PWMピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
+        * 全てのピンに同じパラメータを指定する場合は、連装配列で指定する。個別に設定する場合は、連装配列を配列にして指定する。\r
+        * <pre>{i_opt:associative array}</pre>\r
+        * <ul>\r
+        * <li>pin(option) - array[{PIN_OPTION}] | {PIN_OPTION}</li>\r
+        * <li>enable(option) - array[{1bit int}] | {1bit int}</li>\r
+        * <li>duty(option) - array[{1bit int}] | {1bit int}</li>\r
+        * </ul>\r
         * @example\r
         * var mcu=new LPC1769.Mcu("192.168.128.39",true);\r
         * var pwm=mcu.getPeripheral("PWM",{freq:100});\r
@@ -2933,32 +2979,53 @@ DEV.PwmPort.prototype=
        setOpt:function setOpt(i_opt)\r
        {\r
                try{\r
+                       var pininfo=this._pininfo;\r
                        var db=new Array();\r
                        //BCの生成\r
                        var bc="";\r
-                       //i_optの展開\r
+                       //pinの設定\r
                        if(!isUndef(i_opt.pin)){\r
-                               var optset=new Array();\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       //pinselが_PINSEL_AUTO_DETECTならばauto。そうでなければundefinedも含めて設定\r
-                                       var s=(i_opt.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[i].pin_sel:i_opt.pin.sel;\r
-                                       optset.push({sel:s,mode:i_opt.pin.mode,od:i_opt.pin.od});\r
-                               }\r
-                               //portの設定\r
-                               bc+=this._port.BCF_setOpts(optset,db);\r
+                               bc+=this._port.BCF_setOpts(i_opt.pin,db);\r
                        }\r
-                       //PCRに値設定\r
+                       //enable設定\r
                        if(!isUndef(i_opt.enable)){\r
-                               bc+=this._pwm.BCF_setPCRbits(this._pcr_mask,0,i_opt.enable,db);\r
+                               var pcr_mask=0x0;\r
+                               var enable_bits=0x0;\r
+                               if(isArray(i_opt.enable)){\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               if(isUndef(i_opt.enable[i])){\r
+                                                       continue;\r
+                                               }\r
+                                               enable_bits|=((0x101*i_opt.enable[i])<<pininfo[i].ch);\r
+                                               pcr_mask|=(0x101<<pininfo[i].ch);\r
+                                       }\r
+                               }else{\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               pcr_mask|=(0x101<<pininfo[i].ch);\r
+                                       }\r
+                                       enable_bits=pcr_mask*i_opt.enable;\r
+                               }\r
+                               //edgeは固定でゼロ、enableはビット配列。\r
+                               bc+=this._pwm.BCF_setPCRbits(pcr_mask,0,enable_bits,db);\r
                        }\r
-                       //デューティ比を\r
+                       //dutyの設定\r
                        if(!isUndef(i_opt.duty)){\r
-                               //デューティ比を設定\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       bc+=this._pwm.BCF_setMRnByDuty(this._pins[i].ch,i_opt.duty,db);\r
+                               var ler_value=0;\r
+                               if(isArray(i_opt.duty)){\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               if(isUndef(i_opt.duty[i])){\r
+                                                       continue;\r
+                                               }\r
+                                               bc+=this._pwm.BCF_setMRnByDuty(pininfo[i].ch,i_opt.duty[i],db);\r
+                                               ler_value|=(0x1<<pininfo[i].ch);\r
+                                       }\r
+                               }else{\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               bc+=this._pwm.BCF_setMRnByDuty(pininfo[i].ch,i_opt.duty,db);\r
+                                               ler_value|=(0x1<<pininfo[i].ch);\r
+                                       }\r
                                }\r
-                               //LERにセット\r
-                               bc+=this._pwm.BCF_setLERs(this._ler_mask,1,db);\r
+                               bc+=this._pwm.BCF_setLERs(ler_value,ler_value,db);\r
                        }\r
                        this._pwm._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                        return;\r
@@ -2967,12 +3034,13 @@ DEV.PwmPort.prototype=
                }\r
        },\r
        /**\r
-        * PWMポートのデューティ比をまとめて変更する。\r
+        * PWMポートのデューティ比を変更する。\r
+        * この関数は、LPC1769.PwmPort#setOpt関数へのショートカットである。\r
         * @name LPC1769.PwmPort#setDutys\r
         * @function\r
         * @param {array[double]} i_duty_array\r
         * デューティ比の配列である。0.0<=n<=1.0のdouble値を指定する。\r
-        * ã\83\9dã\83¼ã\83\88ã\82\92æ§\8bæ\88\90ã\81\99ã\82\8bã\83\94ã\83³ã\81®æ\95°ã\81 ã\81\91æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å¤\89æ\9b´ã\81\97ã\81ªã\81\84ã\83\94ã\83³ã\81«ã\81¯ã\80\81undefinedã\82\92æ\8c\87å®\9aã\81\99ã\82\8bã\81\93ã\81¨\r
+        * ã\83\9dã\83¼ã\83\88ã\82\92æ§\8bæ\88\90ã\81\99ã\82\8bã\83\94ã\83³ã\81®æ\95°ã\81 ã\81\91æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å¤\89æ\9b´ã\81\97ã\81ªã\81\84ã\83\94ã\83³ã\81«ã\81¯ã\80\81undefinedã\82\92æ\8c\87å®\9aã\81§ã\81\8dã\82\8b\r
         * @example\r
         * varmcu=new LPC1769.Mcu("192.168.128.39",true);\r
         * var pwm=mcu.getPeripheral("PWM",{freq:100});\r
@@ -2983,20 +3051,7 @@ DEV.PwmPort.prototype=
        setDutys:function setDutys(i_duty_array)\r
        {\r
                try{\r
-                       if(i_duty_array.length!=this._pins.length){\r
-                               throw new MiMicException();\r
-                       }\r
-                       var bc="";\r
-                       var db=new Array();\r
-                       //デューティ比をまとめてセット\r
-                       for(var i=0;i<this._pins.length;i++){\r
-                               if(!isUndef(i_duty_array[i])){\r
-                                       bc+=this._pwm.BCF_setMRnByDuty(this._pins[i].ch,i_duty_array[i],db);\r
-                               }\r
-                       }\r
-                       //LERにセット\r
-                       bc+=this._pwm.BCF_setLERs(this._ler_mask,1,db);\r
-                       this._pwm._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
+                       this.setOpt({duty:i_duty_array});\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -3013,9 +3068,9 @@ DEV.PwmPort.prototype=
  * インスタンスを結びつけるAdcオブジェクト。\r
  * @param {object as pin識別子} i_pin\r
  * ピン識別子。指定できるのは、LPC1769.P?[?]である。\r
- * @param {object as associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{duty:100,enable:1,pin{sel:auto}}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * @param {associative array} i_opt\r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{duty:100,enable:1,pin{sel:undefined}}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create PWM1.0\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -3353,15 +3408,15 @@ DEV.Dac.prototype=
        },      \r
        /**\r
         * DA機能を持つピンを取得する。\r
-        * ピン識別子で指定されるピンをDAペリフェラルと結合して、DaPinを生成する。\r
-        * 関数は、DacPinオブジェクトのコンストラクタをコールして、DaPinを生成する。失敗すると、例外をスローする。\r
+        * ピン識別子で指定されるピンをDAペリフェラルと結合して、DacPinを生成する。\r
+        * 関数は、DacPinオブジェクトのコンストラクタをコールして、DacPinを生成する。失敗すると、例外をスローする。\r
         * 生成ルールについての詳細は、DacPinを参照。\r
         * @name LPC1769.Dac#getPin\r
         * @function\r
         * @param {object as ピン識別子} i_pin\r
-        * Da機能を割り当てるPINの識別子である。値は、LPC1769.Pn[m]のメンバ変数である。\r
+        * Dac機能を割り当てるPINの識別子である。値は、LPC1769.Pn[m]のメンバ変数である。\r
         * @param {associative array} i_opt\r
-        * AdcPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.DacPin.setOptを参照。\r
+        * DacPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.DacPinを参照。\r
         * @return {object as LPC1769.AdcPin}\r
         * LPC1769.DacPinクラスのオブジェクトである。\r
         * @example\r
@@ -3389,7 +3444,7 @@ DEV.Dac.prototype=
         * @param {array[ピン識別子]} i_pin\r
         * AD機能を割り当てるPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
         * @param {associative array} i_opt\r
-        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.DacPort.setOptを参照。\r
+        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.DacPortを参照。\r
         * @return {object as LPC1769.DacPort}\r
         * LPC1769.DacPortクラスのオブジェクトである。\r
         * @example\r
@@ -3435,16 +3490,20 @@ DEV.Dac.prototype=
  * DA pinからDAInfoを取得\r
  * @private\r
  */\r
-function pin2DacPinInfo(i_pin)\r
+function makeDacPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var func_name=DEV.completePinFunctionName(i_pin,"AOUT");\r
-               //portとbitを得る(AD0だけしか管理しないよ)\r
-               return {\r
-                       port:0,\r
-                       pin_sel:DEV.getPinSelByFunctionName(i_pin,func_name)\r
-               };//DAPinは1ピンのみなので、特に識別パラメータはない。\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var func_name=DEV.completePinFunctionName(i_pins[i],"AOUT");\r
+                       //portとbitを得る(AD0だけしか管理しないよ)\r
+                       ret.push({\r
+                               port:0,\r
+                               pin_sel:DEV.getPinSelByFunctionName(i_pins[i],func_name)\r
+                       });\r
+               };\r
+               return ret;\r
        }catch(e){\r
                throw new MiMicException(e);    \r
        }\r
@@ -3461,8 +3520,8 @@ function pin2DacPinInfo(i_pin)
  * @param {array[pin識別子]} i_pins\r
  * ピン識別子の配列。指定できるのは、LPC1769.P?[?]である。順番は、このインスタンスの返す値の順序に影響する。\r
  * @param {associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略時は{pin:{sel:%AUTO%},bias:0}を設定する。\r
- * 詳細はsetOpt関数を参照。 %AUTO%は関数がPin情報から自動的に決定する。(指定は出来ない。)\r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined},bias:0}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create [AOUT]\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -3473,12 +3532,8 @@ DEV.DacPort=function DacPort(i_adc,i_pins,i_opt)
 {\r
        try{\r
                this._dac=i_adc;\r
-               //ピンセットを取得\r
-               var pininf=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       pininf.push(pin2DacPinInfo(i_pins[i]));\r
-               }\r
+               //Pin情報配列を生成\r
+               var pininfo=makeDacPinInfoArray(i_pins);\r
                //ポートの生成\r
                this._port=new DEV.Port(i_adc._mcu,i_pins);\r
                //ピンオプションの生成\r
@@ -3491,9 +3546,9 @@ DEV.DacPort=function DacPort(i_adc,i_pins,i_opt)
                        opt.bias=isUndef(i_opt.bias)?0:i_opt.bias;\r
                };\r
                //pinselの自動設定\r
-               for(var i=0;i<this._port.pins.length;i++){\r
+               for(var i=0;i<pininfo.length;i++){\r
                        if(isUndef(opt.pin[i].sel)){\r
-                               opt.pin[i].sel=pininf[i].pin_sel;\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
                        }\r
                }\r
                //ピンオプションの設定\r
@@ -3508,24 +3563,23 @@ DEV.DacPort.prototype=
        _port:null,\r
        /**\r
         * ポートにオプション値を設定する。\r
-        * 関数は、ポートを構成する全てのピンに、同一なオプション値を設定する。\r
         * 設定可能な値は、LPC1769.DacPin#setOptと同じである。\r
         * @name LPC1769.DacPort#setOpt\r
         * @function\r
-        * @param {associative array| array[associative array]} i_opt\r
-        * DAã\83\94ã\83³ã\81®ã\82³ã\83³ã\83\95ã\82£ã\82°ã\83¬ã\83¼ã\82·ã\83§ã\83³ã\83\91ã\83©ã\83¡ã\82¿ã\81§ã\81\82ã\82\8bã\80\82å¿\85è¦\81ã\81ªå\80¤ã\82\92æ ¼ç´\8dã\81\97ã\81\9fé\80£æ\83³é\85\8då\88\97ã\81§指定する。\r
-        * å\85¨ã\81¦ã\81®ã\83\94ã\83³ã\81«å\90\8cã\81\98ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\82\92æ\8c\87å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\81§æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å\80\8bå\88¥ã\81«è¨­å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\81«é\85\8då\88\97ã\82\92å\85¥ã\82\8cå­\90ã\81§指定する。\r
+        * @param {associative array | array[associative array]} i_opt\r
+        * DAã\83\94ã\83³ã\81®ã\82³ã\83³ã\83\95ã\82£ã\82°ã\83¬ã\83¼ã\82·ã\83§ã\83³ã\83\91ã\83©ã\83¡ã\82¿ã\81§ã\81\82ã\82\8bã\80\82å¿\85è¦\81ã\81ªå\80¤ã\82\92æ ¼ç´\8dã\81\97ã\81\9fé\80£æ\83³é\85\8då\88\97ã\80\81ã\81¾ã\81\9fã\81¯ã\81\9dã\81®é\85\8då\88\97ã\82\92指定する。\r
+        * å\85¨ã\81¦ã\81®ã\83\94ã\83³ã\81«å\90\8cã\81\98ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\82\92æ\8c\87å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\81§æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å\80\8bå\88¥ã\81«è¨­å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\82\92é\85\8då\88\97ã\81«ã\81\97ã\81¦指定する。\r
         * <pre>{i_opt:associative array}</pre>\r
         * <ul>\r
         * <li>pin(option)</li>\r
         * <li>bias(option)</li>\r
         * </ul>\r
-        * パラメータの詳細は、DacPin#setOptを参照。\r
+        * パラメータの詳細は、LPC1769.DacPin#setOptを参照。\r
         * @example\r
         * //ポートを構成する全てのピンに同じパラメータを設定する場合\r
-        * setOpt(pin:v1,bias:v1);\r
+        * setOpt({pin:{v1},bias:v1});\r
         * //ポートを構成するピンに個々にパラメータを設定する場合\r
-        * setOpt(pin:[{v1},{v2}],bias:[v1,v2...]);\r
+        * setOpt({pin:[{v1},{v2}],bias:[v1,v2...]});\r
         */     \r
        setOpt:function setOpt(i_opt)\r
        {\r
@@ -3593,8 +3647,8 @@ DEV.DacPort.prototype=
  * @param {object as pin識別子} i_pin\r
  * ピン識別子。指定できるのは、LPCXpresso1796.P?[?]である。\r
  * @param {associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto},bias:0}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined},bias:0}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create AOUT\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -3614,16 +3668,16 @@ DEV.DacPin.prototype=
 {\r
        _port:null,\r
        /**\r
-        * æ\95°å\80¤ã\82\92DAå¤\89æ\8f\9bã\81\97ã\81¦ã\83\94ã\83³ã\81«å\87ºå\8a\9bã\81\97ã\81¾ã\81\99\r
+        * æ\95°å\80¤ã\82\92DAå¤\89æ\8f\9bã\81\97ã\81¦ã\83\94ã\83³ã\81«å\87ºå\8a\9bã\81\99ã\82\8b\r
         * @name LPC1769.DacPin#setValue\r
         * @function\r
         * @return {int}\r
-        * 10bitã\81®ADå¤\89æ\8f\9bå\80¤ã\82\92è¿\94ã\81\99ã\80\82å\80¤ã\81®æ\84\8få\91³ã\81¯ã\80\81UM10360 Chapter 30: LPC17xx Digital-to-Analog Converter (DAC)ã\82\92å\8f\82ç\85§ã\80\82\r
+        * 10bitのAD変換値。値の意味は、UM10360 Chapter 30: LPC17xx Digital-to-Analog Converter (DAC)を参照。\r
         * @example\r
         * //set value of DA0 pin\r
         * var mcu=new LPC1769.Mcu("192.168.0.39");\r
         * var pin=mcu.getPin("AOUT");\r
-        * pin.setValue(3939);\r
+        * pin.setValue(100);\r
         */\r
        setValue:function setValue(i_value)\r
        {\r
index 324f06f..b300dbd 100644 (file)
@@ -1 +1 @@
-var LPC1769;(function(){var g=MiMicLib.isUndef;var a={_EE:function(n){return{NG:[n|0,"Unknown exception in LPC1769"],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.")};LPC1769=a}());(function(){var f=LPC1769;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",PWM:"PWM"};for(var s in t){if(v==s){return t[s]}}throw new MiMicException("Peripheral for "+v+" 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;case"DAC":new f.Dac(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=LPC1769;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=LPC1769;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=LPC1769;var j=a._BCF;var k=a._EE;var c=MiMicLib.isUndef;var d=MiMicLib.cloneAssoc;var e=MiMicLib.isArray;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 g(m,n,l){try{this._mcu=m;this.pins=new Array();for(var o=0;o<n.length;o++){this.pins.push({pin:n[o],reginfo:a.getPinRegInfo(n[o])})}if(!c(l)){this.setOpts(l)}}catch(p){throw new MiMicException(p)}};a.Port.prototype={_mcu:null,pins:null,BCF_setOpts:function b(t,n){try{var s={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]};var l=e(t)?t:this.clonePinOptAssoc(t);for(var o=0;o<this.pins.length;o++){var p=this.pins[o].reginfo;var m=l[o];if(!c(m.sel)){s.selr[p.s]|=(m.sel<<p.smb);s.selr_mask[p.s]|=(3<<p.smb)}if(!c(m.mode)){s.modr[p.m]|=(m.mode<<p.smb);s.modr_mask[p.m]|=(3<<p.smb)}if(!c(m.od)){s.odr[p.o]|=(m.od<<p.ob);s.odr_mask[p.o]|=(1<<p.ob)}}var r="";for(var o=0;o<10;o++){if(s.selr_mask[o]!=0){r+=j.setBit(h._PINSEL[o],s.selr_mask[o],s.selr[o],0,n)}if(s.modr_mask[o]!=0){r+=j.setBit(h._PINMODE[o],s.modr_mask[o],s.modr[o],0,n)}}for(var o=0;o<5;o++){if(s.odr_mask[o]!=0){r+=j.setBit(h._PINMODE_OD[o],s.odr_mask[o],s.odr[o],0,n)}}return r}catch(q){throw new MiMicException(q)}},setOpts:function f(l){try{var m=new Array();var o=this.BCF_setOpts(l,m);if(o.length>0){this._mcu.callMiMicWithCheck(o+j.END,m)}}catch(n){throw new MiMicException(n)}return},clonePinOptAssoc:function i(l){var m=new Array();if(e(l)){if(l.length!=this.pins.length){throw new MiMicException()}for(var n=0;n<this.pins.length;n++){m.push(d(l[n]))}}else{for(var n=0;n<this.pins.length;n++){m.push(d(l))}}return m}}}());(function(){var f=LPC1769;var d=f._BCF;var b=f._EE;var c=MiMicLib.isUndef;f.Pin=function e(g,h,j){try{if(c(h)){throw new MiMicException(b.INVALID_PIN)}this._port=new f.Port(g,[h],c(j)?undefined:[j])}catch(i){throw new MiMicException(i)}};f.Pin.prototype={_port:null,setOpt:function a(h){try{this._port.setOpts([h])}catch(g){throw new MiMicException(g)}return}}}());(function(){var a=LPC1769;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={_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[u].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=d(x)?{}:k(x);t.sel=1;t.pin=d(t.pin)?{}:k(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)}if(!d(y.sel)){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=LPC1769;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[u].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);t.pin=f(t.pin)?{}:m(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=LPC1769;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(y,u){try{var x="";var v;if(!d(y.phl)){x+=this._phl.BCF_setOpt(y.phl,u)}if(!d(y.freq)){v=Math.round(this._phl.getPCLK()/y.freq);if(v<=0){throw new MiMicException("The peripheral clock too small.")}x+=this.BCF_setMRn(0,v,u);x+=this.BCF_setLER(0,u);this._cache.mr0=v}return x}catch(w){throw new MiMicException(w)}},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[x].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()}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.setDutys([u])}catch(v){throw new MiMicException(v)}}}}());(function(){var f=LPC1769;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,p,o){var n="";var q=new Array();if(!d(p)){for(var l=0;l<8;l++){var k="wm"+l;if(!d(p[k])){n+="FB"+MiMicLib.hexout(l,2)+MiMicLib.hexout(p[k],8)}}if(!d(p.stream)){for(var l=0;l<p.stream.length;l++){q.push(p.stream[l])}}}n+="ZF"+MiMicLib.hexout(j,8);var g=0;if(!d(o)){for(var l=0;l<8;l++){if(!d(o["wm"+l])){n+="EE"+MiMicLib.hexout(l,2);g++}}}var m=this._mcu.callMiMic(n+e.END,q);if(m.result!=0){return false}if(!d(o)){var h=m.stream.length-g;for(var l=0;l<8;l++){var k="wm"+l;if(!d(o[k])){o[k]=m.stream[h];h++}}if(!d(o.stream)){o.stream=m.stream.slice(0,m.stream.length-g)}}return false}}}());(function(){var g=LPC1769;var n=g._BCF;var a=g._EE;var f=MiMicLib.isUndef;var h=MiMicLib.isArray;var k=MiMicLib.cloneAssoc;g.Dac=function i(s,x){try{this._mcu=s;this._phl=new g.Peripheral(s,g.PHL.DAC);var u=f(x)?{phl:{}}:{phl:f(x.phl)?{}:k(x.phl),};if(f(u.phl.clock)){u.phl.clock=0}var w="";var t=new Array();w+=this.BCF_setOpt(u,t);this._mcu.callMiMicWithCheck(w+n.END,t);this._mcu.registerPhl(this,"DAC")}catch(v){throw new MiMicException(v)}};g.Dac.prototype={_DACR:1074315264,_DACCTRL:1074315268,_DACCNTVAL:1074315272,_phl:null,_mcu:null,BCF_setOpt:function j(v,s){try{var u="";if(!f(v.phl)){u+=this._phl.BCF_setOpt(v.phl,s)}return u}catch(t){throw new MiMicException(t)}},setOpt:function c(v){try{var s=new Array();var u=this.BCF_setOpt(v,s);this._mcu.callMiMicWithCheck(u+n.END,s)}catch(t){throw new MiMicException(t)}},getPin:function o(s,u){try{return new g.DacPin(this,s,u)}catch(t){throw new MiMicException(t)}},getPort:function r(s,u){try{return new g.DacPort(this,s,u)}catch(t){throw new MiMicException(t)}},BCF_setBias:function b(u,t,s){try{return n.setBit(this._DACR,u,t*u,0,s)}catch(v){throw new MiMicException(v)}},BCF_setValue:function l(t,s){return n.setBit(this._DACR,1023,t,6,s)}};function p(t){try{var s=g.completePinFunctionName(t,"AOUT");return{port:0,pin_sel:g.getPinSelByFunctionName(t,s)}}catch(u){throw new MiMicException(u)}}g.DacPort=function e(t,s,y){try{this._dac=t;var x=new Array();for(var v=0;v<s.length;v++){x.push(p(s[v]))}this._port=new g.Port(t._mcu,s);var u={};if(f(y)){u.pin=this._port.clonePinOptAssoc({});u.bias=0}else{u.pin=this._port.clonePinOptAssoc(f(y.pin)?{}:y.pin);u.bias=f(y.bias)?0:y.bias}for(var v=0;v<this._port.pins.length;v++){if(f(u.pin[v].sel)){u.pin[v].sel=x[v].pin_sel}}this.setOpt(u)}catch(w){throw new MiMicException(w)}};g.DacPort.prototype={_dac:null,_port:null,setOpt:function c(v){try{var s=new Array();var u="";if(!f(v.pin)){u+=this._port.BCF_setOpts(v.pin,s)}if(!f(v.bias)){if(h(v.pin)){u+=this._dac.BCF_setBias(65536,v.bias[0],s)}else{u+=this._dac.BCF_setBias(65536,v.bias,s)}}this._dac._mcu.callMiMicWithCheck(u+n.END,s);return}catch(t){throw new MiMicException(t)}},setValues:function m(s){try{var t=new Array();var w="";for(var u=0;u<this._port.pins.length;u++){w+=this._dac.BCF_setValue(s[u],t)}this._dac._mcu.callMiMicWithCheck(w+n.END,t);return}catch(v){throw new MiMicException(v)}}};g.DacPin=function q(s,t,v){try{this._port=new g.DacPort(s,[t],v)}catch(u){throw new MiMicException(u)}};g.DacPin.prototype={_port:null,setValue:function d(s){try{this._port.setValues([s])}catch(t){throw new MiMicException(t)}},setOpt:function c(t){try{this._port.setOpt(t)}catch(s){throw new MiMicException(s)}}}}());var MbedM3;(function(){var a=MiMicLib.isUndef;var b=LPC1769;MbedM3=MiMicLib.cloneAssoc(b);if(!a(MbedM3.PINNAME)){alert("invalid override[PINNAME]")}MbedM3.PINNAME={SPI1MOSI:b.P0[9],SPI1MISO:b.P0[8],SPI1SCK:b.P0[7],GPIO:b.P0[6],UART1TX:b.P0[0],I2C1SDA:b.P0[0],UART1RX:b.P0[1],I2C1SCL:b.P0[1],SPI2MODI:b.P0[18],SPI2MISO:b.P0[17],SPI2SCK:b.P0[15],UART2TX:b.P0[15],SPI2SCL:b.P0[15],UART2RX:b.P0[16],AIN0:b.P0[23],AIN1:b.P0[24],AIN2:b.P0[25],AIN3:b.P0[26],AOUT:b.P0[26],AIN4:b.P0[30],AIN5:b.P0[31],USBDP:b.P0[29],USBDM:b.P0[30],CANRD:b.P0[4],CANTD:b.P0[5],UART3TX:b.P0[10],I2C2SDA:b.P0[10],UART3RX:b.P0[11],I2C2SCL:b.P0[10],PWMOUT0:b.P2[0],PWMOUT1:b.P2[1],PWMOUT2:b.P2[2],PWMOUT3:b.P2[3],PWMOUT4:b.P2[4],PWMOUT5:b.P2[5],};if(!a(MbedM3.PIN)){alert("invalid override[PIN]")}MbedM3.PIN=[null,null,null,null,null,b.P0[9],b.P0[8],b.P0[7],b.P0[6],b.P0[0],b.P0[1],b.P0[18],b.P0[17],b.P0[15],b.P0[16],b.P0[23],b.P0[24],b.P0[25],b.P0[26],b.P1[30],b.P1[31],b.P2[5],b.P2[4],b.P2[3],b.P2[2],b.P2[1],b.P2[0],b.P0[11],b.P0[10],b.P0[5],b.P0[4]];if(!a(MbedM3.LED)){alert("invalid override[LED]")}MbedM3.LED=[b.P1[18],b.P1[20],b.P1[21],b.P1[23]]}());
\ No newline at end of file
+var LPC1769;(function(){var g=MiMicLib.isUndef;var a={_EE:function(n){return{NG:[n|0,"Unknown exception in LPC1769"],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.")};LPC1769=a}());(function(){var f=LPC1769;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",PWM:"PWM"};for(var s in t){if(v==s){return t[s]}}throw new MiMicException("Peripheral for "+v+" 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;case"DAC":new f.Dac(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=LPC1769;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 r=true;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);r=false}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 r?m:m[0]}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=LPC1769;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=LPC1769;var j=a._BCF;var k=a._EE;var c=MiMicLib.isUndef;var d=MiMicLib.cloneAssoc;var e=MiMicLib.isArray;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 g(m,n,l){try{this._mcu=m;this.pins=new Array();for(var o=0;o<n.length;o++){this.pins.push({pin:n[o],reginfo:a.getPinRegInfo(n[o])})}if(!c(l)){this.setOpts(l)}}catch(p){throw new MiMicException(p)}};a.Port.prototype={_mcu:null,pins:null,BCF_setOpts:function b(t,n){try{var s={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]};var l=e(t)?t:this.clonePinOptAssoc(t);for(var o=0;o<this.pins.length;o++){var p=this.pins[o].reginfo;var m=l[o];if(!c(m.sel)){s.selr[p.s]|=(m.sel<<p.smb);s.selr_mask[p.s]|=(3<<p.smb)}if(!c(m.mode)){s.modr[p.m]|=(m.mode<<p.smb);s.modr_mask[p.m]|=(3<<p.smb)}if(!c(m.od)){s.odr[p.o]|=(m.od<<p.ob);s.odr_mask[p.o]|=(1<<p.ob)}}var r="";for(var o=0;o<10;o++){if(s.selr_mask[o]!=0){r+=j.setBit(h._PINSEL[o],s.selr_mask[o],s.selr[o],0,n)}if(s.modr_mask[o]!=0){r+=j.setBit(h._PINMODE[o],s.modr_mask[o],s.modr[o],0,n)}}for(var o=0;o<5;o++){if(s.odr_mask[o]!=0){r+=j.setBit(h._PINMODE_OD[o],s.odr_mask[o],s.odr[o],0,n)}}return r}catch(q){throw new MiMicException(q)}},setOpts:function f(l){try{var m=new Array();var o=this.BCF_setOpts(l,m);if(o.length>0){this._mcu.callMiMicWithCheck(o+j.END,m)}}catch(n){throw new MiMicException(n)}return},clonePinOptAssoc:function i(l){var m=new Array();if(e(l)){if(l.length!=this.pins.length){throw new MiMicException()}for(var n=0;n<this.pins.length;n++){m.push(d(l[n]))}}else{for(var n=0;n<this.pins.length;n++){m.push(d(l))}}return m}}}());(function(){var f=LPC1769;var d=f._BCF;var b=f._EE;var c=MiMicLib.isUndef;f.Pin=function e(g,h,j){try{if(c(h)){throw new MiMicException(b.INVALID_PIN)}this._port=new f.Port(g,[h],c(j)?undefined:[j])}catch(i){throw new MiMicException(i)}};f.Pin.prototype={_port:null,setOpt:function a(h){try{this._port.setOpts([h])}catch(g){throw new MiMicException(g)}return}}}());(function(){var a=LPC1769;var p=a._BCF;var q=a._EE;var d=MiMicLib.isUndef;var j=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)?{}:j(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={_AD0CR:1073954816,_AD0DR:[1073954832,1073954836,1073954840,1073954844,1073954848,1073954852,1073954856,1073954860],_phl:null,_mcu:null,BCF_setOpt:function l(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 i(t,s,r){try{return p.setBit(this._AD0CR,t,s*t,0,r)}catch(u){throw new MiMicException(u)}},BCF_getAD0DR:function k(s,r){try{return p.getMem(this._AD0DR[s],r)}catch(t){throw new MiMicException(t)}},setOpt:function g(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 m(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 n(t){try{var u=new Array();for(var v=0;v<t.length;v++){var s=a.completePinFunctionName(t[v],"AD");var r=s.substring(2).split(".");if(isNaN(r[1])){throw new MiMicException(q.INVALID_CFG)}u.push({port:0,ch:parseInt(r[1]),pin_sel:a.getPinSelByFunctionName(t[v],s)})}return u}catch(w){throw new MiMicException(w)}}a.AdcPort=function o(t,s,y){try{this._adc=t;var r=n(s);var x=r[0].port;for(var v=1;v<r.length;v++){if(x!=r[v].port){throw new MiMicException("Invalid pin combination.")}}this._port=new a.Port(t._mcu,s);this._port_no=x;this._adcr_mask=0;for(var v=0;v<r.length;v++){this._adcr_mask|=(1<<r[v].ch)}var u={};if(d(y)){u.pin=this._port.clonePinOptAssoc({});u.sel=1}else{u.pin=this._port.clonePinOptAssoc(d(y.pin)?{}:y.pin);u.sel=1}for(var v=0;v<r.length;v++){if(d(u.pin[v].sel)){u.pin[v].sel=r[v].pin_sel}}this._pininfo=r;this.setOpt(u)}catch(w){throw new MiMicException(w)}};a.AdcPort.prototype={_adc:null,_pininfo:null,_port_no:0,_port:null,_adcr_mask:0,setOpt:function g(u){try{var r=new Array();var t="";if(!d(u.pin)){t+=this._port.BCF_setOpts(u.pin,r)}if(!d(u.sel)){t+=this._adc.BCF_setSels(this._adcr_mask,u.sel,r)}this._adc._mcu.callMiMicWithCheck(t+p.END,r);return}catch(s){throw new MiMicException(s)}},getValues:function h(){try{var s=new Array();var x="";for(var u=0;u<this._port.pins.length;u++){x+=this._adc.BCF_getAD0DR(this._pininfo[u].ch,s)}var t=this._adc._mcu.callMiMicWithCheck(x+p.END,s);var v=new Array();for(var u=0;u<this._port.pins.length;u++){v.push((t.stream[u]>>4)&4095)}return v}catch(w){throw new MiMicException(w)}}};a.AdcPin=function e(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 f(){try{return this._aport.getValues()[0]}catch(r){throw new MiMicException(r)}},setOpt:function g(s){try{this._aport.setOpt(s)}catch(r){throw new MiMicException(r)}}}}());(function(){var g=LPC1769;var p=g._BCF;var a=g._EE;var f=MiMicLib.isUndef;var n=MiMicLib.cloneAssoc;var j=MiMicLib.isArray;g.Gpio=function r(t,v){try{this._mcu=t;t.registerPhl(this,"GPIO")}catch(u){throw new MiMicException(u)}};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 l(u,v,t){try{t.push(this._FIO_PIN[u],this._FIO_MASK[u],~v);return"EA00EA01EA02DF0201DB0300EE03"}catch(w){throw new MiMicException(w)}},BCF_setValues:function h(v,w,u,t){try{t.push(this._FIO_PIN[v],this._FIO_MASK[v],~w,u);return"EA00EA01EA02EA03DF0201DF0300"}catch(x){throw new MiMicException(x)}},BCF_setDirs:function e(u,v,w,t){try{return p.setBit(this._FIO_DIR[u],v,w,0,t)}catch(x){throw new MiMicException(x)}},getPin:function q(t,v){try{return new g.GpioPin(this,t,v)}catch(u){throw new MiMicException(u)}},getPort:function s(t,v){try{return new g.GpioPort(this,t,v)}catch(u){throw new MiMicException(u)}}};function k(u){try{var v=new Array();for(var w=0;w<u.length;w++){var x=g.completePinFunctionName(u[w],"GPIO");var t=x.substring(4).split(".");if(isNaN(t[0])||isNaN(t[1])){throw new MiMicException(a.INVALID_CFG)}v.push({port:parseInt(t[0]),bit:parseInt(t[1]),pin_sel:g.getPinSelByFunctionName(u[w],x)})}return v}catch(y){throw new MiMicException(y)}}g.GpioPort=function o(x,u,A){try{this._gpio=x;var t=k(u);var z=t[0].port;for(var w=1;w<t.length;w++){if(z!=t[w].port){throw new MiMicException("Invalid pin combination.")}}this._port=new g.Port(x._mcu,u);this._port_no=z;this._mask=0;for(var w=0;w<t.length;w++){this._mask|=(1<<t[w].bit)}var v={};if(f(A)){v.pin=this._port.clonePinOptAssoc({})}else{v.pin=this._port.clonePinOptAssoc(f(A.pin)?{}:A.pin)}for(var w=0;w<t.length;w++){if(f(v.pin[w].sel)){v.pin[w].sel=t[w].pin_sel}}this._pininfo=t;this.setOpt(v)}catch(y){throw new MiMicException(y)}};g.GpioPort.prototype={_pininfo:null,_gpio:null,_port_no:0,_port:null,_mask:0,setOpt:function b(z){try{var t=this._pininfo;var u=new Array();var y="";if(!f(z.pin)){y+=this._port.BCF_setOpts(z.pin,u)}if(!f(z.dir)){var A=0;var w=0;if(j(z.dir)){for(var v=0;v<t.length;v++){if(f(z.dir[v])){continue}w|=(1<<t[v].bit);A|=(z.dir[v]<<t[v].bit)}}else{A=this._mask*z.dir;w=this._mask}y+=this._gpio.BCF_setDirs(this._port_no,w,A,u)}this._gpio._mcu.callMiMicWithCheck(y+p.END,u);return}catch(x){throw new MiMicException(x)}},setValue:function c(x){try{var w=0;for(var y=0;y<this._pininfo.length;y++){var t=((x>>y)&1);w|=(t<<this._pininfo[y].bit)}var u=new Array();var A=this._gpio.BCF_setValues(this._port_no,this._mask,w,u);this._gpio._mcu.callMiMicWithCheck(A+p.END,u)}catch(z){throw new MiMicException(z)}},getValue:function d(){try{var x=new Array();var A=this._gpio.BCF_getValues(this._port_no,this._mask,x);var u=this._gpio._mcu.callMiMicWithCheck(A+p.END,x).stream[0];var w=0;for(var y=this._pininfo.length-1;y>=0;y--){var t=((u>>this._pininfo[y].bit)&1);w=(w<<1)|t}return w}catch(z){throw new MiMicException(z)}},outPatt:function i(x){try{var w=new Array();var B="";for(var z=0;z<x.length;z++){var u=0;for(var y=0;y<this._pininfo.length;y++){var t=((x[z]>>y)&1);u|=(t<<this._pininfo[y].bit)}B+=this._gpio.BCF_setValues(this._port_no,this._mask,u,w)}this._gpio._mcu.callMiMicWithCheck(B+p.END,w)}catch(A){throw new MiMicException(A)}}};g.GpioPin=function m(t,u,w){try{this._gport=new g.GpioPort(t,[u],w)}catch(v){throw new MiMicException(v)}};g.GpioPin.prototype={_gport:null,setOpt:function b(u){try{this._gport.setOpt(u)}catch(t){throw new MiMicException(t)}},setValue:function c(t){try{this._gport.setValue(t)}catch(u){throw new MiMicException(u)}},getValue:function d(){try{return this._gport.getValue()}catch(t){throw new MiMicException(t)}},outPatt:function i(t){try{this._gport.outPatt(t)}catch(u){throw new MiMicException(u)}},}}());(function(){var f=LPC1769;var q=f._BCF;var a=f._EE;var d=MiMicLib.isUndef;var l=MiMicLib.isArray;var o=MiMicLib.cloneAssoc;f.Pwm=function j(v,A){try{this._mcu=v;this._phl=new f.Peripheral(v,f.PHL.PWM1);var x=d(A)?{phl:{}}:{phl:d(A.phl)?{}:o(A.phl),freq:A.freq};if(d(x.phl.power)){x.phl.power=1}if(d(x.phl.clock)){x.phl.clock=0}if(d(x.freq)){x.freq=100}var z="";var w=new Array();z+=this.BCF_setOpt(x,w);z+=q.setMem(this._PC,0,w);z+=q.setMem(this._PCR,0,w);z+=q.setMem(this._CTCR,0,w);z+=q.setMem(this._TCR,0,w);z+=q.setMem(this._TC,0,w);z+=q.setMem(this._TCR,9,w);this._mcu.callMiMicWithCheck(z+q.END,w);this._mcu.registerPhl(this,"PWM")}catch(y){throw new MiMicException(y)}};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 n(z,v){try{var y="";var w;if(!d(z.phl)){y+=this._phl.BCF_setOpt(z.phl,v)}if(!d(z.freq)){w=Math.round(this._phl.getPCLK()/z.freq);if(w<=0){throw new MiMicException("The peripheral clock too small.")}y+=this.BCF_setMRn(0,w,v);y+=this.BCF_setLER(0,v);this._cache.mr0=w}return y}catch(x){throw new MiMicException(x)}},BCF_setLER:function b(w,v){try{return q.setBit(this._LER,1,1,w,v)}catch(x){throw new MiMicException(x)}},BCF_setLERs:function m(x,w,v){try{return q.setBit(this._LER,x,w,0,v)}catch(y){throw new MiMicException(y)}},BCF_setMRn:function i(x,w,v){try{return q.setMem(this._MRn[x],w,v)}catch(y){throw new MiMicException(y)}},BCF_setMRnByDuty:function e(w,x,v){try{return this.BCF_setMRn(w,Math.round(x*this._cache.mr0),v)}catch(y){throw new MiMicException(y)}},BCF_setPCRbits:function g(C,y,z,x){try{var w,A;w=A=0;if(!d(y)){var B=255&C;A|=y*B;w|=B}if(!d(z)){var B=65280&C;A|=(z*B);w|=B}return q.setBit(this._PCR,w,A,0,x)}catch(D){throw new MiMicException(D)}},setOpt:function c(y){try{var v=new Array();var x=this.BCF_setOpt(y,v);this._mcu.callMiMicWithCheck(x+q.END,v)}catch(w){throw new MiMicException(w)}},getPin:function r(v,x){try{return new f.PwmPin(this,v,x)}catch(w){throw new MiMicException(w)}},getPort:function t(v,x){try{return new f.PwmPort(this,v,x)}catch(w){throw new MiMicException(w)}}};function h(w){try{var x=new Array();for(var y=0;y<w.length;y++){var z=f.completePinFunctionName(w[y],"PWM");var v=z.substring(2).split(".");if(isNaN(v[1])){throw new MiMicException(a.INVALID_CFG)}x.push({port:0,ch:parseInt(v[1]),pin_sel:f.getPinSelByFunctionName(w[y],z)})}return x}catch(A){throw new MiMicException(A)}}f.PwmPort=function s(x,w,C){try{this._pwm=x;var v=h(w);var B=v[0].port;for(var z=1;z<v.length;z++){if(B!=v[z].port){throw new MiMicException("Invalid pin combination.")}}this._port=new f.Port(x._mcu,w);this._port_no=B;var y={};if(d(C)){y.pin=this._port.clonePinOptAssoc({});y.duty=0;y.enable=1}else{y.pin=this._port.clonePinOptAssoc(d(C.pin)?{}:C.pin);y.duty=d(C.duty)?0:C.duty;y.enable=d(C.enable)?0:C.enable}for(var z=0;z<v.length;z++){if(d(y.pin[z].sel)){y.pin[z].sel=v[z].pin_sel}}this._pininfo=v;this.setOpt(y)}catch(A){throw new MiMicException(A)}};f.PwmPort.prototype={_pwm:null,_pininfo:null,_port_no:0,_port:null,setOpt:function c(v){try{var A=this._pininfo;var D=new Array();var C="";if(!d(v.pin)){C+=this._port.BCF_setOpts(v.pin,D)}if(!d(v.enable)){var w=0;var x=0;if(l(v.enable)){for(var z=0;z<A.length;z++){if(d(v.enable[z])){continue}x|=((257*v.enable[z])<<A[z].ch);w|=(257<<A[z].ch)}}else{for(var z=0;z<A.length;z++){w|=(257<<A[z].ch)}x=w*v.enable}C+=this._pwm.BCF_setPCRbits(w,0,x,D)}if(!d(v.duty)){var y=0;if(l(v.duty)){for(var z=0;z<A.length;z++){if(d(v.duty[z])){continue}C+=this._pwm.BCF_setMRnByDuty(A[z].ch,v.duty[z],D);y|=(1<<A[z].ch)}}else{for(var z=0;z<A.length;z++){C+=this._pwm.BCF_setMRnByDuty(A[z].ch,v.duty,D);y|=(1<<A[z].ch)}}C+=this._pwm.BCF_setLERs(y,y,D)}this._pwm._mcu.callMiMicWithCheck(C+q.END,D);return}catch(B){throw new MiMicException(B)}},setDutys:function k(w){try{this.setOpt({duty:w})}catch(v){throw new MiMicException(v)}}};f.PwmPin=function u(v,w,y){try{this._pport=new f.PwmPort(v,[w],y)}catch(x){throw new MiMicException(x)}};f.PwmPin.prototype={_pport:null,setOpt:function c(w){try{this._pport.setOpt(w)}catch(v){throw new MiMicException(v)}},setDuty:function p(v){try{this._pport.setDutys([v])}catch(w){throw new MiMicException(w)}}}}());(function(){var f=LPC1769;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,p,o){var n="";var q=new Array();if(!d(p)){for(var l=0;l<8;l++){var k="wm"+l;if(!d(p[k])){n+="FB"+MiMicLib.hexout(l,2)+MiMicLib.hexout(p[k],8)}}if(!d(p.stream)){for(var l=0;l<p.stream.length;l++){q.push(p.stream[l])}}}n+="ZF"+MiMicLib.hexout(j,8);var g=0;if(!d(o)){for(var l=0;l<8;l++){if(!d(o["wm"+l])){n+="EE"+MiMicLib.hexout(l,2);g++}}}var m=this._mcu.callMiMic(n+e.END,q);if(m.result!=0){return false}if(!d(o)){var h=m.stream.length-g;for(var l=0;l<8;l++){var k="wm"+l;if(!d(o[k])){o[k]=m.stream[h];h++}}if(!d(o.stream)){o.stream=m.stream.slice(0,m.stream.length-g)}}return false}}}());(function(){var g=LPC1769;var n=g._BCF;var a=g._EE;var f=MiMicLib.isUndef;var h=MiMicLib.isArray;var k=MiMicLib.cloneAssoc;g.Dac=function i(s,x){try{this._mcu=s;this._phl=new g.Peripheral(s,g.PHL.DAC);var u=f(x)?{phl:{}}:{phl:f(x.phl)?{}:k(x.phl),};if(f(u.phl.clock)){u.phl.clock=0}var w="";var t=new Array();w+=this.BCF_setOpt(u,t);this._mcu.callMiMicWithCheck(w+n.END,t);this._mcu.registerPhl(this,"DAC")}catch(v){throw new MiMicException(v)}};g.Dac.prototype={_DACR:1074315264,_DACCTRL:1074315268,_DACCNTVAL:1074315272,_phl:null,_mcu:null,BCF_setOpt:function j(v,s){try{var u="";if(!f(v.phl)){u+=this._phl.BCF_setOpt(v.phl,s)}return u}catch(t){throw new MiMicException(t)}},setOpt:function c(v){try{var s=new Array();var u=this.BCF_setOpt(v,s);this._mcu.callMiMicWithCheck(u+n.END,s)}catch(t){throw new MiMicException(t)}},getPin:function o(s,u){try{return new g.DacPin(this,s,u)}catch(t){throw new MiMicException(t)}},getPort:function r(s,u){try{return new g.DacPort(this,s,u)}catch(t){throw new MiMicException(t)}},BCF_setBias:function b(u,t,s){try{return n.setBit(this._DACR,u,t*u,0,s)}catch(v){throw new MiMicException(v)}},BCF_setValue:function l(t,s){return n.setBit(this._DACR,1023,t,6,s)}};function p(t){try{var u=new Array();for(var v=0;v<t.length;v++){var s=g.completePinFunctionName(t[v],"AOUT");u.push({port:0,pin_sel:g.getPinSelByFunctionName(t[v],s)})}return u}catch(w){throw new MiMicException(w)}}g.DacPort=function e(u,t,y){try{this._dac=u;var s=p(t);this._port=new g.Port(u._mcu,t);var w={};if(f(y)){w.pin=this._port.clonePinOptAssoc({});w.bias=0}else{w.pin=this._port.clonePinOptAssoc(f(y.pin)?{}:y.pin);w.bias=f(y.bias)?0:y.bias}for(var v=0;v<s.length;v++){if(f(w.pin[v].sel)){w.pin[v].sel=s[v].pin_sel}}this.setOpt(w)}catch(x){throw new MiMicException(x)}};g.DacPort.prototype={_dac:null,_port:null,setOpt:function c(v){try{var s=new Array();var u="";if(!f(v.pin)){u+=this._port.BCF_setOpts(v.pin,s)}if(!f(v.bias)){if(h(v.pin)){u+=this._dac.BCF_setBias(65536,v.bias[0],s)}else{u+=this._dac.BCF_setBias(65536,v.bias,s)}}this._dac._mcu.callMiMicWithCheck(u+n.END,s);return}catch(t){throw new MiMicException(t)}},setValues:function m(s){try{var t=new Array();var w="";for(var u=0;u<this._port.pins.length;u++){w+=this._dac.BCF_setValue(s[u],t)}this._dac._mcu.callMiMicWithCheck(w+n.END,t);return}catch(v){throw new MiMicException(v)}}};g.DacPin=function q(s,t,v){try{this._port=new g.DacPort(s,[t],v)}catch(u){throw new MiMicException(u)}};g.DacPin.prototype={_port:null,setValue:function d(s){try{this._port.setValues([s])}catch(t){throw new MiMicException(t)}},setOpt:function c(t){try{this._port.setOpt(t)}catch(s){throw new MiMicException(s)}}}}());var MbedM3;(function(){var a=MiMicLib.isUndef;var b=LPC1769;MbedM3=MiMicLib.cloneAssoc(b);if(!a(MbedM3.PINNAME)){alert("invalid override[PINNAME]")}MbedM3.PINNAME={SPI1MOSI:b.P0[9],SPI1MISO:b.P0[8],SPI1SCK:b.P0[7],GPIO:b.P0[6],UART1TX:b.P0[0],I2C1SDA:b.P0[0],UART1RX:b.P0[1],I2C1SCL:b.P0[1],SPI2MODI:b.P0[18],SPI2MISO:b.P0[17],SPI2SCK:b.P0[15],UART2TX:b.P0[15],SPI2SCL:b.P0[15],UART2RX:b.P0[16],AIN0:b.P0[23],AIN1:b.P0[24],AIN2:b.P0[25],AIN3:b.P0[26],AOUT:b.P0[26],AIN4:b.P0[30],AIN5:b.P0[31],USBDP:b.P0[29],USBDM:b.P0[30],CANRD:b.P0[4],CANTD:b.P0[5],UART3TX:b.P0[10],I2C2SDA:b.P0[10],UART3RX:b.P0[11],I2C2SCL:b.P0[10],PWMOUT0:b.P2[0],PWMOUT1:b.P2[1],PWMOUT2:b.P2[2],PWMOUT3:b.P2[3],PWMOUT4:b.P2[4],PWMOUT5:b.P2[5],};if(!a(MbedM3.PIN)){alert("invalid override[PIN]")}MbedM3.PIN=[null,null,null,null,null,b.P0[9],b.P0[8],b.P0[7],b.P0[6],b.P0[0],b.P0[1],b.P0[18],b.P0[17],b.P0[15],b.P0[16],b.P0[23],b.P0[24],b.P0[25],b.P0[26],b.P1[30],b.P1[31],b.P2[5],b.P2[4],b.P2[3],b.P2[2],b.P2[1],b.P2[0],b.P0[11],b.P0[10],b.P0[5],b.P0[4]];if(!a(MbedM3.LED)){alert("invalid override[LED]")}MbedM3.LED=[b.P1[18],b.P1[20],b.P1[21],b.P1[23]]}());
\ No newline at end of file
index f9ab48d..468c82c 100644 (file)
@@ -842,6 +842,7 @@ LPC1769=DEV;
                 * <li>GPIO - LPC1769.GpioPin</li>\r
                 * <li>AD - LPC1769.AdcPin</li>\r
                 * <li>PWM - LPC1769.PwmPin</li>\r
+                * <li>DA - LPC1769.DacPin</li>\r
                 * </ul>\r
                 */\r
                getPin:function getPin(/*...*/)\r
@@ -875,10 +876,10 @@ LPC1769=DEV;
                 * @return {object as PortObject}\r
                 * 返却されるインスタンスのクラスは、機能により異なる。機能とインスタンスのクラスの対応は、以下の通りである。\r
                 * <ul>\r
-                * <li>GPIO - LPC1769.GpioPin</li>\r
-                * <li>AD - LPC1769.AdcPin</li>\r
-                * <li>PWM - LPC1769.PwmPin</li>\r
-                * <li>DAC - LPC1769.DacPin</li>\r
+                * <li>GPIO - LPC1769.GpioPort</li>\r
+                * <li>AD - LPC1769.AdcPort</li>\r
+                * <li>PWM - LPC1769.PwmPort</li>\r
+                * <li>DA - LPC1769.DacPort</li>\r
                 * </ul>                 \r
                 */\r
                getPort:function getPort(i_pins,i_function_name)\r
@@ -1016,8 +1017,8 @@ DEV.Memory.prototype=
         * コンストラクタで指定したアドレスからのオフセット位置を指定する。4バイト境界でなければならない。\r
         * @param {int} i_size\r
         * 取得するバイト数を指定する。4バイト単位でなければならない。      \r
-        * @return {int or Array[int]}\r
-        * 取得する値の個数は、i_size/4個である。個数により、戻り値の型が異なるので注意すること。\r
+        * @return {Array[int]}\r
+        * 取得する値の個数は、i_size/4個である。\r
         * @example\r
         * var mcu=new LPC1769.Mcu("192.168.0.39");\r
         * var mem=new LPC1769.Memory(mcu); //create instance\r
@@ -1031,7 +1032,7 @@ DEV.Memory.prototype=
         * @param {array[int]} i_offsets\r
         * オフセットアドレスの配列。それぞれ4バイト境界でなければならない。\r
         * @return {int or Array[int]}\r
-        * 返却される値の個数は、i_offsetの長さと同じになる。個数により、戻り値の型が異なるので注意すること。\r
+        * 返却される値の個数は、i_offsetの長さと同じになる。\r
         * @example\r
         * var mcu=new LPC1769.Mcu("192.168.0.39");\r
         * var mem=new LPC1769.Memory(mcu); //create instance\r
@@ -1051,6 +1052,7 @@ DEV.Memory.prototype=
        read32:function read32(/*arguments*/)\r
        {\r
                try{\r
+                       var is_ret_array=true;\r
                        var bc="";\r
                        var ar=new Array();\r
                        var offset=arguments[0];\r
@@ -1061,6 +1063,7 @@ DEV.Memory.prototype=
                                        checkAlign(offset);\r
                                        bc=BCF.READMEM;\r
                                        ar.push(this._base+offset);\r
+                                       is_ret_array=false;\r
                                }else{\r
                                        //read32(i_offsets:array)\r
                                        for(var i=0;i<offset.length;i++){\r
@@ -1083,7 +1086,7 @@ DEV.Memory.prototype=
                                break;\r
                        }\r
                        var ret=this._mcu.callMiMicWithCheck(bc+BCF.END,ar).stream;\r
-                       return ret.length==1?ret[0]:ret;\r
+                       return is_ret_array?ret:ret[0];\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -1419,7 +1422,7 @@ DEV.Port.prototype=
         * 複数のピン設定をレジスタごとにまとめたBCを生成する。\r
         * @private\r
         * @param {array[associative array]| associative array} i_opts\r
-        * ã\83\94ã\83³è¨­å®\9aæ\83\85å ±ã\81®é\80£è£\85é\85\8då\88\97ã\81®é\85\8då\88\97ã\80\82é\85\8då\88\97ã\81®è¦\81ç´ æ\95°ã\81¯ã\80\81Portを構成するPinと同じ数である必要がある。\r
+        * ã\83\94ã\83³è¨­å®\9aæ\83\85å ±ã\81®é\80£è£\85é\85\8då\88\97ã\81\8bã\80\81ã\81\9dã\81®é\85\8då\88\97ã\80\82é\85\8då\88\97ã\81®æ\99\82ã\81¯Portを構成するPinと同じ数である必要がある。\r
         * 単一のassociative arrayを指定した場合は、全てのピンに同じパラメータを設定する。\r
         * <pre>associative array</>\r
         * ピン設定連装配列 {sel:int,mode:int,od:int}\r
@@ -1479,14 +1482,12 @@ DEV.Port.prototype=
                }\r
        },\r
        /**\r
-        * ポートにオプションパラメータをセットする。\r
-        * 関数は、ポートを構成するピンに、ピンオプション配列の値を個別に設定する。\r
+        * Portを構成するPinにオプション値を設定する。\r
         * @name LPC1769.Port#setOpts\r
         * @function\r
-        * @param {array[associative array]} i_opts\r
-        * ã\83\94ã\83³ã\82³ã\83³ã\83\95ã\82£ã\82°ã\83¬ã\83¼ã\82·ã\83§ã\83³ã\81®é\80£è£\85é\85\8då\88\97ã\81®配列である。\r
+        * @param {array[associative array] | associative array} i_opts\r
+        * ã\83\94ã\83³ã\82³ã\83³ã\83\95ã\82£ã\82°ã\83¬ã\83¼ã\82·ã\83§ã\83³ã\81®é\80£è£\85é\85\8då\88\97ã\80\81ã\81¾ã\81\9fã\81¯配列である。\r
         * ピンオプションの連装配列は、Pin#setOptを参照。\r
-        * 配列の要素数は、ポートを構成するピンの数と同じでなければならない。\r
         * @example\r
         * //set GPIO,mode=1,open drain=0\r
         * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -1638,7 +1639,7 @@ var cloneAssoc=MiMicLib.cloneAssoc;
  * @name LPC1769.Adc\r
  * @param {object as LPC1769.Mcu} i_mcu\r
  * インスタンスを結びつけるMcuオブジェクト。\r
- * @param {object as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * インスタンス生成と同時にsetOpt関数で設定する値。省略時は、{phl:{power:1}}とみなす。\r
  * 詳細はsetOpt関数を参照。 \r
  * @example\r
@@ -1725,10 +1726,10 @@ DEV.Adc.prototype=
         * ADCペリフェラルに、i_optのオプション値を設定する。\r
         * @name LPC1769.Adc#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
+        * @param {associative array} i_opt\r
         * ADCペリフェラルのコンフィグレーションパラメタである。必要な値を格納した連想配列で指定する。\r
         * 全ての値を省略することは出来ない。連想配列のメンバは以下の通り。\r
-        * <pre>{phl:object as associative array}</pre>\r
+        * <pre>{phl:associative array}</pre>\r
         * <ul>\r
         * <li>phl - LPC1769.Peripheral#setOpt関数のi_optに渡すパラメタである。</li>\r
         * </ul>\r
@@ -1758,8 +1759,8 @@ DEV.Adc.prototype=
         * @function\r
         * @param {object as ピン識別子} i_pin\r
         * AD機能を割り当てるPINの識別子である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * AdcPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPin.setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * AdcPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPinを参照。\r
         * @return {object as LPC1769.AdcPin}\r
         * LPC1769.AdcPinクラスのオブジェクトである。\r
         * @example\r
@@ -1785,8 +1786,8 @@ DEV.Adc.prototype=
         * @function\r
         * @param {array[ピン識別子]} i_pin\r
         * AD機能を割り当てるPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPort.setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.AdcPortを参照。\r
         * @return {object as LPC1769.AdcPort}\r
         * LPC1769.AdcPortクラスのオブジェクトである。\r
         * @example\r
@@ -1810,24 +1811,27 @@ DEV.Adc.prototype=
  * AD pinからADInfoを取得\r
  * @private\r
  */\r
-function pin2AdcPinInfo(i_pin)\r
+function makeAdcPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var func_name=DEV.completePinFunctionName(i_pin,"AD");\r
-               //portとbitを得る(AD0だけしか管理しないよ)\r
-               var a=func_name.substring(2).split(".");\r
-               var r={port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pin,func_name)};\r
-               if(!isNaN(r.ch)){\r
-                       return r;\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var func_name=DEV.completePinFunctionName(i_pins[i],"AD");\r
+                       //portとbitを得る(AD0だけしか管理しないよ)\r
+                       var a=func_name.substring(2).split(".");\r
+                       if(isNaN(a[1])){\r
+                               throw new MiMicException(EE.INVALID_CFG);\r
+                       }\r
+                       ret.push({port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pins[i],func_name)});\r
                }\r
-               throw new MiMicException(EE.INVALID_CFG,"The pin has not AD fuction.");\r
+               return ret;\r
        }catch(e){\r
-               throw new MiMicException(e);    \r
+               throw new MiMicException(e);\r
        }\r
 }\r
 /**\r
- * LPC1769.AdcPort (AdcPort)クラスのコンストラクタ。複数のADピンから一括で値を取得するときに使用する。\r
+ * LPC1769.AdcPort (AdcPort)クラスのコンストラクタ。複数のADcPinから一括で値を取得するときに使用する。\r
  * Adcペリフェラルオブジェクトにピン識別子の配列で指定されたピン集合を関連付けて、AD機能を持つポートを生成する。\r
  * 関数は、ピン識別子を元に、そのピンがAD機能に接続できるかを調べる。全てのピンにAD機能を割り当てられない場合、例外が発生する。どのピンにAD機能が割り当てられるかは、MCUのスペックシートを参照すること。\r
  * @constructor\r
@@ -1836,9 +1840,9 @@ function pin2AdcPinInfo(i_pin)
  * インスタンスを結びつけるAdcオブジェクト。\r
  * @param {array[pin識別子]} i_pins\r
  * ピン識別子の配列。指定できるのは、LPC1769.P?[?]である。順番は、このインスタンスの返す値の順序に影響する。\r
- * @param {object as associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto}}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * @param {array[associative array] | associative array} i_opt\r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined}}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create [AD0.0,AD0.1]\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -1850,15 +1854,11 @@ DEV.AdcPort=function AdcPort(i_adc,i_pins,i_opt)
        try{\r
                this._adc=i_adc;\r
                //ピンセットを取得\r
-               this._pins=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       this._pins.push(pin2AdcPinInfo(i_pins[i]));\r
-               }\r
+               var pininfo=makeAdcPinInfoArray(i_pins);\r
                //pinが全て同じポートに所属しているか確認\r
-               var p=this._pins[0].port;\r
-               for(var i=1;i<this._pins.length;i++){\r
-                       if(p!=this._pins[i].port){\r
+               var p=pininfo[0].port;\r
+               for(var i=1;i<pininfo.length;i++){\r
+                       if(p!=pininfo[i].port){\r
                                throw new MiMicException("Invalid pin combination.");\r
                        }\r
                }\r
@@ -1867,15 +1867,26 @@ DEV.AdcPort=function AdcPort(i_adc,i_pins,i_opt)
                this._port_no=p;\r
                //AD0CR用のマスクを生成。\r
                this._adcr_mask=0;\r
-               for(var i=0;i<this._pins.length;i++){\r
-                       this._adcr_mask|=(0x1<<this._pins[i].ch);\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       this._adcr_mask|=(0x1<<pininfo[i].ch);\r
                }\r
+\r
                //ピンオプションの生成\r
-               var opt=isUndef(i_opt)?{}:cloneAssoc(i_opt);\r
-               opt.sel=1;//ADxCRの値\r
-               opt.pin=isUndef(opt.pin)?{}:cloneAssoc(opt.pin);\r
-               //設定が無ければ、ピンセレクタを自動に設定\r
-               if(isUndef(opt.pin.sel)){opt.pin.sel=this._PINSEL_AUTO_DETECT;}\r
+               var opt={};\r
+               if(isUndef(i_opt)){\r
+                       opt.pin=this._port.clonePinOptAssoc({});\r
+                       opt.sel=1;//ADxCRの値\r
+               }else{\r
+                       opt.pin=this._port.clonePinOptAssoc(isUndef(i_opt.pin)?{}:i_opt.pin);\r
+                       opt.sel=1;//ADxCRの値\r
+               };\r
+               //pinselの自動設定\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       if(isUndef(opt.pin[i].sel)){\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
+                       }\r
+               }\r
+               this._pininfo=pininfo;\r
                //ピンオプションの設定\r
                this.setOpt(opt);\r
        }catch(e){\r
@@ -1884,9 +1895,8 @@ DEV.AdcPort=function AdcPort(i_adc,i_pins,i_opt)
 }\r
 DEV.AdcPort.prototype=\r
 {\r
-       _PINSEL_AUTO_DETECT:0x0fffffff,\r
        _adc:null,\r
-       _pins:null,\r
+       _pininfo:null,\r
        _port_no:0,\r
        _port:null,\r
        _adcr_mask:0,\r
@@ -1896,8 +1906,19 @@ DEV.AdcPort.prototype=
         * 設定可能な値は、LPC1769.AdcPin#setOptと同じである。\r
         * @name LPC1769.AdcPort#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
-        * LPC1769.AdcPin#setOptを参照。\r
+        * @param {associative array | array[associative array]} i_opt\r
+        * ADピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
+        * 全てのピンに同じパラメータを指定する場合は、連装配列で指定する。個別に設定する場合は、連装配列を配列にして指定する。\r
+        * <pre>{i_opt:associative array}</pre>\r
+        * <ul>\r
+        * <li>pin(option)</li>\r
+        * </ul>\r
+        * パラメータの詳細は、LPC1769.AdcPin#setOptを参照。\r
+        * @example\r
+        * //ポートを構成する全てのピンに同じパラメータを設定する場合\r
+        * setOpt({pin:{v1}});\r
+        * //ポートを構成するピンに個々にパラメータを設定する場合\r
+        * setOpt({pin:[{v1},{v2}]});\r
         */     \r
        setOpt:function setOpt(i_opt)\r
        {\r
@@ -1907,14 +1928,7 @@ DEV.AdcPort.prototype=
                        var bc="";\r
                        //i_optの展開\r
                        if(!isUndef(i_opt.pin)){\r
-                               var optset=new Array();\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       //pinselが_PINSEL_AUTO_DETECTならばauto。そうでなければundefinedも含めて設定\r
-                                       var s=(i_opt.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[i].pin_sel:i_opt.pin.sel;\r
-                                       optset.push({sel:s,mode:i_opt.pin.mode,od:i_opt.pin.od});\r
-                               }\r
-                               //portの設定\r
-                               bc+=this._port.BCF_setOpts(optset,db);\r
+                               bc+=this._port.BCF_setOpts(i_opt.pin,db);\r
                        }\r
                        //隠し。ADxCR\r
                        if(!isUndef(i_opt.sel)){\r
@@ -1945,13 +1959,13 @@ DEV.AdcPort.prototype=
                        //メモリから値取得\r
                        var db=new Array();\r
                        var bc="";\r
-                       for(var i=0;i<this._pins.length;i++){\r
-                               bc+=this._adc.BCF_getAD0DR(this._pins[i].ch,db);\r
+                       for(var i=0;i<this._port.pins.length;i++){\r
+                               bc+=this._adc.BCF_getAD0DR(this._pininfo[i].ch,db);\r
                        }\r
                        var ret=this._adc._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                        //値の整形\r
                        var r=new Array();\r
-                       for(var i=0;i<this._pins.length;i++){\r
+                       for(var i=0;i<this._port.pins.length;i++){\r
                                r.push((ret.stream[i]>>4)&0x00000fff);\r
                        }\r
                        return r;\r
@@ -1971,8 +1985,8 @@ DEV.AdcPort.prototype=
  * @param {object as pin識別子} i_pin\r
  * ピン識別子。指定できるのは、LPCXpresso1796.P?[?]である。\r
  * @param {object as associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto}}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined}}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create AD0.0\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -2015,10 +2029,10 @@ DEV.AdcPin.prototype=
         * ADピンにオプション値を設定する。\r
         * @name LPC1769.AdcPin#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
+        * @param {associative array} i_opt\r
         * ADピンのコンフィグレーションパラメタである。必要な値を格納した連想配列で指定する。\r
         * 全ての値を省略することは出来ない。連想配列のメンバは以下の通り。\r
-        * <pre>{pin:object as associative array}</pre>\r
+        * <pre>{pin:associative array}</pre>\r
         * <ul>\r
         * <li>pin - LPC1769.Pin#setOpt関数のi_optに渡すパラメタである。</li>\r
         * </ul>\r
@@ -2046,7 +2060,7 @@ var BCF=DEV._BCF;
 var EE=DEV._EE;\r
 var isUndef=MiMicLib.isUndef;\r
 var cloneAssoc=MiMicLib.cloneAssoc;\r
-\r
+var isArray=MiMicLib.isArray;\r
 /**\r
  * LPCXPresso1769.Gpio (Gpio)クラスのコンストラクタ。\r
  * MCUに関連付けしたGpioペリフェラルを生成する。\r
@@ -2055,7 +2069,7 @@ var cloneAssoc=MiMicLib.cloneAssoc;
  * @constructor\r
  * @param {object as LPC1769.Mcu} i_mcu\r
  * インスタンスを結びつけるMcuオブジェクト。\r
- * @param {oject as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * 常に無視する。省略すること。\r
  * @example\r
  * //create GPIO (logical)pheripheral\r
@@ -2117,13 +2131,14 @@ DEV.Gpio.prototype=
        },\r
        /**\r
         * \r
-        @param i_dir 1 or 0\r
-        @private
+        * @param {int} i_dir\r
+        * i_maskに合致したビットイメージ\r
+        * @private
         */\r
        BCF_setDirs:function BCF_setDirs(i_ch,i_mask,i_dir,i_db)\r
        {\r
                try{\r
-                       return BCF.setBit(this._FIO_DIR[i_ch],i_mask,i_mask*i_dir,0,i_db);\r
+                       return BCF.setBit(this._FIO_DIR[i_ch],i_mask,i_dir,0,i_db);\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -2137,8 +2152,8 @@ DEV.Gpio.prototype=
         * @function\r
         * @param {object as ピン識別子} i_pin\r
         * GPIO機能を割り当てるPINの識別子である。\r
-        * @param {object as associative array} i_opt\r
-        * GpioPinのコンストラクタに渡すオプション値を指定する。省略可能。省略時はundefinedとみなす。詳細はGpioPinのコンストラクタを参照。\r
+        * @param {associative array} i_opt\r
+        * GpioPinのコンストラクタに渡すオプション値を指定する。省略時はundefinedである。詳細はLPC1769.GpioPinを参照。\r
         * @return {object as GpioPin}\r
         * GpioPinクラスのオブジェクトである。\r
         * @example\r
@@ -2164,8 +2179,8 @@ DEV.Gpio.prototype=
         * @function\r
         * @param {array[ピン識別子]} i_pin\r
         * Gpioポートを構成するPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * GpioPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.GpioPort.setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * GpioPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.GpioPortを参照。\r
         * @return {object as LPC1769.GpioPort}\r
         * LPC1769.GpioPortクラスのオブジェクトである。\r
         * @example\r
@@ -2188,21 +2203,24 @@ DEV.Gpio.prototype=
  * GPIO pinからGPIOInfoを取得
  * @private
  */\r
-function pin2GpioPinInfo(i_pin)\r
+function makeGpioPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var fn=DEV.completePinFunctionName(i_pin,"GPIO");\r
-               //pin名からポートとビットを得る。\r
-               var a=fn.substring(4).split(".");\r
-               //pin情報を構成。\r
-               var r={port:parseInt(a[0]),bit:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pin,fn)};\r
-               if(!isNaN(r.port) && !isNaN(r.bit)){\r
-                       return r;\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var fn=DEV.completePinFunctionName(i_pins[i],"GPIO");\r
+                       //pin名からポートとビットを得る。\r
+                       var a=fn.substring(4).split(".");\r
+                       if(isNaN(a[0]) || isNaN(a[1])){\r
+                               throw new MiMicException(EE.INVALID_CFG);\r
+                       }\r
+                       //pin情報を構成。\r
+                       ret.push({port:parseInt(a[0]),bit:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pins[i],fn)});\r
                }\r
-               throw new MiMicException(EE.INVALID_CFG,"The pin has not GPIO fuction.");\r
+               return ret;\r
        }catch(e){\r
-               throw new MiMicException(e);    \r
+               throw new MiMicException(e);\r
        }\r
 }\r
 \r
@@ -2218,11 +2236,11 @@ function pin2GpioPinInfo(i_pin)
  * ピン識別子の配列。指定できるのは、LPCXpresso1796.P?[?]である。順番は、このインスタンスの返す値の順序に影響する。\r
  * 0番目のピンはビット0に対応する。同様に、1番目のピンはビット1に対応する。\r
  * 組み合わせるピンは、同じ物理ポートに所属している必要がある。例えば、GPIO0.0とGPIO0.1は組み合わせられるが、GPIO0.0とGPIO1.1は組み合わせることが出来ない。\r
- * @param {object as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto}}を設定する。\r
  * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
  * @example\r
- * //create [AD0.0,AD0.1]\r
+ * //create [LPC1769.P0[0],LPC1769.P0[1]]\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
  * var gpio=new LPC1769.Gpio(mcu);\r
  * var port=new LPC1769.GpioPort(adc,[LPC1769.P0[0],LPC1769.P0[1]]); \r
@@ -2232,15 +2250,11 @@ DEV.GpioPort=function GpioPort(i_gpio,i_pins,i_opt)
        try{\r
                this._gpio=i_gpio;\r
                //ピンセットを取得\r
-               this._pins=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       this._pins.push(pin2GpioPinInfo(i_pins[i]));\r
-               }\r
+               var pininfo=makeGpioPinInfoArray(i_pins);\r
                //pinが全て同じポートに所属しているか確認\r
-               var p=this._pins[0].port;\r
-               for(var i=1;i<this._pins.length;i++){\r
-                       if(p!=this._pins[i].port){\r
+               var p=pininfo[0].port;\r
+               for(var i=1;i<pininfo.length;i++){\r
+                       if(p!=pininfo[i].port){\r
                                throw new MiMicException("Invalid pin combination.");\r
                        }\r
                }\r
@@ -2249,15 +2263,24 @@ DEV.GpioPort=function GpioPort(i_gpio,i_pins,i_opt)
                this._port_no=p;\r
                //GPIO用のマスクを生成。\r
                this._mask=0;\r
-               for(var i=0;i<this._pins.length;i++){\r
-                       this._mask|=(0x1<<this._pins[i].bit);\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       this._mask|=(0x1<<pininfo[i].bit);\r
                }\r
+\r
                //ピンオプションの生成\r
-               var opt=cloneAssoc(i_opt);\r
-               //ピンプロパティの複製\r
-               opt.pin=isUndef(opt.pin)?{}:cloneAssoc(opt.pin);\r
-               //設定が無ければ、ピンセレクタを自動に設定\r
-               if(isUndef(opt.pin.sel)){opt.pin.sel=this._PINSEL_AUTO_DETECT;}\r
+               var opt={};\r
+               if(isUndef(i_opt)){\r
+                       opt.pin=this._port.clonePinOptAssoc({});\r
+               }else{\r
+                       opt.pin=this._port.clonePinOptAssoc(isUndef(i_opt.pin)?{}:i_opt.pin);\r
+               };\r
+               //pinselの自動設定\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       if(isUndef(opt.pin[i].sel)){\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
+                       }\r
+               }\r
+               this._pininfo=pininfo;\r
                //ピンオプションの設定\r
                this.setOpt(opt);\r
        }catch(e){\r
@@ -2266,8 +2289,7 @@ DEV.GpioPort=function GpioPort(i_gpio,i_pins,i_opt)
 }\r
 DEV.GpioPort.prototype=\r
 {\r
-       _PINSEL_AUTO_DETECT:0x0fffffff,//setoptに自動を伝えるときに使う\r
-       _pins:null,\r
+       _pininfo:null,\r
        _gpio:null,\r
        _port_no:0,\r
        _port:null,\r
@@ -2275,32 +2297,52 @@ DEV.GpioPort.prototype=
        /**\r
         * Gpioポートにオプション値を設定する。\r
         * 関数は、ポートを構成する全てのピンに、同一なオプション値を設定する。\r
-        * 設定可能な値は、LPC1769.GpioPin#setOptと同じである。\r
+        * 設定可能な値は、LPC1769.GpioPin#setOptと同じである。   \r
         * @name LPC1769.GpioPort#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
-        * LPC1769.GpioPin#setOptを参照。\r
+        * @param {associative array | array[associative array]} i_opt\r
+        * GPIOピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
+        * 全てのピンに同じパラメータを指定する場合は、連装配列で指定する。個別に設定する場合は、連装配列を配列にして指定する。\r
+        * <pre>{i_opt:associative array}</pre>\r
+        * <ul>\r
+        * <li>pin(option) - array[{PIN_OPTION}] | {PIN_OPTION}</li>\r
+        * <li>dir(option) - array[{1bit int}] | {1bit int}</li>\r
+        * </ul>\r
+        * パラメータの詳細は、LPC1769.GpioPin#setOptを参照。\r
+        * @example\r
+        * //ポートを構成する全てのピンに同じパラメータを設定する場合\r
+        * setOpt({pin:{v1},dir:1});\r
+        * //ポートを構成するピンに個々にパラメータを設定する場合\r
+        * setOpt({pin:[{v1},{v2}],dir:[1,1]});\r
         */     \r
        setOpt:function setOpt(i_opt)\r
        {\r
                try{\r
+                       var pininfo=this._pininfo;\r
                        var db=new Array();\r
                        //BCの生成\r
                        var bc="";\r
+                       //pinの設定\r
+                       if(!isUndef(i_opt.pin)){\r
+                               bc+=this._port.BCF_setOpts(i_opt.pin,db);\r
+                       }\r
                        //dir設定\r
                        if(!isUndef(i_opt.dir)){\r
-                               bc+=this._gpio.BCF_setDirs(this._port_no,this._mask,i_opt.dir,db);\r
-                       }\r
-                       //i_optの展開\r
-                       if(!isUndef(i_opt.pin)){\r
-                               var optset=new Array();\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       //pinselが_PINSEL_AUTO_DETECTならばauto。そうでなければundefinedも含めて設定\r
-                                       var s=(i_opt.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[i].pin_sel:i_opt.pin.sel;\r
-                                       optset.push({sel:s,mode:i_opt.pin.mode,od:i_opt.pin.od});\r
+                               var dir_bits=0x0;\r
+                               var dir_mask=0x0;\r
+                               if(isArray(i_opt.dir)){\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               if(isUndef(i_opt.dir[i])){\r
+                                                       continue;\r
+                                               }\r
+                                               dir_mask|=(0x1<<pininfo[i].bit);\r
+                                               dir_bits|=(i_opt.dir[i]<<pininfo[i].bit);\r
+                                       }\r
+                               }else{\r
+                                       dir_bits=this._mask*i_opt.dir;\r
+                                       dir_mask=this._mask;\r
                                }\r
-                               //portの設定\r
-                               bc+=this._port.BCF_setOpts(optset,db);\r
+                               bc+=this._gpio.BCF_setDirs(this._port_no,dir_mask,dir_bits,db);\r
                        }\r
                        this._gpio._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                        return;\r
@@ -2327,12 +2369,11 @@ DEV.GpioPort.prototype=
        {\r
                try{\r
                        var v=0;\r
-                       var l=this._pins.length;\r
-                       for(var i=0;i<l;i++){\r
+                       for(var i=0;i<this._pininfo.length;i++){\r
                                //セットするbit値を得る。\r
                                var sv=((i_val>>i)&0x01);\r
                                //値のセット\r
-                               v|=(sv<<this._pins[i].bit);\r
+                               v|=(sv<<this._pininfo[i].bit);\r
                        }\r
                        //値をセット\r
                        var db=new Array();\r
@@ -2365,9 +2406,9 @@ DEV.GpioPort.prototype=
                        var retval=this._gpio._mcu.callMiMicWithCheck(bc+BCF.END,db).stream[0];\r
                        //値の再構成\r
                        var v=0;\r
-                       for(var i=this._pins.length-1;i>=0;i--){\r
+                       for(var i=this._pininfo.length-1;i>=0;i--){\r
                                //セットするbit値を得る。\r
-                               var sv=((retval>>this._pins[i].bit)&0x1);\r
+                               var sv=((retval>>this._pininfo[i].bit)&0x1);\r
                                //値のセット(pinArrayの並びとビット並びが同じになるようにする)\r
                                v=(v<<1)|sv;\r
                        }\r
@@ -2400,12 +2441,11 @@ DEV.GpioPort.prototype=
                        var bc="";\r
                        for(var i2=0;i2<i_val_array.length;i2++){\r
                                var v=0;\r
-                               var l=this._pins.length;\r
-                               for(var i=0;i<l;i++){\r
+                               for(var i=0;i<this._pininfo.length;i++){\r
                                        //セットするbit値を得る。\r
                                        var sv=((i_val_array[i2]>>i)&0x01);\r
                                        //値のセット(pinArrayの並びと最下位ビットの位置が同じになるように反転)\r
-                                       v|=(sv<<this._pins[i].bit);\r
+                                       v|=(sv<<this._pininfo[i].bit);\r
                                }\r
                                //値をセット\r
                                bc+=this._gpio.BCF_setValues(this._port_no,this._mask,v,db);\r
@@ -2452,7 +2492,7 @@ DEV.GpioPin.prototype=
 {\r
        _gport:null,\r
        /**\r
-        * ADピンにオプション値を設定する。\r
+        * GPIOピンにオプション値を設定する。\r
         * @name LPC1769.GpioPin#setOpt\r
         * @function\r
         * @param {object as associative array} i_opt\r
@@ -2559,6 +2599,7 @@ var DEV=LPC1769;
 var BCF=DEV._BCF;\r
 var EE=DEV._EE;\r
 var isUndef=MiMicLib.isUndef;\r
+var isArray=MiMicLib.isArray;\r
 var cloneAssoc=MiMicLib.cloneAssoc;\r
 \r
 \r
@@ -2572,7 +2613,7 @@ var cloneAssoc=MiMicLib.cloneAssoc;
  * @constructor\r
  * @param {object as LPC1769.Mcu} i_mcu\r
  * インスタンスを結びつけるMcuオブジェクト。\r
- * @param {aobject as associative array} i_opt\r
+ * @param {associative array} i_opt\r
  * インスタンス生成と同時にsetOpt関数でセットする値を指定する。省略時は、{freq:100,phl:{power:1,clock:0}}である。\r
  * 詳細は、setOpt関数を参照。 \r
  * @example\r
@@ -2680,7 +2721,7 @@ DEV.Pwm.prototype=
        {\r
                try{\r
                        //LERにビットをセット\r
-                       return BCF.setBit(this._LER,i_mask,i_value*i_mask,0,i_db);\r
+                       return BCF.setBit(this._LER,i_mask,i_value,0,i_db);\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -2708,7 +2749,6 @@ DEV.Pwm.prototype=
        },\r
        /**\r
         * PCRに値を設定するBC\r
-        i_ch=1の場合、エッジモードは無視します。\r
         @private\r
         @param i_mask\r
         @param i_edge\r
@@ -2743,10 +2783,10 @@ DEV.Pwm.prototype=
         * 設定する値は、全てのPWMチャンネル(PIN)に共通な項目である。\r
         * @name LPC1769.Pwm#setOpt\r
         * @function\r
-        * @param {object as associative array} i_opt\r
+        * @param {associative array} i_opt\r
         * GPIOピンのコンフィグレーションパラメタである。必要な値を格納した連想配列で指定する。\r
         * 全ての値を省略することは出来ない。連想配列のメンバは以下の通り。\r
-        * <pre>{freq:int,phl:object as associative array}</pre>\r
+        * <pre>{freq:int,phl:associative array}</pre>\r
         * <ul>\r
         * <li>freq - PWMの基本周波数(Hz)である。この値は、全てのPWMチャンネルで共通である。</li>\r
         * <li>phl - ペリフェラルの共通パラメタである。LPC1769.Peripheral.setOpt関数のi_optに渡すパラメタである。詳細はLPC1769.Peripheral#setOptを参照。</li>\r
@@ -2776,8 +2816,8 @@ DEV.Pwm.prototype=
         * @function\r
         * @param {object as ピン識別子} i_pin\r
         * PWM機能を割り当てるPINの識別子である。\r
-        * @param {object as associative array} i_opt\r
-        * PemPinのコンストラクタに渡すオプション値。省略時は{duty:0,enable:1,pin:{sel:auto}}である\r
+        * @param {associative array} i_opt\r
+        * PwmPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.PwmPinを参照\r
         * @return {object as LPC1769.PwmPin}\r
         * LPC1769.PwmPinクラスのオブジェクトである。\r
         * @example\r
@@ -2803,8 +2843,8 @@ DEV.Pwm.prototype=
         * @function\r
         * @param {array[ピン識別子]} i_pin\r
         * Pwm機能を割り当てるPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
-        * @param {object as associative array} i_opt\r
-        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.PwmPort#setOptを参照。\r
+        * @param {associative array} i_opt\r
+        * PwmPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.PwmPortを参照。\r
         * @return {object as LPC1769.PwmPort}\r
         * LPC1769.PwmPortクラスのオブジェクトである。\r
         * @example\r
@@ -2827,20 +2867,23 @@ DEV.Pwm.prototype=
  * Pwm pinからPwmInfoを取得\r
  * @private\r
  */\r
-function pin2PwmPinInfo(i_pin)\r
+function makePwmPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var fn=DEV.completePinFunctionName(i_pin,"PWM");\r
-               //portとbitを得る(AD0だけしか管理しないよ)\r
-               var a=fn.substring(2).split(".");\r
-               var r={port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pin,fn)};\r
-               if(!isNaN(r.ch)){\r
-                       return r;\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var fn=DEV.completePinFunctionName(i_pins[i],"PWM");\r
+                       //portとbitを得る\r
+                       var a=fn.substring(2).split(".");\r
+                       if(isNaN(a[1])){\r
+                               throw new MiMicException(EE.INVALID_CFG);\r
+                       }\r
+                       ret.push({port:0,ch:parseInt(a[1]),pin_sel:DEV.getPinSelByFunctionName(i_pins[i],fn)});\r
                }\r
-               throw new MiMicException(EE.INVALID_CFG,"The pin has not PWM fuction.");\r
+               return ret;\r
        }catch(e){\r
-               throw new MiMicException(e);    \r
+               throw new MiMicException(e);\r
        }\r
 }\r
 /**\r
@@ -2870,15 +2913,12 @@ DEV.PwmPort=function PwmPort(i_pwm,i_pins,i_opt)
        try{\r
                this._pwm=i_pwm;\r
                //ピンセットを取得\r
-               this._pins=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       this._pins.push(pin2PwmPinInfo(i_pins[i]));\r
-               }\r
+               var pininfo=makePwmPinInfoArray(i_pins);\r
+\r
                //pinが全て同じポートに所属しているか確認\r
-               var p=this._pins[0].port;\r
-               for(var i=1;i<this._pins.length;i++){\r
-                       if(p!=this._pins[i].port){\r
+               var p=pininfo[0].port;\r
+               for(var i=1;i<pininfo.length;i++){\r
+                       if(p!=pininfo[i].port){\r
                                throw new MiMicException("Invalid pin combination.");\r
                        }\r
                }\r
@@ -2886,22 +2926,25 @@ DEV.PwmPort=function PwmPort(i_pwm,i_pins,i_opt)
                this._port=new DEV.Port(i_pwm._mcu,i_pins);\r
                this._port_no=p;\r
                \r
-               this._ler_mask=0;\r
-               this._pcr_mask=0;\r
-               for(var i=0;i<this._pins.length;i++){\r
-                       this._ler_mask|=(0x1<<this._pins[i].ch);\r
-                       this._pcr_mask|=(0x101<<this._pins[i].ch);\r
-               }               \r
-               var opt=isUndef(i_opt)?{pin:{}}:\r
-               {\r
-                       pin:isUndef(i_opt.pin)?{}:cloneAssoc(i_opt.pin),\r
-                       duty:i_opt.duty,\r
-                       enable:i_opt.enable\r
+\r
+               //ピンオプションの生成\r
+               var opt={};\r
+               if(isUndef(i_opt)){\r
+                       opt.pin=this._port.clonePinOptAssoc({});\r
+                       opt.duty=0;\r
+                       opt.enable=1;\r
+               }else{\r
+                       opt.pin=this._port.clonePinOptAssoc(isUndef(i_opt.pin)?{}:i_opt.pin);\r
+                       opt.duty=isUndef(i_opt.duty)?0:i_opt.duty;\r
+                       opt.enable=isUndef(i_opt.enable)?0:i_opt.enable;\r
                };\r
-               //デフォルト値のロード\r
-               if(isUndef(opt.pin.sel)){opt.pin.sel=this._PINSEL_AUTO_DETECT;}\r
-               if(isUndef(opt.duty)){opt.duty=0;}\r
-               if(isUndef(opt.enable)){opt.enable=1;}\r
+               //pinselの自動設定\r
+               for(var i=0;i<pininfo.length;i++){\r
+                       if(isUndef(opt.pin[i].sel)){\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
+                       }\r
+               }\r
+               this._pininfo=pininfo;\r
                this.setOpt(opt);\r
        }catch(e){\r
                throw new MiMicException(e);\r
@@ -2909,21 +2952,24 @@ DEV.PwmPort=function PwmPort(i_pwm,i_pins,i_opt)
 }\r
 DEV.PwmPort.prototype=\r
 {\r
-       _PINSEL_AUTO_DETECT:0x0fffffff,\r
        _pwm:null,\r
-       _pins:null,\r
+       _pininfo:null,\r
        _port_no:0,\r
        _port:null,\r
-       _pcr_mask:0,\r
-       _ler_mask:0,\r
        /**\r
         * PWMポートにオプション値を設定する。\r
-        * 関数は、ポートを構成する全てのピンに、同じ値を設定する。\r
         * 設定可能な値は、LPC1769.PwmPin#setOptと同じである。    \r
         * @name LPC1769.PwmPort#setOpt\r
         * @function\r
         * @param {object as associative array} i_opt\r
-        * LPC1769.PwmPin#setOptを参照。\r
+        * PWMピンのコンフィグレーションパラメタである。必要な値を格納した連想配列、またはその配列を指定する。\r
+        * 全てのピンに同じパラメータを指定する場合は、連装配列で指定する。個別に設定する場合は、連装配列を配列にして指定する。\r
+        * <pre>{i_opt:associative array}</pre>\r
+        * <ul>\r
+        * <li>pin(option) - array[{PIN_OPTION}] | {PIN_OPTION}</li>\r
+        * <li>enable(option) - array[{1bit int}] | {1bit int}</li>\r
+        * <li>duty(option) - array[{1bit int}] | {1bit int}</li>\r
+        * </ul>\r
         * @example\r
         * var mcu=new LPC1769.Mcu("192.168.128.39",true);\r
         * var pwm=mcu.getPeripheral("PWM",{freq:100});\r
@@ -2933,32 +2979,53 @@ DEV.PwmPort.prototype=
        setOpt:function setOpt(i_opt)\r
        {\r
                try{\r
+                       var pininfo=this._pininfo;\r
                        var db=new Array();\r
                        //BCの生成\r
                        var bc="";\r
-                       //i_optの展開\r
+                       //pinの設定\r
                        if(!isUndef(i_opt.pin)){\r
-                               var optset=new Array();\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       //pinselが_PINSEL_AUTO_DETECTならばauto。そうでなければundefinedも含めて設定\r
-                                       var s=(i_opt.pin.sel==this._PINSEL_AUTO_DETECT)?this._pins[i].pin_sel:i_opt.pin.sel;\r
-                                       optset.push({sel:s,mode:i_opt.pin.mode,od:i_opt.pin.od});\r
-                               }\r
-                               //portの設定\r
-                               bc+=this._port.BCF_setOpts(optset,db);\r
+                               bc+=this._port.BCF_setOpts(i_opt.pin,db);\r
                        }\r
-                       //PCRに値設定\r
+                       //enable設定\r
                        if(!isUndef(i_opt.enable)){\r
-                               bc+=this._pwm.BCF_setPCRbits(this._pcr_mask,0,i_opt.enable,db);\r
+                               var pcr_mask=0x0;\r
+                               var enable_bits=0x0;\r
+                               if(isArray(i_opt.enable)){\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               if(isUndef(i_opt.enable[i])){\r
+                                                       continue;\r
+                                               }\r
+                                               enable_bits|=((0x101*i_opt.enable[i])<<pininfo[i].ch);\r
+                                               pcr_mask|=(0x101<<pininfo[i].ch);\r
+                                       }\r
+                               }else{\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               pcr_mask|=(0x101<<pininfo[i].ch);\r
+                                       }\r
+                                       enable_bits=pcr_mask*i_opt.enable;\r
+                               }\r
+                               //edgeは固定でゼロ、enableはビット配列。\r
+                               bc+=this._pwm.BCF_setPCRbits(pcr_mask,0,enable_bits,db);\r
                        }\r
-                       //デューティ比を\r
+                       //dutyの設定\r
                        if(!isUndef(i_opt.duty)){\r
-                               //デューティ比を設定\r
-                               for(var i=0;i<this._pins.length;i++){\r
-                                       bc+=this._pwm.BCF_setMRnByDuty(this._pins[i].ch,i_opt.duty,db);\r
+                               var ler_value=0;\r
+                               if(isArray(i_opt.duty)){\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               if(isUndef(i_opt.duty[i])){\r
+                                                       continue;\r
+                                               }\r
+                                               bc+=this._pwm.BCF_setMRnByDuty(pininfo[i].ch,i_opt.duty[i],db);\r
+                                               ler_value|=(0x1<<pininfo[i].ch);\r
+                                       }\r
+                               }else{\r
+                                       for(var i=0;i<pininfo.length;i++){\r
+                                               bc+=this._pwm.BCF_setMRnByDuty(pininfo[i].ch,i_opt.duty,db);\r
+                                               ler_value|=(0x1<<pininfo[i].ch);\r
+                                       }\r
                                }\r
-                               //LERにセット\r
-                               bc+=this._pwm.BCF_setLERs(this._ler_mask,1,db);\r
+                               bc+=this._pwm.BCF_setLERs(ler_value,ler_value,db);\r
                        }\r
                        this._pwm._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                        return;\r
@@ -2967,12 +3034,13 @@ DEV.PwmPort.prototype=
                }\r
        },\r
        /**\r
-        * PWMポートのデューティ比をまとめて変更する。\r
+        * PWMポートのデューティ比を変更する。\r
+        * この関数は、LPC1769.PwmPort#setOpt関数へのショートカットである。\r
         * @name LPC1769.PwmPort#setDutys\r
         * @function\r
         * @param {array[double]} i_duty_array\r
         * デューティ比の配列である。0.0<=n<=1.0のdouble値を指定する。\r
-        * ã\83\9dã\83¼ã\83\88ã\82\92æ§\8bæ\88\90ã\81\99ã\82\8bã\83\94ã\83³ã\81®æ\95°ã\81 ã\81\91æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å¤\89æ\9b´ã\81\97ã\81ªã\81\84ã\83\94ã\83³ã\81«ã\81¯ã\80\81undefinedã\82\92æ\8c\87å®\9aã\81\99ã\82\8bã\81\93ã\81¨\r
+        * ã\83\9dã\83¼ã\83\88ã\82\92æ§\8bæ\88\90ã\81\99ã\82\8bã\83\94ã\83³ã\81®æ\95°ã\81 ã\81\91æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å¤\89æ\9b´ã\81\97ã\81ªã\81\84ã\83\94ã\83³ã\81«ã\81¯ã\80\81undefinedã\82\92æ\8c\87å®\9aã\81§ã\81\8dã\82\8b\r
         * @example\r
         * varmcu=new LPC1769.Mcu("192.168.128.39",true);\r
         * var pwm=mcu.getPeripheral("PWM",{freq:100});\r
@@ -2983,20 +3051,7 @@ DEV.PwmPort.prototype=
        setDutys:function setDutys(i_duty_array)\r
        {\r
                try{\r
-                       if(i_duty_array.length!=this._pins.length){\r
-                               throw new MiMicException();\r
-                       }\r
-                       var bc="";\r
-                       var db=new Array();\r
-                       //デューティ比をまとめてセット\r
-                       for(var i=0;i<this._pins.length;i++){\r
-                               if(!isUndef(i_duty_array[i])){\r
-                                       bc+=this._pwm.BCF_setMRnByDuty(this._pins[i].ch,i_duty_array[i],db);\r
-                               }\r
-                       }\r
-                       //LERにセット\r
-                       bc+=this._pwm.BCF_setLERs(this._ler_mask,1,db);\r
-                       this._pwm._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
+                       this.setOpt({duty:i_duty_array});\r
                }catch(e){\r
                        throw new MiMicException(e);\r
                }\r
@@ -3013,9 +3068,9 @@ DEV.PwmPort.prototype=
  * インスタンスを結びつけるAdcオブジェクト。\r
  * @param {object as pin識別子} i_pin\r
  * ピン識別子。指定できるのは、LPC1769.P?[?]である。\r
- * @param {object as associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{duty:100,enable:1,pin{sel:auto}}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * @param {associative array} i_opt\r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{duty:100,enable:1,pin{sel:undefined}}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create PWM1.0\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -3353,15 +3408,15 @@ DEV.Dac.prototype=
        },      \r
        /**\r
         * DA機能を持つピンを取得する。\r
-        * ピン識別子で指定されるピンをDAペリフェラルと結合して、DaPinを生成する。\r
-        * 関数は、DacPinオブジェクトのコンストラクタをコールして、DaPinを生成する。失敗すると、例外をスローする。\r
+        * ピン識別子で指定されるピンをDAペリフェラルと結合して、DacPinを生成する。\r
+        * 関数は、DacPinオブジェクトのコンストラクタをコールして、DacPinを生成する。失敗すると、例外をスローする。\r
         * 生成ルールについての詳細は、DacPinを参照。\r
         * @name LPC1769.Dac#getPin\r
         * @function\r
         * @param {object as ピン識別子} i_pin\r
-        * Da機能を割り当てるPINの識別子である。値は、LPC1769.Pn[m]のメンバ変数である。\r
+        * Dac機能を割り当てるPINの識別子である。値は、LPC1769.Pn[m]のメンバ変数である。\r
         * @param {associative array} i_opt\r
-        * AdcPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.DacPin.setOptを参照。\r
+        * DacPinのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPC1769.DacPinを参照。\r
         * @return {object as LPC1769.AdcPin}\r
         * LPC1769.DacPinクラスのオブジェクトである。\r
         * @example\r
@@ -3389,7 +3444,7 @@ DEV.Dac.prototype=
         * @param {array[ピン識別子]} i_pin\r
         * AD機能を割り当てるPINの識別子の配列である。値は、LPC1769.Pn[m]のメンバ変数である。\r
         * @param {associative array} i_opt\r
-        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.DacPort.setOptを参照。\r
+        * AdcPortのコンストラクタに渡すオプション値。省略時はundefinedである。詳細はLPCXpresso1769.DacPortを参照。\r
         * @return {object as LPC1769.DacPort}\r
         * LPC1769.DacPortクラスのオブジェクトである。\r
         * @example\r
@@ -3435,16 +3490,20 @@ DEV.Dac.prototype=
  * DA pinからDAInfoを取得\r
  * @private\r
  */\r
-function pin2DacPinInfo(i_pin)\r
+function makeDacPinInfoArray(i_pins)\r
 {\r
        try{\r
-               //pinの完全な機能名を得る。(得られれば機能がある。)\r
-               var func_name=DEV.completePinFunctionName(i_pin,"AOUT");\r
-               //portとbitを得る(AD0だけしか管理しないよ)\r
-               return {\r
-                       port:0,\r
-                       pin_sel:DEV.getPinSelByFunctionName(i_pin,func_name)\r
-               };//DAPinは1ピンのみなので、特に識別パラメータはない。\r
+               var ret=new Array();\r
+               for(var i=0;i<i_pins.length;i++){\r
+                       //pinの完全な機能名を得る。(得られれば機能がある。)\r
+                       var func_name=DEV.completePinFunctionName(i_pins[i],"AOUT");\r
+                       //portとbitを得る(AD0だけしか管理しないよ)\r
+                       ret.push({\r
+                               port:0,\r
+                               pin_sel:DEV.getPinSelByFunctionName(i_pins[i],func_name)\r
+                       });\r
+               };\r
+               return ret;\r
        }catch(e){\r
                throw new MiMicException(e);    \r
        }\r
@@ -3461,8 +3520,8 @@ function pin2DacPinInfo(i_pin)
  * @param {array[pin識別子]} i_pins\r
  * ピン識別子の配列。指定できるのは、LPC1769.P?[?]である。順番は、このインスタンスの返す値の順序に影響する。\r
  * @param {associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略時は{pin:{sel:%AUTO%},bias:0}を設定する。\r
- * 詳細はsetOpt関数を参照。 %AUTO%は関数がPin情報から自動的に決定する。(指定は出来ない。)\r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined},bias:0}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create [AOUT]\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -3473,12 +3532,8 @@ DEV.DacPort=function DacPort(i_adc,i_pins,i_opt)
 {\r
        try{\r
                this._dac=i_adc;\r
-               //ピンセットを取得\r
-               var pininf=new Array();\r
-               //pinに変換する。\r
-               for(var i=0;i<i_pins.length;i++){\r
-                       pininf.push(pin2DacPinInfo(i_pins[i]));\r
-               }\r
+               //Pin情報配列を生成\r
+               var pininfo=makeDacPinInfoArray(i_pins);\r
                //ポートの生成\r
                this._port=new DEV.Port(i_adc._mcu,i_pins);\r
                //ピンオプションの生成\r
@@ -3491,9 +3546,9 @@ DEV.DacPort=function DacPort(i_adc,i_pins,i_opt)
                        opt.bias=isUndef(i_opt.bias)?0:i_opt.bias;\r
                };\r
                //pinselの自動設定\r
-               for(var i=0;i<this._port.pins.length;i++){\r
+               for(var i=0;i<pininfo.length;i++){\r
                        if(isUndef(opt.pin[i].sel)){\r
-                               opt.pin[i].sel=pininf[i].pin_sel;\r
+                               opt.pin[i].sel=pininfo[i].pin_sel;\r
                        }\r
                }\r
                //ピンオプションの設定\r
@@ -3508,24 +3563,23 @@ DEV.DacPort.prototype=
        _port:null,\r
        /**\r
         * ポートにオプション値を設定する。\r
-        * 関数は、ポートを構成する全てのピンに、同一なオプション値を設定する。\r
         * 設定可能な値は、LPC1769.DacPin#setOptと同じである。\r
         * @name LPC1769.DacPort#setOpt\r
         * @function\r
-        * @param {associative array| array[associative array]} i_opt\r
-        * DAã\83\94ã\83³ã\81®ã\82³ã\83³ã\83\95ã\82£ã\82°ã\83¬ã\83¼ã\82·ã\83§ã\83³ã\83\91ã\83©ã\83¡ã\82¿ã\81§ã\81\82ã\82\8bã\80\82å¿\85è¦\81ã\81ªå\80¤ã\82\92æ ¼ç´\8dã\81\97ã\81\9fé\80£æ\83³é\85\8då\88\97ã\81§指定する。\r
-        * å\85¨ã\81¦ã\81®ã\83\94ã\83³ã\81«å\90\8cã\81\98ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\82\92æ\8c\87å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\81§æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å\80\8bå\88¥ã\81«è¨­å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\81«é\85\8då\88\97ã\82\92å\85¥ã\82\8cå­\90ã\81§指定する。\r
+        * @param {associative array | array[associative array]} i_opt\r
+        * DAã\83\94ã\83³ã\81®ã\82³ã\83³ã\83\95ã\82£ã\82°ã\83¬ã\83¼ã\82·ã\83§ã\83³ã\83\91ã\83©ã\83¡ã\82¿ã\81§ã\81\82ã\82\8bã\80\82å¿\85è¦\81ã\81ªå\80¤ã\82\92æ ¼ç´\8dã\81\97ã\81\9fé\80£æ\83³é\85\8då\88\97ã\80\81ã\81¾ã\81\9fã\81¯ã\81\9dã\81®é\85\8då\88\97ã\82\92指定する。\r
+        * å\85¨ã\81¦ã\81®ã\83\94ã\83³ã\81«å\90\8cã\81\98ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\82\92æ\8c\87å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\81§æ\8c\87å®\9aã\81\99ã\82\8bã\80\82å\80\8bå\88¥ã\81«è¨­å®\9aã\81\99ã\82\8bå ´å\90\88ã\81¯ã\80\81é\80£è£\85é\85\8då\88\97ã\82\92é\85\8då\88\97ã\81«ã\81\97ã\81¦指定する。\r
         * <pre>{i_opt:associative array}</pre>\r
         * <ul>\r
         * <li>pin(option)</li>\r
         * <li>bias(option)</li>\r
         * </ul>\r
-        * パラメータの詳細は、DacPin#setOptを参照。\r
+        * パラメータの詳細は、LPC1769.DacPin#setOptを参照。\r
         * @example\r
         * //ポートを構成する全てのピンに同じパラメータを設定する場合\r
-        * setOpt(pin:v1,bias:v1);\r
+        * setOpt({pin:{v1},bias:v1});\r
         * //ポートを構成するピンに個々にパラメータを設定する場合\r
-        * setOpt(pin:[{v1},{v2}],bias:[v1,v2...]);\r
+        * setOpt({pin:[{v1},{v2}],bias:[v1,v2...]});\r
         */     \r
        setOpt:function setOpt(i_opt)\r
        {\r
@@ -3593,8 +3647,8 @@ DEV.DacPort.prototype=
  * @param {object as pin識別子} i_pin\r
  * ピン識別子。指定できるのは、LPCXpresso1796.P?[?]である。\r
  * @param {associative array} i_opt\r
- * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:auto},bias:0}を設定する。\r
- * autoは、関数が自動的に決定するPINSELの値である。詳細はsetOpt関数を参照。 \r
+ * setOpt関数のi_optに渡すパラメタである。省略可能。省略時は{pin:{sel:undefined},bias:0}を設定する。\r
+ * 詳細はsetOpt関数を参照。 pin.selを省略(undefined)した場合、関数はpin.selの値をPin情報から自動的に決定する。\r
  * @example\r
  * //create AOUT\r
  * var mcu=new LPC1769.Mcu(“192.168.0.39”);\r
@@ -3614,16 +3668,16 @@ DEV.DacPin.prototype=
 {\r
        _port:null,\r
        /**\r
-        * æ\95°å\80¤ã\82\92DAå¤\89æ\8f\9bã\81\97ã\81¦ã\83\94ã\83³ã\81«å\87ºå\8a\9bã\81\97ã\81¾ã\81\99\r
+        * æ\95°å\80¤ã\82\92DAå¤\89æ\8f\9bã\81\97ã\81¦ã\83\94ã\83³ã\81«å\87ºå\8a\9bã\81\99ã\82\8b\r
         * @name LPC1769.DacPin#setValue\r
         * @function\r
         * @return {int}\r
-        * 10bitã\81®ADå¤\89æ\8f\9bå\80¤ã\82\92è¿\94ã\81\99ã\80\82å\80¤ã\81®æ\84\8få\91³ã\81¯ã\80\81UM10360 Chapter 30: LPC17xx Digital-to-Analog Converter (DAC)ã\82\92å\8f\82ç\85§ã\80\82\r
+        * 10bitのAD変換値。値の意味は、UM10360 Chapter 30: LPC17xx Digital-to-Analog Converter (DAC)を参照。\r
         * @example\r
         * //set value of DA0 pin\r
         * var mcu=new LPC1769.Mcu("192.168.0.39");\r
         * var pin=mcu.getPin("AOUT");\r
-        * pin.setValue(3939);\r
+        * pin.setValue(100);\r
         */\r
        setValue:function setValue(i_value)\r
        {\r
index 1d6e82f..b6cea45 100644 (file)
@@ -41,10 +41,10 @@ function init()
 <body id="body" onload="init();">\r
 <h1>MiMic DA sample</h1>\r
 <hr/>\r
-This sample controls PWM1[0](P2[0]) at 100Hz.\r
+This sample controls AOUT (P0[26])\r
 <div id="gage">-</div>\r
 <div id="sl" style="background-color:#00eeee;width:100%;height:100px">Touch or move cursor in this area.</div>\r
-MiMic Copyright (C) 2011 nyatla.jp All Rights Reserved.<br/>\r
+MiMic Copyright (C) 2011-2012 nyatla.jp All Rights Reserved.<br/>\r
 <a href="http://nyatla.jp/mimic/wp">http://nyatla.jp/mimic/wp</a>\r
 </div>\r
 </body>\r
index f07907a..6e8e9f5 100644 (file)
@@ -8,7 +8,7 @@ function init(){
        var pin=mcu.getPin(LPCXpresso1769.P0[22],"GPIO");\r
        pin.setOpt({dir:1,pin:{mode:1,od:0}});\r
        var i=0;\r
-       setInterval(function(){pin.setValue((i++)%2);},1000);\r
+//     setInterval(function(){pin.setValue((i++)%2);},1000);\r
 }      \r
 </script>\r
 </head>\r
diff --git a/misc/MiMicVM/tool/C0test.html b/misc/MiMicVM/tool/C0test.html
new file mode 100644 (file)
index 0000000..502c2c2
--- /dev/null
@@ -0,0 +1,197 @@
+\r
+<html>\r
+<head>\r
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
+<script src="MiMicCore.js"></script>   \r
+<script src="LPC1769.js"></script>     \r
+<script src="LPC1769.Mcu.js"></script> \r
+<script src="LPC1769769.Memory.js"></script>   \r
+<script src="LPC1769.Port.js"></script>\r
+<script src="LPC1769.Pin.js"></script>\r
+<script src="LPC1769.Gpio.js"></script>\r
+<script src="LPC1769.Peripheral.js"></script>  \r
+<script src="LPC1769.Adc.js"></script> \r
+<script src="LPC1769.Dac.js"></script> \r
+<script src="LPC1769.Pwm.js"></script> \r
+<script src="LPC1769.NativeInterface.js"></script>\r
+<script src="MbedM3.js"></script>\r
+\r
+<script type="text/javascript">\r
+function Logger(i_tag)\r
+{\r
+    var _data=new Array();\r
+    function getTimeStr()\r
+    {\r
+       var now=new Date();\r
+       var h=now.getHours();\r
+       var m=now.getMinutes();\r
+       var s=now.getSeconds();\r
+       return (h<10?"0":"")+h+":"+(m<10?"0":"")+m+":"+(s<10?"0":"")+s;\r
+           \r
+    }\r
+    var _t=this;\r
+    function addLine(s){\r
+       var n=i_tag.innerHTML+s+"\n";\r
+       var l=n.split("\n");\r
+       var m="";\r
+       var i=l.length-10;\r
+       if(i<0){i=0;};\r
+       for(;i<l.length-1;i++){\r
+           m+=l[i]+"\n";\r
+       }\r
+       i_tag.innerHTML=m;\r
+       i_tag.scrollTop=i_tag.scrollHeight-i_tag.offsetHeight;\r
+       \r
+    }\r
+    this.getData=function(){return _data;};\r
+    \r
+    this.addData=function(v){\r
+       addLine("[DATA]"+getTimeStr()+" #"+_data.length+" value:"+ v);\r
+       var now=new Date();\r
+       _data.push({"t":now.getTime(),"d":v});\r
+    };\r
+    this.addSmes=function(s){\r
+       addLine("[SMES]"+getTimeStr()+" "+s);\r
+    };\r
+    this.reset=function(){\r
+       _t.addSmes("Log data was cleared.");\r
+       _data.length=0;\r
+    };\r
+}\r
+\r
+\r
+var MIMIC_IP="192.168.128.39";\r
+function log(s)\r
+{\r
+}\r
+function testGpio()\r
+{\r
+       log("testGpio()");\r
+       var mcu=new LPC1769.Mcu("192.168.128.39");\r
+       //Port\r
+       var port=mcu.getPort([MbedM3.LED[0],MbedM3.LED[1],MbedM3.LED[2]],"GPIO");\r
+       port.setOpt({});\r
+       port.setOpt({pin:{od:0,mode:1},dir:1});\r
+       port.setOpt({dir:0});\r
+       port.setOpt({pin:[{od:0},{od:0},{od:0}],dir:[0,0,0]});\r
+       port.setOpt({pin:[{od:0},{od:0},{od:0}],dir:[1,1,undefined]});\r
+       port.setOpt({pin:[{od:0},{od:0},{od:0}],dir:1});\r
+       port.setValue(7);\r
+       alert(port.getValue());\r
+       port.outPatt([0,1,2,3,4,5,6,7]);        \r
+       //GpioPin\r
+       var pin=mcu.getPin(MbedM3.LED[0],"GPIO");\r
+       pin.setOpt({});\r
+       pin.setOpt({pin:{od:0,mode:1},dir:1});\r
+       pin.setOpt({dir:0});\r
+       pin.setOpt({pin:{od:0},dir:1});\r
+       pin.setValue(0);\r
+       pin.setValue(1);\r
+       alert(pin.getValue());\r
+       pin.outPatt([0,1,0,1,0,0,0]);\r
+       mcu.deactivate();\r
+       log("done");\r
+}\r
+function testAdc()\r
+{\r
+       log("testAdc()");\r
+       var mcu=new LPC1769.Mcu("192.168.128.39");\r
+       //Port\r
+       var port=mcu.getPort([MbedM3.PINNAME.AIN0,MbedM3.PINNAME.AIN1],"AD");\r
+       port.setOpt({});\r
+       port.setOpt({pin:[{od:0,mode:1},{od:0,mode:1}]});\r
+       alert(port.getValues());\r
+       //Pin\r
+       var pin=mcu.getPin(MbedM3.PINNAME.AIN0,"AD");\r
+       pin.setOpt({});\r
+       pin.setOpt({pin:{od:0,mode:1}});\r
+       alert(pin.getValue());\r
+       mcu.deactivate();\r
+       log("done");\r
+}\r
+function testDac()\r
+{\r
+       log("testDac()");\r
+       var mcu=new LPC1769.Mcu("192.168.128.39");\r
+       //Port\r
+       var port=mcu.getPort([MbedM3.PINNAME.AOUT],"DA");\r
+       port.setOpt({});\r
+       port.setOpt({pin:{od:0,mode:1},bias:0});\r
+       port.setOpt({pin:[{od:0,mode:1}],bias:[0]});\r
+       port.setValues([1023]);\r
+       alert("Is AOUT voltage 3.3V?");\r
+       //Pin\r
+       var pin=mcu.getPin(MbedM3.PINNAME.AOUT,"DA");\r
+       pin.setOpt({});\r
+       pin.setOpt({pin:{od:0,mode:1},bias:1});\r
+       pin.setOpt({bias:1});\r
+       pin.setValue(512);\r
+       alert("Is AOUT voltage 1.65V?");\r
+       mcu.deactivate();\r
+       log("done");\r
+}\r
+function testPwm()\r
+{\r
+       log("testPwm()");\r
+       var mcu=new LPC1769.Mcu("192.168.128.39");\r
+       //Port\r
+    var pwm=new LPC1769.Pwm(mcu,{freq:0.5});\r
+    var port=new LPC1769.PwmPort(pwm,[MbedM3.PINNAME.PWMOUT0,MbedM3.PINNAME.PWMOUT1,MbedM3.PINNAME.PWMOUT2]);\r
+       port.setOpt({});\r
+       port.setOpt({pin:{od:0,mode:3},enable:1});\r
+       port.setOpt({pin:[{od:0,mode:3},{od:0,mode:1},{od:0,mode:1}],enable:[1,0,1]});\r
+       port.setOpt({enable:[1,0,1]});\r
+       port.setOpt({duty:[0.9,0.5,0.1]});\r
+       alert("check PWMOUT!(0.9?)");\r
+       port.setDutys([0.1,0.5,0.9]);\r
+       alert("check PWMOUT!(0.1?)");\r
+       //Pin\r
+    var pin=new LPC1769.PwmPin(pwm,MbedM3.PINNAME.PWMOUT0);\r
+       pin.setOpt({});\r
+       pin.setOpt({pin:{od:0,mode:3},enable:1});\r
+       pin.setOpt({enable:1});\r
+       pin.setOpt({duty:0.5});\r
+       alert("check PWMOUT!(0.5?)");\r
+       pin.setDuty(0.9);\r
+       alert("check PWMOUT!(0.9?)");\r
+       mcu.deactivate();\r
+       log("done");\r
+}\r
+</script>\r
+</head>\r
+<body onload="">\r
+<h1>MiMic Javascript API</h1>\r
+<hr/>\r
+<table>\r
+<tr>\r
+       <td>\r
+<h2>GPIO</h2>\r
+<div id="gpio">\r
+       <button onclick="testGpio();" />test GPIO</button>\r
+</div>\r
+<h2>DAC</h2>\r
+<div id="dac">\r
+       <button onclick="testDac();" />test DAC</button>\r
+</div>\r
+<h2>ADC</h2>\r
+<div id="adc">\r
+       <button onclick="testAdc();" />test ADC</button>\r
+</div>\r
+<h2>PWM</h2>\r
+<div id="adc">\r
+       <button onclick="testPwm();" />test PWM</button>\r
+</div>\r
+<h2>NI</h2>\r
+<h2>Memory</h2>\r
+               \r
+       </td>\r
+       <td>\r
+               \r
+       </td>\r
+</tr>  \r
+</table>\r
+\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>\r
diff --git a/misc/MiMicVM/tool/adView.html b/misc/MiMicVM/tool/adView.html
new file mode 100644 (file)
index 0000000..c2646d3
--- /dev/null
@@ -0,0 +1,42 @@
+<head>\r
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
+<script src="../api.js/MiMicCore.js"></script> \r
+<script src="../api.js/LPCXPresso1769.All.js"></script>        \r
+<script type="text/javascript">\r
+\r
+function adddata(v)\r
+{\r
+       var canvas = document.getElementById('c1');\r
+       var ctx = canvas.getContext('2d');\r
+       ctx.fillStyle = "red";\r
+       ctx.fillRect(canvas.width-10,canvas.height-(v*140/4096),1,1);\r
+}\r
+function scroll()\r
+{\r
+       var canvas = document.getElementById('c1');\r
+       var ctx = canvas.getContext('2d');\r
+       var imagedata = ctx.getImageData(0,0,canvas.width,canvas.height);\r
+       ctx.putImageData(imagedata,-1,0);\r
+       \r
+}\r
+function init(){\r
+       var mcu=new LPCXpresso1769.Mcu("192.168.128.39");\r
+       var pin=mcu.getPin(LPCXpresso1769.P0[23],"AD");\r
+       pin.setOpt({pin:{od:0,mode:3}});\r
+       var i=0;\r
+       setInterval(function(){\r
+               var v=pin.getValue();\r
+               adddata(v);\r
+               document.getElementById("ad").value=v;\r
+       scroll();\r
+               \r
+       },10);\r
+}      \r
+</script>\r
+</head>\r
+<body onload="init();">\r
+<h1>MiMic for LPCXpressso1769 + AD graph(P0[23])</h1>\r
+<div>This sample shows LPCXpresso AD value of P[23]. Before running the program, opening this source code, set IP address to your Mimic address.</div>\r
+<canvas style="border-style:solid;border-width:1px;" id="c1" width="280" height="140"></canvas><br/>\r
+<input id="ad" type="text" value="." />\r
+</body>\r
diff --git a/misc/MiMicVM/tool/memDump.html b/misc/MiMicVM/tool/memDump.html
new file mode 100644 (file)
index 0000000..b75996d
--- /dev/null
@@ -0,0 +1,28 @@
+<head>\r
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
+<script src="../api.js/MiMicCore.js"></script> \r
+<script src="../api.js/MbedM3.All.js"></script>        \r
+<script type="text/javascript">\r
+function dump(){\r
+       var mcu=new MbedM3.Mcu(document.getElementById("ip").value);\r
+       var ma=new MbedM3.Memory(mcu);\r
+       var s="";\r
+       var bs=parseInt(document.getElementById("blocks").value);\r
+       var ad=parseInt(document.getElementById("memaddr").value);\r
+       var rd=ma.read32(ad,bs*4);\r
+       for(var i=0;i<bs;i++){\r
+               s+="0x"+MiMicLib.hexout(rd[i],8)+"\n"\r
+       }\r
+       document.getElementById("dump").innerHTML=s;\r
+       mcu.deactivate();\r
+}      \r
+</script>\r
+</head>\r
+<body onload="">\r
+<h1>Memory Dump</h1>\r
+MiMic IP Address<input id="ip" type="text" value="192.168.128.39"/><br/>\r
+Memory address(32bit)<input id="memaddr" type="text" value="0x20080000"/><br/>\r
+blocks address(32bit)<input id="blocks" type="text" value="1"/><br/>\r
+<button id="dumpbutton" onclick="dump()">dump</button><br/>\r
+<textarea id="dump" style="width:640px;height:480px"></textarea>\r
+</body>\r