teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Committer:
MasashiNomura
Date:
Tue Mar 19 12:22:31 2019 +0000
Revision:
73:0720e5550476
Parent:
63:aee44afe6363
Child:
75:215dd63032d6
2019/03/19 add Reading IMU Data ON/OFF.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MasashiNomura 45:3b51dd26b579 1 /**
MasashiNomura 45:3b51dd26b579 2 * @file globalFlags.cpp
MasashiNomura 45:3b51dd26b579 3 * @brief コマンド解析<-->ホバーバイク制御タスク間及びホバーバイク制御タスク内で使用する共用フラグを使用する変数宣言と関数定義
MasashiNomura 45:3b51dd26b579 4 * @author Shirota, Nomura
MasashiNomura 45:3b51dd26b579 5 * @date 2018/10/01 ?
MasashiNomura 45:3b51dd26b579 6 */
MasashiNomura 48:71aec693a7dc 7 #include "typedef.h"
takeru0x1103 16:05b9e44889f1 8 #include "globalFlags.h"
takeru0x1103 16:05b9e44889f1 9
MasashiNomura 45:3b51dd26b579 10 DigitalOut led1(LED1); //!< モニタ用LED1用変数
MasashiNomura 45:3b51dd26b579 11 DigitalOut led2(LED2); //!< モニタ用LED2用変数
MasashiNomura 45:3b51dd26b579 12 DigitalOut led3(LED3); //!< モニタ用LED3用変数
MasashiNomura 45:3b51dd26b579 13 DigitalOut led4(LED4); //!< モニタ用LED4用変数
takeru0x1103 8:1ca49cb18290 14
MasashiNomura 45:3b51dd26b579 15 DigitalOut DO_01(p21); //!< 状態表示用LED1(R)用変数
MasashiNomura 45:3b51dd26b579 16 DigitalOut DO_02(p22); //!< 状態表示用LED2(G)用変数
MasashiNomura 45:3b51dd26b579 17 DigitalOut DO_03(p23); //!< 状態表示用LED3(B)用変数
MasashiNomura 40:debe99e228d3 18
MasashiNomura 45:3b51dd26b579 19 AnalogIn AinAxl(p20); //!< モーターアクセル用アナログ入力
MasashiNomura 45:3b51dd26b579 20
takeru0x1103 21:78302ecdb661 21
MasashiNomura 45:3b51dd26b579 22 char g_CmdBuf[G_CMD_BUF_SIZ]; //!< コマンド受け渡しバッファ
MasashiNomura 45:3b51dd26b579 23 bool gf_CmdPrs; //!< コマンドパーサー実行要求フラグ
MasashiNomura 36:2cc739c7e4cb 24
MasashiNomura 45:3b51dd26b579 25 bool gf_Armed; //!< アーミングフラグ
MasashiNomura 45:3b51dd26b579 26 bool gf_Dbg; //!< デバッグタスク起動フラグ
takeru0x1103 19:4b0fe9a5ec38 27
MasashiNomura 45:3b51dd26b579 28 bool gf_StopMot; //!< モーターの強制停止 サーボ全閉
MasashiNomura 45:3b51dd26b579 29 bool gf_FromActiveStat; //!< モーターの強制停止 サーボ全閉が動作時に発生したかどうか
MasashiNomura 25:f3a6e7eec9c3 30
MasashiNomura 43:156199c2f9b6 31 bool gf_BlinkLED;
MasashiNomura 43:156199c2f9b6 32
MasashiNomura 73:0720e5550476 33 bool gf_EnbImuRead; //!< IMUの値読み出し可否 TRUE:読み込み FALSE:無視(0埋め)
MasashiNomura 73:0720e5550476 34
MasashiNomura 45:3b51dd26b579 35 typPrintFlg gf_Print; //!< デバッグプリントフラグ(1回表示)
MasashiNomura 45:3b51dd26b579 36 typPrintFlg gf_Mon; //!< デバッグモニタフラグ(繰り返し表示)
MasashiNomura 45:3b51dd26b579 37 typCalFlag gf_Cal; //!< キャリブレーションフラグ
MasashiNomura 32:7f4145cc3551 38
MasashiNomura 45:3b51dd26b579 39 typAccel gf_AxReq[2]; //!< エンジンアクセル値更新フラグ
MasashiNomura 45:3b51dd26b579 40 typAccel gf_AxReqH[2]; //!< 浮上時エンジンアクセル値更新フラグ
MasashiNomura 45:3b51dd26b579 41 typAccel gf_AxStepReq[2]; //!< エンジンアクセル用サーボ動作ステップ値更新フラグ
MasashiNomura 53:b09c062cc31c 42 typAccel gf_AxAdjStepReq[2]; //!< エンジンアクセル調整用サーボ動作ステップ値更新フラグ
MasashiNomura 53:b09c062cc31c 43
MasashiNomura 45:3b51dd26b579 44 typAxlRpm gf_MtReq[4]; //!< モーター姿勢制御値更新
MasashiNomura 50:76413e8e073d 45 typAxlRpm gf_MtAttOfs[4]; //!< モーター姿勢制御オフセット値更新
MasashiNomura 45:3b51dd26b579 46 typAxlRpm gf_MtReqOfs[4]; //!< モーターオフセット値更新
MasashiNomura 45:3b51dd26b579 47 typAxlRpm gf_MtReqU[4]; //!< モーターユーザー値更新
MasashiNomura 56:f363a6877c6a 48 typAxlRpm gf_MtBrk; //!< モーターブレーキ時のRPM値更新
MasashiNomura 63:aee44afe6363 49 typAxlRpm gf_MtDefaultOffset; //!< モーターのTAKE_OFFステート時に使用するデフォルトオフセット値更新
MasashiNomura 45:3b51dd26b579 50 typAxlRpm gf_MtReqDct[8]; //!< ダイレクト(FPGA関数直接呼び出し)モーター値更新フラグ
takeru0x1103 19:4b0fe9a5ec38 51
YutakaTakagi 59:6b4dcd964d0f 52 typAxlRpm gf_AngBrk; //!< ブレーキ時の1秒間の目標角度変化値[deg]更新
YutakaTakagi 59:6b4dcd964d0f 53
MasashiNomura 45:3b51dd26b579 54 typSWCmd gf_SwCmd; //!< スイッチが押されたことを模擬するフラグ
MasashiNomura 45:3b51dd26b579 55
MasashiNomura 45:3b51dd26b579 56 enmHbState gf_State = SLEEP; //!< 現在のステートを格納する変数
MasashiNomura 45:3b51dd26b579 57 bool gf_StateEnt; //!< 状態遷移後、最初であることを示す
MasashiNomura 45:3b51dd26b579 58
MasashiNomura 45:3b51dd26b579 59 bool gf_PidParaUpdate; //!< PID Pp,P,I,Dの係数アップデートフラグ
MasashiNomura 45:3b51dd26b579 60 typPidPara g_PidPara; //!< PID Pp,P,I,Dの係数の外部設定用
MasashiNomura 45:3b51dd26b579 61
MasashiNomura 25:f3a6e7eec9c3 62
MasashiNomura 22:24c9c2dedca9 63 void initFlags(){
MasashiNomura 22:24c9c2dedca9 64 memset(g_CmdBuf,0x0,sizeof(g_CmdBuf));
MasashiNomura 22:24c9c2dedca9 65 gf_CmdPrs = false;
MasashiNomura 22:24c9c2dedca9 66 gf_Armed = false;
MasashiNomura 22:24c9c2dedca9 67 gf_Dbg = false;
MasashiNomura 25:f3a6e7eec9c3 68 gf_StopMot = false;
MasashiNomura 43:156199c2f9b6 69
MasashiNomura 43:156199c2f9b6 70 gf_BlinkLED = false;
MasashiNomura 25:f3a6e7eec9c3 71
MasashiNomura 73:0720e5550476 72 gf_EnbImuRead = false;
MasashiNomura 73:0720e5550476 73
MasashiNomura 41:45c982b1c5b6 74 // gf_Print.flg = 0;
MasashiNomura 41:45c982b1c5b6 75 // gf_Mon.flg = 0;
MasashiNomura 41:45c982b1c5b6 76 gf_Print.d1.flg = 0;
MasashiNomura 41:45c982b1c5b6 77 gf_Print.d2.flg = 0;
MasashiNomura 39:1b76f7df8804 78
MasashiNomura 22:24c9c2dedca9 79 gf_Cal.flg = 0;
MasashiNomura 26:732bc37fbefd 80
MasashiNomura 41:45c982b1c5b6 81 //gf_DbgPrint.flg = 0;
MasashiNomura 26:732bc37fbefd 82
MasashiNomura 43:156199c2f9b6 83 // engine
MasashiNomura 43:156199c2f9b6 84 for(int i = 0; i < 2; ++i){
MasashiNomura 43:156199c2f9b6 85 gf_AxReq[i].dt = 0;
MasashiNomura 43:156199c2f9b6 86 gf_AxReqH[i].dt = 0;
MasashiNomura 43:156199c2f9b6 87 gf_AxStepReq[i].bf.req = false;
MasashiNomura 50:76413e8e073d 88 gf_AxStepReq[i].bf.val = 30;
MasashiNomura 53:b09c062cc31c 89 gf_AxAdjStepReq[i].bf.req = false;
MasashiNomura 63:aee44afe6363 90 gf_AxAdjStepReq[i].bf.val = 50;
MasashiNomura 43:156199c2f9b6 91 }
MasashiNomura 43:156199c2f9b6 92
MasashiNomura 27:ff63c23bc689 93 for(int i=0; i<4;++i){
MasashiNomura 32:7f4145cc3551 94 gf_MtReq[i].req = false;
MasashiNomura 32:7f4145cc3551 95 gf_MtReq[i].val = 0;
MasashiNomura 32:7f4145cc3551 96 gf_MtReqOfs[i].req = false;
MasashiNomura 32:7f4145cc3551 97 gf_MtReqOfs[i].val = 0;
MasashiNomura 32:7f4145cc3551 98 gf_MtReqU[i].req = false;
MasashiNomura 32:7f4145cc3551 99 gf_MtReqU[i].val = 0;
MasashiNomura 50:76413e8e073d 100 gf_MtAttOfs[i].req = false;
MasashiNomura 50:76413e8e073d 101 gf_MtAttOfs[i].val = 0;
MasashiNomura 27:ff63c23bc689 102 }
MasashiNomura 56:f363a6877c6a 103 gf_MtBrk.req = false;
MasashiNomura 56:f363a6877c6a 104 gf_MtBrk.val = DEF_BRK_RPM;
YutakaTakagi 59:6b4dcd964d0f 105 gf_AngBrk.req = false;
YutakaTakagi 59:6b4dcd964d0f 106 gf_AngBrk.val = DEF_BRK_ANG;
MasashiNomura 56:f363a6877c6a 107
MasashiNomura 63:aee44afe6363 108 gf_MtDefaultOffset.req = false;
MasashiNomura 63:aee44afe6363 109 gf_MtDefaultOffset.val = DEF_MOT_OFFSET;
MasashiNomura 63:aee44afe6363 110
MasashiNomura 27:ff63c23bc689 111 for(int i = 0; i < 8; ++i){
MasashiNomura 32:7f4145cc3551 112 gf_MtReqDct[i].req = false;
MasashiNomura 32:7f4145cc3551 113 gf_MtReqDct[i].val = 0;
MasashiNomura 27:ff63c23bc689 114 }
MasashiNomura 42:cc8501b824ba 115
MasashiNomura 42:cc8501b824ba 116 gf_SwCmd.dt = 0;
MasashiNomura 42:cc8501b824ba 117
MasashiNomura 22:24c9c2dedca9 118 gf_State = SLEEP;
MasashiNomura 36:2cc739c7e4cb 119 gf_StateEnt = false;
MasashiNomura 27:ff63c23bc689 120 g_PidPara.PP = 2;
MasashiNomura 73:0720e5550476 121 g_PidPara.P = 2800000;
MasashiNomura 73:0720e5550476 122 g_PidPara.I = 800000;
MasashiNomura 73:0720e5550476 123 g_PidPara.D = 2800000;
MasashiNomura 63:aee44afe6363 124 g_PidPara.IMax = 1000000;
MasashiNomura 63:aee44afe6363 125 g_PidPara.IMin = -1000000;
MasashiNomura 50:76413e8e073d 126 g_PidPara.mode = PID_0_OFF;
MasashiNomura 50:76413e8e073d 127
MasashiNomura 36:2cc739c7e4cb 128 // for(int i = 0; i < 4; ++i){
MasashiNomura 36:2cc739c7e4cb 129 // gf_MotParaUpdate[i] = false;
MasashiNomura 36:2cc739c7e4cb 130 // g_MotPara[i].limit_hi = LIM_MOT_INP_MAX;
MasashiNomura 36:2cc739c7e4cb 131 // g_MotPara[i].limit_low = LIM_MOT_INP_MIN;
MasashiNomura 36:2cc739c7e4cb 132 // }
MasashiNomura 22:24c9c2dedca9 133 }
MasashiNomura 35:3779201b4c73 134
MasashiNomura 41:45c982b1c5b6 135 void setDOCol(eLedCol col)
MasashiNomura 41:45c982b1c5b6 136 {
MasashiNomura 41:45c982b1c5b6 137 switch(col){
MasashiNomura 41:45c982b1c5b6 138 case WHITE:
MasashiNomura 42:cc8501b824ba 139 DO_01 = 1;
MasashiNomura 42:cc8501b824ba 140 DO_02 = 1;
MasashiNomura 42:cc8501b824ba 141 DO_03 = 1;
MasashiNomura 41:45c982b1c5b6 142 break;
MasashiNomura 41:45c982b1c5b6 143 case RED:
MasashiNomura 42:cc8501b824ba 144 DO_01 = 1;
MasashiNomura 41:45c982b1c5b6 145 DO_02 = 0;
MasashiNomura 41:45c982b1c5b6 146 DO_03 = 0;
MasashiNomura 41:45c982b1c5b6 147 break;
MasashiNomura 41:45c982b1c5b6 148 case GREEN:
MasashiNomura 41:45c982b1c5b6 149 DO_01 = 0;
MasashiNomura 42:cc8501b824ba 150 DO_02 = 1;
MasashiNomura 41:45c982b1c5b6 151 DO_03 = 0;
MasashiNomura 41:45c982b1c5b6 152 break;
MasashiNomura 41:45c982b1c5b6 153 case BLUE:
MasashiNomura 41:45c982b1c5b6 154 DO_01 = 0;
MasashiNomura 41:45c982b1c5b6 155 DO_02 = 0;
MasashiNomura 42:cc8501b824ba 156 DO_03 = 1;
MasashiNomura 42:cc8501b824ba 157 break;
MasashiNomura 42:cc8501b824ba 158 case YELLOW:
MasashiNomura 42:cc8501b824ba 159 DO_01 = 1;
MasashiNomura 42:cc8501b824ba 160 DO_02 = 1;
MasashiNomura 42:cc8501b824ba 161 DO_03 = 0;
MasashiNomura 42:cc8501b824ba 162 break;
MasashiNomura 42:cc8501b824ba 163 case PURPLE:
MasashiNomura 42:cc8501b824ba 164 DO_01 = 1;
MasashiNomura 42:cc8501b824ba 165 DO_02 = 0;
MasashiNomura 42:cc8501b824ba 166 DO_03 = 1;
MasashiNomura 42:cc8501b824ba 167 break;
MasashiNomura 42:cc8501b824ba 168 case LIGHT_BLUE:
MasashiNomura 42:cc8501b824ba 169 DO_01 = 0;
MasashiNomura 42:cc8501b824ba 170 DO_02 = 1;
MasashiNomura 42:cc8501b824ba 171 DO_03 = 1;
MasashiNomura 42:cc8501b824ba 172 break;
MasashiNomura 42:cc8501b824ba 173 case BLK_WHITE:
MasashiNomura 42:cc8501b824ba 174 DO_01 = !DO_01;
MasashiNomura 42:cc8501b824ba 175 DO_02 = !DO_02;
MasashiNomura 41:45c982b1c5b6 176 DO_03 = !DO_03;
MasashiNomura 41:45c982b1c5b6 177 break;
MasashiNomura 42:cc8501b824ba 178 case BLK_RED:
MasashiNomura 42:cc8501b824ba 179 DO_01 = !DO_01;
MasashiNomura 42:cc8501b824ba 180 DO_02 = 0;
MasashiNomura 42:cc8501b824ba 181 DO_03 = 0;
MasashiNomura 42:cc8501b824ba 182 break;
MasashiNomura 42:cc8501b824ba 183 case BLK_GREEN:
MasashiNomura 42:cc8501b824ba 184 DO_01 = 0;
MasashiNomura 42:cc8501b824ba 185 DO_02 = !DO_02;
MasashiNomura 42:cc8501b824ba 186 DO_03 = 0;
MasashiNomura 42:cc8501b824ba 187 break;
MasashiNomura 42:cc8501b824ba 188 case BLK_BLUE:
MasashiNomura 42:cc8501b824ba 189 DO_01 = 0;
MasashiNomura 42:cc8501b824ba 190 DO_02 = 0;
MasashiNomura 42:cc8501b824ba 191 DO_03 = !DO_03;
MasashiNomura 42:cc8501b824ba 192 break;
MasashiNomura 42:cc8501b824ba 193 case BLK_YELLOW:
MasashiNomura 41:45c982b1c5b6 194 DO_01 = !DO_01;
MasashiNomura 41:45c982b1c5b6 195 DO_02 = !DO_02;
MasashiNomura 41:45c982b1c5b6 196 DO_03 = 0;
MasashiNomura 41:45c982b1c5b6 197 break;
MasashiNomura 42:cc8501b824ba 198 case BLK_PURPLE:
MasashiNomura 41:45c982b1c5b6 199 DO_01 = !DO_01;
MasashiNomura 41:45c982b1c5b6 200 DO_02 = 0;
MasashiNomura 41:45c982b1c5b6 201 DO_03 = !DO_03;
MasashiNomura 41:45c982b1c5b6 202 break;
MasashiNomura 42:cc8501b824ba 203 case BLK_LIGHT_BLUE:
MasashiNomura 41:45c982b1c5b6 204 DO_01 = 0;
MasashiNomura 41:45c982b1c5b6 205 DO_02 = !DO_02;
MasashiNomura 41:45c982b1c5b6 206 DO_03 = !DO_03;
MasashiNomura 41:45c982b1c5b6 207 break;
MasashiNomura 41:45c982b1c5b6 208 case OFF:
MasashiNomura 41:45c982b1c5b6 209 default:
MasashiNomura 41:45c982b1c5b6 210 DO_01 = 0;//R
MasashiNomura 41:45c982b1c5b6 211 DO_02 = 0;//G
MasashiNomura 41:45c982b1c5b6 212 DO_03 = 0;//B
MasashiNomura 41:45c982b1c5b6 213 break;
MasashiNomura 41:45c982b1c5b6 214 }
MasashiNomura 41:45c982b1c5b6 215 }
MasashiNomura 41:45c982b1c5b6 216
MasashiNomura 41:45c982b1c5b6 217 void setDO4LED(enmHbState stat)
MasashiNomura 41:45c982b1c5b6 218 {
MasashiNomura 41:45c982b1c5b6 219 if(stat == NONE)
MasashiNomura 41:45c982b1c5b6 220 {// 消灯
MasashiNomura 41:45c982b1c5b6 221 setDOCol(OFF);
MasashiNomura 41:45c982b1c5b6 222 }
MasashiNomura 41:45c982b1c5b6 223 else if(stat == SLEEP)
MasashiNomura 41:45c982b1c5b6 224 {//YELLOW
MasashiNomura 41:45c982b1c5b6 225 setDOCol(YELLOW);
MasashiNomura 41:45c982b1c5b6 226 }
MasashiNomura 41:45c982b1c5b6 227 else if(stat == WAKEUP || stat == STANDBY)
MasashiNomura 41:45c982b1c5b6 228 {//BLUE
MasashiNomura 41:45c982b1c5b6 229 setDOCol(BLUE);
MasashiNomura 41:45c982b1c5b6 230 }
MasashiNomura 41:45c982b1c5b6 231 else if(stat == IDLE)
MasashiNomura 41:45c982b1c5b6 232 {//GREEN
MasashiNomura 41:45c982b1c5b6 233 setDOCol(GREEN);
MasashiNomura 41:45c982b1c5b6 234 }
MasashiNomura 48:71aec693a7dc 235 else if(stat == UPPER_IDLE)
MasashiNomura 48:71aec693a7dc 236 {//WHITE
MasashiNomura 48:71aec693a7dc 237 setDOCol(WHITE);
MasashiNomura 48:71aec693a7dc 238 }
MasashiNomura 41:45c982b1c5b6 239 else if(stat == TAKE_OFF || stat == HOVER || stat == DRIVE || stat == GROUND || stat == EMGGND)
MasashiNomura 41:45c982b1c5b6 240 {//PURPLE
MasashiNomura 43:156199c2f9b6 241 if(gf_BlinkLED){
MasashiNomura 43:156199c2f9b6 242 setDOCol(BLK_PURPLE);
MasashiNomura 43:156199c2f9b6 243 gf_BlinkLED = false;
MasashiNomura 43:156199c2f9b6 244 }
MasashiNomura 43:156199c2f9b6 245 else{
MasashiNomura 43:156199c2f9b6 246 setDOCol(PURPLE);
MasashiNomura 43:156199c2f9b6 247 }
MasashiNomura 41:45c982b1c5b6 248 }
MasashiNomura 42:cc8501b824ba 249 else if(stat == CHK_EG_ENT || stat == CHK_EG_MID || stat == CHK_EG_EXIT)
MasashiNomura 41:45c982b1c5b6 250 {//LIGHT BLUE
MasashiNomura 41:45c982b1c5b6 251 setDOCol(LIGHT_BLUE);
MasashiNomura 41:45c982b1c5b6 252 }
MasashiNomura 42:cc8501b824ba 253 else if(stat == CHK_EG_F || stat == CHK_EG_R )
MasashiNomura 42:cc8501b824ba 254 {//BLK_LIGHT BLUE
MasashiNomura 42:cc8501b824ba 255 setDOCol(BLK_LIGHT_BLUE);
MasashiNomura 42:cc8501b824ba 256 }
MasashiNomura 41:45c982b1c5b6 257 else if(stat == CHK_ENT || stat == CHK_MOT || stat == CHK_AXL || stat == CHK_ATT || stat == CHK_EXIT)
MasashiNomura 41:45c982b1c5b6 258 {//WHITE
MasashiNomura 41:45c982b1c5b6 259 setDOCol(WHITE);
MasashiNomura 41:45c982b1c5b6 260 }
MasashiNomura 41:45c982b1c5b6 261 else/* if(stat == MOT_STOP)*/
MasashiNomura 41:45c982b1c5b6 262 {
MasashiNomura 41:45c982b1c5b6 263 setDOCol(RED);
MasashiNomura 41:45c982b1c5b6 264 }
MasashiNomura 41:45c982b1c5b6 265 }
MasashiNomura 41:45c982b1c5b6 266
MasashiNomura 22:24c9c2dedca9 267 void setState(enmHbState stat){
MasashiNomura 22:24c9c2dedca9 268 // ありえない遷移を排除
MasashiNomura 22:24c9c2dedca9 269 if(gf_State == SLEEP){if(stat != WAKEUP) return;}
MasashiNomura 22:24c9c2dedca9 270 if(gf_State == WAKEUP){if(stat != STANDBY) return;}
MasashiNomura 22:24c9c2dedca9 271 if(gf_State == STANDBY){if(stat !=IDLE) return;}
MasashiNomura 23:79e20be4bc5b 272 if(gf_State == IDLE){if(stat != TAKE_OFF && stat != SLEEP) return;}
MasashiNomura 23:79e20be4bc5b 273 if(gf_State == TAKE_OFF){if(stat != HOVER && stat != GROUND) return;}
MasashiNomura 22:24c9c2dedca9 274 if(gf_State == GROUND){if(stat != IDLE) return;}
MasashiNomura 22:24c9c2dedca9 275 if(gf_State == HOVER){if(stat != DRIVE && stat != GROUND) return;}
MasashiNomura 22:24c9c2dedca9 276 if(gf_State == DRIVE){if(stat != HOVER && stat != EMGGND) return;}
MasashiNomura 22:24c9c2dedca9 277 if(gf_State == EMGGND){if(stat != IDLE) return;}
MasashiNomura 22:24c9c2dedca9 278
MasashiNomura 23:79e20be4bc5b 279 sp.printf("state: %d\r\n",stat);
MasashiNomura 22:24c9c2dedca9 280 gf_State = stat;
MasashiNomura 36:2cc739c7e4cb 281 gf_StateEnt = true;
MasashiNomura 22:24c9c2dedca9 282 }
MasashiNomura 23:79e20be4bc5b 283 void setStateF(enmHbState stat){
MasashiNomura 23:79e20be4bc5b 284 sp.printf("state: %d\r\n",stat);
MasashiNomura 23:79e20be4bc5b 285 enmHbState tmp;
MasashiNomura 25:f3a6e7eec9c3 286 if((UINT16)stat > MOT_STOP){
MasashiNomura 23:79e20be4bc5b 287 tmp = SLEEP;
MasashiNomura 23:79e20be4bc5b 288 }
MasashiNomura 23:79e20be4bc5b 289 else
MasashiNomura 23:79e20be4bc5b 290 {
MasashiNomura 23:79e20be4bc5b 291 tmp = stat;
MasashiNomura 23:79e20be4bc5b 292 }
MasashiNomura 23:79e20be4bc5b 293 gf_State = tmp;
MasashiNomura 36:2cc739c7e4cb 294 gf_StateEnt = true;
MasashiNomura 23:79e20be4bc5b 295 }
MasashiNomura 37:d51dacb4c30f 296
MasashiNomura 37:d51dacb4c30f 297 bool isActiveState(){
MasashiNomura 37:d51dacb4c30f 298 if(gf_State >= IDLE && gf_State <= EMGGND){
MasashiNomura 37:d51dacb4c30f 299 return true;
MasashiNomura 37:d51dacb4c30f 300 }
MasashiNomura 37:d51dacb4c30f 301 else {
MasashiNomura 37:d51dacb4c30f 302 return false;
MasashiNomura 37:d51dacb4c30f 303 }
MasashiNomura 37:d51dacb4c30f 304 }
MasashiNomura 37:d51dacb4c30f 305