teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

HbUserOpe.cpp

Committer:
MasashiNomura
Date:
2018-12-13
Revision:
26:732bc37fbefd
Parent:
23:79e20be4bc5b
Child:
30:13ada1a24c59

File content as of revision 26:732bc37fbefd:

#include "HbUserOpe.h"
#include "fpga.h"
//=========================================
//コンストラクタ
//=========================================
HbUserOpe::HbUserOpe(){
    oldOpe.w = curOpe.w = 0;
}

//=========================================
//デストラクタ
//=========================================
HbUserOpe::~HbUserOpe(){
}

typUserSw HbUserOpe::GetUserOpe()
{
    oldOpe = curOpe;
    curOpe.w = fpgaGetUserSw();
    return curOpe;
}
bool HbUserOpe::ChkCtrlSW(SW_TYPE styp)
{
            if(styp == ACCEL_R){return curOpe.bf.axl_r;}
    else    if(styp == ACCEL_L){return curOpe.bf.axl_l;}
    else    if(styp == STOP){return curOpe.bf.stop;}
    else    if(styp == YAW_CTRL){return curOpe.bf.y_ctrl;}
    else/*if(styp == ENG_STOP)*/{return curOpe.bf.eng_stop;}
//    UINT16 mask = 0x1 << styp;
//    return curOpe.w & mask;
}
bool HbUserOpe::ChkCtrlSW(SW_TYPE2 styp)
{
            if(styp == F_L){return curOpe.bf.axl_r;}
    else    if(styp == F_R){return curOpe.bf.axl_l;}
    else    if(styp == R_L){return curOpe.bf.stop;}
    else    if(styp == R_R){return curOpe.bf.y_ctrl;}
    else/*if(styp == ENG_STOP)*/{return curOpe.bf.eng_stop;}
//    UINT16 mask = 0x1 << styp;
//    return curOpe.w & mask;
}
bool HbUserOpe::ChkCtrlSwAny()
{
    UINT16 mask = 0x1;
    for(int i = 0; i < 5; ++i){
        if(curOpe.w & mask){
            return true;
        }
        mask = mask << 1;
    }
    return false;
}
bool HbUserOpe::ChkCtrlSwRiseEdge(SW_TYPE2 styp)
{
            if(styp == F_L){return curOpe.bf.axl_r && !oldOpe.bf.axl_r;}
    else    if(styp == F_R){return curOpe.bf.axl_l && !oldOpe.bf.axl_l;}
    else    if(styp == R_L){return curOpe.bf.stop && !oldOpe.bf.stop;}
    else    if(styp == R_R){return curOpe.bf.y_ctrl && !oldOpe.bf.y_ctrl;}
    else/*if(styp == ENG_STOP)*/{return curOpe.bf.eng_stop && !oldOpe.bf.eng_stop;}
//    UINT16 mask = 0x1 << styp;
//    return curOpe.w & mask;
}