⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swsstackcommon.h

📁 ucos在NEC平台下的移植
💻 H
字号:

#ifndef SWSSTACKCOMMON_H
#define  SWSSTACKCOMMON_H
//-------------------------------------------------------------------------------------------------------
// Capability information field formatting (join(NWK),association(MAC) request)

// Indexes
#define CI_ALTERNATE_PAN_COORD_IDX  0
#define CI_DEVICE_TYPE_IS_FFD_IDX   1
#define CI_POWER_SOURCE_IDX         2
#define CI_RX_ON_WHEN_IDLE_IDX      3
#define CI_SECURITY_CAPABILITY_IDX  6
#define CI_ALLOCATE_ADDRESS_IDX     7

// Bit masks
#define CI_ALTERNATE_PAN_COORD_BM   0x01
#define CI_DEVICE_TYPE_IS_FFD_BM    0x02
#define CI_POWER_SOURCE_BM          0x04
#define CI_RX_ON_WHEN_IDLE_BM       0x08
#define CI_SECURITY_CAPABILITY_BM   0x40
#define CI_ALLOCATE_ADDRESS_BM      0x80
//-------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------



//----------------------------------------------------------------------------------------------------------
// Address modes 
#define SRC_ADDR_BM             0xC0
#define SRC_ADDR_NONE           0x00
#define SRC_ADDR_SHORT          0x80
#define SRC_ADDR_EXT            0xC0

#define DEST_ADDR_BM            0x0C
#define DEST_ADDR_NONE          0x00
#define DEST_ADDR_EXT           0x0C
#define DEST_ADDR_SHORT         0x08

// Address modes:
#define AM_NONE                 0
#define AM_SHORT_16             2
#define AM_EXTENDED_64          3
// Internal
#define BOTH_ADDR_USED          0x88
//--------------------------------------------------------------------------------------------------------
/******************the status of the NWK layer****************************/

typedef enum {
  NWK_STATE_IDLE,
  NWK_STATE_COMMAND_START,
  NWK_STATE_GENERIC_TX_WAIT,
  NWK_STATE_FORM_NETWORK_START,
  NWK_STATE_JOIN_NETWORK_START,
  NWK_STATE_JOIN_NETWORK_START_WAIT,
  NWK_STATE_REJOIN_NETWORK_START,
  NWK_STATE_REJOIN_WAIT,
  NWK_STATE_JOIN_SEND_BEACON_REQ,
  NWK_STATE_JOIN_NWK_WAIT1_BREQ,
  NWK_STATE_JOIN_NWK_WAIT2_BREQ,
  NWK_STATE_JOIN_MAC_ASSOC_CHANSELECT,
  NWK_STATE_JOIN_MAC_ASSOC,
  NWK_STATE_JOIN_MAC_ASSOC_WAIT,
  NWK_STATE_FWD_WAIT
} NWK_STATE_TYPE;
//-------------------------------------------------------------------------------------------------------

typedef enum 
{
    NWK_COMMAND_ROUTE_REQUEST       = 0x01,
    NWK_COMMAND_ROUTE_REPLY         = 0x02,
    NWK_COMMAND_ROUTE_ERROR         = 0x03,
    NWK_COMMAND_LEAVE               = 0x04       /*the command type of network layer*/
} NWK_COMMANDS;


// The random generator polynom
#define RANDOM_POLY 0x1021

// The 16-bit shift register which is used to generate random numbers

//-------------------------------------------------------------------------------------------------------


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

//-------------------------------------------------------------------------------------------------------
//  BYTE stackGetRandomByte(void)
//
//  DESCRIPTION:
//      Get a single return pseudo-random byte, initialized from msupInitRandom()
//
//  RETURN VALUE:
//      BYTE
//          The low part of the random word
//-------------------------------------------------------------------------------------------------------
BYTE stackGetRandomByte(void);

