8 * <a href="https://mbed.org/handbook/BusIn">mbed::BusIn</a>と同等の機能を持ちます。
\r
10 * @param {mbedJS.Mcu} i_mcu
\r
11 * インスタンスをバインドするMCUオブジェクトです。
\r
12 * @param {[PinName...]} i_params
\r
13 * ピンIDの配列を指定します。要素数の最大値は16です。
\r
14 * @param {HashMap|Generator} i_event
\r
15 * 非同期イベントハンドラの連想配列、又はGeneratorです。
\r
17 * 非同期イベントハンドラの場合、関数はイベントハンドラで結果を通知します。
\r
19 * <li>{function()} onNew -
\r
20 * インスタンスが使用可能になった時に呼び出されます。
\r
22 * <li>{function(v)} onRead -
\r
23 * read関数のコールバック関数です。
\r
25 * <li>{int} v - 現在のピンの値です。</li>
\r
28 * <li>{function()} onMode -
\r
29 * mode関数のコールバック関数です。
\r
33 * Generatorを指定した場合、コールバック関数の引数はyiledの戻り値として取得できます。
\r
35 * @return {mbedJS.BusIn}
\r
38 var CLASS=function BusIn(i_mcu,i_params,i_handler)
\r
44 if(MI.isGenerator(i_handler)){_t._gen=i_handler;}
\r
45 else if(i_handler){_t._event=i_handler}
\r
48 _t._oid=j.result[0];
\r
49 if(_t._event.onNew){_t._event.onNew();}
\r
50 if(_t._gen){_t._gen.next(_t);}
\r
55 if(ap.length<1 ||ap.length>16){
\r
56 throw new MI.MiMicException(MI.NG_INVALID_ARG);
\r
62 for(;i<i_params.length;i++){
\r
66 pins+=","+NS.PinName.NC;
\r
68 return _t._mcu.rpc(_t.RPC_NS+":_new1",pins,cb);
\r
70 throw new MI.MiMicException(e);
\r
76 RPC_NS:"mbedJS:BusIn",
\r
77 /** @private 最後にコールしたAPIです。*/
\r
79 /** @private Generatorモードの場合にGeneratorオブジェクトを保持します。*/
\r
81 /** @private コールバック関数の連想配列です。要素はコンストラクタを参照してください。*/
\r
83 /** @private リモートインスタンスのオブジェクトIDです。*/
\r
86 * @name mbedJS.BusIn#waitForNew
\r
88 * Generatorモードのときに使用する関数です。
\r
89 * Generatorモードの時は、yieldと併用してnew BusIn()の完了を待ちます。
\r
91 waitForNew:function BusIn_waitForNew()
\r
94 if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);}
\r
95 this._lc=CLASS.waitForNew;
\r
97 throw new MI.MiMicException(e);
\r
101 * @name mbedJS.BusIn#read
\r
104 * 関数の完了時にonReadイベントが発生します。
\r
105 * Generatorモードの時は、yieldと併用して完了を待機できます。
\r
106 * @return {int|int}
\r
107 * <p>Callbackモードの時はRPCメソッドのインデクスを返します。</p>
\r
108 * <p>Generatorモードの時はピンの値を返します。</p>
\r
110 read:function BusIn_read()
\r
114 if(this._gen && this._lc){throw new MI.MiMicException(MI.Error.NG_YIELD_NOT_COMPLETED);}
\r
116 return _t._mcu.rpc(_t.RPC_NS+":read",_t._oid,
\r
120 if(_t._event.onRead){_t._event.onRead(v);}
\r
121 if(_t._gen){_t._gen.next(v);}
\r
126 throw new MI.MiMicException(e);
\r
130 * @name mbedJS.BusIn#mode
\r
133 * 関数の完了時にonModeイベントが発生します。
\r
134 * Generatorモードの時は、yieldと併用して完了を待機できます。
\r
135 * @param {PinMode} i_value
\r
137 * @return {int|none}
\r
138 * <p>Callbackモードの時はRPCメソッドのインデクスを返します。</p>
\r
140 mode:function BusIn_mode(i_value)
\r
144 if(this._gen && this._lc){throw new MI.MiMicException(MI.Error.NG_YIELD_NOT_COMPLETED);}
\r
146 MI.assertInt(i_value);
\r
147 return _t._mcu.rpc(_t.RPC_NS+":mode",_t._oid+","+i_value,
\r
151 if(_t._event.onMode){_t._event.onMode(v);}
\r
152 if(_t._gen){_t._gen.next(v);}
\r
157 throw new MI.MiMicException(e);
\r