Line_In_user.c 2.93 KB
Newer Older
李俭双's avatar
李俭双 committed
1 2 3 4 5

#include "Line_In\Line_In_user.h"
#include "Components.h"
#include "Application.h"

6
 __attribute__((aligned(4)))
李俭双's avatar
李俭双 committed
7 8 9 10
const Line_In_Attribute_st g_stLineInAttribute[LINE_IN_MAX] =
{
    {LEVEL_LOW,    LEVEL_HIGH,   LINE_IN_IG_ON,     20U,  20U,  Get_LINE_IN_TurnLeft,        },
    {LEVEL_LOW,    LEVEL_HIGH,   LINE_IN_IG_ON,     20U,  20U,  Get_LINE_IN_TurnRight,       },
11
    {LEVEL_HIGH,    LEVEL_LOW,   LINE_IN_IG_ON,     40U,  20U,  Get_LINE_IN_HighBeam,        },
12
    {LEVEL_HIGH,   LEVEL_LOW,    LINE_IN_IG_ON,     120U,  20U,  Get_LINE_IN_FAULT_ELECTROSPRAY, },
13
    {LEVEL_HIGH,   LEVEL_LOW,    LINE_IN_IG_ON,     130U,  20U,  Get_LINE_IN_Fault_ABS, },
14
    {LEVEL_HIGH,   LEVEL_LOW,    LINE_IN_IG_ON,     500U,  20U,  Get_LINE_IN_Oil_Pressure, },
15
    {LEVEL_HIGH,   LEVEL_LOW,    LINE_IN_IG_ON,     140U,  20U,  Get_LINE_IN_Auto_Start_Stop, },
16
    {LEVEL_LOW,    LEVEL_HIGH,   LINE_IN_IG_ON,     500U,  500U,  Get_LINE_IN_Little_Lamp, },
李俭双's avatar
李俭双 committed
17 18
};

19 20 21 22 23 24 25 26 27 28 29 30 31
Linelib_uint8_t Get_LINE_IN_Little_Lamp(void)
{
    Linelib_uint8_t ret = 0U;
    if (RTE_GPIO_Get_Level(PositionBeam_P_IN))
    {
        ret = 1u;
    }
    else
    {
        ret = 0UL;
    }
    return ret;
}
李俭双's avatar
李俭双 committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
Linelib_uint8_t Get_LINE_IN_TurnLeft(void)
{
    Linelib_uint8_t ret = 0U;
    if (RTE_GPIO_Get_Level(LeftTurn_P_In))
    {
        ret = 1u;
    }
    else
    {
        ret = 0UL;
    }
    return ret;
}

Linelib_uint8_t Get_LINE_IN_TurnRight(void)
{
    Linelib_uint8_t ret = 0U;
    if (RTE_GPIO_Get_Level(RightTurn_P_In))
    {
        ret = 1u;
    }
    else
    {
        ret = 0UL;
    }
    return ret;
}

Linelib_uint8_t Get_LINE_IN_HighBeam(void)
{
    Linelib_uint8_t ret = 0U;
    if (RTE_GPIO_Get_Level(HighBeam_P_In))
    {
        ret = 1u;
    }
    else
    {
        ret = 0UL;
    }
    return ret;
}

李俭双's avatar
李俭双 committed
74 75 76 77 78 79 80 81 82 83 84
Linelib_uint8_t Get_LINE_IN_FAULT_ELECTROSPRAY(void)
{
    Linelib_uint8_t ret = 0;
    if(RTE_GPIO_Get_Level(Fault_Diagnosis_IN))
    {
        ret = 1;
    }
    else
    {
        ret = 0;
    }
85
    return ret;
李俭双's avatar
李俭双 committed
86 87 88 89 90 91 92 93 94 95 96 97 98
}

Linelib_uint8_t Get_LINE_IN_Fault_ABS(void)
{
    Linelib_uint8_t ret = 0;
    if(RTE_GPIO_Get_Level(Fault_ABS_IN))
    {
        ret = 1;
    }
    else
    {
        ret = 0;
    }
99
    return ret;
李俭双's avatar
李俭双 committed
100 101 102 103 104 105 106 107 108 109 110 111 112
}

Linelib_uint8_t Get_LINE_IN_Oil_Pressure(void)
{
    Linelib_uint8_t ret = 0;
    if(RTE_GPIO_Get_Level(Oil_Pressure_IN))
    {
        ret = 1;
    }
    else
    {
        ret = 0;
    }
113
    return ret;
李俭双's avatar
李俭双 committed
114 115 116
}


李俭双's avatar
李俭双 committed
117 118 119
Linelib_uint8_t Get_LINE_IN_Auto_Start_Stop(void)
{
    Linelib_uint8_t ret = 0U;
李俭双's avatar
李俭双 committed
120
    if (RTE_GPIO_Get_Level(Auto_StartStop_IN))
李俭双's avatar
李俭双 committed
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
    {
        ret = 1u;
    }
    else
    {
        ret = 0UL;
    }
    return ret;
}

__align(4)
Linelib_uint8_t LINE_IN_Men[LINE_IN_MAX * LINE_IN_BLOCK_SIZE];

static Linelib_uint16_t LINE_GET_PWR(void)
{
    Linelib_uint16_t Res;
    Res = Common_Get_IG_Sts() & 0x00FFu;
    return Res;
}

void LINE_IN_Init(void)
{
143
    memset(LINE_IN_Men, 0, sizeof(LINE_IN_Men));
李俭双's avatar
李俭双 committed
144 145
    Line_In_KL30_WakeUp_Init(LINE_IN_Men, g_stLineInAttribute, LINE_IN_MAX, LINE_GET_PWR);
}