X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=misc%2FmbedJS%2FmbddJS.API%2FmbedJS%2Fmbed.I2CSlave.js;fp=misc%2FmbedJS%2FmbddJS.API%2FmbedJS%2Fmbed.I2CSlave.js;h=0000000000000000000000000000000000000000;hb=6bb705eb6d7e46e22bf90ad4770ac30c0b3418c8;hp=182ee3f52da2c0a10dfb235f9dadc02e812c0e03;hpb=4da927972bedbfe714964b6909f1512ed78d63c1;p=mimic%2FMiMicSDK.git diff --git a/misc/mbedJS/mbddJS.API/mbedJS/mbed.I2CSlave.js b/misc/mbedJS/mbddJS.API/mbedJS/mbed.I2CSlave.js deleted file mode 100644 index 182ee3f..0000000 --- a/misc/mbedJS/mbddJS.API/mbedJS/mbed.I2CSlave.js +++ /dev/null @@ -1,437 +0,0 @@ -/** - * @fileOverview I2CSlaveã¯ã©ã¹ãå®ç¾©ãã¾ãã - */ -(function(){ -var NS=mbedJS; -var MI=MiMicJS; - -/** - * I2CSlaveã¯ã©ã¹ã§ãã - * mbed::I2CSlaveã¨åçã®æ©è½ãæã¡ã¾ãã - * @constructor - * @name mbedJS.I2CSlave - * @param {mbedJS.Mcu} i_mcu - * ã¤ã³ã¹ã¿ã³ã¹ããã¤ã³ãããMCUãªãã¸ã§ã¯ãã§ãã - * @param {[PinName,PinName]} i_params - * i2Cãã¹ãæ§æãããã³IDãæå®ãã¾ããsda,sclã®é çªã§ãã - * @param {HashMap|Generator|function} i_handler - * éåæã¤ãã³ããã³ãã©ã®é£æ³é åãGeneratorãã³ã¼ã«ããã¯é¢æ°ã®ä½ãããæå®ãã¾ãã - *
- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã - *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã - *
- *- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿ è¦ãããã¾ãã - *
- * @return {mbedJS.I2CSlave} - * @example //Callback - * var mcu=new mbedJS.Mcu("192.168.128.39", - * { - * onNew:function(){ - * var i2c=new mbedJS.I2CSlave(mcu,[mbedJS.PinName.p28,mbedJS.PinName.p27],{ - * onNew:function(){ - * i2c.frequency(100000); - * }, - * onFrequency:function() - * { - * i2c.address(1); - * }, - * onAddress:function() - * { - * i2c.receive(); - * }, - * onReceive:function(){ - * st=0; - * i2c.write(1); - * }, - * onWrite:function(v){ - * if(st==0){ - * i2c.write([1,2,3]); - * st++; - * }else{ - * i2c.read(); - * st=0; - * } - * }, - * onRead:function(v){ - * if(st==0){ - * i2c.read(2,false); - * st++; - * }else{ - * log("[PASS]onRead:"+v.ret+":"+v.data); - * i2c.stop(); - * } - * }, - * onStop:function(){ - * mcu.close(); - * } - * }); - * }, - * onClose:function(){ - * }, - * onError:function(){ - * alert("Error"); - * } - * }); - * @example //Generator - * var g=function*(){ - * try{ - * var v; - * var mcu=new mbedJS.Mcu("192.168.128.39",g); - * yield mcu.waitForNew(); - * var i2c=new mbedJS.I2CSlave(mcu,[mbedJS.PinName.p28,mbedJS.PinName.p27],g); - * yield i2c.waitForNew(); - * yield i2c.frequency(100000); - * yield i2c.address(1); - * v=yield i2c.receive(); - * v=yield i2c.write(1); - * v=yield i2c.write([1,2,3]); - * v=yield i2c.read(); - * v=yield i2c.read(2,false); - * log("[PASS]onRead:"+v.ret+":"+v.data); - * yield i2c.stop(); - * yield mcu.close(); - * }catch(e){ - * mcu.shutdown(); - * alert(e); - * throw e; - * } - * }(); - * g.next(); - * return; - */ -var CLASS=function I2CSlave(i_mcu,i_params,i_handler) -{ - try{ - var _t=this; - _t._mcu=i_mcu; - _t._lc=CLASS; - var cb=MI._initHandler.call(_t,i_handler); - MI.assertInt(i_params); - _t._mcu.rpc(_t.RPC_NS+":_new1",i_params[0]+","+i_params[1], - function(j) - { - _t._oid=j.result[0]; - if(cb){cb();} - if(_t._gen){_t._gen.next(_t);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } -} -/** - * mbedJS.Serial#receiveã®æ»ãå¤ã®ç¨®é¡ã§ãã - * NoData,ReadAddressed,WriteGeneral,WriteAddressedãããã¾ãã - * @name mbedJS.I2CSlave#RxStatus - */ -CLASS.RxStatus={ - NoData:0,ReadAddressed:1,WriteGeneral:2,WriteAddressed:3 -} -CLASS.prototype={ - /** @private */ - RPC_NS:"mbedJS:I2CSlave", - /** @private æå¾ã«ã³ã¼ã«ããAPIã§ãã*/ - _lc:null, - /** @private Generatorã¢ã¼ãã®å ´åã«Generatorãªãã¸ã§ã¯ããä¿æãã¾ãã*/ - _gen:null, - /** @private ã³ã¼ã«ããã¯é¢æ°ã®é£æ³é åã§ããè¦ç´ ã¯ã³ã³ã¹ãã©ã¯ã¿ãåç §ãã¦ãã ããã*/ - _event:{}, - /** @private ãªã¢ã¼ãã¤ã³ã¹ã¿ã³ã¹ã®ãªãã¸ã§ã¯ãIDã§ãã*/ - _oid:null, - /** - * Generatorã¢ã¼ãã®ã¨ãã«ä½¿ç¨ããé¢æ°ã§ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦new I2CSlave()ã®å®äºãå¾ ã¡ã¾ãã - * @name mbedJS.I2CSlave#waitForNew - * @function - */ - waitForNew:function I2CSlave_waitForNew() - { - try{ - if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);} - this._lc=CLASS.waitForNew; - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * I2CSlaveã®ã¢ãã¬ã¹ãè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onAddressã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.I2CSlave#address - * @function - * @param {int} i_value - * 8ãããã®ã¢ãã¬ã¹å¤ã§ãã - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - address:function I2CSlave_address(i_value) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onAddress); - MI._assertYield.call(_t); - _t._lc=CLASS.write; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":address",_t._oid+","+i_value, - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * Hzåä½ã§ãã¹ã®é度ãæå®ãã¾ãã - * é¢æ°ã®å®äºæã«onFrequencyã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.I2CSlave#frequency - * @function - * @param {int} i_hz - * Hzåä½ã®ãã¹é度ã§ãã - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - frequency:function I2CSlave_frequency(i_hz) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onFrequency); - MI._assertYield.call(_t); - _t._lc=CLASS.frequency; - MI.assertInt(i_hz); - return _t._mcu.rpc(_t.RPC_NS+":frequency",_t._oid+","+i_hz, - function (j) - { - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * å¼æ°ã2åã®å ´å - * @name mbedJS.I2CSlave#read:1 - * @function - * @param {int} length - * èªã¿åºããã¼ã¿ã®é·ãã§ãã256æªæºã®å¤ãæå®ãã¦ãã ããã - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @return {HashMap} - * {ret:int,data:[byte]} - * Generatorã®å ´åã¯æ»ãå¤ãªãã¸ã§ã¯ããè¿ãã¾ãã - *