teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Committer:
MasashiNomura
Date:
Thu Dec 13 12:15:35 2018 +0000
Revision:
26:732bc37fbefd
Parent:
23:79e20be4bc5b
Child:
30:13ada1a24c59
2018/12/13 Add MotorOfs Function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MasashiNomura 22:24c9c2dedca9 1 #include "HbUserOpe.h"
MasashiNomura 22:24c9c2dedca9 2 #include "fpga.h"
MasashiNomura 22:24c9c2dedca9 3 //=========================================
MasashiNomura 22:24c9c2dedca9 4 //コンストラクタ
MasashiNomura 22:24c9c2dedca9 5 //=========================================
MasashiNomura 22:24c9c2dedca9 6 HbUserOpe::HbUserOpe(){
MasashiNomura 22:24c9c2dedca9 7 oldOpe.w = curOpe.w = 0;
MasashiNomura 22:24c9c2dedca9 8 }
MasashiNomura 22:24c9c2dedca9 9
MasashiNomura 22:24c9c2dedca9 10 //=========================================
MasashiNomura 22:24c9c2dedca9 11 //デストラクタ
MasashiNomura 22:24c9c2dedca9 12 //=========================================
MasashiNomura 22:24c9c2dedca9 13 HbUserOpe::~HbUserOpe(){
MasashiNomura 22:24c9c2dedca9 14 }
MasashiNomura 22:24c9c2dedca9 15
MasashiNomura 22:24c9c2dedca9 16 typUserSw HbUserOpe::GetUserOpe()
MasashiNomura 22:24c9c2dedca9 17 {
MasashiNomura 22:24c9c2dedca9 18 oldOpe = curOpe;
MasashiNomura 22:24c9c2dedca9 19 curOpe.w = fpgaGetUserSw();
MasashiNomura 22:24c9c2dedca9 20 return curOpe;
MasashiNomura 23:79e20be4bc5b 21 }
MasashiNomura 23:79e20be4bc5b 22 bool HbUserOpe::ChkCtrlSW(SW_TYPE styp)
MasashiNomura 23:79e20be4bc5b 23 {
MasashiNomura 23:79e20be4bc5b 24 if(styp == ACCEL_R){return curOpe.bf.axl_r;}
MasashiNomura 23:79e20be4bc5b 25 else if(styp == ACCEL_L){return curOpe.bf.axl_l;}
MasashiNomura 23:79e20be4bc5b 26 else if(styp == STOP){return curOpe.bf.stop;}
MasashiNomura 23:79e20be4bc5b 27 else if(styp == YAW_CTRL){return curOpe.bf.y_ctrl;}
MasashiNomura 23:79e20be4bc5b 28 else/*if(styp == ENG_STOP)*/{return curOpe.bf.eng_stop;}
MasashiNomura 23:79e20be4bc5b 29 // UINT16 mask = 0x1 << styp;
MasashiNomura 23:79e20be4bc5b 30 // return curOpe.w & mask;
MasashiNomura 23:79e20be4bc5b 31 }
MasashiNomura 26:732bc37fbefd 32 bool HbUserOpe::ChkCtrlSW(SW_TYPE2 styp)
MasashiNomura 26:732bc37fbefd 33 {
MasashiNomura 26:732bc37fbefd 34 if(styp == F_L){return curOpe.bf.axl_r;}
MasashiNomura 26:732bc37fbefd 35 else if(styp == F_R){return curOpe.bf.axl_l;}
MasashiNomura 26:732bc37fbefd 36 else if(styp == R_L){return curOpe.bf.stop;}
MasashiNomura 26:732bc37fbefd 37 else if(styp == R_R){return curOpe.bf.y_ctrl;}
MasashiNomura 26:732bc37fbefd 38 else/*if(styp == ENG_STOP)*/{return curOpe.bf.eng_stop;}
MasashiNomura 26:732bc37fbefd 39 // UINT16 mask = 0x1 << styp;
MasashiNomura 26:732bc37fbefd 40 // return curOpe.w & mask;
MasashiNomura 26:732bc37fbefd 41 }
MasashiNomura 23:79e20be4bc5b 42 bool HbUserOpe::ChkCtrlSwAny()
MasashiNomura 23:79e20be4bc5b 43 {
MasashiNomura 23:79e20be4bc5b 44 UINT16 mask = 0x1;
MasashiNomura 23:79e20be4bc5b 45 for(int i = 0; i < 5; ++i){
MasashiNomura 23:79e20be4bc5b 46 if(curOpe.w & mask){
MasashiNomura 23:79e20be4bc5b 47 return true;
MasashiNomura 23:79e20be4bc5b 48 }
MasashiNomura 23:79e20be4bc5b 49 mask = mask << 1;
MasashiNomura 23:79e20be4bc5b 50 }
MasashiNomura 23:79e20be4bc5b 51 return false;
MasashiNomura 23:79e20be4bc5b 52 }
MasashiNomura 26:732bc37fbefd 53 bool HbUserOpe::ChkCtrlSwRiseEdge(SW_TYPE2 styp)
MasashiNomura 26:732bc37fbefd 54 {
MasashiNomura 26:732bc37fbefd 55 if(styp == F_L){return curOpe.bf.axl_r && !oldOpe.bf.axl_r;}
MasashiNomura 26:732bc37fbefd 56 else if(styp == F_R){return curOpe.bf.axl_l && !oldOpe.bf.axl_l;}
MasashiNomura 26:732bc37fbefd 57 else if(styp == R_L){return curOpe.bf.stop && !oldOpe.bf.stop;}
MasashiNomura 26:732bc37fbefd 58 else if(styp == R_R){return curOpe.bf.y_ctrl && !oldOpe.bf.y_ctrl;}
MasashiNomura 26:732bc37fbefd 59 else/*if(styp == ENG_STOP)*/{return curOpe.bf.eng_stop && !oldOpe.bf.eng_stop;}
MasashiNomura 26:732bc37fbefd 60 // UINT16 mask = 0x1 << styp;
MasashiNomura 26:732bc37fbefd 61 // return curOpe.w & mask;
MasashiNomura 26:732bc37fbefd 62 }