📄 zmac.h
字号:
* again.
*
* Note: None
********************************************************************/
#define MACSetNextChannel() PHYSetNextChannel()
/*********************************************************************
* Macro: BYTE MACGetChannel(void)
*
* PreCondition: None
*
* Input: None
*
* Output: Channel number.
*
* Side Effects: None
*
* Overview: Selects very first channel in current frequency
* band (i.e. channel 11 for 2.4GHz band)
*
* Note: This macro is designed to allow application to
* browse through all channels irrespective of
* frequency band in use.
********************************************************************/
#define MACGetChannel() PHYGetChannel()
/*********************************************************************
* Macros: void MACSetLongAddrByte?(BYTE b)
*
* PreCondition: None
*
* Input: b - Long address byte '?' value.
*
* Output: None
*
* Side Effects: None
*
* Overview: Saves given byte 'b' into corresponding long address
* byte.
*
* Note: There are total of 8 long address bytes.
* If required, you may also access macInfo.longAddr
* directly and load it with a value.
*
* This macro simply updates local variable. To
* actuall start using the new address, you must call
* MACUpdateAddressInfo()
********************************************************************/
#define MACSetLongAddrByte0(b) (macInfo.longAddr.v[0] = b)
#define MACSetLongAddrByte1(b) (macInfo.longAddr.v[1] = b)
#define MACSetLongAddrByte2(b) (macInfo.longAddr.v[2] = b)
#define MACSetLongAddrByte3(b) (macInfo.longAddr.v[3] = b)
#define MACSetLongAddrByte4(b) (macInfo.longAddr.v[4] = b)
#define MACSetLongAddrByte5(b) (macInfo.longAddr.v[5] = b)
#define MACSetLongAddrByte6(b) (macInfo.longAddr.v[6] = b)
#define MACSetLongAddrByte7(b) (macInfo.longAddr.v[7] = b)
/*********************************************************************
* Macros: BYTE MACGetLongAddrByte?(void)
*
* PreCondition: None
*
* Input: None
*
* Output: Returns a value for specified address byte.
*
* Side Effects: None
*
* Overview: Returns given byte 'b' of corresponding long address
* byte.
*
* Note: There are total of 8 long address bytes.
* If required, you may also access macInfo.longAddr
* directly and load it with a value.
*
********************************************************************/
#define MACGetLongAddrByte0() (macInfo.longAddr.v[0])
#define MACGetLongAddrByte1() (macInfo.longAddr.v[1])
#define MACGetLongAddrByte2() (macInfo.longAddr.v[2])
#define MACGetLongAddrByte3() (macInfo.longAddr.v[3])
#define MACGetLongAddrByte4() (macInfo.longAddr.v[4])
#define MACGetLongAddrByte5() (macInfo.longAddr.v[5])
#define MACGetLongAddrByte6() (macInfo.longAddr.v[6])
#define MACGetLongAddrByte7() (macInfo.longAddr.v[7])
/*********************************************************************
* Macros: void MACSetShortAddr?SB(BYTE b)
*
* PreCondition: None
*
* Input: b - Byte value that is to be set
*
* Output: None
*
* Side Effects: None
*
* Overview: Saves given vale to either LSB or MSB as per
* actual macro call.
*
* Note: Normally, short address is automatically set upon
* network association. This macro is provided to
* manually set the value if required.
* In current version, only automatic short address
* is supported.
*
* This macro simply updates local variable. To
* actuall start using the new address, you must call
* MACUpdateAddressInfo()
********************************************************************/
#define MACSetShortAddrLSB(b) (macInfo.shortAddr.byte.LSB = b)
#define MACSetShortAddrMSB(b) (macInfo.shortAddr.byte.MSB = b)
/*********************************************************************
* Macros: BYTE MACGetShortAddr?SB(void)
*
* PreCondition: None
*
* Input: None
*
* Output: A byte value of either LSB or MSB.
*
* Side Effects: None
*
* Overview: Returns either LSB or MSB of short address
*
* Note: If required, you may access macInfo.shortAddr
* directly.
*
********************************************************************/
#define MACGetShortAddrLSB() (macInfo.shortAddr.byte.LSB)
#define MACGetShortAddrMSB() (macInfo.shortAddr.byte.MSB)
#define MACGetShortAddr (macInfo.shortAddr)
/*********************************************************************
* Macros: void MACSetPANId?SB(BYTE b)
*
* PreCondition: None
*
* Input: b - Byte value that is to be set
*
* Output: None
*
* Side Effects: None
*
* Overview: Saves given vale to either LSB or MSB as per
* actual macro call.
*
* Note: Normally, PAN id is automatically set upon
* network association. This macro is provided to
* manually set the value if required.
* In current version, only automatic PAN id
* is supported.
*
* This macro simply updates local variable. To
* actuall start using the new address, you must call
* MACUpdateAddressInfo()
********************************************************************/
#define MACSetPANIdLSB(b) (macInfo.panID.byte.LSB = b)
#define MACSetPANIdMSB(b) (macInfo.panID.byte.MSB = b)
/*********************************************************************
* Macros: BYTE MACGetPANId?SB(void)
*
* PreCondition: None
*
* Input: None
*
* Output: Returns either LSB or MSB of PAN id
*
* Side Effects: None
*
* Overview: Returns pan id value.
*
* Note: If required, you may access pan ID directly.
********************************************************************/
#define MACGetPANIdLSB() (macInfo.panID.byte.LSB)
#define MACGetPANIdMSB() (macInfo.panID.byte.MSB)
#define MACGetPANId() (macInfo.panID)
/*********************************************************************
* Function: void MACUpdateAddressInfo(void)
*
* PreCondition: MACEnable() is called
*
* Input: None
*
* Output: None
*
* Side Effects: None
*
* Overview: Writes our MAC address, PAN ID and short address
* transciever configuration RAM.
*
* Note: None
********************************************************************/
void MACUpdateAddressInfo(void);
/*********************************************************************
* Macros: void MACSetAssociationPermit?SB(BOOL v)
*
* PreCondition: None
*
* Input: v - TRUE if association is permitted
* FALSE if otherwise
*
* Output: None
*
* Side Effects: None
*
* Overview: Marks the flag that allows/disallows future
* association requests.
*
* Note: None
********************************************************************/
#define MACSetAssociationPermit(v) (macState.bits.bPermitAssociation = v)
/*********************************************************************
* Function: BOOL MACIsPutReady(void)
*
* PreCondition: None
*
* Input: None
*
* Output: None
*
* Side Effects: None
*
* Overview: Determines if it is okay to load new tx frame
* into RF TX buffer.
*
* Note: None
********************************************************************/
BOOL MACIsPutReady(void);
/*********************************************************************
* Function: void MACPutHeader(NODE_INFO *dest, BYTE frameCON)
*
* PreCondition: MACIsPutReady() = TRUE
*
* Input: dest - Destination node info
* frameCON - Frame control for frame header
* Logical AND of
* "Frame Control flags" as defined
* in zMAC.h
*
* Output: None
*
* Side Effects: None
*
* Overview: Constructs and loads frame header as per
* IEEE spec.
* If frame requires ack, it makes an entry into
* DSN queue so that future ack can be matches
* against this frame.
*
* Note: None
********************************************************************/
void MACPutHeader(NODE_INFO *dst, BYTE frameCON);
/*********************************************************************
* Function: void MACPut(BYTE v)
*
* PreCondition: MACIsPutReady() == TRUE
*
* Input: v - A byte to put
*
* Output: None
*
* Side Effects: None
*
* Overview: Copies given byte into RF TX buffer and increments
* write pointer.
*
* Note: None
********************************************************************/
void MACPut(BYTE v);
/*********************************************************************
* Function: void MACPutArray(BYTE *v, BYTE len)
*
* PreCondition: MACIsPutReady() == TRUE
*
* Input: b - Buffer that is to be loaded.
* len - Number of bytes to get
*
* Output: None
*
* Side Effects: None
*
* Overview: Loads given bytes into RF TX buffer.
*
* Note: None
********************************************************************/
void MACPutArray(BYTE *v, BYTE len);
/*********************************************************************
* Function: HFRAME MACFlush(void)
*
* PreCondition: MACIsPutReady() == TRUE and
* a valid TX frame is constructured using
* MACPutHeader() and MACPut()
*
* Input: None
*
* Output: None
*
* Side Effects: None
*
* Overview: Sets the tx frame length, marks the tx frame
* as ready to be transmitted.
* If this frame requires ack from remote node,
* an entry is made into DSN queue so that
* we can match future ACK with this frame.
*
* Note: None
********************************************************************/
HFRAME MACFlush(void);
/*********************************************************************
* Function: BOOL MACFrameIsAcked(HFRAME h)
*
* PreCondition: MACPutHeader() is called
*
* Input: h - Handle to frame whose ack state
* is to be determined
*
* Output: None
*
* Side Effects: None
*
* Overview: Peeks into DSN queue and checks to see if
* dsn associated with this frame was ack'ed.
*
* Note: None
********************************************************************/
BOOL MACFrameIsAcked(HFRAME h);
/*********************************************************************
* Function: void MACFrameRemove(HFRAME h)
*
* PreCondition: MACPutHeader() is called
*
* Input: h - Handle to frame that is to be removed
* from DSN queue
*
* Output: None
*
* Side Effects: None
*
* Overview: Sets given DSN queue entry to free.
*
* Note: None
********************************************************************/
void MACFrameRemove(HFRAME h);
/*********************************************************************
* Macro: BOOL MACFrameIsTimedOut(HFRAME h)
*
* PreCondition: h is a valid hFrame
*
* Input: h - Handle to frame that is to be checked
*
* Output: TRUE if frame is timed out
* FALSE, otherwise
*
* Side Effects: None
*
* Overview: Returns timeout flag of given frame handle.
*
* Note: None
********************************************************************/
#define MACFrameIsTimedOut(h) (macFrameStatusQ[h].Flags.bits.bIsTimedOut)
/*********************************************************************
* Macro: BOOL MACFrameIsRetryExhausted(HFRAME h)
*
* PreCondition: h is a valid hFrame
*
* Input: h - Handle to frame whose retry status
* is to be checked
*
* Output: TRUE if retry exhausted,
* FALSE otherwise
*
* Side Effects: None
*
* Overview: Checks retry count for this frame.
*
* Note: None
********************************************************************/
#define MACFrameIsRetryExhausted(h) (macFrameStatusQ[h].retryCount == 0)
/*********************************************************************
* Macro: BOOL MACIsGetReady(void)
*
* PreCondition: None
*
* Input: None
*
* Output: TRUE if there is a new frame pending in RX buffer
*
* Side Effects: None
*
* Overview: Returns private frame ready flag.
* Actual frame was fetched during MACTask()
*
* Note: None
********************************************************************/
#define MACIsGetReady() (macCurrentFrame.Flags.bits.bIsGetReady)
/*********************************************************************
* Function: BYTE MACGet(void)
*
* PreCondition: MACIsGetReady() == TRUE
*
* Input: None
*
* Output: Byte that was read
*
* Side Effects: None
*
* Overview: Retrives one bytes from RF RX buffer.
*
* Note: Caller must make sure that RX buffer contains
* at least one byte calling MACIsGetReady()
********************************************************************/
BYTE MACGet(void);
/*********************************************************************
* Function: BYTE MACGetArray(BYTE *b, BYTE len)
*
* PreCondition: MACIsGetReady() == TRUE
*
* Input: b - Buffer to hold the data
* len - Number of bytes to get
*
* Output: Number of bytes actually read.
*
* Side Effects: None
*
* Overview: Reads RF RX buffer until given len bytes are
* are read or buffer is empty.
*
* Note: Actual number of bytes read may be less than
* asked. Caller must make sure that
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -