📄 zmac_type.h
字号:
//--------------------------------------------------------------------------
//-- Option : Implementation option
//--------------------------------------------------------------------------
// #define IMPLEMENT_DISASSOCIATE 1 // #ifdef
// #define IMPLEMENT_BEACON_NETWORK 1 // #ifdef
// #define IMPLEMENT_GTS_TRANSFER 1 // #ifdef
// #define IMPLEMENT_CONFLICT_AND_REALIGNMENT 1 // #ifdef
// #define IMPLEMENT_MCPS_PURGE 1 // #ifdef
// #define IMPLEMENT_MLME_RX_ENA 1 // #ifdef
//--------------------------------------------------------------------------
//--------------------------------------------------------
//- PHY/MAC Constants
//--------------------------------------------------------
#define aMaxPHYPacketSize 127
#define aTurnaroundTime 12 // 192 us
//--------------------------------------------------------
#define aBaseSlotDuration 60
#define aBaseSuperframeDuration 960 // 60*16
#define aMaxBE 5
#define aMaxBeaconOverhead 75
#define aMaxBeaconPayloadLength (127 - aMaxBeaconOverhead)
#define aGTSDescPersistenceTime 4
#define aMaxFrameOverhead 25
#define aMaxFrameResponseTime 1220
#define aMaxFrameRetries 3
#define aMaxLostBeacons 4
#define aMaxMACFrameSize (127 - aMaxFrameOverhead)
#define aMaxSIFSFrameSize 18
#define aMinCAPLength 440 // 7040 us
#define aMinLIFSPeriod 40 // 640 us
#define aMinSIFSPeriod 12 // 192 us
#define aNumSuperframeSlots 16
#define aResponseWaitTime 30720 // 32*60*16
#define aUnitBackoffPeriod 20 // 320 us
//--------------------------------------------------------
//- PHY/MAC PIB Attribute Code
//--------------------------------------------------------
#define cPPIB_Channel 0x00
#define cPPIB_ChannelSupport 0x01
#define cPPIB_TransmitPower 0x02
#define cPPIB_CCAMode 0x03
//--------------------------------------------------------
#define cMPIB_AckDuration 0x40
#define cMPIB_AssoPermit 0x41
#define cMPIB_AutoRequest 0x42
#define cMPIB_BattLifeExt 0x43
#define cMPIB_BattLifeExtPeriod 0x44
#define cMPIB_BeaconPayload 0x45
#define cMPIB_BeaconPayloadLength 0x46
#define cMPIB_BeaconOrder 0x47
#define cMPIB_BeaconTxTime 0x48
#define cMPIB_BSN 0x49
#define cMPIB_CoordExtendAddr 0x4A
#define cMPIB_CoordShortAddr 0x4B
#define cMPIB_DSN 0x4C
#define cMPIB_GTSPermit 0x4D
#define cMPIB_MaxCSMABAckoff 0x4E
#define cMPIB_MinBE 0x4F
#define cMPIB_PANId 0x50
#define cMPIB_PromiscuousMode 0x51
#define cMPIB_RxOnWhenIdle 0x52
#define cMPIB_ShortAddr 0x53
#define cMPIB_SuperframeOrder 0x54
#define cMPIB_TranPersistTIme 0x55
#define cMPIB_IEEEAddr 0x7F
//--------------------------------------------------------
//- MAC Status
//--------------------------------------------------------
#define cMACS_SUCCESS 0x00
#define cMACS_BEACON_LOSS 0xE0
#define cMACS_CHANNEL_ACCESS_FAILURE 0xE1
#define cMACS_DENIED 0xE2
#define cMACS_DISABLE_TRX_FAILURE 0xE3
#define cMACS_FAILED_SECURITY_CHECK 0xE4
#define cMACS_FRAME_TOO_LONG 0xE5
#define cMACS_INVALID_GTS 0xE6
#define cMACS_INVALID_HANDLE 0xE7
#define cMACS_INVALID_PARAMETER 0xE8
#define cMACS_NO_ACK 0xE9
#define cMACS_NO_BEACON 0xEA
#define cMACS_NO_DATA 0xEB
#define cMACS_NO_SHORT_ADDRESS 0xEC
#define cMACS_OUT_OF_CAP 0xED
#define cMACS_PAN_ID_CONFLICT 0xEE
#define cMACS_REALIGNMENT 0xEF
#define cMACS_TRANSACTION_EXPIRED 0xF0
#define cMACS_TRANSACTION_OVERFLOW 0xF1
#define cMACS_TX_ACTIVE 0xF2
#define cMACS_UNAVAILABLE_KEY 0xF3
#define cMACS_UNSUPPORTED_ATTRIBUTE 0xF4
//--------------------------------------------------------
#define cMACS_NOT_SUPPORT 0xFA
#define cMACS_ONAIR_DOWNLOAD 0xFB
#define cMACS_INVALID_RSSI_CHECK 0xFC
#define cMACS_INDIRECT_TEMP_RETURN 0xFD
#define cMACS_NO_DATA_REQ_CMD 0xFE
#define cMACS_CHIPCON_NO_IDLE 0xFF
//--------------------------------------------------------
#define dSYS_BPS_300 0
#define dSYS_BPS_600 1
#define dSYS_BPS_1200 2
#define dSYS_BPS_2400 3
#define dSYS_BPS_4800 4
#define dSYS_BPS_9600 5
#define dSYS_BPS_14400 6
#define dSYS_BPS_19200 7
#define dSYS_BPS_28800 8
#define dSYS_BPS_38400 9
#define dSYS_BPS_57600 10
#define dSYS_BPS_115200 11
//--------------------------------------------------------
#define dDATARATE_250K 0
#define dDATARATE_500K 1
#define dDATARATE_1M 2
//--------------------------------------------------------
//- UART Mode
//--------------------------------------------------------
#define dUART_DATA_7 0x70
#define dUART_DATA_8 0x80
#define dUART_PAR_NONE 0x00
#define dUART_PAR_ODD 0x01
#define dUART_PAR_EVEN 0x02
#define dUART_PAR_MARK 0x03
#define dUART_PAR_SPAC 0x04
//--------------------------------------------------------
#define dUART_MODE_7N0 0x70
#define dUART_MODE_7O1 0x71
#define dUART_MODE_7E1 0x72
#define dUART_MODE_7M1 0x73
#define dUART_MODE_7S1 0x74
#define dUART_MODE_8N0 0x80
#define dUART_MODE_8O1 0x81
#define dUART_MODE_8E1 0x82
#define dUART_MODE_8M1 0x83
#define dUART_MODE_8S1 0x84
//--------------------------------------------------------
#define dMAC_UNSECURE 0x00
#define dMAC_ACL 0x01
#define dMAC_SECURE 0x02
#define dMAC_NO_ACL 0x08
//--------------------------------------------------------
#define dMAC_AES_DISABLE 0
#define dMAC_AES_CBCMAC 1
#define dMAC_AES_CTR 2
#define dMAC_AES_CCM 3
//--------------------------------------------------------
#define dSEC_LEVEL_NONE 0x00
#define dSEC_LEVEL_MIC32 0x01
#define dSEC_LEVEL_MIC64 0x02
#define dSEC_LEVEL_MIC128 0x03
#define dSEC_LEVEL_ENC 0x04
#define dSEC_LEVEL_ENCMIC32 0x05
#define dSEC_LEVEL_ENCMIC64 0x06
#define dSEC_LEVEL_ENCMIC128 0x07
//--------------------------------------------------------
#define dMAC_SUITE_NONE 0x00
#define dMAC_SUITE_CTR 0x01
#define dMAC_SUITE_CCM128 0x02
#define dMAC_SUITE_CCM64 0x03
#define dMAC_SUITE_CCM32 0x04
#define dMAC_SUITE_CBC128 0x05
#define dMAC_SUITE_CBC64 0x06
#define dMAC_SUITE_CBC32 0x07
//--------------------------------------------------------
#define dMAC_AddrMode_NO 0
#define dMAC_AddrMode_NA 1
#define dMAC_AddrMode_16 2
#define dMAC_AddrMode_64 3
//--------------------------------------------------------
#define dMAC_FRAME_BEACON 0
#define dMAC_FRAME_DATA 1
#define dMAC_FRAME_ACK 2
#define dMAC_FRAME_MACCMD 3
//--------------------------------------------------------
#define dMAC_FC_FT 0x07
#define dMAC_FC_SE 0x08
#define dMAC_FC_FP 0x10
#define dMAC_FC_AR 0x20
#define dMAC_FC_IP 0x40
#define dMAC_FC_DAM 0x0C
#define dMAC_FC_SAM 0xC0
//--------------------------------------------------------
#define dMAC_TxOptions_ACK 0x01 // bit[0]
#define dMAC_TxOptions_GTS 0x02 // bit[1]
#define dMAC_TxOptions_INDIRECT 0x04 // bit[2]
#define dMAC_TxOptions_SECURITY 0x08 // bit[3]
//--------------------------------------------------------
#define dMAC_ScanType_EnergyDetection 0x00
#define dMAC_ScanType_ActiveScan 0x01
#define dMAC_ScanType_PassiveSCan 0x02
#define dMAC_ScanType_OrphanSCan 0x03
//--------------------------------------------------------
#define dMAC_CMD_ASSO_REQ 0x01
#define dMAC_CMD_ASSO_RES 0x02
#define dMAC_CMD_DISA_NOTI 0x03
#define dMAC_CMD_DATA_REQ 0x04
#define dMAC_CMD_PANID_CON 0x05
#define dMAC_CMD_ORPH_NOTI 0x06
#define dMAC_CMD_BEA_REQ 0x07
#define dMAC_CMD_COOR_REAL 0x08
#define dMAC_CMD_GTS_REQ 0x09
#define dMAC_DATA_TRANSFER 0x10
//--------------------------------------------------------
#define dMAC_DISA_BY_COORDI 0x01
#define dMAC_DISA_BY_DEVICE 0x02
//--------------------------------------------------------
#define dMAC_GTS_C2D 0x01
#define dMAC_GTS_D2C 0x00
//--------------------------------------------------------
#define dMAC_ACK_SIZE 0x05
//--------------------------------------------------------
#define dMAC_MAX_RAND_RETURN 0x20
#define dMAC_MIN_RAND_RETURN 0x08
#define dMAC_MAX_SERIAL_BUFF_MASK 0x3F
#define dMAC_MAX_PEND_ADDR_DEPTH 3
#define dMAC_MAX_BEACON_PAYLOAD_DEPTH 16
#define dMAC_MAX_GTS_LIST_DEPTH 7
#define dMAC_MAX_INDIRECT_BUFF_DEPTH (96)
#define dMAC_MAX_GTSTX_BUFF_DEPTH (30+8)
#define dMAC_MAX_PHY_PACKET_DEPTH 128
#define dMAC_MAX_RXQ_DEPTH 2
#define dMAC_MAX_INDIRECT_EXPIRE_TIME_MS 5000 // 500 ms
//--------------------------------------------------------
typedef struct {
UINT8 ExpCounter; // Counter for expiring when not used
UINT8 IncCounter; // Counter for including in Beacon Frame
UINT8 GtsCtrl; // GTS Control bits. bit[7]=Enable/Disable, bit[1]=RemoveFlag, bit[0]=Dir
UINT16 DevAddr; // GTS device's short address
UINT8 StartSlot;
UINT8 Length;
} S_GTSList;
typedef struct {
UINT8 DescCnt;
S_GTSList rsList[dMAC_MAX_GTS_LIST_DEPTH];
} S_GTSInfo;
typedef struct {
// [7] : Enable/Disable
// [0] : Direction(D2C=1, C2D=0)
UINT8 Ctrl;
UINT8 SlotInfo; // [7:4]=Length, [3:0]=StartSlot
UINT8 BeaconWait;
} S_DevGTSDesc;
typedef struct {
S_DevGTSDesc DevC2D;
S_DevGTSDesc DevD2C;
} S_DeviceGTS;
typedef struct {
UINT8 ListNum;
UINT8 FlagMode; // bit[7]=Enable/Disable
} S_TxGTS;
typedef struct {
UINT8 ModeFlag; // bit[7]=Enable/Disable
UINT16 TimerTickBI;
UINT16 TimerTickSD;
UINT16 TimerTickSlot;
UINT8 CurrSlotNum;
UINT16 BeaconTick;
} S_TxBeaManager;
typedef struct {
UINT8 SyncTiming;
UINT8 ModeFlag; // bit[7]=Ena/Disable, bit[6]=no-tracking sync req, bit[0]=Sync Ok
UINT8 CurrSlotNum;
UINT8 LostCnt;
UINT16 TimerTickBI;
UINT16 TimerTickSlot;
UINT16 BeaconTick;
UINT32 TimeStamp;
} S_RxBeaManager;
typedef struct {
unsigned BO : 4 ;
unsigned SO : 4 ;
unsigned FinalCap : 4 ;
unsigned BattExt : 1 ;
unsigned rsv0 : 1 ;
unsigned PANCoord : 1 ;
unsigned AssoPermit : 1 ;
} S_UnionSuperframe;
typedef union {
UINT16 word;
S_UnionSuperframe b;
} U_SuperframeSpec;
typedef struct {
UINT8 Ena;
UINT8 CoordAddrMode;
UINT16 CoordPANId;
UINT16 CoordAddr[4];
UINT8 LogicalChannel;
U_SuperframeSpec SuperframeSpec;
UINT8 GTSPermit;
UINT8 LinkQuality;
UINT32 TimeStamp;
UINT8 SecurityUse;
UINT8 ACLEntry;
UINT8 SecurityFail;
// BEACON-PAYLOAD
UINT8 BeaconPayload[dMAC_MAX_BEACON_PAYLOAD_DEPTH];
} S_PANDescriptor;
typedef struct
{
UINT8 ProtoID;
UINT8 Ver_Stack;
UINT8 B2;
//-- B2
// bit[7] : EndDevCapa. 1=Accept Joining from ZED
// bit[6:3] : DevDepth
// bit[2] : RouteCapa;
// bit[1:0] : reserve
UINT8 EPID[8];
UINT8 TxOffset[3];
} S_ZigBee2006;
typedef union
{
S_ZigBee2006 Z2006;
UINT8 Buff[dMAC_MAX_BEACON_PAYLOAD_DEPTH];
} U_BEA_PAY;
typedef struct
{
UINT8 Chan;
UINT16 PanID;
UINT8 AddrMode;
UINT16 ShortAddr;
UINT8 ExtAddr[8];
UINT8 SO_BO; // SuperSpec_L, bit[7:4]=SO, bit[3:0]=BO
UINT8 SuperSpec_H; // bit[3:0]=FinalCap, bit[4]=BattExt, bit[5]=rsv, bit[6]=PANCoord, bit[7]=PermitJoin
UINT8 GTSPermit;
UINT8 LinkQuality;
UINT32 TimeStamp;
UINT8 SecurityUse;
UINT8 ACLEntry;
UINT8 SecurityFail;
UINT8 BeaPayLen;
U_BEA_PAY BeaPayload;
UINT8 EnaZN; // by RadioPusle
} S_ZIGBEE_NET;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -