Common_Interface(2054).c 6.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
#include "Common_Interface.h"
#include "System_Monitor.h"

/*修饰变量static*/

/*ig on off时间线*/
static uint32_t PowerIgnOnTimeLine;
static uint32_t PowerIgnOffTimeLine;

static MSG_01_DISP_MODE_t g_Disp_Mode;
    
static LANGUAGE_t g_Language;



static COMMON_PowerStatus_t PowerSts;/*1 ON ;  0 OFF*/
static uint16_t Act_V_Speed;/*实际值,十倍的*/
static uint16_t Act_E_Speed;/*实际值*/
static uint16_t Disp_V_Speed;/*显示值,十倍的*/
static uint16_t Disp_E_Speed;/*显示值*/
static uint16_t Disp_Gauges_E_Speed;/*Gauges*/
static uint16_t Disp_E_Speed_Test;/*自检值*/
static uint16_t Disp_V_Speed_Test;/*自检值*/
static uint16_t Disp_Fuel_Test;/*自检值*/
static uint16_t Disp_Temp_Test;/*自检值*/
//**************************************************

static uint16_t Act_RV_Speed;
static uint16_t Disp_RV_Speed;
//**************************************************

static uint16_t Disp_RV_Speed_Test;




/*数据有效 1 ;数据无效 0 /0xff */
static DataValid_t Act_V_Speed_Valid;
static DataValid_t Act_E_Speed_Valid;
//**************************************************

static DataValid_t Act_RV_Speed_Valid;
//**************************************************


static DataValid_t Disp_V_Speed_Valid;
static DataValid_t Disp_E_Speed_Valid;
//**************************************************

static DataValid_t Disp_RV_Speed_Valid;
//**************************************************


static uint16_t SysRollingCounter;

/*每次唤醒调用*/
void Common_DataInit(void)
{
    PowerSts = COMMON_POWER_UNKNOW;
    Act_V_Speed = 0;
    Act_E_Speed = 0;
    Disp_V_Speed = 0;
    Disp_E_Speed = 0;
	//**************************************************
	Act_RV_Speed = 0;
	Disp_RV_Speed = 0;

	//**************************************************

	Act_RV_Speed_Valid = COMMON_Valid_UNKNOW;
	Disp_RV_Speed_Valid = COMMON_Valid_UNKNOW;
	//**************************************************
    Act_V_Speed_Valid = COMMON_Valid_UNKNOW;
    Act_E_Speed_Valid = COMMON_Valid_UNKNOW;
    Disp_V_Speed_Valid = COMMON_Valid_UNKNOW;
    Disp_E_Speed_Valid = COMMON_Valid_UNKNOW;
    PowerIgnOnTimeLine = 0x0ul;
    PowerIgnOffTimeLine = 0x0ul;
    g_Disp_Mode = DISP_MODE_ANIMATION;

}



/*以下由各个处理模块按需调用*/
/*使用数据之前,需要先判断数据是否有效,如果无效,则不可以使用*/

MSG_01_DISP_MODE_t Common_Get_DispMode(void)
{
    return g_Disp_Mode;
}
void Common_Set_DispMode(MSG_01_DISP_MODE_t mode)
{
    g_Disp_Mode = mode;
}
LANGUAGE_t Common_Get_Language(void)
{
    return g_Language;
}



COMMON_PowerStatus_t Common_Get_IG_Sts(void)
{
    return PowerSts;
}
//**************************************************
uint16_t Common_Get_Act_RV_Speed(void)
{
	return Act_RV_Speed;
}

uint16_t Common_Get_Disp_RV_Speed(void)
{
	return Disp_RV_Speed;
}
//**************************************************

uint16_t Common_Get_Act_V_Speed(void)
{
    return Act_V_Speed;
}
uint16_t Common_Get_Act_E_Speed(void)
{
    return Act_E_Speed;
}
uint16_t Common_Get_Disp_V_Speed(void)
{
    return Disp_V_Speed;
}
uint16_t Common_Get_Disp_E_Speed(void)
{
    return Disp_E_Speed;
}
uint16_t Common_Get_Gauges_Disp_E_Speed(void)
{
    return Disp_Gauges_E_Speed;
}

//自检
uint16_t Common_Get_E_Speed_TEST(void)
{
    return Disp_E_Speed_Test;
}
uint16_t Common_Get_V_Speed_TEST(void)
{
    return Disp_V_Speed_Test;
}
uint8_t Common_Get_Fuel_TEST(void)
{
    return Disp_Fuel_Test;
}
uint8_t Common_Get_Temp_TEST(void)
{
    return Disp_Temp_Test;
}
/**********************************/

//**************************************************
void Common_Set_Act_RV_Speed(uint16_t Val)
{
    Act_RV_Speed = Val;
}

void Common_Set_Disp_RV_Speed(uint16_t Val)
{
    Disp_RV_Speed = Val;
}

void Common_Set_Act_RV_Speed_Valid(DataValid_t Val)
{
    Act_RV_Speed_Valid = Val;
}

void Common_Set_Disp_RV_Speed_Valid(DataValid_t Val)
{
    Disp_RV_Speed_Valid = Val;
}


//**************************************************





void Common_Set_IG_Sts(COMMON_PowerStatus_t Val)
{
    PowerSts = Val;
}
void Common_Set_Act_V_Speed(uint16_t Val)
{
    Act_V_Speed = Val;
}
void Common_Set_Act_E_Speed(uint16_t Val)
{
    Act_E_Speed = Val;
}
void Common_Set_Disp_V_Speed(uint16_t Val)
{
    Disp_V_Speed = Val;
}
void Common_Set_Disp_E_Speed(uint16_t Val)
{
    Disp_E_Speed = Val;
}
void Common_Set_Gauges_E_Speed(uint16_t Val)
{
    Disp_Gauges_E_Speed = Val;
}

//自检
void Common_Set_E_Speed_Test(uint16_t Val)
{
    Disp_E_Speed_Test = Val;
}
void Common_Set_V_Speed_Test(uint16_t Val)
{
    Disp_V_Speed_Test = Val;
}
void Common_Set_Fuel_Test(uint8_t Val)
{
    Disp_Fuel_Test = Val;
}
void Common_Set_Temp_Test(uint8_t Val)
{
    Disp_Temp_Test = Val;
}

/***************************************/

DataValid_t Common_Get_Act_V_Speed_Valid(void)
{
    return  Act_V_Speed_Valid;
}
DataValid_t Common_Get_Act_E_Speed_Valid(void)
{
    return  Act_E_Speed_Valid;
}
DataValid_t Common_Get_Disp_V_Speed_Valid(void)
{
    return Disp_V_Speed_Valid;
}
DataValid_t Common_Get_Disp_E_Speed_Valid(void)
{
    return Disp_E_Speed_Valid;
}

/*=======================================================================*/

void Common_Set_Act_V_Speed_Valid(DataValid_t Val)
{
    Act_V_Speed_Valid = Val;
}
void Common_Set_Act_E_Speed_Valid(DataValid_t Val)
{
    Act_E_Speed_Valid = Val;
}
void Common_Set_Disp_V_Speed_Valid(DataValid_t Val)
{
    Disp_V_Speed_Valid = Val;
}
void Common_Set_Disp_E_Speed_Valid(DataValid_t Val)
{
    Disp_E_Speed_Valid = Val;
}



/*2MS任务*/
void Common_Input_Para(void)
{

    if (Common_Get_IG_Sts() == COMMON_POWER_ON)
    {
        PowerIgnOffTimeLine = 0ul;
        if (PowerIgnOnTimeLine < 0x7ffffffful)
        {
            //PowerIgnOnTimeLine += 2u;
			PowerIgnOnTimeLine += 1u;
        }
        

    }
    else
    {
        PowerIgnOnTimeLine = 0ul;
        if (PowerIgnOffTimeLine < 0x7ffffffful)
        {
            //PowerIgnOffTimeLine += 2u;
			PowerIgnOffTimeLine += 1u;
        }
    }

}

void Common_RollingCounterAdd(void)
{
    SysRollingCounter++;
}

void Common_RollingCounterClear(void)
{
    SysRollingCounter = 0u;
}

uint16_t Common_ReadRollingCounter(void)
{
    return SysRollingCounter;
}

void Common_BlockDelay(uint16_t m_MS)
{
    uint16_t RocBackup;
    uint16_t Counter;
    uint16_t DIMCounter;

    DIMCounter = m_MS * 20u;
    Common_RollingCounterClear();
    RocBackup = Common_ReadRollingCounter();
    do
    {
        Counter = Common_ReadRollingCounter();

        if (Counter >= RocBackup)
        {
            Counter -= RocBackup;
        }
        else
        {
            Counter = 65535u - RocBackup + Counter + 1u;
        }

    }
    while (Counter < DIMCounter);
}

uint32_t Common_GetIgnOnTime(void)
{
    return PowerIgnOnTimeLine;
}

uint32_t Common_GetIgnOffTime(void)
{
    return PowerIgnOffTimeLine;
}