OSDN Git Service

CALL命令の追加。
authornyatla <nyatla@47198e57-cb75-475f-84c4-a814cd6f29e0>
Sun, 13 Nov 2011 13:28:02 +0000 (13:28 +0000)
committernyatla <nyatla@47198e57-cb75-475f-84c4-a814cd6f29e0>
Sun, 13 Nov 2011 13:28:02 +0000 (13:28 +0000)
MiMicRemoteMCUを1.1に

git-svn-id: http://svn.osdn.jp/svnroot/mimic/trunk@99 47198e57-cb75-475f-84c4-a814cd6f29e0

13 files changed:
LICENCE.txt [new file with mode: 0644]
lib/src/mimicvm/NyLPC_cMiMicTxtCompiler.c
lib/src/mimicvm/NyLPC_cMiMicVM.c
lib/src/mimicvm/NyLPC_cMiMicVM.h
lib/src/mimicvm/NyLPC_cMiMicVM_protected.h
misc/MiMicVM/api.js/LPCXPresso1769.All-mini.js
misc/MiMicVM/api.js/LPCXPresso1769.All.js
misc/MiMicVM/api.js/MiMicCore.js
misc/MiMicVM/api.js/MiMicILAsm.js
misc/MiMicVM/api.js/demo/ad.html
misc/MiMicVM/api.js/demo/led_blink.html
projects/app.RemoteMCU/src/sketch.c
readme.ja.txt

