Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: fpga.cpp
- Revision:
- 20:0394e15412c3
- Parent:
- 18:5aa48aec9cae
- Child:
- 28:fdb3b144e342
--- a/fpga.cpp Wed Dec 05 00:12:38 2018 +0000
+++ b/fpga.cpp Wed Dec 05 01:43:55 2018 +0000
@@ -133,14 +133,15 @@
}
//レジスタ設定範囲内にリミット
- if(iVal<0){
- regVal = 0;
- }else if(iVal>4095){
- regVal = 4095;
- }else{
- regVal = iVal;
- }
-
+ regVal = (iVal<0) ? 0 :(iVal>4095)? 4095 : iVal;
+// if(iVal<0){
+// regVal = 0;
+// }else if(iVal>4095){
+// regVal = 4095;
+// }else{
+// regVal = iVal;
+// }
+
xSpi(regAdr[0] , regVal);//吸気側
xSpi(regAdr[1] , regVal);//排気側
@@ -149,28 +150,15 @@
}
//================================================================
-//モーター個別
+//モーター個別設定
//================================================================
-void fpgaMotorChk(){
- UCHAR id;
- UINT16 val;
-
- sp.printf("Motor check start!!\r\n");
+void fpgaMotor(UCHAR iPos,INT16 iVal){
+ UCHAR regAdr = ADR_SUB_FL_I;//モーターの先頭番地を指しておく
+ UINT16 regVal;
- for(id=0; id<8; id++){
- sp.printf("Motor[%d] check!!\r\n",id);
- for(val=0; val<500; val=val+4){
- xSpi(ADR_SUB_FL_I + id , val);//
- wait(0.01);
- }
- for(val=500; val>10; val=val-4){
- xSpi(ADR_SUB_FL_I + id , val);//
- wait(0.01);
- }
- xSpi(ADR_SUB_FL_I + id , 0);
- }
- gf_Chk.bf.mot = false;
-
+ if( iPos<8){ regAdr += iPos; } //指定位置だけオフセットさせる
+ regVal = (iVal<0) ? 0 :(iVal>4095)? 4095 : iVal; //レジスタ設定範囲内にリミット
+ xSpi(regAdr , regVal);//
}
//================================================================
@@ -197,4 +185,4 @@
spi.format(16,3) ;//SPIのフォーマット指定(bit長、極性)
spi.frequency(500000) ;//クロック周波数
CS_n =1 ;//Low有意なのでHighにしておく
-}
\ No newline at end of file
+}