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

📄 iai_ezmac_lite.h

📁 Integration的EZMac Lite
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
 *                                                                          *
 * FILE NAME:   IAI_EZMac_Lite.h                                            *
 *                                                                          *
 * DESIGNER:	Lukacs, Miklos; Kovacs, Krisztian                            *
 * PROGRAMMER: Lukacs, Miklos                                               *
 *                                                                          *
 * DESCRIPTION: EZMac function definitions                                  *
 *                                                                          *
 * REVISION:    01_5  Maj  10, 2005     From the original EZmac version     *
 *                                      removed:                            *
 *                                     - Multicast addressing.              *
 *                                     - Network address mode.              *
 *                                     - Reduced address mode.              *
 *                                     - Dynamic packet length.             *
 *                                     - Error detection.                   *
 *                                     - CID is mandatory.                  *
 *              01_6  Aug    11, 2005                                       *
 *                                                                          *
 *				01_7  Dec	 08, 2005	Port to HiTech						*
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#pragma nolist

#ifndef EZmac_Lite
#define  EZmac_Lite


                /* ======================================= *
                 *         I N T R O D U C T I O N         *
                 * ======================================= */
/*
Using EZmac is only consist of calling the following functions:
char EZMacIdle (void);
char EZMac_Transmit (void);
char EZMac_Receive (void);
char EZMacReg_Write (MacRegs Name,char Value);
char EZMacReg_Read (MacRegs Name,char* Value);
char EZMacBuf_Write (char* buf);
char EZMacBuf_Read (char* buf);
Before any transmit or receive the RF parameters must be configured by EZMacReg_Write.
Before transmit, the data buffer must be filled with EZMacBuf_Write.
After receive, the received packet can be read by EZMacBuf_Read.

The MAC uses only two resources of the microcontroller, the Timer1 IT, and the external IT.
For the correct operation the following routines must be included into the global ISR:
(void) EZMac_TimerISR (void);
(void) EZMac_CommISR (void);

There is no any restriction about the structure of the application program, the only requirement is that:
this two routines must be included into the very first lines of main() function:
(void) EZMac_SysInit (void);
(void) EZMac_Config (void);

*/
                /* ======================================= *
                 *           P A R A M E T E R S           *
                 * ======================================= */


#define  PLEN_MAX           16

#define BAND915

#ifdef BAND315
#define  FREQ_Band         0x0000      // for IA4420 config command
//#define FREQ_C1   1
//#define FREQ_C2   31
//#define FREQ_start ...
//#define FREQ_step  ..
//#define FREQ_maxid ..

#elif defined(BAND433)
#define  FREQ_Band         0x0010      // for IA4420 config command
//#define FREQ_C1   1
//#define FREQ_C2   43
//#define FREQ_start ...
//#define FREQ_step  ..
//#define FREQ_maxid ..

#elif defined(BAND868)
#define  FREQ_Band         0x0020      // for IA4420 config command
//#define FREQ_C1   2
//#define FREQ_C2   43
//#define FREQ_start ...
//#define FREQ_step  ..
//#define FREQ_maxid ..

#elif defined(BAND915)
#define  FREQ_Band         0x0030      // for IA4420 config command
//#define FREQ_C1   3
//#define FREQ_C2   30
#define FREQ_start 112
#define FREQ_step  64
#define FREQ_maxid 60

#endif


                /* ======================================= *
                 *          D E F I N I T I O N S          *
                 * ======================================= */

//#define CCS_COMPILER

#define  MAC_OK             0
#define  STATE_ERROR        1
#define  NAME_ERROR         2
#define  VALUE_ERROR        3
#define  WKUP_ERROR         4

// Changed by Laszlo Kadar on 29.11.05
#ifdef HITECH_COMPILER
 _NEAR__ byte BANK_2 STRL,STRH;                 //holds the actual status of the EZRadio chip
#endif
#ifdef CCS_C_COMPILER
 byte STRL,STRH;                 //holds the actual status of the EZRadio chip
#endif

#ifdef FIX_MEM_ADDRESS
 #pragma byte STRL=0x29
 #pragma byte STRH=0x2A
#endif


#define DQD_bit    0x80
#define DRSSI_bit  0x01

//states of the EZMac
#define  EZMac_S_Sleep             0x00
#define  EZMac_S_WakeUp            0x80
#define  EZMac_S_Idle              0x40
#define  EZMac_S_RxDQDCheck        0x20
#define  EZMac_S_Receiving         0x24
#define  EZMac_S_PacketValid       0x28
#define  EZMac_S_TxCheckChannel    0x10
#define  EZMac_S_TxError           0x14
#define  EZMac_S_TxPacket          0x18

//the default addresses after POR
#define  DEFAULT_CID     0xCD
#define  DEFAULT_SFID    0xF1
#define  DEFAULT_SFLT    0xFE
#define  DEFAULT_SMSK    0xFF

                /* ======================================= *
                 *     T Y P E   D E C L A R A T I O N     *
                 * ======================================= */

typedef enum
{
    MCR,
    TCR,
    RCR,
    PFCR,
    F0,
    F1,
    F2,
    F3,
    F4,
    F5,
    F6,
    F7,
    FMASK,
    CID,
    SFLT,
    SMSK,
    SFID,
    RPL,
    MSR,
    RSR,
    R_CID,
    SID,
    DID,
    PLEN

}MacRegs;

#define EZ_LASTREG PLEN

#define  REGBANK_SIZE      18
#define  DATABANK_SIZE     6





                /* ======================================= *
                 *        M I S C E L L A N E O U S        *
                 * ======================================= */
#include "IAI_EZMac_Lite_Int.h"


                /* ======================================= *
                 *  F U N C T I O N   P R O T O T Y P E S  *
                 * ======================================= */

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  +
  + FUNCTION NAME:  EZMac_Wake_Up
  +
  + DESCRIPTION:    Switches the MAC from Sleep to Idle state. Puts the EZRadio chip into standby state
  +
  + RETURN:         Mac_OK: The operation was succesfull
  +
  +                 State_Error: The operation is ignored, because the current state of EZMAC is not Sleep.
  +
  + NOTES:          Switches on the oscillator circuit of the EZRadio chip.
  +                 This function returns immediately, but the transition from Sleep to Idle
  +                 state lasts 5ms. At the and of this period the Wake-up timer in the EZradio will be
  +                 switched on for the longest period (6300 day)
  +
  +
  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#pragma separate
char EZMac_Wake_Up (void);

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  +
  + FUNCTION NAME:  EZMac_Sleep
  +
  + DESCRIPTION:    Switches the MAC from Idle to Sleep state. Puts the EZRadio chip into completely halt state.
  +
  + RETURN:         Mac_OK: The operation was succesfull
  +                 State_Error: The operation is ignored, because the current state of EZMAC is not Idle.
  +
  + NOTES:          Every RF part of the EZRadio chip is switched off in this state,
  +                 even the oscillator circuit.
  +                 The Wake-up timer is also switched off, but the Low Battery detector state is not affected
  +
  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#pragma separate
char EZMac_Sleep (void);

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  +
  + FUNCTION NAME:  EZMacIdle
  +
  + DESCRIPTION:    Puts the RF MAC into idle state
  +
  + RETURN:         Mac_OK:The operation was succesfull
  +
  +                 State_Error:If an ongoing transmission, or reception was aborted (the current
  +                 state is Transmit packet or Receive packet)
  +
  +                 Wkup_Error:the current state is Sleep, or the wake-up process hasn't been completed.
  +

⌨️ 快捷键说明

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