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

📄 mftmac.h

📁 motorola jw32 usb 源码
💻 H
📖 第 1 页 / 共 2 页
字号:
 * 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 + -