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

📄 hardware.h

📁 一个单片机实现以太网通信的程序
💻 H
字号:
#ifndef	__HARDWARE_H__
#define	__HARDWARE_H__

//////////////////////////////////////////////////////////////////
// Define Area for I/O									
//////////////////////////////////////////////////////////////////
#define	P_IOA_Data   		 0x7000        //portA data
#define P_IOA_Buffer         0x7001        //portA buffer
#define P_IOA_Dir            0x7002        //portA direction
#define P_IOA_Attrib         0x7003        //portA attribution
#define P_IOA_Latch          0x7004        //Latch PortA data for key change wake-up
#define P_IOB_Data           0x7005        //portB data
#define P_IOB_Buffer         0x7006        //portB buffer
#define P_IOB_Dir            0x7007        //portB direction
#define P_IOB_Attrib         0x7008        //portB attribution

#define P_Feed_Back          0x7009        //portB.4 portB.5 SFC
#define P_TimerA_Data        0x700A        //timer A data
#define P_TimerA_Ctrl        0x700B        //timer A control
#define P_TimerB_Data        0x700C        //timer B data
#define P_TimerB_Ctrl        0x700D        //timer B control
#define P_TimeBase_Setup     0x700E        //time base configuration
#define P_TimeBase_Clear	 0x700F		   //Reset Timerbase counter
#define P_INT_Ctrl           0x7010        //interrupt control
#define P_INT_Clear          0x7011        //Interrupt clear register
#define P_Watchdog_Clear     0x7012        //clear watchdog ??
#define P_SystemClock        0x7013        //system clock generator setup

//... PA6442 Old version (for EC-02) ...........
//#define P_ADDA               0x7014        //10-bit DA(W) AD(R)
//#define P_DAC1               0x7014        //
//#define P_AD_Ctrl            0x7015        //AD/DA control
//#define P_AD_Status          0x7015        //AD status
//#define P_DAC2               0x7016        //DAC channel 2
//#define P_PWM                0x7016        //PWM output
//#define P_DA_Ctrl            0x7017        //DAC latch control
//#define P_LVD_Ctrl           0x7018        //Low voltage detect control

//... PA6442 New version MC52A (For EC-03)....
#define P_ADC 	        	 0x7014        	//Data Port for AD
#define P_ADC_Ctrl           0x7015        	//Control Port for AD control
#define P_ADC_Status         0x7015        	//AD Port Status
#define P_DAC2               0x7016        	//Data Port for DAC2
#define P_PWM                0x7016        	//Data Port for PWM
#define P_DAC1	        	 0x7017        	//Data Port for DAC1
#define P_DAC_Ctrl			 0x702A			//Control Port for two DAC and audio output mode
//............................................

#define P_IR_Ctrl			 0x7018			// Control Port for IR
#define P_LVD_Ctrl           0x7019        	// Control Port for LVD

#define P_SIO_Addr_Low		 0x701B			// Address Port low
#define P_SIO_Addr_Mid		 0x701C			// Address Port middle
#define P_SIO_Addr_High	 	 0x701D			// Address Port high
#define P_SIO_Ctrl			 0x701E			// Control Port
#define P_SIO_Start			 0x701F			// Start port for serial interface
#define P_SIO_Stop			 0x7020			// Stop port for serial interface

//added by hs
#define P_UART_Command1		   0x7021    	  //Command1 Port for UART
#define P_UART_Command2		   0x7022		  //Command2 Port for UART
#define P_UART_Data			   0x7023 	      //Data Port for UART
#define	P_UART_BaudScalarLow   0x7024	      //Set Baud Rate scalar low
#define	P_UART_BaudScalarHigh  0x7025	      //Set Baud Rate scalar high

// Constants value

// Interrupt control bit,defined for P_INT_Ctrl,
// used as param in function
// unsigned int SpFSetINTVec(unsigned int Vector);/*write data to 0x7010 [P_INT_Ctrl]*/
// unsigned int SpFGetINTVec();
// void SpFAddINTVec(unsigned int Vector); /*add data to 0x7010 [P_INT_Ctrl]*/       
// void SpFDelINTVec(unsigned int Vector);  /*delete data from 0x7010 [P_INT_Ctrl]*/
// void SpFClrINTReq(unsigned int Vector); /*write data for 0x7011 [P_INT_Clear]*/
#define C_IRQ6_TMB2             0x0001        	// Timer B IRQ6
#define C_IRQ6_TMB1             0x0002        	// Timer A IRQ6
#define C_IRQ5_2Hz              0x0004        	// 2Hz IRQ5
#define C_IRQ5_4Hz              0x0008        	// 4Hz IRQ5
#define C_IRQ4_1KHz             0x0010        	// 1024Hz IRQ4
#define C_IRQ4_2KHz             0x0020        	// 2048Hz IRQ4
#define C_IRQ4_4KHz             0x0040        	// 4096Hz IRQ4
#define C_IRQ3_KEY              0x0080        	// Key Change IRQ3
#define C_IRQ3_EXT1             0x0100        	// Ext1 IRQ3
#define C_IRQ3_EXT2             0x0200        	// Ext2 IRQ3
#define C_IRQ2_TMB              0x0400        	// Timer B IRQ2
#define C_FIQ_TMB               0x0800        	// Timer B FIQ
#define C_IRQ1_TMA              0x1000        	// Timer A IRQ1
#define C_FIQ_TMA               0x2000        	// Timer A FIQ
#define C_IRQ0_PWM              0x4000        	// PWM IRQ0
#define C_FIQ_PWM               0x8000        	// PWM FIQ

// Interrupt Vector Number,
// used as param 1 in function SpSSetVector() and SpSSetVectorExt()*/
// int SpSSetVector(int Vector_No, void (*Function_Ptr)());    /* foreground function register */
// int SpSSetVectorExt(int Vector_No, void (*Function_Ptr)()); /* background function register */ 
#define C_BREAK_Vec 0x0
#define C_FIQ_Vec   0x1
#define C_IRQ0_Vec  0x2
#define C_IRQ1_Vec  0x3
#define C_IRQ2_Vec  0x4
#define C_IRQ3_Vec  0x5
#define C_IRQ4_Vec  0x6
#define C_IRQ5_Vec  0x7
#define C_IRQ6_Vec  0x8
#define C_IRQ7_Vec  0x9	

// Define for Port_TimerA_Ctrl, Port_TimerB_Ctrl                               
#define	C_Fosc_2				0x0000			// Timer A
#define	C_Fosc_256		    	0x0001			//
#define	C_32768Hz				0x0002			//
#define	C_8192Hz				0x0003			//
#define	C_4096Hz				0x0004			//
#define	C_A1					0x0005			//
#define C_A0					0x0006			//
#define C_Ext1					0x0007			//

#define	C_2048Hz				0x0000			//
#define	C_1024Hz				0x0008			//
#define	C_256Hz					0x0010			//
#define	C_TMB1Hz				0x0018			//
#define	C_4Hz					0x0020			//
#define	C_2Hz					0x0028			//
#define	C_B1					0x0030			//
#define	C_Ext2					0x0038			//

#define	C_Off					0x0000			//
#define C_D1					0x0040			//
#define C_D2					0x0080			//
#define C_D3					0x00C0			//
#define C_D4					0x0100			//
#define C_D5					0x0140			//
#define C_D6					0x0180			//
#define C_D7					0x01C0			//
#define C_D8					0x0200			//
#define C_D9					0x0240			//
#define C_D10					0x0280			//
#define C_D11					0x02C0			//
#define C_D12					0x0300			//
#define C_D13					0x0340			//
#define C_D14					0x0380			//
#define C_TA_Div_2				0x03C0			// Timer A

#define C_TB_Div_2				0x03C0			// Timer B

// Define for Port_SystemClock
#define C_Fosc					0x0000			// b3..b0
#define C_Fosc_Div_2			0x0001			//
#define C_Fosc_Div_4			0x0002			//
#define C_Fosc_Div_8			0x0003			// (default)
#define C_Fosc_Div_16			0x0004			//
#define C_Fosc_Div_32			0x0005			//
#define C_Fosc_Div_64			0x0006			//
#define C_Sleep					0x0007		 	//

#define	C_32K_Work				0x0000			// b4
#define C_32K_Off				0x0000			// 
#define C_StrongMode			0x0000			// b5
#define C_AutoMode				0x0000			//

// Define for Port_AD_Ctrl
#define	C_AD					0x0001			//
#define C_DA					0x0000			//
#define C_MIC					0x0000			//
#define C_LINE					0x0002			//

// Define for Port_DA_Ctrl
#define C_PushPull				0x0000			// b0, (default) 
#define C_DoubleEnd				0x0001			// b0
#define	C_DAC_Mode				0x0000			// b1, (default)
#define C_PWM_Mode				0x0002			// b1

#define	C_D1_Direct				0x0000			// DAC1 latch
#define C_D1_LatchA				0x0008			// 
#define C_D1_LatchB				0x0010			//
#define C_D1_LatchAB			0x0018			//

#define	C_D2_Direct				0x0000			// DAC2 latch
#define C_D2_LatchA				0x0020			// 
#define C_D2_LatchB				0x0040			//
#define C_D2_LatchAB			0x00C0			//

// Define for Port_LVD_Ctrl
#define C_LVD24V				0x0000			// LVD = 2.4V 
#define C_LVD28V				0x0001			// LVD = 2.8V
#define C_LVD32V				0x0002			// LVD = 3.2V
#define C_LVD36V				0x0003			// LVD = 3.6V


#endif

⌨️ 快捷键说明

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