//-----------------------------------------------------------------------------------------
//  ZBOOL ContentIsEqual(BYTE *a,BYTE *b, BYTE compareLength);
//
//  DESCRIPTION:
//            Compare the contents of two byte arrays,the length of the array is stored in compareLength.
//  PARAMETER:
//            BYTE *a,BYTE *b
//             Two byte pointers,point to the start address of two arrays;
//            BYTE compareLength,
//             The length of the array
//  RETURN-VALUE:
//            TRUE:the contents of the two byte arrays are equal.
//            FALSE:the contents of the two byte arrays are not equal.
//-----------------------------------------------------------------------------------------
ZBOOL ContentIsEqual(BYTE *a,BYTE *b, BYTE compareLength);

//-----------------------------------------------------------------
//  void ByteArrayContentCopy(BYTE *dest,BYTE *src, BYTE copyLength);
//
//  DESCRIPTION:
//           Copy the contents of the src to the dest.
//  PARAMETER:
//            BYTE *dest,
//            the start address of the dest byte array.
//            BYTE *src, 
//            the start address of the src byte array.
//            BYTE copyLength,
//            how many bytes should be copied,usually copyLength is the length of
//                   the src byte array,and the length of the two byte array should be equal.
//  RETURN-VALUE:
//             NO
//--------------------------------------------------------------------
void ByteArrayContentCopy(BYTE *dest,BYTE *src, BYTE copyLength);

//--------------------------------------------------------------------
//   ZBOOL NWKThisIsMyLongAddress( BYTE *address );
//
//   DESCRIPTION:
//            This function determines if the address stored in the  'BYTE *address' is my
//             long address.It will call the ContentIsEqual()function.
//   PARAMETER:
//            BYTE *address ,
//            The initial address of the byte array which is used to store the contents the deviceAddress
//            input from the nlmeLeaveRequest()function.
//   RETURN-VALUE:
//            TRUE - values at address match my long address
//            FALSE-else
//-----------------------------------------------------------------------
ZBOOL NWKThisIsMyLongAddress( BYTE *address );

//-----------------------------------------------------------------
//   void ContentCopy(BYTE *dest,BYTE *src,BYTE length);
//
//   DESCRIPTION:
//           This function copies the contents from src into dest.We need this function
//            because in the program we not only need copy the contents from one byte
//            array to another,but also need copy the contents from one byte array
//            to another memory pointed by BYTE pointer;
//   PARAMETER:
//            BYTE *dest,
//            where the contents will be copied to.
//            BYTE *src,
//            where the contents from.
//            BYTE length,
//            how many bytes will be copied.
//   RETURN-VALUE:
//            NO
//------------------------------------------------------------------
void ContentCopy(BYTE *dest,BYTE *src,BYTE length);

//-----------------------------------------------------------------
//   BYTE *ContactTwoByteArray(BYTE *first,BYTE *second);
//
//   DESCRIPTION:
//          Contacts the contents of two byte array.
//   PARAMETER:
//           BYTE *first,
//                the initial address of the first byte array.
//           BYTE *second,
//                the initial address of the second byte array.
//   RETURN-VALUE:
//           NO,we return the initial address of the contacted array through 'first'.
//           This can save memory.
//-----------------------------------------------------------------
void ContactTwoByteArray(BYTE *first,BYTE *second);


//-----------------------------------------------------------------
//    BYTE CompareTime(INT16 startTimeStamp,INT16 endTimeStamp,INT16 duration);
//
//    DESCRIPTION:
//            Compare the two timaStamp to justify if timeout occurs
//    PARAMETER:
//            BYTE *startTimeStamp,
//              A pointer points to the startTimeStamp;
//            BYTE *endTimeStamp,
//              A pointer points to the endTimeStamp.
//            BYTE *duration
//              A pointer points to the duration.
//   RETURN-VALUES;
//            1:timeout occurs
//            -1:timeoutout doesn't occurs
//-----------------------------------------------------------------
BYTE CompareTime(TICK startTimeStamp,TICK endTimeStamp,TICK duration);
#endif 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -