System_Monitor.h 3.18 KB
Newer Older
hu's avatar
hu committed
1 2 3 4

#ifndef SYSTEM_MONITOR_H
#define SYSTEM_MONITOR_H

hu's avatar
hu committed
5
#include "System_Monitor.h"
hu's avatar
hu committed
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
#include "TYW_stdint.h"


typedef struct
{
    uint8_t SumCnt;
    uint16_t DebounceTimer;
    uint32_t ActVoltage;
    uint8_t FinalSts;
    uint8_t ActSts;
} MonitorStruct;


/*
     0 ----1st-------6500   不可运行   1
  6500 ----2st-------7000   回差段     2

  7000 ----3st-------9000   低压段     3
  9000 ----4st-------9500   回差段     4
  9500-----5st------16000   正常段     5
  16000----6st------16500   回差段     6

  16500----7st------18000   高压段     7
  18000----8st------18500   回差段     8
  18500----9st------65535   高压段     9

    0-----6.5   不可运行--ALL----------限制
  6.5-----9     除电机外均可运行--------正常
    9-----16.5  均可运行---------------正常
 16.5-----18.5  只有CAN可运行----------限制
 18.8-----65535 不可运行--ALL----------限制

6.5-18.5  CAN 可运行区间

*/



/*电源运行状态*/
#define   SYS_OPR_STAT_RUN           ((System_FUN_KL30_Status_Get() > 1u)&&(System_FUN_KL30_Status_Get() < 7u ))
#define   SYS_OPR_STAT_HALT          ((System_FUN_KL30_Status_Get() == 1u) || (System_FUN_KL30_Status_Get() >= 7u))

#define   SYS_OPR_STAT_LIM_LVP       (System_FUN_KL30_Status_Get() == 1U)
#define   SYS_OPR_STAT_LIM_OVP       (System_FUN_KL30_Status_Get() >= 7u)

/*仪表工作状态*/
#define   SYS_OPR_STAT_IGN_ON        (System_FUN_KL15_Status_Get() == 1U)
#define   SYS_OPR_STAT_IGN_OFF       (System_FUN_KL15_Status_Get() == 0U)


/*网络管理电源工作状态*/
#define   SYS_OPR_STAT_IGN_ON_NM     (System_NM_KL15_Status_Get() == 1U)
#define   SYS_OPR_STAT_IGN_OFF_NM    (System_NM_KL15_Status_Get() == 0U)

/*网络管理电源运行状态*/
#define   SYS_OPR_STAT_RUN_NM        ((System_NM_KL30_Status_Get() > 1u) && (System_NM_KL30_Status_Get() < 9u ))
#define   SYS_OPR_STAT_HALT_NM       ((System_NM_KL30_Status_Get() == 9u) || (System_NM_KL30_Status_Get() == 1u))


static uint8_t System_Calc_FunRange(uint16_t u16Vol);
static uint8_t System_Calc_NMRange(uint16_t u16Vol);

uint8_t Read_KL30_ConvertFinish(void);

static void System_Fun_Process(void);
static void System_NM_Process(void);
void Sys_LogicProcess(void);
void Sys_Status_Update_Service ( void );

uint16_t Sys_Read_KL30_Voltage(void);
uint16_t Sys_Read_KL15_Voltage(void);
uint8_t Sys_Read_KL30_Valid(void);
uint8_t Sys_Read_KL15_Valid(void);

uint16_t Sys_Force_Read_KL30_Voltage(void);
uint16_t Sys_Force_Read_KL15_Voltage(void);

uint8_t System_FUN_KL30_Status_Get(void);
uint8_t System_FUN_KL15_Status_Get(void);
uint8_t System_NM_KL15_Status_Get(void);
uint8_t System_NM_KL30_Status_Get(void);

uint8_t System_LINE_KL15(void);

void Sys_Set_DebounceTimer(uint16_t u16NMKL30, uint16_t u16NMKL15, uint16_t u16FUNKL30, uint16_t u16FUNKL15);
/*void Sys_Set_VolRange(uint16_t FUN_Vol[], uint16_t NM_Vol[]);*/
void Sys_Set_VolRange(const uint16_t FUN_Vol[], const uint16_t  NM_Vol[]);
void System_Monitor_KL30Init(void);
void System_Monitor_WakeupInit(void);
void System_Fast_WakeUp(void);

void Sys_KL30_Init (void);
void Sys_WakeUp_Init (void);
void Sys_BlockDelay(uint32_t u32Ms);

void Sys_Rolling(void);
void Sys_RollingClear(void);
uint32_t Sys_Get_ms_Rolling_Counter(void);

#endif