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.
globalFlags.h@20:0394e15412c3, 2018-12-05 (annotated)
- Committer:
- takeru0x1103
- Date:
- Wed Dec 05 01:43:55 2018 +0000
- Revision:
- 20:0394e15412c3
- Parent:
- 19:4b0fe9a5ec38
- Child:
- 21:78302ecdb661
1205_?????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
takeru0x1103 | 8:1ca49cb18290 | 1 | #ifndef __GLOBALFLAGS_H__ |
takeru0x1103 | 8:1ca49cb18290 | 2 | #define __GLOBALFLAGS_H__ |
takeru0x1103 | 8:1ca49cb18290 | 3 | |
takeru0x1103 | 16:05b9e44889f1 | 4 | #include "mbed.h" |
takeru0x1103 | 17:f9610f3cfa1b | 5 | #include "typedef.h" |
takeru0x1103 | 17:f9610f3cfa1b | 6 | |
takeru0x1103 | 19:4b0fe9a5ec38 | 7 | #define G_CMD_BUF_SIZ 32 |
takeru0x1103 | 19:4b0fe9a5ec38 | 8 | #define STATE_QUE_SIZ 8 |
takeru0x1103 | 19:4b0fe9a5ec38 | 9 | |
takeru0x1103 | 17:f9610f3cfa1b | 10 | typedef union{ |
takeru0x1103 | 17:f9610f3cfa1b | 11 | UINT16 flg; |
takeru0x1103 | 17:f9610f3cfa1b | 12 | struct{ |
takeru0x1103 | 17:f9610f3cfa1b | 13 | bool e1 : 1;//前エンジン回転数 |
takeru0x1103 | 17:f9610f3cfa1b | 14 | bool e2 : 1;//後ろエンジン回転数 |
takeru0x1103 | 17:f9610f3cfa1b | 15 | bool m1 : 1;//サブモーター回転数 |
takeru0x1103 | 17:f9610f3cfa1b | 16 | bool m2 : 1;//サブモーター回転数 |
takeru0x1103 | 17:f9610f3cfa1b | 17 | bool m3 : 1;//サブモーター回転数 |
takeru0x1103 | 17:f9610f3cfa1b | 18 | bool m4 : 1;//サブモーター回転数 |
takeru0x1103 | 17:f9610f3cfa1b | 19 | bool gy : 1;//ジャイロ |
takeru0x1103 | 17:f9610f3cfa1b | 20 | bool yaw : 1;//ヨー角 |
takeru0x1103 | 18:5aa48aec9cae | 21 | bool fb : 1;//PID制御feedback結果 |
takeru0x1103 | 18:5aa48aec9cae | 22 | bool pp : 1;//P制御ゲイン(アウターループ) |
takeru0x1103 | 18:5aa48aec9cae | 23 | bool p : 1;//P制御ゲイン |
takeru0x1103 | 18:5aa48aec9cae | 24 | bool i : 1;//I制御ゲイン |
takeru0x1103 | 18:5aa48aec9cae | 25 | bool d : 1;//D制御ゲイン |
takeru0x1103 | 17:f9610f3cfa1b | 26 | }bf; |
takeru0x1103 | 17:f9610f3cfa1b | 27 | }typPrintFlag; |
takeru0x1103 | 17:f9610f3cfa1b | 28 | |
takeru0x1103 | 17:f9610f3cfa1b | 29 | typedef union{ |
takeru0x1103 | 17:f9610f3cfa1b | 30 | UINT16 flg; |
takeru0x1103 | 17:f9610f3cfa1b | 31 | struct{ |
takeru0x1103 | 17:f9610f3cfa1b | 32 | bool e1 : 1;// |
takeru0x1103 | 17:f9610f3cfa1b | 33 | bool e2 : 1;// |
takeru0x1103 | 17:f9610f3cfa1b | 34 | bool m1 : 1;// |
takeru0x1103 | 17:f9610f3cfa1b | 35 | bool m2 : 1;// |
takeru0x1103 | 17:f9610f3cfa1b | 36 | bool m3 : 1;// |
takeru0x1103 | 17:f9610f3cfa1b | 37 | bool m4 : 1;// |
takeru0x1103 | 17:f9610f3cfa1b | 38 | bool gy : 1;// |
takeru0x1103 | 17:f9610f3cfa1b | 39 | bool yaw : 1;// |
takeru0x1103 | 18:5aa48aec9cae | 40 | bool fb : 1;//PID制御feedback結果 |
takeru0x1103 | 18:5aa48aec9cae | 41 | bool pp : 1;//P制御ゲイン(アウターループ) |
takeru0x1103 | 18:5aa48aec9cae | 42 | bool p : 1;//P制御ゲイン |
takeru0x1103 | 18:5aa48aec9cae | 43 | bool i : 1;//I制御ゲイン |
takeru0x1103 | 18:5aa48aec9cae | 44 | bool d : 1;//D制御ゲイン |
takeru0x1103 | 17:f9610f3cfa1b | 45 | }bf; |
takeru0x1103 | 17:f9610f3cfa1b | 46 | }typCalFlag; |
takeru0x1103 | 17:f9610f3cfa1b | 47 | |
takeru0x1103 | 19:4b0fe9a5ec38 | 48 | // |
takeru0x1103 | 17:f9610f3cfa1b | 49 | typedef union{ |
takeru0x1103 | 17:f9610f3cfa1b | 50 | UINT16 dt; |
takeru0x1103 | 17:f9610f3cfa1b | 51 | struct{ |
takeru0x1103 | 18:5aa48aec9cae | 52 | UINT16 val : 12;//アクセル設定値 |
takeru0x1103 | 17:f9610f3cfa1b | 53 | bool req : 1;//アクセル更新要求 |
takeru0x1103 | 17:f9610f3cfa1b | 54 | }bf; |
takeru0x1103 | 17:f9610f3cfa1b | 55 | }typAccel; |
takeru0x1103 | 17:f9610f3cfa1b | 56 | |
takeru0x1103 | 19:4b0fe9a5ec38 | 57 | //ステート定義 |
takeru0x1103 | 19:4b0fe9a5ec38 | 58 | enum enmHbState |
takeru0x1103 | 19:4b0fe9a5ec38 | 59 | {NONE //何もなし |
takeru0x1103 | 20:0394e15412c3 | 60 | ,WAKEUP //起動処理 |
takeru0x1103 | 20:0394e15412c3 | 61 | ,STANDBY //スタンバイ(エンジンかかるの待ち) |
takeru0x1103 | 20:0394e15412c3 | 62 | ,IDLE //アイドル(エンジン) |
takeru0x1103 | 20:0394e15412c3 | 63 | ,TAKE_OFF //離陸 |
takeru0x1103 | 20:0394e15412c3 | 64 | ,HOVER //ホバリング |
takeru0x1103 | 20:0394e15412c3 | 65 | ,GROUND //着陸 |
takeru0x1103 | 20:0394e15412c3 | 66 | ,CHK_ENT //チェックエンター |
takeru0x1103 | 20:0394e15412c3 | 67 | ,CHK_MOT //モーターチェック |
takeru0x1103 | 20:0394e15412c3 | 68 | ,CHK_AXL //アクセルサーボチェック |
takeru0x1103 | 20:0394e15412c3 | 69 | ,CHK_ATT //姿勢制御チェック |
takeru0x1103 | 20:0394e15412c3 | 70 | ,CHK_EXIT //チェックステート脱出 |
takeru0x1103 | 19:4b0fe9a5ec38 | 71 | }; |
takeru0x1103 | 19:4b0fe9a5ec38 | 72 | |
takeru0x1103 | 17:f9610f3cfa1b | 73 | ///////////////////////////////////////////////// |
takeru0x1103 | 19:4b0fe9a5ec38 | 74 | class GlobalFlags{ |
takeru0x1103 | 19:4b0fe9a5ec38 | 75 | private: |
takeru0x1103 | 19:4b0fe9a5ec38 | 76 | enmHbState stateQueue[STATE_QUE_SIZ];//ステート予約用のキューバッファ |
takeru0x1103 | 19:4b0fe9a5ec38 | 77 | int wp; //ライトポインタ |
takeru0x1103 | 19:4b0fe9a5ec38 | 78 | int rp; //リードポインタ |
takeru0x1103 | 19:4b0fe9a5ec38 | 79 | bool full; //フルフラグ |
takeru0x1103 | 19:4b0fe9a5ec38 | 80 | bool empty; //エンプティフラグ |
takeru0x1103 | 19:4b0fe9a5ec38 | 81 | public: |
takeru0x1103 | 20:0394e15412c3 | 82 | enmHbState state;//現在のステート |
takeru0x1103 | 20:0394e15412c3 | 83 | GlobalFlags();//コンストラクタ |
takeru0x1103 | 19:4b0fe9a5ec38 | 84 | bool push(enmHbState iState); |
takeru0x1103 | 19:4b0fe9a5ec38 | 85 | bool pull(); |
takeru0x1103 | 19:4b0fe9a5ec38 | 86 | }; |
takeru0x1103 | 16:05b9e44889f1 | 87 | |
takeru0x1103 | 17:f9610f3cfa1b | 88 | //モニタ用LED |
takeru0x1103 | 16:05b9e44889f1 | 89 | extern DigitalOut led1; |
takeru0x1103 | 16:05b9e44889f1 | 90 | extern DigitalOut led2; |
takeru0x1103 | 16:05b9e44889f1 | 91 | extern DigitalOut led3; |
takeru0x1103 | 16:05b9e44889f1 | 92 | extern DigitalOut led4; |
takeru0x1103 | 8:1ca49cb18290 | 93 | |
takeru0x1103 | 19:4b0fe9a5ec38 | 94 | extern GlobalFlags gf; |
takeru0x1103 | 19:4b0fe9a5ec38 | 95 | |
takeru0x1103 | 19:4b0fe9a5ec38 | 96 | extern char g_CmdBuf[G_CMD_BUF_SIZ] ;// コマンド受け渡しバッファ |
takeru0x1103 | 19:4b0fe9a5ec38 | 97 | extern bool gf_CmdPrs; //コマンドパーサー実行要求フラグ |
takeru0x1103 | 19:4b0fe9a5ec38 | 98 | |
takeru0x1103 | 19:4b0fe9a5ec38 | 99 | extern typPrintFlag gf_Print; //デバッグプリントフラグ(1回表示) |
takeru0x1103 | 19:4b0fe9a5ec38 | 100 | extern typPrintFlag gf_Mon; //デバッグモニタフラグ(繰り返し表示) |
takeru0x1103 | 18:5aa48aec9cae | 101 | extern typCalFlag gf_Cal; // |
takeru0x1103 | 20:0394e15412c3 | 102 | //extern typChkFlag gf_Chk; //チェックフラグ |
takeru0x1103 | 17:f9610f3cfa1b | 103 | extern typAccel gf_AxReq[2]; //アクセル更新 |
takeru0x1103 | 17:f9610f3cfa1b | 104 | extern typAccel gf_MtReq[4]; //モーター更新 |
takeru0x1103 | 18:5aa48aec9cae | 105 | extern bool gf_AttCntEna; //姿勢制御イネーブル |
takeru0x1103 | 8:1ca49cb18290 | 106 | |
takeru0x1103 | 18:5aa48aec9cae | 107 | |
takeru0x1103 | 19:4b0fe9a5ec38 | 108 | |
takeru0x1103 | 19:4b0fe9a5ec38 | 109 | |
takeru0x1103 | 18:5aa48aec9cae | 110 | #endif |