diff --git a/LICENCE.txt b/LICENCE.txt
new file mode 100644 (file)
index 0000000..232b068
--- /dev/null
@@ -0,0 +1,40 @@
+MiMic\r
+\r
+Copyright (C)2011 Ryo Iizuka\r
+<nyatla39(at)gmail.com>\r
+\r
+\r
+This program is free software; you can redistribute it and/or\r
+modify it under the terms of the GNU Lesser General Public License\r
+as published by the Free Software Foundation; either version 3\r
+of the License, or (at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU Lesser General Public License for more details.\r
+\r
+You should have received a copy of the GNU Lesser General Public\r
+License along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+\r
+\r
+--\r
+MiMic\r
+\r
+Copyright (C)2011  Ryo Iizuka\r
+<nyatla39(at)gmail.com>\r
+\r
+\r
+このプログラムはフリーソフトウェアです。あなたはこれを、フリーソフトウェア\r
+財団によって発行されたGNU 劣等一般公衆利用許諾書(バージョン3か、 それ以降の\r
+バージョンのうちどれか)が定める条件の下で再頒布または改変することができます。\r
+\r
+このプログラムは有用であることを願って頒布されますが、*全くの無保証 *です。\r
+商業可能性の保証や特定目的への適合性は、言外に示されたものも 含め、\r
+全く存在しません。詳しくはGNU 劣等一般公衆利用許諾書をご覧ください。\r
+\r
+あなたはこのプログラムと共に、GNU 劣等一般公衆利用許諾書のコピーを一部\r
+受け取っているはずです。もし受け取っていなければ、<http://www.gnu.org/licenses/>\r
+をご覧ください。\r
+\r
index e926802..166d169 100644 (file)
@@ -300,10 +300,13 @@ static NyLPC_TBool bc2opc(const NyLPC_TChar* i_char,NyLPC_TcMiMicVM_OP_TYPE* o_o
                {"FA",NyLPC_TcMiMicVM_OP_TYPE_LD,NyLPC_TcMiMicVM_OPR_TYPE_WM_WM},\r
                {"FB",NyLPC_TcMiMicVM_OP_TYPE_LD,NyLPC_TcMiMicVM_OPR_TYPE_WM_H32},\r
 \r
-\r
                {"ZA",NyLPC_TcMiMicVM_OP_TYPE_NOP,NyLPC_TcMiMicVM_OPR_TYPE_NONE},\r
                {"ZB",NyLPC_TcMiMicVM_OP_TYPE_NOP,NyLPC_TcMiMicVM_OPR_TYPE_H08},\r
 \r
+               {"ZE",NyLPC_TcMiMicVM_OP_TYPE_CALL,NyLPC_TcMiMicVM_OPR_TYPE_WM},\r
+               {"ZF",NyLPC_TcMiMicVM_OP_TYPE_CALL,NyLPC_TcMiMicVM_OPR_TYPE_H32},\r
+\r
+\r
                {"ZZ",NyLPC_TcMiMicVM_OP_TYPE_EXIT,NyLPC_TcMiMicVM_OPR_TYPE_NONE},\r
                {NULL}\r
        };\r
index 8327f7f..e5bb4a9 100644 (file)
@@ -27,7 +27,7 @@
 #include <stdlib.h>\r
 #include "NyLPC_cMiMicVM_protected.h"\r
 \r
-static NyLPC_TUInt8 process_instruction(NyLPC_TcMiMicVM_t* i_inst,const union NyLPC_TcMiMicVM_TInstruction* ist);\r
+static NyLPC_TUInt8 process_instruction(NyLPC_TcMiMicVM_t* i_inst,const union NyLPC_TcMiMicVM_TInstruction* ist,NyLPC_TUInt32* o_code);\r
 \r
 \r
 \r
@@ -45,27 +45,46 @@ void NyLPC_cMiMicVM_initialize(NyLPC_TcMiMicVM_t* i_inst,struct NyLPC_TcMiMicVM_
 \r
 /**\r
  * 固定長命令+固定長データを実行します。\r
- * 関数の終了条件は、1.EXIT命令に到達する。2.インストラクションの終端に到達する。3.エラーが発生する。です。\r
+ * 関数の終了条件は、1.EXIT命令に到達する。2.インストラクションの終端に到達する。3.エラーが発生する。\r
  * \r
  */\r
-NyLPC_TBool NyLPC_cMiMicVM_run(NyLPC_TcMiMicVM_t* i_inst,const NyLPC_TUInt32* i_instruction,const NyLPC_TUInt16 i_size_of_instruction)\r
+NyLPC_TUInt32 NyLPC_cMiMicVM_run(NyLPC_TcMiMicVM_t* i_inst,const NyLPC_TUInt32* i_instruction,const NyLPC_TUInt16 i_size_of_instruction)\r
 {\r
        //データ部をgetstreamと連動させること。\r
+       NyLPC_TUInt32 retcode=NyLPC_cMiMicVM_RESULT_OK;\r
        NyLPC_TUInt16 pc=0;\r
        NyLPC_TUInt8 proc_in_byte;\r
-       i_inst->ret_code=0;\r
        if(i_size_of_instruction>0){\r
-               proc_in_byte=process_instruction(i_inst,(const union NyLPC_TcMiMicVM_TInstruction*)(i_instruction+pc));\r
+               proc_in_byte=process_instruction(i_inst,(const union NyLPC_TcMiMicVM_TInstruction*)(i_instruction+pc),&retcode);\r
                pc+=proc_in_byte;\r
                //プログラムの終端に到達するか、0バイト処理の場合にブレーク。\r
                while(proc_in_byte>0 && pc<i_size_of_instruction){\r
-                       proc_in_byte=process_instruction(i_inst,(const union NyLPC_TcMiMicVM_TInstruction*)(i_instruction+pc));\r
+                       proc_in_byte=process_instruction(i_inst,(const union NyLPC_TcMiMicVM_TInstruction*)(i_instruction+pc),&retcode);\r
                        pc+=proc_in_byte;\r
                }\r
        }\r
-       return i_inst->ret_code==0?NyLPC_TBool_TRUE:NyLPC_TBool_FALSE;\r
+       return retcode;\r
+}\r
+/**\r
+ * 出力ストリームへ32ビット値を書き出す。\r
+ */\r
+NyLPC_TBool NyLPC_cMiMicVM_sput(NyLPC_TcMiMicVM_t* i_inst,NyLPC_TUInt32 i_val)\r
+{\r
+       if(!i_inst->_event_handler->put_stream(i_inst->_event_handler,i_val)){\r
+               return NyLPC_TBool_FALSE;\r
+       }\r
+       return NyLPC_TBool_TRUE;\r
+}\r
+/**\r
+ * 入力ストリームから32ビット値を読み出す。\r
+ */\r
+NyLPC_TBool NyLPC_cMiMicVM_sget(NyLPC_TcMiMicVM_t* i_inst,NyLPC_TUInt32* o_val)\r
+{\r
+       if(!i_inst->_event_handler->get_stream(i_inst->_event_handler,o_val)){\r
+               return NyLPC_TBool_FALSE;\r
+       }\r
+       return NyLPC_TBool_TRUE;\r
 }\r
-\r
 \r
 \r
 \r
@@ -74,10 +93,11 @@ NyLPC_TBool NyLPC_cMiMicVM_run(NyLPC_TcMiMicVM_t* i_inst,const NyLPC_TUInt32* i_
  * インストラクションの境界値はチェックされないので、コンパイル時にチェックしておくこと。\r
  * @return\r
  * 処理したインストラクションのワード数(UInt32単位)。\r
- * çµ\82äº\86ã\81\97ã\81\9få ´å\90\88ã\81¯0ã\82\92è¿\94ã\81\99ã\80\82\82\92è¿\94ã\81\97ã\81\9fã\81¨ã\81\8dã\81¯ã\80\81ret_codeã\83¡ã\83³ã\83\90ã\82\92ã\83\81ã\82§ã\83\83ã\82¯ã\81\97ã\81¦ã\80\81ç\90\86ç\94±ã\82\92調ã\81¹ã\82\8bã\81\93ã\81¨\r
+ * çµ\82äº\86ã\81\97ã\81\9få ´å\90\88ã\81¯0ã\82\92è¿\94ã\81\99ã\80\82\82\92è¿\94ã\81\97ã\81\9fã\81¨ã\81\8dã\81¯ã\80\81ret_codeã\81«MiMicVMã\81®çµ\82äº\86ã\82³ã\83¼ã\83\89ã\82\92è¿\94ã\81\99\r
  */\r
-static NyLPC_TUInt8 process_instruction(NyLPC_TcMiMicVM_t* i_inst,const union NyLPC_TcMiMicVM_TInstruction* ist)\r
+static NyLPC_TUInt8 process_instruction(NyLPC_TcMiMicVM_t* i_inst,const union NyLPC_TcMiMicVM_TInstruction* ist,NyLPC_TUInt32* o_code)\r
 {\r
+       NyLPC_TUInt32 tret;\r
        switch(ist->op.opc){\r
        case NyLPC_TcMiMicVM_OP_TYPE_AND:\r
                switch(ist->op.oprtype){\r
@@ -258,8 +278,29 @@ static NyLPC_TUInt8 process_instruction(NyLPC_TcMiMicVM_t* i_inst,const union Ny
                        NyLPC_OnErrorGoto(ERROR);\r
                }\r
                break;\r
+       //native call\r
+       case NyLPC_TcMiMicVM_OP_TYPE_CALL:\r
+               switch(ist->op.oprtype){\r
+               case NyLPC_TcMiMicVM_OPR_TYPE_WM:\r
+                       tret=i_inst->_event_handler->native_call(i_inst->_event_handler,i_inst->wm[ist->wm_32.wm],i_inst);\r
+                       if(!NyLPC_cMiMicVM_RESULT_isOK(tret)){\r
+                               *o_code=tret;\r
+                               NyLPC_OnErrorGoto(ERROR_INHERIT);//エラー継承\r
+                       }\r
+                       break;\r
+               case NyLPC_TcMiMicVM_OPR_TYPE_H32:\r
+                       tret=i_inst->_event_handler->native_call(i_inst->_event_handler,ist->h32_64.h32,i_inst);\r
+                       if(!NyLPC_cMiMicVM_RESULT_isOK(tret)){\r
+                               *o_code=tret;\r
+                               NyLPC_OnErrorGoto(ERROR_INHERIT);//エラー継承\r
+                       }\r
+                       break;\r
+               default:\r
+                       NyLPC_OnErrorGoto(ERROR);\r
+               }\r
+               break;\r
        case NyLPC_TcMiMicVM_OP_TYPE_EXIT:\r
-               i_inst->ret_code=0;\r
+               *o_code=NyLPC_cMiMicVM_RESULT_OK;//OKに上書き\r
                return 0;\r
        default:\r
                NyLPC_OnErrorGoto(ERROR);\r
@@ -272,14 +313,17 @@ static NyLPC_TUInt8 process_instruction(NyLPC_TcMiMicVM_t* i_inst,const union Ny
        case NyLPC_TcMiMicVM_OPR_TYPE_WM:\r
        case NyLPC_TcMiMicVM_OPR_TYPE_H08:\r
        case NyLPC_TcMiMicVM_OPR_TYPE_H16:\r
+               *o_code=NyLPC_cMiMicVM_RESULT_OK;//OKに上書き\r
                return 1;\r
        case NyLPC_TcMiMicVM_OPR_TYPE_WM_H16:\r
        case NyLPC_TcMiMicVM_OPR_TYPE_WM_H32:\r
        case NyLPC_TcMiMicVM_OPR_TYPE_H32:\r
+               *o_code=NyLPC_cMiMicVM_RESULT_OK;//OKに上書き\r
                return 2;\r
        }\r
 ERROR:\r
-       i_inst->ret_code=1;\r
+       *o_code=NyLPC_cMiMicVM_RESULT_RUNTIME_NG;//ランタイムNG\r
+ERROR_INHERIT:\r
        return 0;\r
 }\r
 \r
index 1b4847a..0067f53 100644 (file)
@@ -30,6 +30,13 @@ struct NyLPC_TcMiMicVM_TEvent;
 \r
 #include "NyLPC_stdlib.h"\r
 \r
+#define NyLPC_cMiMicVM_RESULT_OK 0x00000000\r
+#define NyLPC_cMiMicVM_RESULT_NG 0x80000000\r
+#define NyLPC_cMiMicVM_RESULT_RUNTIME_NG (NyLPC_cMiMicVM_RESULT_NG|0x00010000)\r
+#define NyLPC_cMiMicVM_RESULT_RUNTIME_NG_UNKNOWN_CALL (NyLPC_cMiMicVM_RESULT_RUNTIME_NG|0x00000021)\r
+#define NyLPC_cMiMicVM_RESULT_RUNTIME_NG_CALL (NyLPC_cMiMicVM_RESULT_RUNTIME_NG|0x00000022)\r
+#define NyLPC_cMiMicVM_RESULT_isOK(v) ((v&0x80000000)==0x00000000)\r
+\r
 /**\r
  * MiMicVMのワークメモリの個数\r
  */\r
@@ -40,12 +47,25 @@ typedef NyLPC_TUInt8 NyLPC_TcMiMicVM_OPR_TYPE;
 \r
 typedef NyLPC_TBool (*NyLPC_TcMiMicVM_putStream)(struct NyLPC_TcMiMicVM_TEvent* i_evh,NyLPC_TUInt32 i_val);\r
 typedef NyLPC_TBool (*NyLPC_TcMiMicVM_getStream)(struct NyLPC_TcMiMicVM_TEvent* i_evh,NyLPC_TUInt32* o_val);\r
+/**\r
+ * MiMicVMのCALL命令ハンドラ。\r
+ * i_idに関数IDを指定する。\r
+ * @param i_id\r
+ * CALL命令のパラメタ\r
+ * @param i_vm\r
+ * VMのインスタンス。\r
+ * @return\r
+ * MiMicVMのエラーコード。\r
+ * 関数コールが成功したら、NyLPC_cMiMicVM_RESULT_OKを返すこと。エラーの場合はNyLPC_cMiMicVM_RESULT_NG又はカスタムエラーコードを返すこと。\r
+ */\r
+typedef NyLPC_TUInt32 (*NyLPC_TcMiMicVM_nativeCall)(struct NyLPC_TcMiMicVM_TEvent* i_evh,NyLPC_TUInt32 i_id,NyLPC_TcMiMicVM_t* i_vm);\r
 typedef void (*NyLPC_TcMiMicVM_sleep)(struct NyLPC_TcMiMicVM_TEvent* i_evh,NyLPC_TUInt32 i_sleep_in_msec);\r
 struct NyLPC_TcMiMicVM_TEvent\r
 {\r
        NyLPC_TcMiMicVM_putStream put_stream;\r
        NyLPC_TcMiMicVM_getStream get_stream;\r
        NyLPC_TcMiMicVM_sleep sleep;\r
+       NyLPC_TcMiMicVM_nativeCall native_call;\r
 };\r
 \r
 \r
@@ -53,12 +73,12 @@ struct NyLPC_TcMiMicVM
 {\r
        struct NyLPC_TcMiMicVM_TEvent* _event_handler;\r
        NyLPC_TUInt32 wm[NyLPC_TcMiMicVM_NUMBER_OF_WM];\r
-       NyLPC_TUInt8 ret_code;\r
 };\r
 void NyLPC_cMiMicVM_initialize(NyLPC_TcMiMicVM_t* i_inst,struct NyLPC_TcMiMicVM_TEvent* i_handler);\r
 #define NyLPC_cMiMicVM_finalize(i);\r
-NyLPC_TBool NyLPC_cMiMicVM_run(NyLPC_TcMiMicVM_t* i_inst,const NyLPC_TUInt32* i_instruction,const NyLPC_TUInt16 i_size_of_instruction);\r
-\r
+NyLPC_TUInt32 NyLPC_cMiMicVM_run(NyLPC_TcMiMicVM_t* i_inst,const NyLPC_TUInt32* i_instruction,const NyLPC_TUInt16 i_size_of_instruction);\r
+NyLPC_TBool NyLPC_cMiMicVM_sput(NyLPC_TcMiMicVM_t* i_inst,NyLPC_TUInt32 i_val);\r
+NyLPC_TBool NyLPC_cMiMicVM_sget(NyLPC_TcMiMicVM_t* i_inst,NyLPC_TUInt32* o_val);\r
 \r
 \r
 #endif /* NYLPC_CMIMICVM_H_ */\r
index b583e2d..287194b 100644 (file)
@@ -52,6 +52,7 @@
 \r
 #define NyLPC_TcMiMicVM_OP_TYPE_NOP            0x61\r
 #define NyLPC_TcMiMicVM_OP_TYPE_EXIT   0x62\r
+#define NyLPC_TcMiMicVM_OP_TYPE_CALL   0x63\r
 \r
 #define NyLPC_TcMiMicVM_OP_TYPE_LD             0x71\r
 \r
@@ -74,7 +75,7 @@
 #define NyLPC_TcMiMicVM_OPR_TYPE_WM_H16  0x13\r
 #define NyLPC_TcMiMicVM_OPR_TYPE_WM_H32  0x14\r
 #define NyLPC_TcMiMicVM_OPR_TYPE_WM      0x21\r
-#define NyLPC_TcMiMicVM_OPR_TYPE_H08      0x22\r
+#define NyLPC_TcMiMicVM_OPR_TYPE_H08     0x22\r
 #define NyLPC_TcMiMicVM_OPR_TYPE_H16     0x23\r
 #define NyLPC_TcMiMicVM_OPR_TYPE_H32     0x24\r
 \r
index 58b5856..3f38a5b 100644 (file)
@@ -1 +1 @@
-var LPCXpresso1769;(function(){var g=MiMicLib.isUndef;var a={_EE:function(n){return{NG:[n|0,"Unknown exception in LPCXpresso1769"],INVALID_ARG:[n|1,"Invalid argument"],INVALID_PIN:[n|2,"Invalid pin"],INVALID_CFG:[n|3,"Invalid configulation"],VM_RUNTIME:[n|4,"MVM runtime error"],}}(MiMicError.NG[0]|MiMicError.MID_MiMic|MiMicError.CAID_LPCXPresso1769),_BCF:{setBit:function m(p,r,o,q,n){try{n.push(p);n.push(~(r<<q));n.push((r&o)<<q);return"EA00EA01EA02DB0700AA0701AE0702DF0700"}catch(s){throw new MiMicException(s)}},setMem:function b(p,o,n){try{n.push(p);n.push(o);return"EA00EA01DF0100"}catch(q){throw new MiMicException(q)}},getMem:function i(o,n){try{n.push(o);return"EA00DB0000EE00"}catch(p){throw new MiMicException(p)}},READMEM:"EA00DB0000EE00",END:"ZZ.E"},FUNC_NAME:["GPIO","AD","DA","PWM"],PHL_NAME:["GPIO","ADC","DAC","PWM"],PHL:{WDT:[0,0,null],TIMER0:[0,2,1],TIMER1:[0,4,2],UART0:[0,6,3],UART1:[0,8,4],PWM1:[0,12,6],I2C0:[0,14,7],SPI:[0,16,8],RTC:[null,null,9],SSPI1:[0,20,10],DAC:[0,22,null],ADC:[0,24,12],CAN1:[0,26,13],CAN2:[0,28,14],ACF:[0,30,null],QEI:[1,0,18],GPIOINT:[1,2,15],PCB:[1,4,null],I2C1:[1,6,19],SSP0:[1,10,21],TIMER2:[1,12,22],TIMER3:[1,14,23],UART2:[1,16,24],UART3:[1,18,25],I2C2:[1,20,26],I2S:[1,22,27],RIT:[1,26,16],SYSCON:[1,28,null],PWM_MC:[1,30,17],GPDMA:[null,null,29],ENET:[null,null,30],USB:[null,null,31]},P0:[[0,0,0,0,["GPIO0.0","RD1","TXD3","SDA1"]],[0,0,0,1,["GPIO0.1","TD1","RXD3","SCL1"]],[0,0,0,2,["GPIO0.2","TXD0","AD0.7",null]],[0,0,0,3,["GPIO0.3","RXD0","AD0.6",null]],[0,0,0,4,["GPIO0.4","I2SRX_CLK","RD2","CAP2.0"]],[0,0,0,5,["GPIO0.5","I2SRX_WS","TD2","CAP2.1"]],[0,0,0,6,["GPIO0.6","I2SRX_SDA","SSEL1","MAT2.0"]],[0,0,0,7,["GPIO0.7","I2STX_CLK","SCK1","MAT2.1"]],[0,0,0,8,["GPIO0.8","I2STX_WS","MISO1","MAT2.2"]],[0,0,0,9,["GPIO0.9","I2STX_SDA","MOSI1","MAT2.3"]],[0,0,0,10,["GPIO0.10","TXD2","SDA2","MAT3.0"]],[0,0,0,11,["GPIO0.11","RXD2","SCL2","MAT3.1"]],null,null,null,[0,0,0,15,["GPIO0.15","TXD1","SCK0","SCK"]],[1,1,0,16,["GPIO0.16","RXD1","SSEL0","SSEL"]],[1,1,0,17,["GPIO0.17","CTS1","MISO0","MISO"]],[1,1,0,18,["GPIO0.18","DCD1","MOSI0","MOSI"]],[1,1,0,19,["GPIO0.19","DSR1",null,"SDA1"]],[1,1,0,20,["GPIO0.20","DTR1",null,"SCL1"]],[1,1,0,21,["GPIO0.21","RI1",null,"RD1"]],[1,1,0,22,["GPIO0.22","RTS1",null,"TD1"]],[1,1,0,23,["GPIO0.23","AD0.0","I2SRX_CLK","CAP3.0"]],[1,1,0,24,["GPIO0.24","AD0.1","I2SRX_WS","CAP3.1"]],[1,1,0,25,["GPIO0.25","AD0.2","I2SRX_SDA","TXD3"]],[1,1,0,26,["GPIO0.26","AD0.3","AOUT","RXD3"]],[1,null,null,22,["GPIO0.27","SDA0","USB_SDA",null]],[1,null,null,24,["GPIO0.28","SCL0","USB_SCL",null]],[1,null,0,29,["GPIO0.29","USB_D+",null,null]],[1,null,0,30,["GPIO0.30","USB_D-",null,null]],],P1:[[2,2,1,0,["GPIO1.0","ENET_TXD0",null,null]],[2,2,1,1,["GPIO1.1","ENET_TXD1",null,null]],null,null,[2,2,1,4,["GPIO1.4","ENET_TX_EN",null,null]],null,null,null,[2,2,1,8,["GPIO1.8","ENET_CRS",null,null]],[2,2,1,9,["GPIO1.9","ENET_RXD0",null,null]],[2,2,1,10,["GPIO1.10","ENET_RXD1",null,null]],null,null,null,[2,2,1,14,["GPIO1.14","ENET_RX_ER",null,null]],[2,2,1,15,["GPIO1.15","ENET_REF_CLK",null,null]],[3,3,1,16,["GPIO1.16","ENET_MDC",null,null]],[3,3,1,17,["GPIO1.17","ENET_MDIO",null,null]],[3,3,1,18,["GPIO1.18","USB_UP_LED","PWM1.1","CAP1.0"]],[3,3,1,19,["GPIO1.19","MCOA0","USB_PPWR","CAP1.1"]],[3,3,1,20,["GPIO1.20","MCI0","PWM1.2","SCK0"]],[3,3,1,21,["GPIO1.21","MCABORT","PWM1.3","SSEL0"]],[3,3,1,22,["GPIO1.22","MCOB0","USB_PWRD","MAT1.0"]],[3,3,1,23,["GPIO1.23","MCI1","PWM1.4","MISO0"]],[3,3,1,24,["GPIO1.24","MCI2","PWM1.5","MOSI0"]],[3,3,1,25,["GPIO1.25","MCOA1",null,"MAT1.1"]],[3,3,1,26,["GPIO1.26","MCOB1","PWM1.6","CAP0.0"]],[3,3,1,27,["GPIO1.27","CLKOUT","USB_OVRCR","CAP0.1"]],[3,3,1,28,["GPIO1.28","MCOA2","PCAP1.0","MAT0.0"]],[3,3,1,29,["GPIO1.29","MCOB2","PCAP1.1","MAT0.1"]],[3,3,1,30,["GPIO1.30",null,"VBUS","AD0.4"]],[3,3,1,31,["GPIO1.31",null,"SCK1","AD0.5"]],],P2:[[4,4,2,0,["GPIO2.0","PWM1.1","TXD1",null]],[4,4,2,1,["GPIO2.1","PWM1.2","RXD1",null]],[4,4,2,2,["GPIO2.2","PWM1.3","CTS1",null]],[4,4,2,3,["GPIO2.3","PWM1.4","DCD1",null]],[4,4,2,4,["GPIO2.4","PWM1.5","DSR1",null]],[4,4,2,5,["GPIO2.5","PWM1.6","DTR1",null]],[4,4,2,6,["GPIO2.6","PCAP1.0","RI1",null]],[4,4,2,7,["GPIO2.7","RD2","RTS1",null]],[4,4,2,8,["GPIO2.8","TD2","TXD2","ENET_MDC"]],[4,4,2,9,["GPIO2.9","USB_CONNECT","RXD2","ENET_MDIO"]],[4,4,2,10,["GPIO2.10","EINT0","NMI",null]],[4,4,2,11,["GPIO2.11","EINT1",null,"I2STX_CLK"]],[4,4,2,12,["GPIO2.12","EINT2",null,"I2STX_WS"]],[4,4,2,13,["GPIO2.13","EINT3",null,"I2STX_SDA"]],],P3:[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[7,7,3,25,["GPIO3.25",null,"MAT0.0","PWM1.2"]],[7,7,3,26,["GPIO3.26","STCLK","MAT0.1","PWM1.3"]],],P4:[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[9,9,4,28,["GPIO4.28","RX_MCLK","MAT2.0","TXD3"]],[9,9,4,29,["GPIO4.29","TX_MCLK","MAT2.1","RXD3"]]],completePinFunctionName:function j(p,o){try{for(var n=0;n<p[4].length;n++){if(p[4][n].indexOf(o)==0){return p[4][n]}}throw new MiMicException("The function name '"+o+"' is not unknown.")}catch(q){throw new MiMicException(q)}},getPinRegInfo:function d(n){try{return{s:n[0],m:n[1],o:n[2],smb:(n[3]%16)*2,ob:n[3]}}catch(o){throw new MiMicException(o)}},getPinSelByFunctionName:function h(o,q){try{for(var n=0;n<o[4].length;n++){if(o[4][n]==q){return n}}throw new MiMicException("The function name '"+q+"' has not function.")}catch(p){throw new MiMicException(p)}},hasPinFunctionName:function l(n,o){return n[4].indexOf(o)>=0}};a.I2c=function c(){throw new MiMicException("Not imprement.")};a.Dma=function k(){throw new MiMicException("Not imprement.")};a.Uart=function f(){throw new MiMicException("Not imprement.")};a.Usb=function e(){throw new MiMicException("Not imprement.")};LPCXpresso1769=a}());(function(){var f=LPCXpresso1769;var p=f._BCF;var a=f._EE;var e=MiMicLib.isUndef;function b(w){try{var y=["0000000","000000","00000","0000","000","00","0",""];var A="";for(var u=0;u<w.length;u++){var t=(w[u]>>>0);var x=t.toString(16).toLowerCase();if(x.length<1||x.length>8){throw new MiMicException(a.NG)}A+=y[x.length-1]+x}return A}catch(z){throw new MiMicException(z)}}function h(w){try{function x(A,z){for(var y=0;y<A.length;y++){if(A[y]==null){continue}if(f.hasPinFunctionName(A[y],z)){return A[y]}}return null}var v=[f.P0,f.P1,f.P2,f.P3,f.P4];for(var t=0;t<v.length;t++){var s=x(v[t],w);if(s!=null){return s}}throw new MiMicException("pin function '"+w+"' not found")}catch(u){throw new MiMicException(u)}}function n(v){try{var t={GPIO:"GPIO",AD:"ADC",DA:"DAC"};for(var s in t){if(v.indexOf(s)==0){return t[s]}}throw new MiMicException("Peripheral for "+i_pinfunction+" not found.")}catch(u){throw new MiMicException(u)}}f.Mcu=function o(v,t){try{this.events={onActivateChanged:null};this._phl_holder=[];this._mif=new MiMicRemoteMcuInterface(v);var s=e(t)?true:t;if(s){this.activate()}}catch(u){throw new MiMicException(u)}};f.Mcu.prototype={_mif:null,isActive:function m(){try{return this._mif.isConnected()}catch(s){throw new MiMicException(s)}},events:null,_phl_holder:null,getClockInfo:function g(){return{cclk:100*1000*1000}},activate:function d(){try{var s=this;if(this.isActive()){throw new MiMicException("Already activated!")}this._mif.connect(function(u){if(!u){if(s.events.onActivateChanged!=null){s.events.onActivateChanged(false)}}});if(this.events.onActivateChanged!=null){this.events.onActivateChanged(true)}}catch(t){throw new MiMicException(t)}},deactivate:function c(){try{if(!this.isActive()){throw new MiMicException("Already activated!")}this._mif.disconnect();if(this.events.onActivateChanged!=null){this.events.onActivateChanged(false)}}catch(s){throw new MiMicException(s)}},callMiMic:function l(){try{var t;switch(arguments.length){case 1:t=arguments[0];break;case 2:t=arguments[0]+b(arguments[1]);break;default:throw new MiMicException(s)}return this._mif.execBc(t)}catch(s){throw new MiMicException(s)}},callMiMicWithCheck:function k(){try{var s=this.callMiMic.apply(this,arguments);if(s.result!=0){throw new MiMicException(a.VM_RUNTIME,"Result="+s.toString())}return s}catch(t){throw new MiMicException(t)}},getPin:function q(){switch(arguments.length){case 1:var s=h(arguments[0]);var t=n(arguments[0]);return this.getPeripheral(t).getPin(s);case 2:var t=n(arguments[1]);return this.getPeripheral(t).getPin(arguments[0]);default:throw new MiMicException()}},getPort:function r(s){throw new MiMicException("Not implemented.")},getPeripheral:function i(s,t){if(e(this._phl_holder[s])){switch(s){case"GPIO":new f.Gpio(this,t);break;case"ADC":new f.Adc(this,t);break;case"PWM":new f.Pwm(this,t);break;default:throw new MiMicException("Unknown peripheral symbol "+s)}}else{if(!e(t)){throw new MiMicException()}}return this._phl_holder[s]},registerPhl:function j(t,s){try{if(!e(this._phl_holder[s])){throw new MiMicException("Peripheral symbol "+s+" is already exist on mcu.")}this._phl_holder[s]=t}catch(u){throw new MiMicException(u)}}}}());(function(){var f=LPCXpresso1769;var d=f._BCF;var a=f._EE;var b=MiMicLib.isUndef;f.Memory=function e(g,h){if(!b(h)){this._base=h}this._mcu=g};f.Memory.prototype={_base:0,_mcu:null,read32:function c(){try{function o(i){if(i%4!=0){throw new MiMicException(a.INVALID_ARG,"An alignment is not 32bit unit.")}}var n="";var h=new Array();var p=arguments[0];switch(arguments.length){case 1:if(!isNaN(p)){o(p);n=d.READMEM;h.push(this._base+p)}else{for(var k=0;k<p.length;k++){o(p[k]);n+=d.getMem(this._base+p[k],h)}}break;case 2:o(p);o(arguments[1]);var g=arguments[1]/4;for(var k=0;k<g;k++){n+=d.READMEM;h.push(this._base+p+k*4)}break;default:break}var j=this._mcu.callMiMicWithCheck(n+d.END,h).stream;return j.length==1?j[0]:j}catch(m){throw new MiMicException(m)}}}}());(function(){var g=LPCXpresso1769;var f=g._BCF;var c=g._EE;var e=MiMicLib.isUndef;g.Peripheral=function(h,i,k){try{if(e(i)){throw new MiMicException(c.INVALID_PHL)}this._mcu=h;this._phl=i;if(!e(k)){this.setOpt(k)}}catch(j){throw new MiMicException(j)}};g.Peripheral.prototype={_PCLKSEL:[1074774440,1074774444],_PCONP:1074774212,_phl:null,_mcu:null,_cache:{pclk:0},BCF_setOpt:function a(k,h){try{var j="";if(!e(k.power)){if(this._phl[2]==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PCONP.")}j+=f.setBit(this._PCONP,1,k.power,this._phl[2],h)}if(!e(k.clock)){if(this._phl[0]==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PCLKSEL.")}this._cache.pclk=k.clock;j+=f.setBit(this._PCLKSEL[this._phl[0]],3,k.clock,this._phl[1],h)}return j}catch(i){throw new MiMicException(i)}},setOpt:function b(k){try{var h=new Array();var j=this.BCF_setOpt(k,h);if(j.length==0){throw new MiMicException("i_opt is empty or invalid.")}this._mcu.callMiMicWithCheck(j+f.END,h)}catch(i){throw new MiMicException(i)}return},getPCLK:function d(){try{var h=[4,1,2,0];var i=h[this._cache.pclk];var j;if(i==0){if(this._phl===g.PHL.CAN1||this._phl===g.PHL.CAN2){j=this._mcu.getClockInfo().cclk/6}else{j=this._mcu.getClockInfo().cclk/8}}else{j=this._mcu.getClockInfo().cclk/i}return Math.round(j)}catch(k){throw new MiMicException(k)}}}}());(function(){var g=LPCXpresso1769;var e=g._BCF;var c=g._EE;var d=MiMicLib.isUndef;g.Pin=function f(h,i,k){try{if(d(i)){throw new MiMicException(c.INVALID_PIN)}this._mcu=h;this._pininfo=g.getPinRegInfo(i);if(!d(k)){this.setOpt(k)}}catch(j){throw new MiMicException(j)}};g.Pin.prototype={_PINSEL:[1073922048,1073922052,1073922056,1073922060,1073922064,null,null,1073922240,null,1073922084,1073922088],_PINMODE:[1073922112,1073922116,1073922120,1073922124,1073922128,1073922132,1073922136,1073922140,null,1073922148],_PINMODE_OD:[1073922152,1073922156,1073922160,1073922164,1073922168],_pininfo:null,_mcu:null,BCF_setOpt:function a(k,h){try{var j="";if(!d(k.sel)){j+=e.setBit(this._PINSEL[this._pininfo.s],3,k.sel,this._pininfo.smb,h)}if(!d(k.mode)){if(this._pininfo.m==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PINMODE. pininfo.")}j+=e.setBit(this._PINMODE[this._pininfo.m],3,k.mode,this._pininfo.smb,h)}if(!d(k.od)){if(this._pininfo.o==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PINMODE_OD. pininfo.")}j+=e.setBit(this._PINMODE_OD[this._pininfo.o],1,k.od,this._pininfo.ob,h)}return j}catch(i){throw new MiMicException(i)}},setOpt:function b(k){try{var h=new Array();var j=this.BCF_setOpt(k,h);if(j.length==0){throw new MiMicException("i_opt is empty or invalid.")}this._mcu.callMiMicWithCheck(j+e.END,h)}catch(i){throw new MiMicException(i)}return}}}());(function(){var a=LPCXpresso1769;var k=a._BCF;var l=a._EE;var c=MiMicLib.isUndef;a.Adc=function b(m,r){try{this._mcu=m;this._phl=new a.Peripheral(m,a.PHL.ADC);var o=c(r)?{phl:{}}:{phl:c(r.phl)?{}:cloneAssoc(r.phl),};if(c(o.phl.power)){o.phl.power=1}var q="";var n=new Array();q+=this.BCF_setOpt(o,n);q+=k.setMem(this._AD0CR,2098432,n);q+=k.setMem(this._AD0CR,2163968,n);this._mcu.callMiMicWithCheck(q+k.END,n);this._mcu.registerPhl(this,"ADC")}catch(p){throw new MiMicException(p)}};a.Adc.prototype={_PHL_DEF:{power:1},_AD0CR:1073954816,_AD0DR:[1073954832,1073954836,1073954840,1073954844,1073954848,1073954852,1073954856,1073954860],_phl:null,_mcu:null,BCF_setOpt:function h(p,m){try{var o="";if(!c(p.phl)){o+=this._phl.BCF_setOpt(p.phl,m)}return o}catch(n){throw new MiMicException(n)}},BCF_setSel:function i(o,n,m){try{return k.setBit(this._AD0CR,1,n,o,m)}catch(p){throw new MiMicException(p)}},BCF_getAD0DR:function g(n,m){try{return k.getMem(this._AD0DR[n],m)}catch(o){throw new MiMicException(o)}},setOpt:function f(p){try{var m=new Array();var o=this.BCF_setOpt(p,m);this._mcu.callMiMicWithCheck(o+k.END,m)}catch(n){throw new MiMicException(n)}},getPin:function j(m,o){try{return new a.AdcPin(this,m,o)}catch(n){throw new MiMicException(n)}}};a.AdcPin=function d(m,o,q){try{this._adc=m;this._pin=new a.Pin(m._mcu,o);this._adinfo=function(v){var t=a.completePinFunctionName(v,"AD");var s=t.substring(2).split(".");var u={port:0,ch:parseInt(s[1]),pin_sel:a.getPinSelByFunctionName(v,t)};if(!isNaN(u.ch)){return u}throw new MiMicException(l.INVALID_CFG,"The pin has not AD fuction.")}(o);var n=c(q)?{pin:{}}:{pin:c(q.pin)?{}:cloneAssoc(q.pin)};n.sel=1;if(c(n.pin.sel)){n.pin.sel=this._adinfo.pin_sel}this.setOpt(n)}catch(p){throw new MiMicException(p)}};a.AdcPin.prototype={_adc:null,_pin:null,_adinfo:null,getValue:function e(){try{var m=new Array();var p=this._adc.BCF_getAD0DR(this._adinfo.ch,m);var n=this._adc._mcu.callMiMicWithCheck(p+k.END,m);return(n.stream[0]>>4)&4095}catch(o){throw new MiMicException(o)}},setOpt:function f(p){try{var o="";var m=new Array();if(!c(p.pin)){o+=this._pin.BCF_setOpt(p.pin,m)}if(!c(p.sel)){o+=this._adc.BCF_setSel(this._adinfo.ch,p.sel,m)}this._adc._mcu.callMiMicWithCheck(o+k.END,m);return}catch(n){throw new MiMicException(n)}}}}());(function(){var a=LPCXpresso1769;var n=a._BCF;var o=a._EE;var c=MiMicLib.isUndef;var h=MiMicLib.cloneAssoc;a.Gpio=function i(p,r){try{this._mcu=p;p.registerPhl(this,"GPIO")}catch(q){throw new MiMicException(q)}};a.Gpio.prototype={_FIO_DIR:[537509888,537509920,537509952,537509984,537510016],_FIO_PIN:[537509908,537509940,537509972,537510004,537510036],_FIO_SET:[537509912,537509944,537509976,537510008,537510040],_FIO_CLR:[537509916,537509948,537509980,537510012,537510044],_FIO_MASK:[537509904,537509936,537509968,537510000,537510032],_mcu:null,BCF_setDir:function k(r,q,s,p){try{return n.setBit(this._FIO_DIR[r],1,s,q,p)}catch(t){throw new MiMicException(t)}},BCF_setValue:function b(s,r,q,p){try{if(q){p.push(this._FIO_SET[s],this._FIO_MASK[s],~(1<<r))}else{p.push(this._FIO_CLR[s],this._FIO_MASK[s],~(1<<r))}return"EA00EA01EA02DF0201FB02ffffffffDF0200"}catch(t){throw new MiMicException(t)}},BCF_getValue:function d(r,q,p){try{p.push(this._FIO_PIN[r],this._FIO_MASK[r],~(1<<q));return"EA00EA01EA02DF0201DB0300EE03"}catch(s){throw new MiMicException(s)}},getPin:function j(p,r){try{return new a.GpioPin(this,p,r)}catch(q){throw new MiMicException(q)}}};a.GpioPin=function l(q,r,t){try{this._gpio=q;this._pin=new a.Pin(q._mcu,r);this._gpioinfo=function(x){var v=a.completePinFunctionName(x,"GPIO");var u=v.substring(4).split(".");var w={port:parseInt(u[0]),bit:parseInt(u[1]),pin_sel:a.getPinSelByFunctionName(x,v)};if(!isNaN(w.port)&&!isNaN(w.bit)){return w}throw new MiMicException(o.INVALID_CFG,"The pin has not GPIO fuction.")}(r);var p=c(t)?{pin:{}}:{dir:t.dir,pin:c(t.pin)?{}:h(t.pin)};if(c(p.pin.sel)){p.pin.sel=this._gpioinfo.pin_sel}this.setOpt(p)}catch(s){throw new MiMicException(s)}};a.GpioPin.prototype={_gpio:null,_pin:null,_gpioinfo:null,setOpt:function g(s){try{var r="";var p=new Array();if(!c(s.dir)){r+=this._gpio.BCF_setDir(this._gpioinfo.port,this._gpioinfo.bit,s.dir,p)}if(!c(s.pin)){r+=this._pin.BCF_setOpt(s.pin,p)}this._gpio._mcu.callMiMicWithCheck(r+n.END,p)}catch(q){throw new MiMicException(q)}},setValue:function e(q){try{var s="";var p=new Array();s+=this._gpio.BCF_setValue(this._gpioinfo.port,this._gpioinfo.bit,q,p);this._gpio._mcu.callMiMicWithCheck(s+n.END,p)}catch(r){throw new MiMicException(r)}},getValue:function f(){try{var s="";var p=new Array();s+=this._gpio.BCF_getValue(this._gpioinfo.port,this._gpioinfo.bit,p);var q=this._gpio._mcu.callMiMicWithCheck(s+n.END,p);return(q.stream[0]>>this._gpioinfo.bit)&1}catch(r){throw new MiMicException(r)}},outPatt:function m(q){try{var t="";var p=new Array();for(var r=0;r<q.length;r++){t+=this._gpio.BCF_setValue(this._gpioinfo.port,this._gpioinfo.bit,q[r],p)}this._gpio._mcu.callMiMicWithCheck(t+n.END,p)}catch(s){throw new MiMicException(s)}},}}());(function(){var a=LPCXpresso1769;var n=a._BCF;var o=a._EE;var b=MiMicLib.isUndef;var g=MiMicLib.cloneAssoc;a.Pwm=function d(p,u){try{this._mcu=p;this._phl=new a.Peripheral(p,a.PHL.PWM1);var r=b(u)?{phl:{}}:{phl:b(u.phl)?{}:g(u.phl),freq:u.freq};if(b(r.phl.power)){r.phl.power=1}if(b(r.phl.clock)){r.phl.clock=0}if(b(r.freq)){r.freq=100}var t="";var q=new Array();t+=this.BCF_setOpt(r,q);t+=n.setMem(this._PC,0,q);t+=n.setMem(this._PCR,0,q);t+=n.setMem(this._CTCR,0,q);t+=n.setMem(this._TCR,0,q);t+=n.setMem(this._TC,0,q);t+=n.setMem(this._TCR,9,q);this._mcu.callMiMicWithCheck(t+n.END,q);this._mcu.registerPhl(this,"PWM")}catch(s){throw new MiMicException(s)}};a.Pwm.prototype={_cache:{mr0:0},_TCR:1073840132,_TC:1073840136,_PR:1073840140,_PC:1073840144,_MCR:1073840152,_PCR:1073840204,_LER:1073840208,_CTCR:1073840240,_MRn:[1073840152,1073840156,1073840160,1073840164,1073840192,1073840196,1073840200],_phl:null,_mcu:null,BCF_setOpt:function h(u,p){try{var t="";var r;var q;if(!b(u.phl)){t+=this._phl.BCF_setOpt(u.phl,p)}if(!b(u.freq)){q=Math.round(this._phl.getPCLK()/u.freq);if(q<=0){throw new MiMicException("The peripheral clock too small.")}t+=this.BCF_setMRn(0,q,p);t+=this.BCF_setLER(0,p);this._cache.mr0=q}return t}catch(s){throw new MiMicException(s)}},BCF_setLER:function e(q,p){return n.setBit(this._LER,1,1,q,p)},BCF_setMRn:function j(r,q,p){try{return n.setMem(this._MRn[r],q,p)}catch(s){throw new MiMicException(s)}},BCF_setMRnByDuty:function m(q,r,p){try{return this.BCF_setMRn(q,Math.round(r*this._cache.mr0),p)}catch(s){throw new MiMicException(s)}},BCF_setPCRbit:function l(u,r,s,q){try{var p,t;p=t=0;if(!b(r)){t|=r;p|=1}if(!b(s)){t|=(s<<8);p|=256}return n.setBit(this._PCR,p,t,u,q)}catch(w){throw new MiMicException(w)}},setOpt:function f(s){try{var p=new Array();var r=this.BCF_setOpt(s,p);this._mcu.callMiMicWithCheck(r+n.END,p)}catch(q){throw new MiMicException(q)}},getPin:function i(p,r){try{return new a.PwmPin(this,p,r)}catch(q){throw new MiMicException(q)}}};a.PwmPin=function k(p,r,t){try{this._pwm=p;this._pin=new a.Pin(p._mcu,r);this._pwminfo=function(x){var v=a.completePinFunctionName(x,"PWM");var u=v.substring(2).split(".");var w={port:0,ch:parseInt(u[1]),pin_sel:a.getPinSelByFunctionName(x,v)};if(!isNaN(w.ch)){return w}throw new MiMicException(o.INVALID_CFG,"The pin has not PWM fuction.")}(r);var q=b(t)?{pin:{}}:{pin:b(t.pin)?{}:g(t.pin),duty:t.duty,enable:t.enable};if(b(q.pin.sel)){q.pin.sel=this._pwminfo.pin_sel}if(b(q.duty)){q.duty=0}if(b(q.enable)){q.enable=1}this.setOpt(q)}catch(s){throw new MiMicException(s)}};a.PwmPin.prototype={_pwm:null,_pin:null,_pwminfo:null,BCF_setOpt:function h(s,p){try{var r="";if(!b(s.pin)){r+=this._pin.BCF_setOpt(s.pin,p)}if(!b(s.enable)){r+=this._pwm.BCF_setPCRbit(this._pwminfo.ch,0,s.enable,p)}if(!b(s.duty)){r+=this._pwm.BCF_setMRnByDuty(this._pwminfo.ch,s.duty,p);r+=this._pwm.BCF_setLER(this._pwminfo.ch,p)}return r}catch(q){throw new MiMicException(q)}},setOpt:function f(s){try{var p=new Array();var r=this.BCF_setOpt(s,p);this._pwm._mcu.callMiMicWithCheck(r+n.END,p)}catch(q){throw new MiMicException(q)}},setDuty:function c(p){try{this.setOpt({duty:p})}catch(q){throw new MiMicException(q)}}}}());
\ No newline at end of file
+var LPCXpresso1769;(function(){var g=MiMicLib.isUndef;var a={_EE:function(n){return{NG:[n|0,"Unknown exception in LPCXpresso1769"],INVALID_ARG:[n|1,"Invalid argument"],INVALID_PIN:[n|2,"Invalid pin"],INVALID_CFG:[n|3,"Invalid configulation"],VM_RUNTIME:[n|4,"MVM runtime error"],}}(MiMicError.NG[0]|MiMicError.MID_MiMic|MiMicError.CAID_LPCXPresso1769),_BCF:{setBit:function m(p,r,o,q,n){try{n.push(p);n.push(~(r<<q));n.push((r&o)<<q);return"EA00EA01EA02DB0700AA0701AE0702DF0700"}catch(s){throw new MiMicException(s)}},setMem:function b(p,o,n){try{n.push(p);n.push(o);return"EA00EA01DF0100"}catch(q){throw new MiMicException(q)}},getMem:function i(o,n){try{n.push(o);return"EA00DB0000EE00"}catch(p){throw new MiMicException(p)}},READMEM:"EA00DB0000EE00",END:"ZZ.E"},FUNC_NAME:["GPIO","AD","DA","PWM"],PHL_NAME:["GPIO","ADC","DAC","PWM"],PHL:{WDT:[0,0,null],TIMER0:[0,2,1],TIMER1:[0,4,2],UART0:[0,6,3],UART1:[0,8,4],PWM1:[0,12,6],I2C0:[0,14,7],SPI:[0,16,8],RTC:[null,null,9],SSPI1:[0,20,10],DAC:[0,22,null],ADC:[0,24,12],CAN1:[0,26,13],CAN2:[0,28,14],ACF:[0,30,null],QEI:[1,0,18],GPIOINT:[1,2,15],PCB:[1,4,null],I2C1:[1,6,19],SSP0:[1,10,21],TIMER2:[1,12,22],TIMER3:[1,14,23],UART2:[1,16,24],UART3:[1,18,25],I2C2:[1,20,26],I2S:[1,22,27],RIT:[1,26,16],SYSCON:[1,28,null],PWM_MC:[1,30,17],GPDMA:[null,null,29],ENET:[null,null,30],USB:[null,null,31]},P0:[[0,0,0,0,["GPIO0.0","RD1","TXD3","SDA1"]],[0,0,0,1,["GPIO0.1","TD1","RXD3","SCL1"]],[0,0,0,2,["GPIO0.2","TXD0","AD0.7",null]],[0,0,0,3,["GPIO0.3","RXD0","AD0.6",null]],[0,0,0,4,["GPIO0.4","I2SRX_CLK","RD2","CAP2.0"]],[0,0,0,5,["GPIO0.5","I2SRX_WS","TD2","CAP2.1"]],[0,0,0,6,["GPIO0.6","I2SRX_SDA","SSEL1","MAT2.0"]],[0,0,0,7,["GPIO0.7","I2STX_CLK","SCK1","MAT2.1"]],[0,0,0,8,["GPIO0.8","I2STX_WS","MISO1","MAT2.2"]],[0,0,0,9,["GPIO0.9","I2STX_SDA","MOSI1","MAT2.3"]],[0,0,0,10,["GPIO0.10","TXD2","SDA2","MAT3.0"]],[0,0,0,11,["GPIO0.11","RXD2","SCL2","MAT3.1"]],null,null,null,[0,0,0,15,["GPIO0.15","TXD1","SCK0","SCK"]],[1,1,0,16,["GPIO0.16","RXD1","SSEL0","SSEL"]],[1,1,0,17,["GPIO0.17","CTS1","MISO0","MISO"]],[1,1,0,18,["GPIO0.18","DCD1","MOSI0","MOSI"]],[1,1,0,19,["GPIO0.19","DSR1",null,"SDA1"]],[1,1,0,20,["GPIO0.20","DTR1",null,"SCL1"]],[1,1,0,21,["GPIO0.21","RI1",null,"RD1"]],[1,1,0,22,["GPIO0.22","RTS1",null,"TD1"]],[1,1,0,23,["GPIO0.23","AD0.0","I2SRX_CLK","CAP3.0"]],[1,1,0,24,["GPIO0.24","AD0.1","I2SRX_WS","CAP3.1"]],[1,1,0,25,["GPIO0.25","AD0.2","I2SRX_SDA","TXD3"]],[1,1,0,26,["GPIO0.26","AD0.3","AOUT","RXD3"]],[1,null,null,22,["GPIO0.27","SDA0","USB_SDA",null]],[1,null,null,24,["GPIO0.28","SCL0","USB_SCL",null]],[1,null,0,29,["GPIO0.29","USB_D+",null,null]],[1,null,0,30,["GPIO0.30","USB_D-",null,null]],],P1:[[2,2,1,0,["GPIO1.0","ENET_TXD0",null,null]],[2,2,1,1,["GPIO1.1","ENET_TXD1",null,null]],null,null,[2,2,1,4,["GPIO1.4","ENET_TX_EN",null,null]],null,null,null,[2,2,1,8,["GPIO1.8","ENET_CRS",null,null]],[2,2,1,9,["GPIO1.9","ENET_RXD0",null,null]],[2,2,1,10,["GPIO1.10","ENET_RXD1",null,null]],null,null,null,[2,2,1,14,["GPIO1.14","ENET_RX_ER",null,null]],[2,2,1,15,["GPIO1.15","ENET_REF_CLK",null,null]],[3,3,1,16,["GPIO1.16","ENET_MDC",null,null]],[3,3,1,17,["GPIO1.17","ENET_MDIO",null,null]],[3,3,1,18,["GPIO1.18","USB_UP_LED","PWM1.1","CAP1.0"]],[3,3,1,19,["GPIO1.19","MCOA0","USB_PPWR","CAP1.1"]],[3,3,1,20,["GPIO1.20","MCI0","PWM1.2","SCK0"]],[3,3,1,21,["GPIO1.21","MCABORT","PWM1.3","SSEL0"]],[3,3,1,22,["GPIO1.22","MCOB0","USB_PWRD","MAT1.0"]],[3,3,1,23,["GPIO1.23","MCI1","PWM1.4","MISO0"]],[3,3,1,24,["GPIO1.24","MCI2","PWM1.5","MOSI0"]],[3,3,1,25,["GPIO1.25","MCOA1",null,"MAT1.1"]],[3,3,1,26,["GPIO1.26","MCOB1","PWM1.6","CAP0.0"]],[3,3,1,27,["GPIO1.27","CLKOUT","USB_OVRCR","CAP0.1"]],[3,3,1,28,["GPIO1.28","MCOA2","PCAP1.0","MAT0.0"]],[3,3,1,29,["GPIO1.29","MCOB2","PCAP1.1","MAT0.1"]],[3,3,1,30,["GPIO1.30",null,"VBUS","AD0.4"]],[3,3,1,31,["GPIO1.31",null,"SCK1","AD0.5"]],],P2:[[4,4,2,0,["GPIO2.0","PWM1.1","TXD1",null]],[4,4,2,1,["GPIO2.1","PWM1.2","RXD1",null]],[4,4,2,2,["GPIO2.2","PWM1.3","CTS1",null]],[4,4,2,3,["GPIO2.3","PWM1.4","DCD1",null]],[4,4,2,4,["GPIO2.4","PWM1.5","DSR1",null]],[4,4,2,5,["GPIO2.5","PWM1.6","DTR1",null]],[4,4,2,6,["GPIO2.6","PCAP1.0","RI1",null]],[4,4,2,7,["GPIO2.7","RD2","RTS1",null]],[4,4,2,8,["GPIO2.8","TD2","TXD2","ENET_MDC"]],[4,4,2,9,["GPIO2.9","USB_CONNECT","RXD2","ENET_MDIO"]],[4,4,2,10,["GPIO2.10","EINT0","NMI",null]],[4,4,2,11,["GPIO2.11","EINT1",null,"I2STX_CLK"]],[4,4,2,12,["GPIO2.12","EINT2",null,"I2STX_WS"]],[4,4,2,13,["GPIO2.13","EINT3",null,"I2STX_SDA"]],],P3:[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[7,7,3,25,["GPIO3.25",null,"MAT0.0","PWM1.2"]],[7,7,3,26,["GPIO3.26","STCLK","MAT0.1","PWM1.3"]],],P4:[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[9,9,4,28,["GPIO4.28","RX_MCLK","MAT2.0","TXD3"]],[9,9,4,29,["GPIO4.29","TX_MCLK","MAT2.1","RXD3"]]],completePinFunctionName:function j(p,o){try{for(var n=0;n<p[4].length;n++){if(p[4][n].indexOf(o)==0){return p[4][n]}}throw new MiMicException("The function name '"+o+"' is not unknown.")}catch(q){throw new MiMicException(q)}},getPinRegInfo:function d(n){try{return{s:n[0],m:n[1],o:n[2],smb:(n[3]%16)*2,ob:n[3]}}catch(o){throw new MiMicException(o)}},getPinSelByFunctionName:function h(o,q){try{for(var n=0;n<o[4].length;n++){if(o[4][n]==q){return n}}throw new MiMicException("The function name '"+q+"' has not function.")}catch(p){throw new MiMicException(p)}},hasPinFunctionName:function l(n,o){return n[4].indexOf(o)>=0}};a.I2c=function c(){throw new MiMicException("Not imprement.")};a.Dma=function k(){throw new MiMicException("Not imprement.")};a.Uart=function f(){throw new MiMicException("Not imprement.")};a.Usb=function e(){throw new MiMicException("Not imprement.")};LPCXpresso1769=a}());(function(){var f=LPCXpresso1769;var p=f._BCF;var a=f._EE;var e=MiMicLib.isUndef;function b(w){try{var y=["0000000","000000","00000","0000","000","00","0",""];var A="";for(var u=0;u<w.length;u++){var t=(w[u]>>>0);var x=t.toString(16).toLowerCase();if(x.length<1||x.length>8){throw new MiMicException(a.NG)}A+=y[x.length-1]+x}return A}catch(z){throw new MiMicException(z)}}function h(w){try{function x(A,z){for(var y=0;y<A.length;y++){if(A[y]==null){continue}if(f.hasPinFunctionName(A[y],z)){return A[y]}}return null}var v=[f.P0,f.P1,f.P2,f.P3,f.P4];for(var t=0;t<v.length;t++){var s=x(v[t],w);if(s!=null){return s}}throw new MiMicException("pin function '"+w+"' not found")}catch(u){throw new MiMicException(u)}}function n(v){try{var t={GPIO:"GPIO",AD:"ADC",DA:"DAC"};for(var s in t){if(v.indexOf(s)==0){return t[s]}}throw new MiMicException("Peripheral for "+i_pinfunction+" not found.")}catch(u){throw new MiMicException(u)}}f.Mcu=function o(v,t){try{this.events={onActivateChanged:null};this._phl_holder=[];this._mif=new MiMicRemoteMcuInterface(v);var s=e(t)?true:t;if(s){this.activate()}}catch(u){throw new MiMicException(u)}};f.Mcu.prototype={_mif:null,isActive:function m(){try{return this._mif.isConnected()}catch(s){throw new MiMicException(s)}},events:null,_phl_holder:null,getClockInfo:function g(){return{cclk:100*1000*1000}},activate:function d(){try{var s=this;if(this.isActive()){throw new MiMicException("Already activated!")}this._mif.connect(function(u){if(!u){if(s.events.onActivateChanged!=null){s.events.onActivateChanged(false)}}});if(this.events.onActivateChanged!=null){this.events.onActivateChanged(true)}}catch(t){throw new MiMicException(t)}},deactivate:function c(){try{if(!this.isActive()){throw new MiMicException("Already activated!")}this._mif.disconnect();if(this.events.onActivateChanged!=null){this.events.onActivateChanged(false)}}catch(s){throw new MiMicException(s)}},callMiMic:function l(){try{var t;switch(arguments.length){case 1:t=arguments[0];break;case 2:t=arguments[0]+b(arguments[1]);break;default:throw new MiMicException(s)}return this._mif.execBc(t)}catch(s){throw new MiMicException(s)}},callMiMicWithCheck:function k(){try{var s=this.callMiMic.apply(this,arguments);if(s.result!=0){throw new MiMicException(a.VM_RUNTIME,"Result="+s.toString())}return s}catch(t){throw new MiMicException(t)}},getPin:function q(){switch(arguments.length){case 1:var s=h(arguments[0]);var t=n(arguments[0]);return this.getPeripheral(t).getPin(s);case 2:var t=n(arguments[1]);return this.getPeripheral(t).getPin(arguments[0]);default:throw new MiMicException()}},getPort:function r(s){throw new MiMicException("Not implemented.")},getPeripheral:function i(s,t){if(e(this._phl_holder[s])){switch(s){case"GPIO":new f.Gpio(this,t);break;case"ADC":new f.Adc(this,t);break;case"PWM":new f.Pwm(this,t);break;default:throw new MiMicException("Unknown peripheral symbol "+s)}}else{if(!e(t)){throw new MiMicException()}}return this._phl_holder[s]},registerPhl:function j(t,s){try{if(!e(this._phl_holder[s])){throw new MiMicException("Peripheral symbol "+s+" is already exist on mcu.")}this._phl_holder[s]=t}catch(u){throw new MiMicException(u)}}}}());(function(){var f=LPCXpresso1769;var d=f._BCF;var a=f._EE;var b=MiMicLib.isUndef;f.Memory=function e(g,h){if(!b(h)){this._base=h}this._mcu=g};f.Memory.prototype={_base:0,_mcu:null,read32:function c(){try{function o(i){if(i%4!=0){throw new MiMicException(a.INVALID_ARG,"An alignment is not 32bit unit.")}}var n="";var h=new Array();var p=arguments[0];switch(arguments.length){case 1:if(!isNaN(p)){o(p);n=d.READMEM;h.push(this._base+p)}else{for(var k=0;k<p.length;k++){o(p[k]);n+=d.getMem(this._base+p[k],h)}}break;case 2:o(p);o(arguments[1]);var g=arguments[1]/4;for(var k=0;k<g;k++){n+=d.READMEM;h.push(this._base+p+k*4)}break;default:break}var j=this._mcu.callMiMicWithCheck(n+d.END,h).stream;return j.length==1?j[0]:j}catch(m){throw new MiMicException(m)}}}}());(function(){var g=LPCXpresso1769;var f=g._BCF;var c=g._EE;var e=MiMicLib.isUndef;g.Peripheral=function(h,i,k){try{if(e(i)){throw new MiMicException(c.INVALID_PHL)}this._mcu=h;this._phl=i;if(!e(k)){this.setOpt(k)}}catch(j){throw new MiMicException(j)}};g.Peripheral.prototype={_PCLKSEL:[1074774440,1074774444],_PCONP:1074774212,_phl:null,_mcu:null,_cache:{pclk:0},BCF_setOpt:function a(k,h){try{var j="";if(!e(k.power)){if(this._phl[2]==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PCONP.")}j+=f.setBit(this._PCONP,1,k.power,this._phl[2],h)}if(!e(k.clock)){if(this._phl[0]==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PCLKSEL.")}this._cache.pclk=k.clock;j+=f.setBit(this._PCLKSEL[this._phl[0]],3,k.clock,this._phl[1],h)}return j}catch(i){throw new MiMicException(i)}},setOpt:function b(k){try{var h=new Array();var j=this.BCF_setOpt(k,h);if(j.length==0){throw new MiMicException("i_opt is empty or invalid.")}this._mcu.callMiMicWithCheck(j+f.END,h)}catch(i){throw new MiMicException(i)}return},getPCLK:function d(){try{var h=[4,1,2,0];var i=h[this._cache.pclk];var j;if(i==0){if(this._phl===g.PHL.CAN1||this._phl===g.PHL.CAN2){j=this._mcu.getClockInfo().cclk/6}else{j=this._mcu.getClockInfo().cclk/8}}else{j=this._mcu.getClockInfo().cclk/i}return Math.round(j)}catch(k){throw new MiMicException(k)}}}}());(function(){var g=LPCXpresso1769;var e=g._BCF;var c=g._EE;var d=MiMicLib.isUndef;g.Pin=function f(h,i,k){try{if(d(i)){throw new MiMicException(c.INVALID_PIN)}this._mcu=h;this._pininfo=g.getPinRegInfo(i);if(!d(k)){this.setOpt(k)}}catch(j){throw new MiMicException(j)}};g.Pin.prototype={_PINSEL:[1073922048,1073922052,1073922056,1073922060,1073922064,null,null,1073922240,null,1073922084,1073922088],_PINMODE:[1073922112,1073922116,1073922120,1073922124,1073922128,1073922132,1073922136,1073922140,null,1073922148],_PINMODE_OD:[1073922152,1073922156,1073922160,1073922164,1073922168],_pininfo:null,_mcu:null,BCF_setOpt:function a(k,h){try{var j="";if(!d(k.sel)){j+=e.setBit(this._PINSEL[this._pininfo.s],3,k.sel,this._pininfo.smb,h)}if(!d(k.mode)){if(this._pininfo.m==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PINMODE. pininfo.")}j+=e.setBit(this._PINMODE[this._pininfo.m],3,k.mode,this._pininfo.smb,h)}if(!d(k.od)){if(this._pininfo.o==null){throw new MiMicException(c.INVALID_CFG,"The pin does not support PINMODE_OD. pininfo.")}j+=e.setBit(this._PINMODE_OD[this._pininfo.o],1,k.od,this._pininfo.ob,h)}return j}catch(i){throw new MiMicException(i)}},setOpt:function b(k){try{var h=new Array();var j=this.BCF_setOpt(k,h);if(j.length==0){throw new MiMicException("i_opt is empty or invalid.")}this._mcu.callMiMicWithCheck(j+e.END,h)}catch(i){throw new MiMicException(i)}return}}}());(function(){var a=LPCXpresso1769;var k=a._BCF;var l=a._EE;var c=MiMicLib.isUndef;a.Adc=function b(m,r){try{this._mcu=m;this._phl=new a.Peripheral(m,a.PHL.ADC);var o=c(r)?{phl:{}}:{phl:c(r.phl)?{}:cloneAssoc(r.phl),};if(c(o.phl.power)){o.phl.power=1}var q="";var n=new Array();q+=this.BCF_setOpt(o,n);q+=k.setMem(this._AD0CR,2098176,n);q+=k.setMem(this._AD0CR,2163712,n);this._mcu.callMiMicWithCheck(q+k.END,n);this._mcu.registerPhl(this,"ADC")}catch(p){throw new MiMicException(p)}};a.Adc.prototype={_PHL_DEF:{power:1},_AD0CR:1073954816,_AD0DR:[1073954832,1073954836,1073954840,1073954844,1073954848,1073954852,1073954856,1073954860],_phl:null,_mcu:null,BCF_setOpt:function h(p,m){try{var o="";if(!c(p.phl)){o+=this._phl.BCF_setOpt(p.phl,m)}return o}catch(n){throw new MiMicException(n)}},BCF_setSel:function i(o,n,m){try{return k.setBit(this._AD0CR,1,n,o,m)}catch(p){throw new MiMicException(p)}},BCF_getAD0DR:function g(n,m){try{return k.getMem(this._AD0DR[n],m)}catch(o){throw new MiMicException(o)}},setOpt:function f(p){try{var m=new Array();var o=this.BCF_setOpt(p,m);this._mcu.callMiMicWithCheck(o+k.END,m)}catch(n){throw new MiMicException(n)}},getPin:function j(m,o){try{return new a.AdcPin(this,m,o)}catch(n){throw new MiMicException(n)}}};a.AdcPin=function d(m,o,q){try{this._adc=m;this._pin=new a.Pin(m._mcu,o);this._adinfo=function(v){var t=a.completePinFunctionName(v,"AD");var s=t.substring(2).split(".");var u={port:0,ch:parseInt(s[1]),pin_sel:a.getPinSelByFunctionName(v,t)};if(!isNaN(u.ch)){return u}throw new MiMicException(l.INVALID_CFG,"The pin has not AD fuction.")}(o);var n=c(q)?{pin:{}}:{pin:c(q.pin)?{}:cloneAssoc(q.pin)};n.sel=1;if(c(n.pin.sel)){n.pin.sel=this._adinfo.pin_sel}this.setOpt(n)}catch(p){throw new MiMicException(p)}};a.AdcPin.prototype={_adc:null,_pin:null,_adinfo:null,getValue:function e(){try{var m=new Array();var p=this._adc.BCF_getAD0DR(this._adinfo.ch,m);var n=this._adc._mcu.callMiMicWithCheck(p+k.END,m);return(n.stream[0]>>4)&4095}catch(o){throw new MiMicException(o)}},setOpt:function f(p){try{var o="";var m=new Array();if(!c(p.pin)){o+=this._pin.BCF_setOpt(p.pin,m)}if(!c(p.sel)){o+=this._adc.BCF_setSel(this._adinfo.ch,p.sel,m)}this._adc._mcu.callMiMicWithCheck(o+k.END,m);return}catch(n){throw new MiMicException(n)}}}}());(function(){var a=LPCXpresso1769;var n=a._BCF;var o=a._EE;var c=MiMicLib.isUndef;var h=MiMicLib.cloneAssoc;a.Gpio=function i(p,r){try{this._mcu=p;p.registerPhl(this,"GPIO")}catch(q){throw new MiMicException(q)}};a.Gpio.prototype={_FIO_DIR:[537509888,537509920,537509952,537509984,537510016],_FIO_PIN:[537509908,537509940,537509972,537510004,537510036],_FIO_SET:[537509912,537509944,537509976,537510008,537510040],_FIO_CLR:[537509916,537509948,537509980,537510012,537510044],_FIO_MASK:[537509904,537509936,537509968,537510000,537510032],_mcu:null,BCF_setDir:function k(r,q,s,p){try{return n.setBit(this._FIO_DIR[r],1,s,q,p)}catch(t){throw new MiMicException(t)}},BCF_setValue:function b(s,r,q,p){try{if(q){p.push(this._FIO_SET[s],this._FIO_MASK[s],~(1<<r))}else{p.push(this._FIO_CLR[s],this._FIO_MASK[s],~(1<<r))}return"EA00EA01EA02DF0201FB02ffffffffDF0200"}catch(t){throw new MiMicException(t)}},BCF_getValue:function d(r,q,p){try{p.push(this._FIO_PIN[r],this._FIO_MASK[r],~(1<<q));return"EA00EA01EA02DF0201DB0300EE03"}catch(s){throw new MiMicException(s)}},getPin:function j(p,r){try{return new a.GpioPin(this,p,r)}catch(q){throw new MiMicException(q)}}};a.GpioPin=function l(q,r,t){try{this._gpio=q;this._pin=new a.Pin(q._mcu,r);this._gpioinfo=function(x){var v=a.completePinFunctionName(x,"GPIO");var u=v.substring(4).split(".");var w={port:parseInt(u[0]),bit:parseInt(u[1]),pin_sel:a.getPinSelByFunctionName(x,v)};if(!isNaN(w.port)&&!isNaN(w.bit)){return w}throw new MiMicException(o.INVALID_CFG,"The pin has not GPIO fuction.")}(r);var p=c(t)?{pin:{}}:{dir:t.dir,pin:c(t.pin)?{}:h(t.pin)};if(c(p.pin.sel)){p.pin.sel=this._gpioinfo.pin_sel}this.setOpt(p)}catch(s){throw new MiMicException(s)}};a.GpioPin.prototype={_gpio:null,_pin:null,_gpioinfo:null,setOpt:function g(s){try{var r="";var p=new Array();if(!c(s.dir)){r+=this._gpio.BCF_setDir(this._gpioinfo.port,this._gpioinfo.bit,s.dir,p)}if(!c(s.pin)){r+=this._pin.BCF_setOpt(s.pin,p)}this._gpio._mcu.callMiMicWithCheck(r+n.END,p)}catch(q){throw new MiMicException(q)}},setValue:function e(q){try{var s="";var p=new Array();s+=this._gpio.BCF_setValue(this._gpioinfo.port,this._gpioinfo.bit,q,p);this._gpio._mcu.callMiMicWithCheck(s+n.END,p)}catch(r){throw new MiMicException(r)}},getValue:function f(){try{var s="";var p=new Array();s+=this._gpio.BCF_getValue(this._gpioinfo.port,this._gpioinfo.bit,p);var q=this._gpio._mcu.callMiMicWithCheck(s+n.END,p);return(q.stream[0]>>this._gpioinfo.bit)&1}catch(r){throw new MiMicException(r)}},outPatt:function m(q){try{var t="";var p=new Array();for(var r=0;r<q.length;r++){t+=this._gpio.BCF_setValue(this._gpioinfo.port,this._gpioinfo.bit,q[r],p)}this._gpio._mcu.callMiMicWithCheck(t+n.END,p)}catch(s){throw new MiMicException(s)}},}}());(function(){var a=LPCXpresso1769;var n=a._BCF;var o=a._EE;var b=MiMicLib.isUndef;var g=MiMicLib.cloneAssoc;a.Pwm=function d(p,u){try{this._mcu=p;this._phl=new a.Peripheral(p,a.PHL.PWM1);var r=b(u)?{phl:{}}:{phl:b(u.phl)?{}:g(u.phl),freq:u.freq};if(b(r.phl.power)){r.phl.power=1}if(b(r.phl.clock)){r.phl.clock=0}if(b(r.freq)){r.freq=100}var t="";var q=new Array();t+=this.BCF_setOpt(r,q);t+=n.setMem(this._PC,0,q);t+=n.setMem(this._PCR,0,q);t+=n.setMem(this._CTCR,0,q);t+=n.setMem(this._TCR,0,q);t+=n.setMem(this._TC,0,q);t+=n.setMem(this._TCR,9,q);this._mcu.callMiMicWithCheck(t+n.END,q);this._mcu.registerPhl(this,"PWM")}catch(s){throw new MiMicException(s)}};a.Pwm.prototype={_cache:{mr0:0},_TCR:1073840132,_TC:1073840136,_PR:1073840140,_PC:1073840144,_MCR:1073840152,_PCR:1073840204,_LER:1073840208,_CTCR:1073840240,_MRn:[1073840152,1073840156,1073840160,1073840164,1073840192,1073840196,1073840200],_phl:null,_mcu:null,BCF_setOpt:function h(u,p){try{var t="";var r;var q;if(!b(u.phl)){t+=this._phl.BCF_setOpt(u.phl,p)}if(!b(u.freq)){q=Math.round(this._phl.getPCLK()/u.freq);if(q<=0){throw new MiMicException("The peripheral clock too small.")}t+=this.BCF_setMRn(0,q,p);t+=this.BCF_setLER(0,p);this._cache.mr0=q}return t}catch(s){throw new MiMicException(s)}},BCF_setLER:function e(q,p){return n.setBit(this._LER,1,1,q,p)},BCF_setMRn:function j(r,q,p){try{return n.setMem(this._MRn[r],q,p)}catch(s){throw new MiMicException(s)}},BCF_setMRnByDuty:function m(q,r,p){try{return this.BCF_setMRn(q,Math.round(r*this._cache.mr0),p)}catch(s){throw new MiMicException(s)}},BCF_setPCRbit:function l(u,r,s,q){try{var p,t;p=t=0;if(!b(r)){t|=r;p|=1}if(!b(s)){t|=(s<<8);p|=256}return n.setBit(this._PCR,p,t,u,q)}catch(w){throw new MiMicException(w)}},setOpt:function f(s){try{var p=new Array();var r=this.BCF_setOpt(s,p);this._mcu.callMiMicWithCheck(r+n.END,p)}catch(q){throw new MiMicException(q)}},getPin:function i(p,r){try{return new a.PwmPin(this,p,r)}catch(q){throw new MiMicException(q)}}};a.PwmPin=function k(p,r,t){try{this._pwm=p;this._pin=new a.Pin(p._mcu,r);this._pwminfo=function(x){var v=a.completePinFunctionName(x,"PWM");var u=v.substring(2).split(".");var w={port:0,ch:parseInt(u[1]),pin_sel:a.getPinSelByFunctionName(x,v)};if(!isNaN(w.ch)){return w}throw new MiMicException(o.INVALID_CFG,"The pin has not PWM fuction.")}(r);var q=b(t)?{pin:{}}:{pin:b(t.pin)?{}:g(t.pin),duty:t.duty,enable:t.enable};if(b(q.pin.sel)){q.pin.sel=this._pwminfo.pin_sel}if(b(q.duty)){q.duty=0}if(b(q.enable)){q.enable=1}this.setOpt(q)}catch(s){throw new MiMicException(s)}};a.PwmPin.prototype={_pwm:null,_pin:null,_pwminfo:null,BCF_setOpt:function h(s,p){try{var r="";if(!b(s.pin)){r+=this._pin.BCF_setOpt(s.pin,p)}if(!b(s.enable)){r+=this._pwm.BCF_setPCRbit(this._pwminfo.ch,0,s.enable,p)}if(!b(s.duty)){r+=this._pwm.BCF_setMRnByDuty(this._pwminfo.ch,s.duty,p);r+=this._pwm.BCF_setLER(this._pwminfo.ch,p)}return r}catch(q){throw new MiMicException(q)}},setOpt:function f(s){try{var p=new Array();var r=this.BCF_setOpt(s,p);this._pwm._mcu.callMiMicWithCheck(r+n.END,p)}catch(q){throw new MiMicException(q)}},setDuty:function c(p){try{this.setOpt({duty:p})}catch(q){throw new MiMicException(q)}}}}());
\ No newline at end of file
index f3e1c3c..05e39a3 100644 (file)
@@ -1412,8 +1412,8 @@ DEV.Adc=function Adc(i_mcu,i_opt)
                var db=new Array();\r
                bc+=this.BCF_setOpt(opt,db);\r
                //0x00210000(PDN,BURSTを1)\r
-               bc+=BCF.setMem(this._AD0CR,0x00200500,db);\r
-               bc+=BCF.setMem(this._AD0CR,0x00210500,db);\r
+               bc+=BCF.setMem(this._AD0CR,0x00200400,db);\r
+               bc+=BCF.setMem(this._AD0CR,0x00210400,db);\r
                //\r
                this._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
                //ペリフェラルをMCUに登録\r
index 4f0c869..462be9f 100644 (file)
@@ -79,7 +79,7 @@ var MiMicError=
                return (0x40000000 & v)==0x00000000;\r
        },\r
        /*\r
-        * 定数定義
+        * 定数定義\r
         */\r
        /** @private*/\r
        MID_MiMic:0x00390000,\r
@@ -166,7 +166,7 @@ function MiMicException(/*...*/)
                }else{\r
                        //文字列やオブジェクト\r
                        this.code=MiMicError.NG[0];\r
-                       sfx=MiMicError.NG[1]+(((typeof v)!='undefined')?v.toString():"v==undefined");\r
+                       sfx=MiMicError.NG[1]+" "+(((typeof v)!='undefined')?v.toString():"v==undefined");\r
                }\r
                this.message=pfx+" code(0x"+this.code.toString(16)+")"+sfx;\r
                return;\r
@@ -194,12 +194,12 @@ function MiMicException(/*...*/)
 MiMicException.prototype={\r
        /**\r
         * MiMicErrorCode形式のエラーコードを保持する。\r
-        * @field {object as MiMicErrorCode}
+        * @field {object as MiMicErrorCode}\r
         */\r
        code:MiMicError.OK,\r
        /**\r
         * エラーメッセージを保持する。この値は、改行区切りのコールスタックである。\r
-        * @field {string}
+        * @field {string}\r
         */\r
        message:"",\r
        /**\r
@@ -210,7 +210,7 @@ MiMicException.prototype={
         *      throw new MiMicException();\r
         * }catch(e){\r
         *      e.alert();\r
-        * }     
+        * }     \r
         */\r
        alert:function(){\r
                alert(this.message);\r
@@ -226,7 +226,7 @@ MiMicException.prototype={
         *      throw new MiMicException();\r
         * }catch(e){\r
         *      alert(e.toString());\r
-        * }     
+        * }     \r
         */\r
        toString:function()\r
        {\r
@@ -240,14 +240,14 @@ MiMicException.prototype={
 \r
 \r
 /*\r
- * MiMicRemoteMCU
+ * MiMicRemoteMCU\r
  */\r
 var MiMicRemoteMcuInterface;\r
 \r
 (function(){\r
        /**\r
         * エラーID定義\r
-        * @private
+        * @private\r
         */\r
        var EE=function(i_base)\r
        {\r
@@ -268,7 +268,7 @@ var MiMicRemoteMcuInterface;
         * ex. “127.0.0.1” , “127.0.0.1:3939”\r
         * @example\r
         * //create a controlable MCU via network.\r
-        * var mcu=new MiMicRemoteMcuInterface(“192.168.0.39”);      
+        * var mcu=new MiMicRemoteMcuInterface(“192.168.0.39”);      \r
         */\r
        MiMicRemoteMcuInterface=function MiMicRemoteMcuInterface(server)\r
        {\r
@@ -325,12 +325,31 @@ var MiMicRemoteMcuInterface;
                 */\r
                _isOnline_parseResponse: function(res)\r
                {\r
+                       function isok(i_s)\r
+                       {\r
+                               function parse_version_tag(i_v)\r
+                               {\r
+                                       var t=i_v.split("/");\r
+                                       var n=t[1].split(".");\r
+                                       return {name:t[0],major:parseInt(n[0]),minor:parseInt(n[1])};\r
+                               }\r
+                               try{\r
+                                       //"MiMicRemoteMCU/1.n;xならOK.(n>=1)\r
+                                       var l=i_s.split(";");\r
+                                       var rmcu=parse_version_tag(l[0]);//RemoteMcu\r
+                                       var mcut=l[1];//MCUTYPE\r
+                                       return ((rmcu.name=="MiMicRemoteMCU") && (rmcu.major==1) && (rmcu.minor>=1));\r
+                               }catch(e){\r
+                                       throw MiMicException(e);\r
+                               }\r
+                       }\r
+\r
                        try{\r
                                if(res.status!=200){\r
                                        return false;\r
                                }\r
                                var ret=eval("("+res.responseText+")");\r
-                               if(ret.application.split(";")[0]!="MiMicRemoteMCU/1.0a"){\r
+                               if(!isok(ret.application)){\r
                                        return false;\r
                                }\r
                        }catch(e){\r
@@ -348,8 +367,14 @@ var MiMicRemoteMcuInterface;
                 */\r
                _parseMvmResult:function(i_mvmresult)\r
                {\r
+                       function isok(i_s)\r
+                       {\r
+                               //MiMicVM/1.x;Json/1.0ならOK\r
+                               var l=i_s.split(";");\r
+                               return((l[0].indexOf("MiMicVM/1.")==0) && (l[1]=="Json/1.0"));\r
+                       }\r
                        var ret=eval("("+i_mvmresult+")");\r
-                       if(ret.version=="MiMicVM/1.0a;Json/1.0"){\r
+                       if(isok(ret.version)){\r
                                if(ret.result!=undefined){\r
                                        if(ret.result!=0x0 || ret.stream!=undefined){\r
                                                return ret;\r
@@ -357,7 +382,7 @@ var MiMicRemoteMcuInterface;
                                }\r
                        }\r
                        //なんかうまくいかない。\r
-                       throw new MiMicException(EE.NG);\r
+                       throw new MiMicException(EE.NG,"Invalid json version:'"+ret.version+"'");\r
                },\r
                /**\r
                 * 接続状態を真偽値で返す。\r
@@ -369,7 +394,7 @@ var MiMicRemoteMcuInterface;
                 * @example\r
                 * //show connection status\r
                 * var mri=new  MiMicRemoteMcuInterface(“192.168.0.1”);\r
-                * alert(mri.isConnected());             
+                * alert(mri.isConnected());             \r
                 */\r
                isConnected:function isConnected()\r
                {\r
@@ -433,27 +458,31 @@ var MiMicRemoteMcuInterface;
                                if(this._keep_alive!=null){\r
                                        return;\r
                                }\r
-                               var res=this._xhrGet("http://"+this._mimic_host+"/status.api",false,null);\r
-                               function startCheck()\r
+                               function checkProc(i_res)\r
                                {\r
-                                       function checkProc(res)\r
-                                       {\r
-                                               //結果の確認\r
-                                               if(!_t._isOnline_parseResponse(res)){\r
-                                                       if(_t._keep_alive!=null){\r
-                                                               _t._keep_alive=null;\r
-                                                               i_callback(false);\r
-                                                       }\r
-                                               }else{\r
-                                                       i_callback(true);\r
-                                                       startCheck();\r
+                                       //結果の確認\r
+                                       if(!_t._isOnline_parseResponse(i_res)){\r
+                                               if(_t._keep_alive!=null){\r
+                                                       _t._keep_alive=null;\r
+                                                       i_callback(false);\r
                                                }\r
-                                               return;\r
+                                       }else{\r
+                                               i_callback(true);\r
+                                               startCheck();\r
                                        }\r
+                                       return;\r
+                               }\r
+                               function startCheck()\r
+                               {\r
                                        _t._keep_alive={\r
                                                tid:setTimeout(function(){_t._keep_alive.xhr=_t._xhrGet("http://"+_t._mimic_host+"/status.api",true,checkProc);},5000),\r
                                                xhr:null};\r
                                };\r
+                               //同期チェック\r
+                               var res=this._xhrGet("http://"+this._mimic_host+"/status.api",false,null);\r
+                               if(!this._isOnline_parseResponse(res)){\r
+                                       throw new MiMicException("Bad response from "+this._mimic_host);\r
+                               }                               \r
                                //非同期監視の開始\r
                                startCheck();\r
                        }catch(e){\r
index a1b9f88..99435f9 100644 (file)
@@ -14,7 +14,7 @@ function MiMicILAsm(i_def)
 }\r
 MiMicILAsm.prototype=\r
 {\r
-       version:"MiMicILAsm/0.9a",\r
+       version:"MiMicILAsm/1.1.0",\r
        _exception:new Object(),\r
        _def:undefined,\r
        OPR_WM  :0x0001,\r
@@ -294,6 +294,9 @@ MiMicILAsm.prototype=
                ["NOP",function(code){\r
                        return oprset_NONEHEX8(code,"ZA","ZB");\r
                }],\r
+               ["CALL",function(code){\r
+                       return oprset_WMHEXn(code,"ZE","ZF",32);\r
+               }],\r
                ["EXIT",function(code){\r
                        return oprset_NONE(code,"ZZ");\r
                }],\r
index 1231108..ad19d3f 100644 (file)
@@ -1,7 +1,7 @@
 <head>\r
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
 <script src="../MiMicCore.js"></script>        \r
-<script src="../LPCXPresso1769.All-mini.js"></script>  \r
+<script src="../LPCXPresso1769.All.js"></script>       \r
 <script type="text/javascript">\r
 \r
 function adddata(v)\r
index f31bcbd..f07907a 100644 (file)
@@ -1,7 +1,7 @@
 <head>\r
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
 <script src="../MiMicCore.js"></script>        \r
-<script src="../LPCXPresso1769.All-mini.js"></script>  \r
+<script src="../LPCXPresso1769.All.js"></script>       \r
 <script type="text/javascript">\r
 function init(){\r
        var mcu=new LPCXpresso1769.Mcu("192.168.128.39");\r
index 95dc213..1c795a6 100644 (file)
@@ -4,7 +4,8 @@
  */\r
 \r
 \r
-#include "sketch_config.h"     //include this file at first!\r
+#include "sketch_config.h"     //must include this file at first!\r
+#include "native_function.h"\r
 #include "boot/sketch.h"\r
 #include "NyLPC_uipService.h"\r
 #include "NyLPC_httpService.h"\r
@@ -51,10 +52,10 @@ static NyLPC_TcMutex_t _vm_mutex;
 #define LIMIT_OF_PERSISTENT_CONNECTION 2\r
 \r
 //MVMのVERSION情報\r
-#define MVM_VERSION "MiMicVM/1.0a;Json/1.0"\r
-#define APPLICATION_VERSION "MiMicRemoteMCU/1.0a;LPCXpresso1769"\r
+#define MVM_VERSION "MiMicVM/1.0;Json/1.0"\r
+#define APPLICATION_VERSION "MiMicRemoteMCU/1.1;LPCXpresso1769"\r
 //スレッドのスタックサイズ\r
-#define THREAD_STACK_SIZE 256+128\r
+#define THREAD_STACK_SIZE 256+256\r
 \r
 \r
 \r
@@ -290,7 +291,7 @@ struct NyLPC_TRemoteMCU_EventHandler
 };\r
 \r
 /**\r
- * ストリームハンドラ\r
+ * ストリームハンドラ(put)\r
  */\r
 static NyLPC_TBool mvmputs_json(struct NyLPC_TcMiMicVM_TEvent* i_eh,NyLPC_TUInt32 i_val)\r
 {\r
@@ -305,7 +306,7 @@ static NyLPC_TBool mvmputs_json(struct NyLPC_TcMiMicVM_TEvent* i_eh,NyLPC_TUInt3
 }\r
 \r
 /**\r
- * ストリームハンドラ\r
+ * ストリームハンドラ(get)\r
  */\r
 static NyLPC_TBool mvmgets(struct NyLPC_TcMiMicVM_TEvent* i_eh,NyLPC_TUInt32* o_val)\r
 {\r
@@ -319,6 +320,20 @@ static NyLPC_TBool mvmgets(struct NyLPC_TcMiMicVM_TEvent* i_eh,NyLPC_TUInt32* o_
        eh->db_pos++;\r
        return NyLPC_TBool_TRUE;\r
 }\r
+/**\r
+ * ネイティブCALLハンドラ\r
+ */\r
+static NyLPC_TUInt32 nativeCall(struct NyLPC_TcMiMicVM_TEvent* i_evh,NyLPC_TUInt32 i_id,NyLPC_TcMiMicVM_t* i_vm)\r
+{\r
+       (void)i_evh;\r
+       NyLPC_TNativeFunction f=getNativeFunctionById(i_id);\r
+       if(f==NULL){\r
+               return NyLPC_cMiMicVM_RESULT_RUNTIME_NG_UNKNOWN_CALL;\r
+       }\r
+       return f(i_vm)?NyLPC_cMiMicVM_RESULT_OK:NyLPC_cMiMicVM_RESULT_RUNTIME_NG_CALL;\r
+}\r
+\r
+\r
 static void mvmsleep(struct NyLPC_TcMiMicVM_TEvent* i_eh,NyLPC_TUInt32 i_sleep_in_msec)\r
 {\r
        (void)i_eh;\r
@@ -510,6 +525,7 @@ static NyLPC_TBool mvm(NyLPC_TcHttpStream_t* i_st,const struct TRemoteMcuRequest
        union{\r
                NyLPC_TcHttpHeaderWriter_t hw;\r
                struct{\r
+                       NyLPC_TUInt32 vmret;\r
                        NyLPC_TcMiMicVM_t vm;\r
                        struct NyLPC_TRemoteMCU_EventHandler eh;\r
                }bw;\r
@@ -527,6 +543,7 @@ static NyLPC_TBool mvm(NyLPC_TcHttpStream_t* i_st,const struct TRemoteMcuRequest
        //ハンドラインスタンスの設定\r
        work.bw.eh.super.get_stream=mvmgets;\r
        work.bw.eh.super.put_stream=mvmputs_json;\r
+       work.bw.eh.super.native_call=nativeCall;\r
        work.bw.eh.super.sleep=mvmsleep;\r
        work.bw.eh.db_pos=0;\r
        work.bw.eh.st_len=0;\r
@@ -549,16 +566,10 @@ static NyLPC_TBool mvm(NyLPC_TcHttpStream_t* i_st,const struct TRemoteMcuRequest
                NyLPC_OnErrorGoto(Error_NyLPC_cHttpBodyWriter_format);\r
        }\r
 \r
-       //VMの起動\r
-       if(!NyLPC_cMiMicVM_run(&(work.bw.vm),i_rqh->content.mvm.vm_instruction.bc_buf,i_rqh->content.mvm.vm_instruction.txt_len)){\r
-               if(!NyLPC_cHttpBodyWriter_format(&(work.bw.eh.bw),"],result:0x80030000}")){\r
-                       NyLPC_OnErrorGoto(Error_NyLPC_cHttpBodyWriter_format);\r
-               }\r
-               //VMエラー\r
-       }else{\r
-               if(!NyLPC_cHttpBodyWriter_format(&(work.bw.eh.bw),"],result:0x00000000}")){\r
-                       NyLPC_OnErrorGoto(Error_NyLPC_cHttpBodyWriter_format);\r
-               }\r
+       //VMの実行\r
+       work.bw.vmret=NyLPC_cMiMicVM_run(&(work.bw.vm),i_rqh->content.mvm.vm_instruction.bc_buf,i_rqh->content.mvm.vm_instruction.txt_len);\r
+       if(!NyLPC_cHttpBodyWriter_format(&(work.bw.eh.bw),"],result:0x%x}",work.bw.vmret)){\r
+               NyLPC_OnErrorGoto(Error_NyLPC_cHttpBodyWriter_format);\r
        }\r
        //エラーチェック\r
        if(!NyLPC_cHttpBodyWriter_close(&(work.bw.eh.bw))){\r
index 92b7838..d7b92c5 100644 (file)
@@ -1,6 +1,6 @@
 ======================================================================\r
 MiMic\r
- version 1.0.0\r
+ version 1.1.0\r
 ======================================================================\r
 \r
 Copyright (C)2011 Ryo Iizuka\r