资源简介
基于osek的直接网络管理,可参考并应用于实际项目开发中
代码片段和文件信息
#include “OsekNm.h“
// Macros for OpCode
#define NM_MaskAlive 0x01
#define NM_MaskRing 0x02
#define NM_MaskLimphome 0x04
#define NM_MaskSI 0x10 /* sleep ind */
#define NM_MaskSA 0x20 /* sleep ack */
#define rx_limit 4
#define tx_limit 8
#define NET_ID 0
/* Alarm Management */
#define nmSetAlarm(Timer) \
do \
{ \
NM_ControlBlock[NET_ID].Alarm._##Timer = 1+NM_ControlBlock[NET_ID].nmDirectNMParams._##Timer; \
}while(0)
/* signal the alarm to process one step/tick forward */
#define nmSingalAlarm(Timer) \
do \
{ \
if(NM_ControlBlock[NET_ID].Alarm._##Timer > 1) \
{ \
(NM_ControlBlock[NET_ID].Alarm._##Timer)--; \
} \
}while(0)
#define nmIsAlarmTimeout(Timer) (1 == NM_ControlBlock[NET_ID].Alarm._##Timer)
#define nmIsAlarmStarted(Timer) (0 != NM_ControlBlock[NET_ID].Alarm._##Timer)
#define nmCancelAlarm(Timer) \
do \
{ \
NM_ControlBlock[NET_ID].Alarm._##Timer = 0; \
}while(0)
#define nmSendMessage() \
do{ \
StatusType ercd; \
ercd = D_Transmit(NetId&(NM_ControlBlock[NET_ID].nmTxPdu)8); \
if(ercd != E_OK) \
{ \
nmSetAlarm(TTx); /* re-Transmit after TTx */ \
} \
}while(0)
#define nmDebug(str) ASLOG(OSEK_NMstr)
/* ============================ [ TYPES ] ====================================================== */
/* OK we could see terrible thing here too big the struct is. */
typedef struct
{
NMType nmType;
ScalingParamType nmScalingParams; /* not used */
struct
{
uint8_t normal[32];
uint8_t normalExtended[32];
uint8_t limphome[32];
}nmConfig;
struct
{
uint8_t normal[32];
uint8_t normalExtended[32];
uint8_t limphome[32];
}nmCMask;
struct
{
struct{
SignallingMode SMode;
}normal;
struct{
SignallingMode SMode;
}normalExtended;
struct{
SignallingMode SMode;
}limphome;
}nmIndDeltaConfig;
struct{
NetworkStatusType SMask;
NetworkStatusType NetworkStatus;
SignallingMode SMode;
}nmStatus;
struct{
SignallingMode SMode;
}nmRingDataInd;
union
{
uint32_t w;
struct
{
unsigned stable : 1;
unsigned limphome : 1;
}W;
}nmMerker;
NMStateType nmState;
struct
{
NodeIdType NodeId;
TickType _TTx;
TickType _TTyp;
TickType _TMax;
TickType _TError;
TickType _TWbs;
}nmDirectNMParams;
uint8_t nmRxCount;
uint8_t nmTxCount;
struct{
TickType _TTx;
TickType _TTyp;
TickType _TMax;
TickType _TError;
TickType _TWbs;
}Alarm;
NMPduType nmTxPdu;
}NM_ControlBlockType;
/* ============================ [ DECLARES ] ====================================================== */
void NMInit(NetIdType NetId);
static void nmInit3(NetIdType NetId);
static void nmAddtoPresent(NetIdType NetIdNodeIdType NodeId);
static void nmAddtoLimphome(NetIdType NetIdNodeIdType NodeId);
static void nmInitReset5(NetIdType NetId);
static void nmInitReset6(NetIdType NetId);
static void nmAddToConfig(NetIdTyp
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 24092 2018-04-19 09:26 OsekNm\OsekNm.c
文件 4889 2018-04-19 09:23 OsekNm\OsekNm.h
文件 2378 2018-04-19 09:22 OsekNm\OsekNm_Cfg.c
文件 341 2018-04-19 09:22 OsekNm\OsekNm_Cfg.h
目录 0 2018-04-20 09:01 OsekNm\
评论
共有 条评论