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

📄 iai_ezmac_plus.h

📁 Integration的EZMac Plus
💻 H
📖 第 1 页 / 共 3 页
字号:
		#define TX_CMD				0x9860											//deviation: 90kHz
		#define RX_CMD				(RELATIVE_LNA_GAIN | 0x9780)					//BW: 200kHz				
		#define FREQ_start 			112
		#define FREQ_step  			86
		#define FREQ_maxid 			45
		#define BAND_SELECTED
	#endif
	#define BAUD_RATE_SELECTED
#endif

#ifdef DATA_RATE_57600
	//is any other data rate selected too -> error
	#ifdef DATA_RATE_9600 | DATA_RATE_19200 | DATA_RATE_38400 | DATA_RATE_115200
		#error EZMac error: only one baud rate can be selected!
	#endif

	#define DR_CMD				0xC605												//57600bps

	#ifdef BAND_315
		//is any other band selected?
		#ifdef BAND_434 | BAND_868 | BAND_915 
			#error EZMac error: define only one frequency band!
		#endif
		//define radio parameters
		#define FREQ_Band			0x0000											//315MHz
		#define TX_CMD				0x9860											//deviation: 105kHz
		#define RX_CMD				(RELATIVE_LNA_GAIN | 0x9780)					//BW: 200kHz				
		#define FREQ_start 			112
		#define FREQ_step  			256
		#define FREQ_maxid 			15

		#define BAND_SELECTED
	#endif

	#ifdef  BAND_434
		#ifdef BAND_315 | BAND_868 | BAND_915 
			#error EZMac error: only one frequency band can be selected!
		#endif
		//define radio parameters
		#define FREQ_Band			0x0010											//434MHz
		#define TX_CMD				0x9860											//deviation: 105kHz
		#define RX_CMD				(RELATIVE_LNA_GAIN | 0x9760)					//BW: 270kHz				
		#define FREQ_start 			1444
		#define FREQ_step  			256
		#define FREQ_maxid 			2
		#define BAND_SELECTED
	#endif

	#ifdef  BAND_868
		#ifdef BAND_315 | BAND_434 | BAND_915 
			#error EZMac error: only one frequency band can be selected!
		#endif
		//define radio parameters
		#define FREQ_Band			0x0020											//868MHz
		#define TX_CMD				0x9880											//deviation: 135kHz
		#define RX_CMD				(RELATIVE_LNA_GAIN | 0x9760)					//BW: 270kHz				
		#define FREQ_start 			750
		#define FREQ_step  			157
		#define FREQ_maxid 			8
		#define BAND_SELECTED
	#endif

    #ifdef  BAND_915	
		#ifdef BAND_315 | BAND_434 | BAND_868
			#error EZMac error: only one frequency band can be selected!
		#endif
		//define radio parameters
		#define FREQ_Band			0x0030											//915MHz
		#define TX_CMD				0x9880											//deviation: 135kHz
		#define RX_CMD				(RELATIVE_LNA_GAIN | 0x9760)					//BW: 270kHz				
		#define FREQ_start 			112
		#define FREQ_step  			104
		#define FREQ_maxid 			37
		#define BAND_SELECTED
	#endif
	#define BAUD_RATE_SELECTED
#endif

#ifdef DATA_RATE_115200
	//is any other data rate selected too -> error
	#ifdef DATA_RATE_9600 | DATA_RATE_19200 | DATA_RATE_38400 | DATA_RATE_57600
		#error EZMac error: define only one baud rate!
	#endif

	#define DR_CMD				0xC602												//115200bps

	#ifdef BAND_315
		//is any other band selected?
		#ifdef BAND_434 | BAND_868 | BAND_915 
			#error EZMac error: define only one frequency band!
		#endif
		//define radio parameters
		#define FREQ_Band			0x0000											//315MHz
		#define TX_CMD				0x9880											//deviation: 135kHz
		#define RX_CMD				(RELATIVE_LNA_GAIN | 0x9760)					//BW: 270kHz				
		#define FREQ_start 			112
		#define FREQ_step  			314
		#define FREQ_maxid 			13

		#define BAND_SELECTED
	#endif

	#ifdef  BAND_434
		#ifdef BAND_315 | BAND_868 | BAND_915 
			#error EZMac error: only one frequency band can be selected!
		#endif
		//define radio parameters
		#define FREQ_Band			0x0010											//434MHz
		#define TX_CMD				0x9890											//deviation: 150kHz
		#define RX_CMD				(RELATIVE_LNA_GAIN | 0x9760)					//BW: 270kHz				
		#define FREQ_start 			1564
		#define FREQ_step  			345
		#define FREQ_maxid 			1
		#define BAND_SELECTED
	#endif

	#ifdef  BAND_868
		#ifdef BAND_315 | BAND_434 | BAND_915 
			#error EZMac error: only one frequency band can be selected!
		#endif
		//define radio parameters
		#define FREQ_Band			0x0020											//868MHz
		#define TX_CMD				0x98B0											//deviation: 180kHz
		#define RX_CMD				(RELATIVE_LNA_GAIN | 0x9740)					//BW: 340kHz				
		#define FREQ_start 			800
		#define FREQ_step  			200
		#define FREQ_maxid 			6
		#define BAND_SELECTED
	#endif

    #ifdef  BAND_915	
		#ifdef BAND_315 | BAND_434 | BAND_868
			#error EZMac error: only one frequency band can be selected!
		#endif
		//define radio parameters
		#define FREQ_Band			0x0030											//915MHz
		#define TX_CMD				0x98B0											//deviation: 180kHz
		#define RX_CMD				(RELATIVE_LNA_GAIN | 0x9740)					//BW: 340kHz				
		#define FREQ_start 			112
		#define FREQ_step  			134
		#define FREQ_maxid 			29
		#define BAND_SELECTED
	#endif
	#define BAUD_RATE_SELECTED
#endif
#ifndef BAUD_RATE_SELECTED
	#error: EZMac error: baud rate is not selected!
#endif
#ifndef BAND_SELECTED
	#error: EZMac error: frequency band is not selected!
#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

#ifdef HITECH_COMPILER
 byte bank2 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
#define  PLEN_MAX           	   16

//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_AckReceiveError   0x16
#define  EZMac_S_TxPacket          0x18
#define  EZMac_S_Forwarding        0x30 // Additional state for EzMacPlus
#define  EZMac_S_WaitingForAck     0x2c // Additional state for EzMacPlus
#define  EZMac_S_SendingAck        0x1c // Additional state for EzMacPlus

//the default addresses after POR
#define  DEFAULT_CID     		   0xCD
#define  DEFAULT_SFID    	       0xF1
#define  DEFAULT_NIDL    		   0xFE
#define  DEFAULT_NIDH    		   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,
    EC0,
    EC1,
    EC2,
    EC3,
    EC4,
    EC5,
    EC6,
    EC7,
    EDCR,
    CID,
    SFLT_NIDFL,
    SMSK_NIDFH,
    SFID,
    MCA_MCM,
    RPL_MPL,
	PFWCR, // EzMacPlus register
    MSR,
    RSR,
    R_CID,
    SID,
    DID,
    PLEN
}MacRegs;

#define EZ_LASTREG PLEN

#define  REGBANK_SIZE      29  // EzMacPlus 28 + 1
#define  DATABANK_SIZE     6			// 6: MSR, RSR, CID, SID, DID, PLEN



                /* ======================================= *
                 *        M I S C E L L A N E O U S        *
                 * ======================================= */
#include "IAI_EZMac_Plus_Internal.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.

⌨️ 快捷键说明

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