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.cpp@21:78302ecdb661, 2018-12-06 (annotated)
- Committer:
- takeru0x1103
- Date:
- Thu Dec 06 01:50:17 2018 +0000
- Revision:
- 21:78302ecdb661
- Parent:
- 20:0394e15412c3
- Child:
- 22:24c9c2dedca9
for nomurasan;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
takeru0x1103 | 19:4b0fe9a5ec38 | 1 | |
takeru0x1103 | 16:05b9e44889f1 | 2 | #include "globalFlags.h" |
takeru0x1103 | 19:4b0fe9a5ec38 | 3 | #define STATE_BUF_SIZ 8 |
takeru0x1103 | 16:05b9e44889f1 | 4 | |
takeru0x1103 | 16:05b9e44889f1 | 5 | DigitalOut led1(LED1); |
takeru0x1103 | 16:05b9e44889f1 | 6 | DigitalOut led2(LED2); |
takeru0x1103 | 16:05b9e44889f1 | 7 | DigitalOut led3(LED3); |
takeru0x1103 | 16:05b9e44889f1 | 8 | DigitalOut led4(LED4); |
takeru0x1103 | 8:1ca49cb18290 | 9 | |
takeru0x1103 | 21:78302ecdb661 | 10 | //GlobalFlags gf; |
takeru0x1103 | 21:78302ecdb661 | 11 | |
takeru0x1103 | 19:4b0fe9a5ec38 | 12 | char g_CmdBuf[G_CMD_BUF_SIZ] ;// コマンド受け渡しバッファ |
takeru0x1103 | 17:f9610f3cfa1b | 13 | bool gf_CmdPrs = false; |
takeru0x1103 | 19:4b0fe9a5ec38 | 14 | |
takeru0x1103 | 21:78302ecdb661 | 15 | bool gf_Armed = false ;//アーミングフラグ |
takeru0x1103 | 19:4b0fe9a5ec38 | 16 | typPrintFlag gf_Print ;// |
takeru0x1103 | 19:4b0fe9a5ec38 | 17 | typPrintFlag gf_Mon ;// |
takeru0x1103 | 19:4b0fe9a5ec38 | 18 | typCalFlag gf_Cal ;// |
takeru0x1103 | 19:4b0fe9a5ec38 | 19 | typAccel gf_AxReq[2] ={0,} ;//アクセル更新 |
takeru0x1103 | 19:4b0fe9a5ec38 | 20 | typAccel gf_MtReq[4] ={0,} ;//モーター更新 |
takeru0x1103 | 19:4b0fe9a5ec38 | 21 | |
takeru0x1103 | 20:0394e15412c3 | 22 | |
takeru0x1103 | 21:78302ecdb661 | 23 | /* |
takeru0x1103 | 19:4b0fe9a5ec38 | 24 | //=========================================== |
takeru0x1103 | 19:4b0fe9a5ec38 | 25 | //コンストラクタ |
takeru0x1103 | 19:4b0fe9a5ec38 | 26 | //=========================================== |
takeru0x1103 | 19:4b0fe9a5ec38 | 27 | GlobalFlags::GlobalFlags(){ |
takeru0x1103 | 19:4b0fe9a5ec38 | 28 | //初期ステート |
takeru0x1103 | 21:78302ecdb661 | 29 | state = SLEEP; |
takeru0x1103 | 19:4b0fe9a5ec38 | 30 | //ステートキュー初期化 |
takeru0x1103 | 19:4b0fe9a5ec38 | 31 | for(int i=0; i<STATE_QUE_SIZ; i++){ |
takeru0x1103 | 19:4b0fe9a5ec38 | 32 | stateQueue[i] = NONE; |
takeru0x1103 | 19:4b0fe9a5ec38 | 33 | } |
takeru0x1103 | 19:4b0fe9a5ec38 | 34 | rp = wp = 0;//先頭を指す |
takeru0x1103 | 19:4b0fe9a5ec38 | 35 | full = false;//最初はエンプティ |
takeru0x1103 | 19:4b0fe9a5ec38 | 36 | empty = true; |
takeru0x1103 | 19:4b0fe9a5ec38 | 37 | } |
takeru0x1103 | 19:4b0fe9a5ec38 | 38 | |
takeru0x1103 | 21:78302ecdb661 | 39 | |
takeru0x1103 | 19:4b0fe9a5ec38 | 40 | //----------------------------------- |
takeru0x1103 | 19:4b0fe9a5ec38 | 41 | //ステートのFIFOにプッシュする |
takeru0x1103 | 19:4b0fe9a5ec38 | 42 | //----------------------------------- |
takeru0x1103 | 19:4b0fe9a5ec38 | 43 | bool GlobalFlags::push(enmHbState iState){ |
takeru0x1103 | 19:4b0fe9a5ec38 | 44 | if(full){ |
takeru0x1103 | 19:4b0fe9a5ec38 | 45 | return false;//FFULLフラグが立ってら入力を受け付けない |
takeru0x1103 | 19:4b0fe9a5ec38 | 46 | }else{ |
takeru0x1103 | 19:4b0fe9a5ec38 | 47 | stateQueue[wp] = iState;//キューに突っ込んで |
takeru0x1103 | 19:4b0fe9a5ec38 | 48 | wp = (wp==STATE_QUE_SIZ) ? 0 : wp+1;//ライトポインタを進める |
takeru0x1103 | 19:4b0fe9a5ec38 | 49 | full = (wp == rp)? true : false; //次ライト予定の場所がリードポインタに追いついたらFULLを立てる |
takeru0x1103 | 19:4b0fe9a5ec38 | 50 | empty = false; |
takeru0x1103 | 19:4b0fe9a5ec38 | 51 | return true; |
takeru0x1103 | 19:4b0fe9a5ec38 | 52 | } |
takeru0x1103 | 19:4b0fe9a5ec38 | 53 | } |
takeru0x1103 | 19:4b0fe9a5ec38 | 54 | |
takeru0x1103 | 19:4b0fe9a5ec38 | 55 | //----------------------------------- |
takeru0x1103 | 19:4b0fe9a5ec38 | 56 | //ステートFIFOから次の予約ステートを引き抜く |
takeru0x1103 | 19:4b0fe9a5ec38 | 57 | //----------------------------------- |
takeru0x1103 | 19:4b0fe9a5ec38 | 58 | bool GlobalFlags::pull(){ |
takeru0x1103 | 19:4b0fe9a5ec38 | 59 | if(empty){ |
takeru0x1103 | 19:4b0fe9a5ec38 | 60 | return false;//EMPTYだったら引き抜けない |
takeru0x1103 | 19:4b0fe9a5ec38 | 61 | }else{ |
takeru0x1103 | 19:4b0fe9a5ec38 | 62 | state = stateQueue[rp];//リードポインタの指すデータをステートに移す |
takeru0x1103 | 19:4b0fe9a5ec38 | 63 | stateQueue[rp] = NONE;//バッファを消す |
takeru0x1103 | 19:4b0fe9a5ec38 | 64 | rp = (rp==STATE_QUE_SIZ) ? 0 : rp+1;//リードポインタを進める |
takeru0x1103 | 19:4b0fe9a5ec38 | 65 | full = false; //フルではなくなる |
takeru0x1103 | 19:4b0fe9a5ec38 | 66 | empty = (stateQueue[rp] == NONE) ? true : false;//次にリードする場所がNONEだったらEMPTYを立てる |
takeru0x1103 | 19:4b0fe9a5ec38 | 67 | return true; |
takeru0x1103 | 19:4b0fe9a5ec38 | 68 | } |
takeru0x1103 | 19:4b0fe9a5ec38 | 69 | } |
takeru0x1103 | 21:78302ecdb661 | 70 | */ |
takeru0x1103 | 19:4b0fe9a5ec38 | 71 | |
takeru0x1103 | 19:4b0fe9a5ec38 | 72 |