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

📄 phy.i

📁 ATmega128L+CC2420的单片机源程序
💻 I
📖 第 1 页 / 共 2 页
字号:
// CodeVisionAVR C Compiler
// (C) 1998-2004 Pavel Haiduc, HP InfoTech S.R.L.

// I/O registers definitions for the ATmega128


#pragma used+
sfrb PINF=0;
sfrb PINE=1;
sfrb DDRE=2;
sfrb PORTE=3;
sfrb ADCL=4;
sfrb ADCH=5;
sfrw ADCW=4;      // 16 bit access
sfrb ADCSRA=6;
sfrb ADMUX=7;
sfrb ACSR=8;
sfrb UBRR0L=9;
sfrb UCSR0B=0xa;
sfrb UCSR0A=0xb;
sfrb UDR0=0xc;
sfrb SPCR=0xd;
sfrb SPSR=0xe;
sfrb SPDR=0xf;
sfrb PIND=0x10;
sfrb DDRD=0x11;
sfrb PORTD=0x12;
sfrb PINC=0x13;
sfrb DDRC=0x14;
sfrb PORTC=0x15;
sfrb PINB=0x16;
sfrb DDRB=0x17;
sfrb PORTB=0x18;
sfrb PINA=0x19;
sfrb DDRA=0x1a;
sfrb PORTA=0x1b;
sfrb EECR=0x1c;
sfrb EEDR=0x1d;
sfrb EEARL=0x1e;
sfrb EEARH=0x1f;
sfrw EEAR=0x1e;   // 16 bit access
sfrb SFIOR=0x20;
sfrb WDTCR=0x21;
sfrb OCDR=0x22;
sfrb OCR2=0x23;
sfrb TCNT2=0x24;
sfrb TCCR2=0x25;
sfrb ICR1L=0x26;
sfrb ICR1H=0x27;
sfrw ICR1=0x26;   // 16 bit access
sfrb OCR1BL=0x28;
sfrb OCR1BH=0x29;
sfrw OCR1B=0x28;  // 16 bit access
sfrb OCR1AL=0x2a;
sfrb OCR1AH=0x2b;
sfrw OCR1A=0x2a;  // 16 bit access
sfrb TCNT1L=0x2c;
sfrb TCNT1H=0x2d;
sfrw TCNT1=0x2c;  // 16 bit access
sfrb TCCR1B=0x2e;
sfrb TCCR1A=0x2f;
sfrb ASSR=0x30;
sfrb OCR0=0x31;
sfrb TCNT0=0x32;
sfrb TCCR0=0x33;
sfrb MCUCSR=0x34;
sfrb MCUCR=0x35;
sfrb TIFR=0x36;
sfrb TIMSK=0x37;
sfrb EIFR=0x38;
sfrb EIMSK=0x39;
sfrb EICRB=0x3a;
sfrb RAMPZ=0x3b;
sfrb XDIV=0x3c;
sfrb SPL=0x3d;
sfrb SPH=0x3e;
sfrb SREG=0x3f;
#pragma used-


// Interrupt vectors definitions


/*
  CodeVisionAVR C Compiler
  (C) 1998-2004 Pavel Haiduc, HP InfoTech S.R.L.

  Prototype for SPI access function */
  

#pragma used+
unsigned char spi(unsigned char data);
#pragma used-

#pragma library spi.lib

// CodeVisionAVR C Compiler
// (C) 1998-2000 Pavel Haiduc, HP InfoTech S.R.L.


#pragma used+

void delay_us(unsigned int n);
void delay_ms(unsigned int n);

#pragma used-





 /******************************************************************************************************
 **************************                     函数声明                      **************************
 *******************************************************************************************************/

//-------------------------------------------------------------------------------------------------------
unsigned char WriteStrobeReg_spi(unsigned char cmd);
unsigned char WriteStrobeReg(unsigned char cmd);
unsigned char WriteConfigReg_spi(unsigned char cmd, unsigned int data);
unsigned int ReadConfigReg_spi(unsigned char cmd);

void Write_TXFIFO(unsigned char *data,unsigned char n);

void WriteRAM_spi(unsigned int cmd,unsigned char data[],unsigned char n);

unsigned char ReadRAM(unsigned int cmd);

void PHY_Init(void);
//-------------------------------------------------------------------------------------------------------







/*******************************************************************************************************
 *******************************************************************************************************
 **************************                定义 cc2420寄存器                  **************************
 *******************************************************************************************************
 *******************************************************************************************************/

//------------------------------------------------------------------------------------------------------
//定义cc2420命令选通寄存器地址

//定义cc2420配置寄存器地址

//-------------------------------------------------------------------------------------------------------



/*******************************************************************************************************
 *******************************************************************************************************
 **************************                定义 cc2420 Memory                 **************************
 *******************************************************************************************************
 *******************************************************************************************************/

//------------------------------------------------------------------------------------------------------
// Sizes

//定义cc2420 RAM Memory Space 地址
//------------------------------------------------------------------------------------------------------------




/*******************************************************************************************************
 *******************************************************************************************************
 ************************                定义 cc2420 Status byte              **************************
 *******************************************************************************************************
 *******************************************************************************************************/

//-------------------------------------------------------------------------------------------------------
// Status byte
//-------------------------------------------------------------------------------------------------------




//-------------------------------------------------------------------------------------------------------
// SECCTRL0




//-------------------------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------------------------
// RSSI to Energy Detection conversion
// RSSI_OFFSET defines the RSSI level where the PLME.ED generates a zero-value
//-------------------------------------------------------------------------------------------------------







/*******************************************************************************************************
 *******************************************************************************************************
 **************************                   Global macros                   **************************
 *******************************************************************************************************
 *******************************************************************************************************/




/*******************************************************************************************************
 *******************************************************************************************************
 **************************                定义 Mega128L 寄存器位               ************************
 *******************************************************************************************************
 *******************************************************************************************************/

//------------------------------------------------------------------------------------------------------
//SPI--->SPCR 

//SPI--->SPSR

//------------------------------------------------------------------------------------------------------



/*******************************************************************************************************
 *******************************************************************************************************
 **************************                ATmega128L I/O PORTS               **************************
 *******************************************************************************************************
 *******************************************************************************************************/

//------------------------------------------------------------------------------------------------------
// Port B 

// Port D 
//#define UART1_RXD       2 // PD.2 - Input:  UART1 RXD 
//#define UART1_TXD       3 // PD.3 - Output: UART1 TXD 
//#define UART1_CTS       7 // PD.7 - Input:  UART HW handshaking: CTS 

// Port E 


// Enables/disables the SPI interface

//------------------------------------------------------------------------------------------------------



 /******************************************************************************************************
 *******************************************************************************************************
 **************************                 CC2420 PIN ACCESS                 **************************
 *******************************************************************************************************
 *******************************************************************************************************/

//-------------------------------------------------------------------------------------------------------
// Pin status

// CC2420 voltage regulator enable pin

// The CC2420 reset pin  
//-------------------------------------------------------------------------------------------------------




/*******************************************************************************************************
 *******************************************************************************************************
 **************************                   SERIAL PORTS                    **************************
 *******************************************************************************************************
 *******************************************************************************************************/
 
//-------------------------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------------------------




/*******************************************************************************************************
 *******************************************************************************************************

⌨️ 快捷键说明

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