teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Committer:
MasashiNomura
Date:
Wed Dec 19 12:22:22 2018 +0000
Revision:
31:56c554c560c1
Parent:
30:13ada1a24c59
Child:
33:eb260dbfc22a
12/19 test modify PID etc

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 30:13ada1a24c59 22 // bool HbUserOpe::ChkCtrlSW(SW_TYPE styp)
MasashiNomura 30:13ada1a24c59 23 // {
MasashiNomura 30:13ada1a24c59 24 // if(styp == ACCEL_R){return curOpe.bf.brk_l;}
MasashiNomura 30:13ada1a24c59 25 // else if(styp == ACCEL_L){return curOpe.bf.axl_l;}
MasashiNomura 30:13ada1a24c59 26 // else if(styp == STOP){return curOpe.bf.stop;}
MasashiNomura 30:13ada1a24c59 27 // else if(styp == YAW_CTRL){return curOpe.bf.y_ctrl;}
MasashiNomura 30:13ada1a24c59 28 // else/*if(styp == ENG_STOP)*/{return curOpe.bf.eng_stop;}
MasashiNomura 30:13ada1a24c59 29 // // UINT16 mask = 0x1 << styp;
MasashiNomura 30:13ada1a24c59 30 // // return curOpe.w & mask;
MasashiNomura 30:13ada1a24c59 31 // }
MasashiNomura 23:79e20be4bc5b 32 bool HbUserOpe::ChkCtrlSW(SW_TYPE styp)
MasashiNomura 23:79e20be4bc5b 33 {
MasashiNomura 30:13ada1a24c59 34 if(styp == BRK_L) {return curOpe.bf.brk_l;}
MasashiNomura 30:13ada1a24c59 35 else if(styp == BRK_R) {return curOpe.bf.brk_r;}
MasashiNomura 30:13ada1a24c59 36 else if(styp == R_1) {return curOpe.bf.resv_1;}
MasashiNomura 30:13ada1a24c59 37 else if(styp == R_2) {return curOpe.bf.resv_2;}
MasashiNomura 30:13ada1a24c59 38 else if(styp == MOT_STOP){return curOpe.bf.mot_stop;}
MasashiNomura 30:13ada1a24c59 39 else if(styp == R_3) {return curOpe.bf.resv_3;}
MasashiNomura 30:13ada1a24c59 40 else if(styp == R_4) {return curOpe.bf.resv_4;}
MasashiNomura 30:13ada1a24c59 41 else if(styp == R_5) {return curOpe.bf.resv_5;}
MasashiNomura 30:13ada1a24c59 42 else if(styp == R_6) {return curOpe.bf.resv_6;}
MasashiNomura 30:13ada1a24c59 43 else if(styp == ALL_STOP){return curOpe.bf.all_stop;}
MasashiNomura 31:56c554c560c1 44 else {return false;}
MasashiNomura 26:732bc37fbefd 45 }
MasashiNomura 23:79e20be4bc5b 46 bool HbUserOpe::ChkCtrlSwAny()
MasashiNomura 23:79e20be4bc5b 47 {
MasashiNomura 23:79e20be4bc5b 48 UINT16 mask = 0x1;
MasashiNomura 23:79e20be4bc5b 49 for(int i = 0; i < 5; ++i){
MasashiNomura 23:79e20be4bc5b 50 if(curOpe.w & mask){
MasashiNomura 23:79e20be4bc5b 51 return true;
MasashiNomura 23:79e20be4bc5b 52 }
MasashiNomura 23:79e20be4bc5b 53 mask = mask << 1;
MasashiNomura 23:79e20be4bc5b 54 }
MasashiNomura 23:79e20be4bc5b 55 return false;
MasashiNomura 23:79e20be4bc5b 56 }
MasashiNomura 30:13ada1a24c59 57 bool HbUserOpe::ChkCtrlSwRiseEdge(SW_TYPE styp)
MasashiNomura 26:732bc37fbefd 58 {
MasashiNomura 30:13ada1a24c59 59 if(styp == BRK_L) {return curOpe.bf.brk_l && !oldOpe.bf.brk_l;}
MasashiNomura 30:13ada1a24c59 60 else if(styp == BRK_R) {return curOpe.bf.brk_r && !oldOpe.bf.brk_r;}
MasashiNomura 30:13ada1a24c59 61 else if(styp == R_1) {return curOpe.bf.resv_1 && !oldOpe.bf.resv_1;}
MasashiNomura 30:13ada1a24c59 62 else if(styp == R_2) {return curOpe.bf.resv_2 && !oldOpe.bf.resv_2;}
MasashiNomura 30:13ada1a24c59 63 else if(styp == MOT_STOP){return curOpe.bf.mot_stop && !oldOpe.bf.mot_stop;}
MasashiNomura 30:13ada1a24c59 64 else if(styp == R_3) {return curOpe.bf.resv_3 && !oldOpe.bf.resv_3;}
MasashiNomura 30:13ada1a24c59 65 else if(styp == R_4) {return curOpe.bf.resv_4 && !oldOpe.bf.resv_4;}
MasashiNomura 30:13ada1a24c59 66 else if(styp == R_5) {return curOpe.bf.resv_5 && !oldOpe.bf.resv_5;}
MasashiNomura 30:13ada1a24c59 67 else if(styp == R_6) {return curOpe.bf.resv_6 && !oldOpe.bf.resv_6;}
MasashiNomura 30:13ada1a24c59 68 else if(styp == ALL_STOP){return curOpe.bf.all_stop && !oldOpe.bf.all_stop;}
MasashiNomura 31:56c554c560c1 69 else{return false;}
MasashiNomura 26:732bc37fbefd 70 }