summaryrefslogtreecommitdiffhomepage
path: root/digital/beacon/src/Bitcloud_stack/Components/MAC_PHY/include/macAddr.h
diff options
context:
space:
mode:
Diffstat (limited to 'digital/beacon/src/Bitcloud_stack/Components/MAC_PHY/include/macAddr.h')
-rw-r--r--digital/beacon/src/Bitcloud_stack/Components/MAC_PHY/include/macAddr.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/digital/beacon/src/Bitcloud_stack/Components/MAC_PHY/include/macAddr.h b/digital/beacon/src/Bitcloud_stack/Components/MAC_PHY/include/macAddr.h
new file mode 100644
index 00000000..c9ff0ccb
--- /dev/null
+++ b/digital/beacon/src/Bitcloud_stack/Components/MAC_PHY/include/macAddr.h
@@ -0,0 +1,85 @@
+/**************************************************************************//**
+ \file macAddr.h
+
+ \brief MAC addressing types and constants.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 18/06/07 ALuzhetsky - Created.
+******************************************************************************/
+
+#ifndef _MACADDR_H
+#define _MACADDR_H
+
+/******************************************************************************
+ Includes section.
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Define(s) section.
+******************************************************************************/
+#define MAC_BROADCAST_PANID 0xFFFFU ///< Broadcast PANID.
+#define MAC_BROADCAST_SHORT_ADDR 0xFFFFU ///< Broadcast short address, no association.
+#define MAC_NO_SHORT_ADDR 0xFFFEU ///< After association no short address.
+#define MAC_NO_EXT_ADDR 0x00ULL
+
+/******************************************************************************
+ Types section.
+******************************************************************************/
+typedef uint16_t PanId_t; ///< PAN identifier type declaration.
+typedef uint16_t ShortAddr_t; ///< Short address type declaration.
+typedef uint64_t ExtAddr_t; ///< Extended address type declaration.
+
+/// Union of possible MAC address types.
+typedef union
+{
+ ShortAddr_t sh;
+ ExtAddr_t ext;
+} MAC_Addr_t;
+
+//! MAC address mode types (IEEE 802.15.4-2006 Table 80).
+ typedef enum
+{
+ MAC_NO_ADDR_MODE = 0x00,
+ MAC_RSRV_ADDR_MODE = 0x01,
+ MAC_SHORT_ADDR_MODE = 0x02,
+ MAC_EXT_ADDR_MODE = 0x03
+} MAC_AddrMode_t;
+
+/******************************************************************************
+ Definitions section.
+******************************************************************************/
+#if defined UINT64_MEMCMP
+ #define IS_EQ_EXT_ADDR(A, B) (0 == memcmp(&(A), &(B), sizeof(uint64_t)))
+ #define IS_CORRECT_EXT_ADDR(A) isCorrectExtAddr((const uint8_t *)&A)
+ #define COPY_EXT_ADDR(DST, SRC) __builtin_memcpy(&(DST), &(SRC), sizeof(uint64_t))
+#else
+ #define IS_EQ_EXT_ADDR(A, B) ((A) == (B))
+ #define IS_CORRECT_EXT_ADDR(A) (MAC_NO_EXT_ADDR != (A))
+ #define COPY_EXT_ADDR(DST, SRC) (DST) = (SRC)
+#endif
+
+/******************************************************************************
+ Inline static functions prototypes section
+******************************************************************************/
+INLINE bool isCorrectExtAddr(const uint8_t *extAddr)
+{
+ uint8_t i = 0U;
+
+ do
+ if (extAddr[i]) return true;
+ while (++i < sizeof(uint64_t));
+ return false;
+}
+
+#endif //_MACADDR_H
+
+// eof macAddr.h