/**\r
* @see API manual\r
*/\r
- PHY_NAME:[\r
+ PHL_NAME:[\r
"GPIO","ADC","DAC"\r
],\r
/**\r
* @see API manual\r
- PHY:{PHY_NAME:[PCLKSELreg#PCLKSELbit,PCONPbit]}\r
+ PHL:{PHL_NAME:[PCLKSELreg#PCLKSELbit,PCONPbit]}\r
*/\r
- PHY:{\r
+ PHL:{\r
WDT: [0,0,null],\r
TIMER0: [0,2,1],\r
TIMER1: [0,4,2],\r
/**\r
* PIN機能名から使用するペリフェラルシンボルを推定する。
*/\r
- function pinFuncName2PhyName(i_pinfuncname)\r
+ function pinFuncName2PhlName(i_pinfuncname)\r
{\r
try{\r
//Pin function nameプレフィクスとペリフェラル名の対比表\r
* ペリフェラルオブジェクトのホルダ。ペリフェラル名をキーにした、ペリフェラルオブジェクトの連想配列。\r
MCUが、自身のペリフェラルオブジェクトを管理する為に使う。\r
*/\r
- _phy_holder:[],\r
+ _phl_holder:[],\r
/**\r
* @see API manual
*/\r
//pin_functionを持ってるPINを探す。\r
var pin=getPinByFuncName(arguments[0]);\r
//function名からペリフェラル名を得る。\r
- var phy_name=pinFuncName2PhyName(arguments[0]);\r
+ var phl_name=pinFuncName2PhlName(arguments[0]);\r
//ピンコンストラクタとペリフェラルを使ってピンを生成。\r
- return this.getPeripheral(phy_name).getPin(pin);\r
+ return this.getPeripheral(phl_name).getPin(pin);\r
case 2://getPin:function getPin(i_pin,i_function_name)\r
//function名からペリフェラル名を得る。(PINシンボル変換を流用)\r
- var phy_name=pinFuncName2PhyName(arguments[1]);\r
- return this.getPeripheral(phy_name).getPin(arguments[0]);\r
+ var phl_name=pinFuncName2PhlName(arguments[1]);\r
+ return this.getPeripheral(phl_name).getPin(arguments[0]);\r
default:\r
throw new MiMicException();\r
}\r
/**\r
* @see API manual
*/\r
- getPeripheral:function getPeripheral(i_phy_symbol)\r
+ getPeripheral:function getPeripheral(i_phl_symbol)\r
{\r
//ペリフェラルアイテムが生成済か確認\r
- if(isUndef(this._phy_holder[i_phy_symbol])){\r
+ if(isUndef(this._phl_holder[i_phl_symbol])){\r
//存在しなければPhyを生成。\r
- var phy;\r
- switch(i_phy_symbol){\r
+ var phl;\r
+ switch(i_phl_symbol){\r
case "GPIO":new DEV.Gpio(this);break;\r
case "ADC":new DEV.Adc(this);break;\r
default:\r
- throw new MiMicException("Unknown peripheral symbol "+i_phy_symbol);\r
+ throw new MiMicException("Unknown peripheral symbol "+i_phl_symbol);\r
}\r
}\r
- //phyからregisterのコールバックがかかるはず。\r
- return this._phy_holder[i_phy_symbol];\r
+ //phlからregisterのコールバックがかかるはず。\r
+ return this._phl_holder[i_phl_symbol];\r
},\r
/**\r
* [forSystem]システム関数。MCU依存のペリフェラルオブジェクトを登録する。
*/\r
- registerPhy:function registerPhy(i_phy,i_symbol)\r
+ registerPhl:function registerPhy(i_phl,i_symbol)\r
{\r
try{\r
//登録済みのシンボルは登録できない。\r
- if(!isUndef(this._phy_holder[i_symbol])){\r
+ if(!isUndef(this._phl_holder[i_symbol])){\r
throw new MiMicException("Peripheral symbol "+i_symbol+" is already exist on mcu.");\r
}\r
- this._phy_holder[i_symbol]=i_phy;\r
+ this._phl_holder[i_symbol]=i_phl;\r
}catch(e){\r
throw new MiMicException(e);\r
}\r
/**\r
* @see API manual\r
*/\r
-DEV.Peripheral=function(i_mcu,i_phy,i_opt)\r
+DEV.Peripheral=function(i_mcu,i_phl,i_opt)\r
{\r
try{\r
- if(isUndef(i_phy)){\r
- throw new MiMicException(EE.INVALID_PHY);\r
+ if(isUndef(i_phl)){\r
+ throw new MiMicException(EE.INVALID_PHL);\r
}\r
this._mcu=i_mcu;\r
- this._phy=i_phy;\r
+ this._phl=i_phl;\r
//オプション設定するならする。\r
if(!isUndef(i_opt)){\r
this.setOpt(i_opt);\r
{\r
_PCLKSEL:[0x400FC1A8,0x400FC1AC],\r
_PCONP:0x400FC0C4,\r
- _phy:null,\r
+ _phl:null,\r
_mif:null,\r
BCF_setOpt:function BCF_setOpt(i_opt,i_db)\r
{\r
var bc="";\r
//pconp\r
if(!isUndef(i_opt.power)){\r
- if(this._phy[2]==null){\r
+ if(this._phl[2]==null){\r
throw new MiMicException(EE.INVALID_CFG,"The pin does not support PCONP.");\r
}\r
//pinselAddrを得る\r
- bc+=BCF.setBit(this._PCONP,0x00000001,i_opt.power,this._phy[2],i_db);\r
+ bc+=BCF.setBit(this._PCONP,0x00000001,i_opt.power,this._phl[2],i_db);\r
}\r
//clock\r
if(!isUndef(i_opt.clock)){\r
- if(this._phy[0]==null){\r
+ if(this._phl[0]==null){\r
throw new MiMicException(EE.INVALID_CFG,"The pin does not support PCLKSEL.");\r
}\r
- bc+=BCF.setBit(this._PCLKSEL[this._phy[0]],0x00000003,i_opt.clock,this._phy[1],i_db);\r
+ bc+=BCF.setBit(this._PCLKSEL[this._phl[0]],0x00000003,i_opt.clock,this._phl[1],i_db);\r
}\r
return bc;\r
}catch(e){\r
/**\r
* このクラスは、ADCペリフェラルを管理します。\r
@param i_opt\r
- オプション値です。省略時は、{phy:{power:1}}を指定します。\r
- {phy:{ペリフェラルオプション}}\r
+ オプション値です。省略時は、{phl:{power:1}}を指定します。\r
+ {phl:{ペリフェラルオプション}}\r
*/\r
DEV.Adc=function Adc(i_mcu,i_opt)\r
{\r
try{\r
this._mcu=i_mcu;\r
- var phyopt=isUndef(i_opt)?{power:1}:i_opt.phy;\r
- //PHY生成。\r
- this._phy=new DEV.Peripheral(i_mcu,DEV.PHY.ADC);\r
+ var phlopt=isUndef(i_opt)?{power:1}:i_opt.phl;\r
+ //PHL生成。\r
+ this._phl=new DEV.Peripheral(i_mcu,DEV.PHL.ADC);\r
//初期化。\r
var bc="";\r
var db=new Array();\r
if(isUndef(i_opt)){\r
//パワーONのみ\r
- bc+=this._phy.BCF_setOpt({power:1},db);\r
+ bc+=this._phl.BCF_setOpt({power:1},db);\r
}else{\r
- bc+=this._phy.BCF_setOpt(i_opt.phy,db);\r
+ bc+=this._phl.BCF_setOpt(i_opt.phl,db);\r
}\r
//0x00210000(PDN,BURSTを1)\r
bc+=BCF.setMem(this._AD0CR,0x00200500,db);\r
//\r
this._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
//ペリフェラルをMCUに登録\r
- this._mcu.registerPhy(this,"ADC");\r
+ this._mcu.registerPhl(this,"ADC");\r
}catch(e){\r
throw new MiMicException(e);\r
}\r
{\r
_AD0CR:0x40034000,\r
_AD0DR:[0x40034010,0x40034014,0x40034018,0x4003401C,0x40034020,0x40034024,0x40034028,0x4003402C],\r
- _phy:null,\r
+ _phl:null,\r
_mcu:null,\r
/**\r
* AD0CRのSELフィールドの値を更新するBC\r
var BCF=DEV._BCF;\r
var EE=DEV._EE;\r
var isUndef=MiMicLib.isUndef;\r
+var cloneAssoc=MiMicLib.cloneAssoc;\r
\r
/**\r
* このクラスは、GPIOペリフェラルを管理します。
{\r
try{\r
this._mcu=i_mcu;\r
- i_mcu.registerPhy(this,"GPIO");\r
+ i_mcu.registerPhl(this,"GPIO");\r
}catch(e){\r
throw new MiMicException(e);\r
}\r
}\r
throw new MiMicException(EE.INVALID_CFG,"The pin has not GPIO fuction.");\r
}(i_pin);\r
- if(isUndef(i_opt)){\r
- //optionが無いときは、GPIO化だけ。\r
- this.setOpt({sel:this._gpioinfo.pin_sel});\r
- }else{\r
- //optionがあるときはGPIO化と、pinコンフィギュレーションの継承\r
- this.setOpt(i_opt);\r
+ //optの構成\r
+ var opt=isUndef(i_opt)?{pin:{}}:\r
+ {\r
+ dir:i_opt.dir,\r
+ pin:isUndef(i_opt.pin)?{}:cloneAssoc(i_opt.pin)\r
}\r
+ //デフォルト値\r
+ if(isUndef(opt.pin.sel)){opt.pin.sel=this._gpioinfo.pin_sel;}\r
+ //Pinのコンフィギュレーション\r
+ this.setOpt(opt);\r
}catch(e){\r
throw new MiMicException(e);\r
}\r
{\r
_gpio:null,\r
_pin:null,//LPCXpressoのpin\r
- _gpioinfo:null,//GPIOの情報{port,bit}\r
+ _gpioinfo:null,//GPIOの情報{port,bit,pin_sel}\r
/**\r
* @see API manual
*/\r
bc+=this._gpio.BCF_setDir(this._gpioinfo.port,this._gpioinfo.bit,i_opt.dir,db);\r
}\r
//pinselの値\r
- if(isUndef(i_opt.pin)){\r
- //pinコンフィギュレーションが無いとき\r
- bc+=this._pin.BCF_setOpt({sel:this._gpioinfo.pin_sel},db);\r
- }else{\r
- //pinコンフィギュレーションがあるとき\r
- var t=i_opt.pin.sel;//待避\r
- i_opt.pin.sel=this._gpioinfo.pin_sel;//selの上書き\r
+ if(!isUndef(i_opt.pin)){\r
bc+=this._pin.BCF_setOpt(i_opt.pin,db);\r
- i_opt.pin.sel=t;\r
}\r
- //実行なう\r
//MiMicBCを生成して実行\r
this._gpio._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
}catch(e){\r
\r
\r
/**\r
- * このクラスは、ADCペリフェラルを管理します。\r
- @param i_opt\r
- オプション値です。省略時は、{phy:{power:1}}を指定します。\r
- {phy:{ペリフェラルオプション}}\r
+ * see API manual.\r
*/\r
DEV.Adc=function Adc(i_mcu,i_opt)\r
{\r
try{\r
this._mcu=i_mcu;\r
- var phyopt=isUndef(i_opt)?{power:1}:i_opt.phy;\r
- //PHY生成。\r
- this._phy=new DEV.Peripheral(i_mcu,DEV.PHY.ADC);\r
+ //phl値の決定\r
+ var phlopt=this._PHL_DEF;\r
+ //optにphlが指定されていたら、それを採用。\r
+ if(!isUndef(i_opt) && !isUndef(i_opt.phl)){\r
+ phlopt=i_opt.phl;\r
+ }\r
+ //PHL生成。\r
+ this._phl=new DEV.Peripheral(i_mcu,DEV.PHL.ADC);\r
//初期化。\r
var bc="";\r
var db=new Array();\r
- if(isUndef(i_opt)){\r
- //パワーONのみ\r
- bc+=this._phy.BCF_setOpt({power:1},db);\r
- }else{\r
- bc+=this._phy.BCF_setOpt(i_opt.phy,db);\r
- }\r
+ bc+=this._phl.BCF_setOpt(phlopt,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
- this._mcu.registerPhy(this,"ADC");\r
+ this._mcu.registerPhl(this,"ADC");\r
}catch(e){\r
throw new MiMicException(e);\r
}\r
}\r
DEV.Adc.prototype=\r
{\r
+ _PHL_DEF:{power:1},\r
_AD0CR:0x40034000,\r
_AD0DR:[0x40034010,0x40034014,0x40034018,0x4003401C,0x40034020,0x40034024,0x40034028,0x4003402C],\r
- _phy:null,\r
+ _phl:null,\r
_mcu:null,\r
/**\r
* AD0CRのSELフィールドの値を更新するBC\r
}\r
\r
/**\r
- * このクラスは、ADCペリフェラルとPin識別子から、ADCピンを構成します。\r
- @param i_adc\r
- ADCペリフェラル\r
- @param i_pin\r
- ADCを構成するピン番号\r
- @param i_opt\r
- ピンオプション。省略してください。\r
+ * see API manual.\r
*/\r
DEV.AdcPin=function AdcPin(i_adc,i_pin,i_opt)\r
{\r
}\r
throw new MiMicException(EE.INVALID_CFG,"The pin has not AD fuction.");\r
}(i_pin);\r
- //設定用のBCを作って実行\r
+ var opt=isUndef(i_opt)?{pin:{}}:\r
{\r
- var bc="";\r
- var db=new Array();\r
- bc+=this._pin.BCF_setOpt({sel:this._adinfo.pin_sel},db);\r
- //AD0CRに値設定\r
- bc+=this._adc.BCF_setSel(this._adinfo.ch,1,db);\r
- var ret=this._adc._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
- }\r
+ pin:isUndef(i_opt.pin)?{}:cloneAssoc(i_opt.pin)\r
+ };\r
+ //AD0CR-SELの値(強制0)\r
+ opt.sel=1;\r
+ //デフォルト値\r
+ if(isUndef(opt.pin.sel)){opt.pin.sel=this._adinfo.pin_sel;}\r
+ //オプション設定\r
+ this.setOpt(opt);\r
}catch(e){\r
throw new MiMicException(e);\r
}\r
}catch(e){\r
throw new MiMicException(e);\r
}\r
-\r
- } \r
+ },\r
+ /**\r
+ * {sel:1bit,pin:{pin option}}
+ */\r
+ setOpt:function setOpt(i_opt)\r
+ {\r
+ try{\r
+ var bc="";\r
+ var db=new Array();\r
+ if(!isUndef(i_opt.pin)){\r
+ bc+=this._pin.BCF_setOpt(i_opt.pin,db);\r
+ }\r
+ //enable\r
+ if(!isUndef(i_opt.sel)){\r
+ bc+=this._adc.BCF_setSel(this._adinfo.ch,i_opt.sel,db);\r
+ }\r
+ this._adc._mcu.callMiMicWithCheck(bc+BCF.END,db);\r
+ return;\r
+ }catch(e){\r
+ throw new MiMicException(e);\r
+ }\r
+ }\r
}\r
\r
\r
}\r
return p;\r
}catch(e){\r
- throw MiMicException(e);\r
+ throw new MiMicException(e);\r
}\r
}\r
\r
/**\r
* PIN機能名から使用するペリフェラルシンボルを推定する。
*/\r
- function pinFuncName2PhyName(i_pinfuncname)\r
+ function pinFuncName2PhlName(i_pinfuncname)\r
{\r
try{\r
//Pin function nameプレフィクスとペリフェラル名の対比表\r
* ペリフェラルオブジェクトのホルダ。ペリフェラル名をキーにした、ペリフェラルオブジェクトの連想配列。\r
MCUが、自身のペリフェラルオブジェクトを管理する為に使う。\r
*/\r
- _phy_holder:[],\r
+ _phl_holder:[],\r
+ /**\r
+ * Clockに関する情報を返す。
+ */\r
+ getClockInfo:function getClockProperty()\r
+ {\r
+ //CCLCK値(RemoteMCU側と合わせること。将来的にはactivateの時に決定する。)\r
+ return {cclk:100*1000*1000};\r
+ },\r
/**\r
* @see API manual
*/\r
}\r
return ret;\r
}catch(e){\r
- throw MiMicException(e);\r
+ throw new MiMicException(e);\r
}\r
},\r
/**\r
//pin_functionを持ってるPINを探す。\r
var pin=getPinByFuncName(arguments[0]);\r
//function名からペリフェラル名を得る。\r
- var phy_name=pinFuncName2PhyName(arguments[0]);\r
+ var phl_name=pinFuncName2PhlName(arguments[0]);\r
//ピンコンストラクタとペリフェラルを使ってピンを生成。\r
- return this.getPeripheral(phy_name).getPin(pin);\r
+ return this.getPeripheral(phl_name).getPin(pin);\r
case 2://getPin:function getPin(i_pin,i_function_name)\r
//function名からペリフェラル名を得る。(PINシンボル変換を流用)\r
- var phy_name=pinFuncName2PhyName(arguments[1]);\r
- return this.getPeripheral(phy_name).getPin(arguments[0]);\r
+ var phl_name=pinFuncName2PhlName(arguments[1]);\r
+ return this.getPeripheral(phl_name).getPin(arguments[0]);\r
default:\r
throw new MiMicException();\r
}\r
/**\r
* @see API manual
*/\r
- getPeripheral:function getPeripheral(i_phy_symbol)\r
+ getPeripheral:function getPeripheral(i_phl_symbol)\r
{\r
//ペリフェラルアイテムが生成済か確認\r
- if(isUndef(this._phy_holder[i_phy_symbol])){\r
- //存在しなければPhyを生成。\r
- var phy;\r
- switch(i_phy_symbol){\r
+ if(isUndef(this._phl_holder[i_phl_symbol])){\r
+ //存在しなければPhlを生成。\r
+ var phl;\r
+ switch(i_phl_symbol){\r
case "GPIO":new DEV.Gpio(this);break;\r
case "ADC":new DEV.Adc(this);break;\r
default:\r
- throw new MiMicException("Unknown peripheral symbol "+i_phy_symbol);\r
+ throw new MiMicException("Unknown peripheral symbol "+i_phl_symbol);\r
}\r
}\r
- //phyからregisterのコールバックがかかるはず。\r
- return this._phy_holder[i_phy_symbol];\r
+ //phlからregisterのコールバックがかかるはず。\r
+ return this._phl_holder[i_phl_symbol];\r
},\r
/**\r
* [forSystem]システム関数。MCU依存のペリフェラルオブジェクトを登録する。
*/\r
- registerPhy:function registerPhy(i_phy,i_symbol)\r
+ registerPhl:function registerPhl(i_phl,i_symbol)\r
{\r
try{\r
//登録済みのシンボルは登録できない。\r
- if(!isUndef(this._phy_holder[i_symbol])){\r
+ if(!isUndef(this._phl_holder[i_symbol])){\r
throw new MiMicException("Peripheral symbol "+i_symbol+" is already exist on mcu.");\r
}\r
- this._phy_holder[i_symbol]=i_phy;\r
+ this._phl_holder[i_symbol]=i_phl;\r
}catch(e){\r
throw new MiMicException(e);\r
}\r
/**\r
* @see API manual\r
*/\r
-DEV.Peripheral=function(i_mcu,i_phy,i_opt)\r
+DEV.Peripheral=function(i_mcu,i_phl,i_opt)\r
{\r
try{\r
- if(isUndef(i_phy)){\r
- throw new MiMicException(EE.INVALID_PHY);\r
+ if(isUndef(i_phl)){\r
+ throw new MiMicException(EE.INVALID_PHL);\r
}\r
this._mcu=i_mcu;\r
- this._phy=i_phy;\r
+ this._phl=i_phl;\r
//オプション設定するならする。\r
if(!isUndef(i_opt)){\r
this.setOpt(i_opt);\r
{\r
_PCLKSEL:[0x400FC1A8,0x400FC1AC],\r
_PCONP:0x400FC0C4,\r
- _phy:null,\r
- _mif:null,\r
+ _phl:null,\r
+ _mcu:null,\r
+ _cache:{\r
+ pclk:0\r
+ },\r
+ /**\r
+ * BCフラグメントを生成して、_cacheを更新します。
+ */\r
BCF_setOpt:function BCF_setOpt(i_opt,i_db)\r
{\r
try{\r
var bc="";\r
//pconp\r
if(!isUndef(i_opt.power)){\r
- if(this._phy[2]==null){\r
+ if(this._phl[2]==null){\r
throw new MiMicException(EE.INVALID_CFG,"The pin does not support PCONP.");\r
}\r
//pinselAddrを得る\r
- bc+=BCF.setBit(this._PCONP,0x00000001,i_opt.power,this._phy[2],i_db);\r
+ bc+=BCF.setBit(this._PCONP,0x00000001,i_opt.power,this._phl[2],i_db);\r
}\r
//clock\r
if(!isUndef(i_opt.clock)){\r
- if(this._phy[0]==null){\r
+ if(this._phl[0]==null){\r
throw new MiMicException(EE.INVALID_CFG,"The pin does not support PCLKSEL.");\r
}\r
- bc+=BCF.setBit(this._PCLKSEL[this._phy[0]],0x00000003,i_opt.clock,this._phy[1],i_db);\r
+ //キャッシュ更新\r
+ this._cache.pclk=i_opt.clock;\r
+ bc+=BCF.setBit(this._PCLKSEL[this._phl[0]],0x00000003,i_opt.clock,this._phl[1],i_db);\r
}\r
return bc;\r
}catch(e){\r
throw new MiMicException(e);\r
}\r
return; \r
+ },\r
+ /**\r
+ * ペリフェラルのクロックを返す。\r
+ Table 42. Peripheral Clock Selection register bit valuesの変換テーブルです。\r
+ クロックは、最後のキャッシュ値から計算します。\r
+ */\r
+ getPCLK:function getPCLK()\r
+ {\r
+ try{\r
+ //倍率変換テーブル\r
+ var m=[4,1,2,0];\r
+ var t=m[this._cache.pclk];\r
+ var r;\r
+ if(t==0){\r
+ if(this._phl===DEV.PHL.CAN1 || this._phl===DEV.PHL.CAN2){\r
+ r=this._mcu.getClockInfo().cclk/6;\r
+ }else{\r
+ r=this._mcu.getClockInfo().cclk/8;\r
+ }\r
+ }else{\r
+ r=this._mcu.getClockInfo().cclk/t;\r
+ }\r
+ return Math.round(r);\r
+ }catch(e){\r
+ throw new MiMicException(e);\r
+ }\r
}\r
}\r
\r
/**\r
* @see API manual\r
*/\r
- PHY_NAME:[\r
+ PHL_NAME:[\r
"GPIO","ADC","DAC"\r
],\r
/**\r
* @see API manual\r
- PHY:{PHY_NAME:[PCLKSELreg#PCLKSELbit,PCONPbit]}\r
+ PHL:{PHL_NAME:[PCLKSELreg#PCLKSELbit,PCONPbit]}\r
*/\r
- PHY:{\r
+ PHL:{\r
WDT: [0,0,null],\r
TIMER0: [0,2,1],\r
TIMER1: [0,4,2],\r
{\r
throw new MiMicException("Not imprement.");\r
}\r
-DEV.Pwm=function Pwm()\r
-{\r
- throw new MiMicException("Not imprement.");\r
-}\r
+\r
DEV.Dma=function Dma()\r
{\r
throw new MiMicException("Not imprement.");\r
*/\r
var MiMicLib=\r
{\r
- isUndef:function isUndef(a){return typeof a==="undefined"}\r
+ isUndef:function isUndef(a){return typeof a==="undefined"},\r
+ cloneAssoc:function cloneAssoc(a)\r
+ {\r
+ var r={};\r
+ for(var i in a){\r
+ r[i]=a[i];\r
+ }\r
+ return r;\r
+ }\r
}\r
\r
\r
<script src="LPCXpresso1769.Gpio.js"></script>\r
<script src="LPCXpresso1769.Peripheral.js"></script> \r
<script src="LPCXpresso1769.Adc.js"></script> \r
+<script src="LPCXpresso1769.Pwm.js"></script> \r
<script type="text/javascript">\r
function init(){\r
try{\r
* MCUにあるピンに機能を割り当る為の手順。
*/\r
\r
- \r
+ var mcu=new LPCXpresso1769.Mcu("192.168.128.39",true);\r
+ var pwmpin;\r
//オーソドックスな方法\r
function case1()\r
{\r
- var mcu=new LPCXpresso1769.Mcu("192.168.0.39",true);\r
//ADCペリフェラルを作る。\r
var adc=new LPCXpresso1769.Adc(mcu);\r
//ペリフェラルからピンに接続\r
//GPIOペリフェラルを作る。\r
var gpio=new LPCXpresso1769.Gpio(mcu);\r
//ペリフェラルからピンに接続\r
- var gpiopin=new LPCXpresso1769.GpioPin(gpio,LPCXpresso1769.P0[0]);\r
+ var gpiopin=new LPCXpresso1769.GpioPin(gpio,LPCXpresso1769.P0[0],{dir:1});\r
alert(adpin.getValue()+","+gpiopin.getValue());\r
}\r
\r
function case2()\r
{\r
//MCU生成\r
- var mcu=new LPCXpresso1769.Mcu("192.168.0.39");\r
//機能名でPINを作る。(物理PINは自動)\r
var gpiopin=mcu.getPin("GPIO0.0");\r
var gpiopin2=mcu.getPin("GPIO0.1");\r
function case3()\r
{\r
//MCU生成\r
- var mcu=new LPCXpresso1769.Mcu("192.168.128.39");\r
//PIN0[0]をGPIO機能を割り当て\r
var gpiopin=mcu.getPin(LPCXpresso1769.P0[0],"GPIO");\r
//PIN0[0]をAD機能を割り当て\r
var adpin=mcu.getPin(LPCXpresso1769.P0[23],"AD");\r
alert(adpin.getValue()+","+gpiopin.getValue());\r
}\r
- //case3();\r
+ function test()\r
+ {\r
+// var gpiopin=mcu.getPin(LPCXpresso1769.P2[0],"GPIO");\r
+// gpiopin.setOpt({dir:1,pin:{mode:1,od:0}});\r
+ var i=0;\r
+// setInterval(function(){gpiopin.setValue((i++)%2);},500);\r
+ var pwm=new LPCXpresso1769.Pwm(mcu,{freq:100});\r
+ pwmpin=new LPCXpresso1769.PwmPin(pwm,LPCXpresso1769.P2[0],{duty:0.0});\r
+ \r
+ }\r
+ test();\r
/*\r
var mcu=new LPCXpresso1769.Mcu("192.168.128.39");\r
var gpiopin=mcu.getPin(LPCXpresso1769.P0[0],"GPIO");\r
var i=0;\r
setInterval(function(){gpiopin.setValue((i++)%2);},30);\r
\r
-\r
+*/\r
\r
\r
}catch(e){\r
//e.alert(); \r
throw e;\r
}\r
+document.getElementById("ga").onmousemove=onpos;\r
+function onpos(e)\r
+{\r
+ var d=document.getElementById("ga");\r
+ var v=(e.pageX-d.style.left);\r
+ if(v>300)v=300;\r
+ d.innerHTML=(v/6);\r
+ pwmpin.setDuty(v/600);\r
+ \r
+}\r
} \r
+\r
</script>\r
</head>\r
<body onload="init();">\r
-<h1>MiMic demo</h1>\r
+<h1>MiMic test</h1>\r
<hr/>\r
MiMic Copyright (C) 2011 nyatla.jp All Rights Reserved.<br/>\r
+<div id="ga" style="width:300;height:100px;border-style:solid;border-color:black">aaa</div>\r
<a href="http://nyatla.jp/mimic/wp">http://nyatla.jp/mimic/wp</a>\r
</div>\r
</body>\r