95 lines
2.4 KiB
C
95 lines
2.4 KiB
C
#ifndef __CANNW_H
|
||
#define __CANNW_H
|
||
|
||
#include "CanNwConfig.h"
|
||
#include "appTask.h"
|
||
/***************************************************************/
|
||
/*
|
||
奇瑞新能源 网络管理模块
|
||
|
||
描述:参考Autosar网络管理
|
||
日期:2018\06\20
|
||
|
||
*/
|
||
/***************************************************************/
|
||
|
||
/*
|
||
网络管理状态机切换
|
||
缩略语:
|
||
RMS = Repeat Message State 重复消息状态
|
||
NOS = Normal Operation State 正常运行状态
|
||
*/
|
||
typedef enum
|
||
{
|
||
CAN_NW_RESERVED, //0 缺省
|
||
CAN_NW_RMS_SLEEP, //1 睡眠模式到重复消息模式
|
||
CAN_NW_RMS_PREPARE_SLEEP, //2 准备进入睡眠模式到重复消息模式
|
||
CAN_NW_RMS_NORMAL_OPERATION, //3 正常操作模式到重复消息模式
|
||
CAN_NW_RMS_READY_SLEEP, //4 准备睡眠模式到重复消息模式
|
||
CAN_NW_NOS_REPEAT_MESSAGE, //5 重复消息模式到正常操作状态
|
||
CAN_NW_NOS_READY_SLEEP, //6 准备睡眠模式到正常操作状态
|
||
CAN_NW_GOTO_SLEEP, //7 网络超时2.5S后进入睡眠模式
|
||
CAN_NW_READY_SLEEP
|
||
}CAN_NW_STATE;
|
||
|
||
/*
|
||
网络超时设置
|
||
时间单位:10MS
|
||
*/
|
||
#define NM_TIMEOUT_TIMER_THR 2000U
|
||
#define REPEAT_MESSAGE_TIMER_THR 1600U
|
||
#define WAIT_BUS_SLEEP_TIMER_THR 2000U
|
||
#define REPEAT_NW_CYCLE_TIMER_THR 500U
|
||
#define NM_NORMAL_CYCLE_TIMER_THR 500U
|
||
#define IMMEDIATENM_CYCLE_TIMER_THR 20U
|
||
#define NM_TIMEOUT 0U
|
||
#define T_NM_ImmediateCycleTime 20U
|
||
|
||
|
||
|
||
#define PASSIVE_WAKEUP 0U
|
||
#define LOCAL_ACTIVE_WAKEUP 1U
|
||
#define REMOTE_ACTIVE_WAKEUP 2U
|
||
|
||
|
||
#define SEND_DISABLE 0
|
||
#define SEND_APP_PDU 1
|
||
#define SEND_NWAPP_PDU 2
|
||
|
||
extern unsigned char ucNwSendPduType;
|
||
|
||
extern CAN_NW_STATE euNwState;
|
||
|
||
extern unsigned int uiNwTimCnt;
|
||
extern unsigned int uiNwToutCnt;
|
||
extern unsigned int uiNwRMSCnt;
|
||
extern unsigned int uiNwBsSlpCnt;
|
||
extern unsigned int uiSetNwPduCycVal;
|
||
extern unsigned int uiNwPduCycCnt;
|
||
extern unsigned char ucActiveWakeupBit;
|
||
extern unsigned char ucNwPowerUpFlg;
|
||
extern unsigned char ucRemoteWakupFlg;
|
||
extern unsigned char ucNwNetIdelCheck;
|
||
extern unsigned char ucNwNetIdelFlg;
|
||
extern unsigned char ucPreLocWkpStu;
|
||
extern unsigned int uiNwLocWkpOffCnt;
|
||
extern unsigned char ImmediateNM_count;
|
||
extern unsigned char RepeatMessageReq;
|
||
extern unsigned char DiagMsgRcvFlag;
|
||
extern unsigned int DiagCnt;
|
||
|
||
|
||
|
||
#define NW_NET_INACTIVE 0
|
||
#define NW_NET_ACTIVE 1
|
||
|
||
extern unsigned char ucNetActiveFlg; //0 自清洁功能关闭;1自清洁功能开启
|
||
|
||
void CanNwInit(void);
|
||
void CanNwHandle(void);
|
||
|
||
|
||
|
||
|
||
#endif
|