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
- Committer:
- takeru0x1103
- Date:
- 2018-12-05
- Revision:
- 19:4b0fe9a5ec38
- Parent:
- 18:5aa48aec9cae
- Child:
- 20:0394e15412c3
File content as of revision 19:4b0fe9a5ec38:
#ifndef __GLOBALFLAGS_H__
#define __GLOBALFLAGS_H__
#include "mbed.h"
#include "typedef.h"
#define G_CMD_BUF_SIZ 32
#define STATE_QUE_SIZ 8
typedef union{
UINT16 flg;
struct{
bool e1 : 1;//前エンジン回転数
bool e2 : 1;//後ろエンジン回転数
bool m1 : 1;//サブモーター回転数
bool m2 : 1;//サブモーター回転数
bool m3 : 1;//サブモーター回転数
bool m4 : 1;//サブモーター回転数
bool gy : 1;//ジャイロ
bool yaw : 1;//ヨー角
bool fb : 1;//PID制御feedback結果
bool pp : 1;//P制御ゲイン(アウターループ)
bool p : 1;//P制御ゲイン
bool i : 1;//I制御ゲイン
bool d : 1;//D制御ゲイン
}bf;
}typPrintFlag;
typedef union{
UINT16 flg;
struct{
bool e1 : 1;//
bool e2 : 1;//
bool m1 : 1;//
bool m2 : 1;//
bool m3 : 1;//
bool m4 : 1;//
bool gy : 1;//
bool yaw : 1;//
bool fb : 1;//PID制御feedback結果
bool pp : 1;//P制御ゲイン(アウターループ)
bool p : 1;//P制御ゲイン
bool i : 1;//I制御ゲイン
bool d : 1;//D制御ゲイン
}bf;
}typCalFlag;
//チェックフラグ
typedef union{
UINT16 flg;
struct{
bool mot : 1;//
bool sw : 1;//
bool accel: 1;//
}bf;
}typChkFlag;
//
typedef union{
UINT16 dt;
struct{
UINT16 val : 12;//アクセル設定値
bool req : 1;//アクセル更新要求
}bf;
}typAccel;
//ステート定義
enum enmHbState
{NONE //何もなし
,WAKEUP //
,CHECK_MOT //
,IDLE //
,TAKE_OFF //
,GROUND //
};
/////////////////////////////////////////////////
class GlobalFlags{
private:
enmHbState state;//現在のステート
enmHbState stateQueue[STATE_QUE_SIZ];//ステート予約用のキューバッファ
int wp; //ライトポインタ
int rp; //リードポインタ
bool full; //フルフラグ
bool empty; //エンプティフラグ
public:
GlobalFlags();
bool push(enmHbState iState);
bool pull();
};
//モニタ用LED
extern DigitalOut led1;
extern DigitalOut led2;
extern DigitalOut led3;
extern DigitalOut led4;
extern GlobalFlags gf;
extern char g_CmdBuf[G_CMD_BUF_SIZ] ;// コマンド受け渡しバッファ
extern bool gf_CmdPrs; //コマンドパーサー実行要求フラグ
extern typPrintFlag gf_Print; //デバッグプリントフラグ(1回表示)
extern typPrintFlag gf_Mon; //デバッグモニタフラグ(繰り返し表示)
extern typCalFlag gf_Cal; //
extern typChkFlag gf_Chk; //チェックフラグ
extern typAccel gf_AxReq[2]; //アクセル更新
extern typAccel gf_MtReq[4]; //モーター更新
extern bool gf_AttCntEna; //姿勢制御イネーブル
#endif