?? mftmac.h
字號:
* Output: None
*
* Side Effects: None
*
* Overview: Disbales PHY and marks MAC module as disabled.
*
* Note: None
********************************************************************/
//#define MACDisable() {macState.bits.bIsEnabled = FALSE; macCurrentFrame.IsGetReady = 0x00; PHYDisable();}
#define MACPANCLR() (PANDescCount = 0)
/*********************************************************************
* Function: void MACISR(void)
*
* PreCondition: MACInit() is previously called.
*
* Input: None
*
* Output: None
*
* Side Effects: None
*
* Overview: Determines if a frame has completed transmission
* or not.
*
* Note: None
********************************************************************/
extern void MACISR(void);
/*********************************************************************
* Function: BYTE MACTask(void)
*
* PreCondition: MACInit() is called
*
* Input: None
*
* Output: TRUE - If Processing is complete
* FALSE - If further processing is required
*
* Side Effects: None
*
* Overview: If previous frame is processed, it checks
* for new RX frame.
* Fetches the header and determiens if it is valid
* Automatically sends ACK if remote node has
* requested it.
* Also performs some other automatic processing
* based on the frame type.
* If there is no frame in buffer, it goes through
* DSN queue and calculates timeout for unack'ed
* TX frames.
*
* Note: This function must be called as many times as
* possible to keep handling MAC frames.
********************************************************************/
extern void MACTask(void);
/*********************************************************************
* Macro: void MACSetFirstChannel(void)
*
* PreCondition: None
*
* Input: None
*
* Output: None
*
* 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 MACSetFirstChannel(b) PHYSetFirstChannel(b)
/*********************************************************************
* Function: BYTE MACSetNextChannel(void)
*
* PreCondition: None
*
* Input: None
*
* Output: TRUE if a valid next channel was selected
* FALES if end of available channels was reached.
*
* Side Effects: None
*
* Overview: Sequences to next available channel specific
* to current frequency band.
* When end of channels is reached, FALSE is returned
* and application call SetFirstChannel() to start
* again.
*
* Note: None
********************************************************************/
#define MACSetNextChannel(b) PHYSetNextChannel(b)
/*********************************************************************
* Macros: void MACSetDeviceID(uchar b)
*
* PreCondition: None
*
* Input: b - uchar value that is to be set
*
* Output: None
*
* Side Effects: None
*
* Overview: Saves given vale to device id
*
* Note: every device have one device id,when power up,
must mannual set slef device id.orelse the device
can not associate with controller.
********************************************************************/
#define MACSetDeviceID(b) (macInfo.devId = b)
/*********************************************************************
* Macros: uchar MACGetDeviceID?SB(void)
*
* PreCondition: None
*
* Input: None
*
* Output: A uchar value of deviceid
*
* Side Effects: None
*
*
* Note: If required, you may access macInfo.deviceid
* directly.
*
********************************************************************/
#define MACGetDeviceID (macInfo.devId)
/*********************************************************************
* Macros: void MACSetPANId?SB(uchar b)
*
* PreCondition: None
*
* Input: b - uchar value that is to be set
*
* Output: None
*
* Side Effects: None
*
* Overview: Saves given vale to either panid
*
* Note: Normally, PAN id is automatically set upon
* network association. This macro is provided to
* manually set the value if required.
*
********************************************************************/
#define MACSetPANId(b) (macInfo.panId = b)
/*********************************************************************
* Macros: uchar MACGetPANId?SB(void)
*
* PreCondition: None
*
* Input: None
*
* Output: Returns panid
*
* Side Effects: None
*
* Overview: Returns pan id value.
*
* Note: If required, you may access macInfo.panID directly.
********************************************************************/
#define MACGetPANId() (macInfo.panId)
/*********************************************************************
* Macros: void MACSetDeviceAddress(uchar b)
*
* PreCondition: None
*
* Input: b - uchar value that is to be set
*
* Output: None
*
* Side Effects: None
*
* Overview: Saves given vale to devAddress
*
* Note: every device have one device Address,when associate,
controller will allocate one address to this device.
device should call this function save it.
********************************************************************/
#define MACSetDeviceAddress(b) (macInfo.devAddress = b)
/*********************************************************************
* Macros: uchar MACGetAddress(void)
*
* PreCondition: None
*
* Input: None
*
* Output: Returns devAddress
*
* Side Effects: None
*
* Note: If required, you may access macInfo.devAddress directly.
********************************************************************/
//#define MACGetAddress(void) (macInfo.devAddress)
/*********************************************************************
* Macro: BYTE 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() (macState.bits.bIsGetReady)
#define MACIsGetReady() (bIsGetReady)
#define MAC_FRAME_JNET (0x00)
#define MAC_FRAME_JNETACK (0x01)
#define MAC_FRAME_CHKNET (0x02)
#define MAC_FRAME_NETST (0x03)
#define MAC_FRAME_DATA (0x04)
#define MAC_FRAME_TEST (0x05)
#define MAC_FRAME_TESTACK (0x06)
#define MAC_FRAME_CMD (0x07)
#define MAC_FRAME_BEACON (0x08)
#define MAC_FRAME_WARN (0x09)
/*
// Macros to determine current frame type
#define MACIsData() (macCurrentFrame.frameCtrl.Control.fields.type == MAC_FRAME_DATA)
#define MACIsTESTACK() (macCurrentFrame.frameCtrl.Control.fields.type == MAC_FRAME_TESTACK)
#define MACIsJNet() (macCurrentFrame.frameCtrl.Control.fields.type == MAC_FRAME_JNET)
#define MACIsJNetAck() (macCurrentFrame.frameCtrl.Control.fields.type == MAC_FRAME_JNETACK)
#define MACIsChkNet() (macCurrentFrame.frameCtrl.Control.fields.type == MAC_FRAME_CHKNET)
#define MACIsNetSts() (macCurrentFrame.frameCtrl.Control.fields.type == MAC_FRAME_NETST)
#define MACIsTest() (macCurrentFrame.frameCtrl.Control.fields.type == MAC_FRAME_TEST)
#define MACFramIsPan() (macCurrentFrame.sndAddress == macInfo.panId)
*/
/*********************************************************************
* 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
********************************************************************/
extern void MACPut(BYTE v);
/*********************************************************************
* 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()
********************************************************************/
extern BYTE MACGet(void);
/*********************************************************************
* Macro: BYTE MACIsNetworkEstablished(void)
*
* PreCondition: None
*
* Input: None
*
* Output: TRUE if network is established.
* FALSE otherwise
*
* Side Effects: None
*
* Overview: Returns network establish status
*
* Note: Available to coordinator only.
********************************************************************/
// #define MACIsNetworkEstablished() (macState.bits.bIsAssociated)
#define MACIsNetworkEstablished() (bIsAssociated)
/*********************************************************************
* Macro: void MACStart(void)
*
* PreCondition: MACEnable is called.
*
* Input: None
*
* Output: None
*
* Side Effects: None
*
* Overview: Enables PHY receiver.
*
* Note: Available to coordinator only.
********************************************************************/
extern void MACStart() ;
/*********************************************************************
* Macro: BYTE MACIsPANAvailable(void)
*
* PreCondition: MACStartAssociation() process is completed.
*
* Input: None
*
* Output: TRUE if there was at least one PAN was detected
* FALSE otherwise
*
* Side Effects: None
*
* Overview: Returns previously detected network count
*
* Note: None
********************************************************************/
#define MACIsPANAvailable() (PANDescCount)
/*********************************************************************
* Function: void MACStartScan()
*
* PreCondition: MACInit(), MACEnable() are called
* And MACIsPutReady() == TRUE
* Output: None
*
* Side Effects: None
*
*
* Note: None
********************************************************************/
extern void MACStartScan();
/*********************************************************************
* Function: BYTE MACIsScanComplete(void)
*
* PreCondition: MACStartScan() is called.
*
* Input: None
*
* Output: TRUE if scan is complete
* FALSE otherwise.
*
* Side Effects: None
*
* Overview: Checks to see a beacon was received and if it is,
* it processes it.
*
* Note: None
********************************************************************/
extern BYTE MACIsScanComplete(void);
/*********************************************************************
* Function: BYTE GetMACMaxChannelNumber()
*
*
* Input: None
*
* Output: number of physical channel supported by rf chip
*
* Note: None
********************************************************************/
extern BYTE GetMACMaxChannelNumber(void);
/*********************************************************************
Function: BYTE MACProcessDataReq(char length,char *sendBuffer)
功能: 發送一幀數據
輸入:length 發送數據的長度,sendBuffer 發送數據的地址
輸出:發送成功或失敗.
描述:上層調用此函數發送數據幀,此函數需要將數據打包成MAC幀格式,然后調用
物理層發送數據API 將數據發送出去.
********************************************************************/
//extern BYTE MACProcessDataReq(char length,char *sendBuffer);
/*********************************************************************
Function: BYTE MACGetData()
功能: 取MAC一幀數據
輸入:
輸出:取數據成功或失敗.
描述:上層調用此函數華C數據幀,數據為MAC數據包
********************************************************************/
extern BYTE MACGetData();
/*********************************************************************
* Function: BYTE MACIsAssociationComplete(void)
*
*
* description: check join network is success/fail.
*
*********************************************************************/
extern BYTE MACIsAssociationComplete(void);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -