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

📄 common.h

📁 ARM的串口源码
💻 H
📖 第 1 页 / 共 2 页
字号:
#define P0_0_PINSEL    2 * P0_0
#define P0_1_GPIO      __0//通用数字输入输出管脚
  #define P0_1_RXD0    __1//UART0的接收器输入
  #define P0_1_PWM3    __2//脉宽调制器输出3
  #define P0_1_EINT0   __3//**外部中断0输入
#define P0_1_PINSEL    2 * P0_1
#define P0_2_GPIO      __0//通用数字输入输出管脚
  #define P0_2_SCL0    __1//I2C0时钟输入/输出。开漏输出(符合I2C规范)
  #define P0_2_CAP0_0  __2//***定时器0的捕获输入通道0
#define P0_2_PINSEL    2 * P0_2
#define P0_3_GPIO      __0//通用数字输入输出管脚
  #define P0_3_SDA0    __1//I2C0数据输入/输出。开漏输出(符合I2C规范)
  #define P0_3_MAT0_0  __2//**定时器0的匹配输出通道0
  #define P0_3_EINT1   __3//**外部中断1输入
#define P0_3_PINSEL    2 * P0_3
#define P0_4_GPIO      __0//通用数字输入输出管脚
  #define P0_4_SCK0    __1//SPI0的串行时钟。SPI时钟从主机输出,从机输入
  #define P0_4_CAP0_1  __2//**定时器0的捕获输入通道1
  #define P0_4_AD0_6   __3//A/D转换器0输入6。该模拟输入总是连接到相应的管脚
#define P0_4_PINSEL  2 * P0_4
#define P0_5_GPIO      __0//通用数字输入输出管脚
  #define P0_5_MISO0   __1//SPI0主机输入从机输出端。从机到主机的数据传输
  #define P0_5_MAT0_1  __2//**定时器0的匹配输出通道1
  #define P0_5_AD0_7   __3//A/D转换器0输入7。该模拟输入总是连接到相应的管脚
#define P0_5_PINSEL    2 * P0_5
#define P0_6_GPIO      __0//通用数字输入输出管脚
  #define P0_6_MOSI0   __1//SPI0主机输出从机输入端。主机到从机的数据传输
  #define P0_6_CAP0_2  __2//***定时器0的捕获输入通道2
  #define P0_6_AD1_0   __3//A/D转换器1输入0。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_6_PINSEL    2 * P0_6
#define P0_7_GPIO      __0//通用数字输入输出管脚
  #define P0_7_SSEL0   __1//SPI0从机选择。选择SPI接口用作从机
  #define P0_7_PWM2    __2//脉宽调制器输出2
  #define P0_7_EINT2   __3//**外部中断2输入
#define P0_7_PINSEL    2 * P0_7
#define P0_8_GPIO      __0//通用数字输入输出管脚
  #define P0_8_TXD1    __1//UART1的发送器输出
  #define P0_8_PWM4    __2//脉宽调制器输出4
  #define P0_8_AD1_1   __3//A/D转换器1输入1。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_8_PINSEL    2 * P0_8
#define P0_9_GPIO      __0//通用数字输入输出管脚
  #define P0_9_RXD1    __1//UART1的接收器输入
  #define P0_9_PWM6    __2//脉宽调制器输出6
  #define P0_9_EINT3   __3//***外部中断3输入
#define P0_9_PINSEL    2 * P0_9
#define P0_10_GPIO     __0//通用数字输入输出管脚
  #define P0_10_RTS1   __1//UART1请求发送出端(仅用于LP138)
  #define P0_10_CAP1_0 __2//定时器1的捕获输入通道0
  #define P0_10_AD1_2  __3//A/D转换器1输入2。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_10_PINSEL   2 * P0_10
#define P0_11_GPIO     __0//通用数字输入输出管脚
  #define P0_11_CTS1   __1//UART1清除发送入端(仅用于LP138)
  #define P0_11_CAP1_1 __2//定时器1的捕获输入通道1
  #define P0_11_SCL1   __3//I2C1时钟输入/输。开漏输出(符合I2C规范)
#define P0_11_PINSEL   2 * P0_11
#define P0_12_GPIO     __0//通用数字输入输出管脚
  #define P0_12_DSR1   __1//UART1数据设置就绪端(仅用于 LPC2138)
  #define P0_12_MAT1_0 __2//定时器1的匹配输出通道0
  #define P0_12_AD1_3  __3//A/D转换器1输入3。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_12_PINSEL   2 * P0_12
#define P0_13_GPIO     __0//通用数字输入输出管脚
  #define P0_13_DTR1   __1//UART1数据终端就绪
  #define P0_13_MAT1_1 __2//定时器1的匹配输出通道1
  #define P0_13_AD1_4  __3//A/D转换器1输入4。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_13_PINSEL   2 * P0_13
#define P0_14_GPIO     __0//通用数字输入输出管脚
  #define P0_14_DCD1   __1//UART1数据载波检测输入(仅用于 LPC2138)
  #define P0_14_EINT1  __2//**外部中断1输入
  #define P0_14_SDA1   __3//I2C1数据输入/输出。开漏输出(符合I2C规范)
#define P0_14_PINSEL   2 * P0_14
#define P0_15_GPIO     __0//通用数字输入输出管脚
  #define P0_15_RI1    __1//UART1铃响指示输入(仅用于 LPC2138)
  #define P0_15_EINT2  __2//**外部中断2输入
  #define P0_15_AD1_5  __3//A/D转换器1输入5。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_15_PINSEL   2 * P0_15
#define P0_16_GPIO     __0//通用数字输入输出管脚
  #define P0_16_EINT0  __1//**外部中断0输入
  #define P0_16_MAT0_2 __2//**定时器0的匹配输出通道2
  #define P0_16_CAP0_2 __3//***定时器0的捕获输入通道2
#define P0_16_PINSEL   2 * P0_0

#define P0_17_GPIO     __0//通用数字输入输出管脚
  #define P0_17_CAP1_2 __1//**定时器1的捕获输入通道2
  #define P0_17_SCK1   __2//SPI1的串行时钟。SPI时钟从主机输出,从机输入
  #define P0_17_MAT1_2 __3//**定时器1的匹配输出通道2
#define P0_17_PINSEL   2 * P0_1
#define P0_18_GPIO     __0//通用数字输入输出管脚
  #define P0_18_CAP1_3 __1//**定时器1的捕获输入通道3
  #define P0_18_MISO1  __2//SPI1主机输入从机输出端。从机到主机的数据传输
  #define P0_18_MAT1_3 __3//**定时器1的匹配输出通道3
#define P0_18_PINSEL   2 * P0_2

#define P0_19_GPIO     __0//通用数字输入输出管脚
  #define P0_19_MAT1_2 __1//**定时器1的匹配输出通道2
  #define P0_19_MOSI1  __2//SPI1主机输出从机输入端。主机到从机的数据传输
  #define P0_19_CAP1_2 __3//**定时器1的捕获输入通道2
#define P0_19_PINSEL   2 * P0_3

#define P0_20_GPIO     __0//通用数字输入输出管脚
  #define P0_20_MAT1_3 __1//**定时器1的匹配输出通道3
  #define P0_20_SSEL1  __2//SPI1从机选择。选择SPI接口用作从机
  #define P0_20_EINT3  __3//***外部中断3输入
#define P0_20_PINSEL   2 * P0_4

#define P0_21_GPIO     __0//通用数字输入输出管脚
  #define P0_21_PWM5   __1//脉宽调制器输出5
  #define P0_21_AD1_6  __2//A/D转换器1输入6。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
  #define P0_21_CAP1_3 __3//**定时器1的捕获输入通道3
#define P0_21_PINSEL   2 * P0_5

#define P0_22_GPIO     __0//通用数字输入输出管脚
  #define P0_22_AD1_7  __1//A/D转换器1输入7。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
  #define P0_22_CAP0_0 __2//***定时器0的捕获输入通道0
  #define P0_22_MAT0_0 __3//**定时器0的匹配输出通道0
#define P0_22_PINSEL   2 * P0_6

#define P0_23_GPIO     __0//通用数字输入输出管脚
#define P0_23_PINSEL   2 * P0_7
/*-----------------------------------------------------------------------
#define P0_24_GPIO     0//P0.24 脚未用
#define P0_24_PINSEL 2 * P0_8
------------------------------------------------------------------------*/

#define P0_25_GPIO     __0//通用数字输入输出管脚
  #define P0_25_AD0_4  __1//A/D转换器0输入4。该模拟输入总是连接到相应的管脚.
  #define P0_25_DAC    __2//D/A 转换器输出(仅用于 LPC2138)
#define P0_25_PINSEL   2 * P0_9

#define P0_26_GPIO     __0//通用数字输入输出管脚
  #define P0_26_AD0_5  __1//A/D转换器0输入5。该模拟输入总是连接到相应的管脚
#define P0_26_PINSEL   2 * P0_10

#define P0_27_GPIO     __0//通用数字输入输出管脚
  #define P0_27_AD0_0  __1//A/D转换器0输入0。该模拟输入总是连接到相应的管脚
  #define P0_27_CAP0_1 __2//**定时器0的捕获输入通道1
  #define P0_27_MAT0_1 __3//**定时器0的捕获输入通道1
#define P0_27_PINSEL   2 * P0_11

#define P0_28_GPIO     __0//通用数字输入输出管脚
  #define P0_28_AD0_1  __1//A/D转换器0输入1。该模拟输入总是连接到相应的管脚
  #define P0_28_CAP0_2 __2//***定时器0的捕获输入通道2
  #define P0_28_MAT0_2 __3//**定时器0的匹配输出通道2
#define P0_28_PINSEL   2 * P0_12

#define P0_29_GPIO     __0//通用数字输入输出管脚
  #define P0_29_AD0_2  __1//A/D转换器0输入2。该模拟输入总是连接到相应的管脚
  #define P0_29_CAP0_3 __2//定时器0的捕获输入通道3
  #define P0_29_MAT0_3 __3//定时器0的匹配输出通道3
#define P0_29_PINSEL   2 * P0_13

#define P0_30_GPIO     __0//通用数字输入输出管脚
  #define P0_30_AD0_3  __1//A/D转换器0输入3。该模拟输入总是连接到相应的管脚
  #define P0_30_EINT3  __2//***外部中断3输入
  #define P0_30_CAP0_0 __3//***定时器0的捕获输入通道0
#define P0_30_PINSEL   2 * P0_14

#define P0_31_GPO      __0//通用数字输出管脚(注意:此管脚仅为输出)
#define P0_31_PINSEL   2 * P0_15

/*--------------------------------------------------
        外部中断方式寄存器EXTMODE位定义
---------------------------------------------------*/
#define EXTMODE0 0//EXTMODE.0//该位为0时,EINT0使用电平激活;该位为1时,EINT0使用边沿激活。
#define EXTMODE1 1//EXTMODE.1//该位为0时,EINT1使用电平激活;该位为1时,EINT1使用边沿激活。
#define EXTMODE2 2//EXTMODE.2//该位为0时,EINT2使用电平激活;该位为1时,EINT2使用边沿激活。
#define EXTMODE3 3//EXTMODE.3//该位为0时,EINT3使用电平激活;该位为1时,EINT3使用边沿激活。
/*--------------------------------------------------
        外部中断极性寄存器EXTPOLAR位定义  
---------------------------------------------------*/
#define EXTPOLAR0 0//EXTPOLAR.0//该位为0时,EINT0低电平或下降沿有效(由EXTMODE0决定)。
                   //该位为1时,EINT0高电平或上升沿有效(由EXTMODE0决定)。
#define EXTPOLAR1 1//EXTPOLAR.1//该位为0时,EINT1低电平或下降沿有效(由EXTMODE1决定)。
                   //该位为1时,EINT1高电平或上升沿有效(由EXTMODE1决定)。
#define EXTPOLAR2 2//EXTPOLAR.2//该位为0时,EINT2低电平或下降沿有效(由EXTMODE2决定)。
                   //该位为1时,EINT2高电平或上升沿有效(由EXTMODE2决定)。
#define EXTPOLAR3 3//EXTPOLAR.3//该位为0时,EINT3低电平或下降沿有效(由EXTMODE3决定)。
                   //该位为1时,EINT3高电平或上升沿有效(由EXTMODE3决定)。
/*----------------------------------------------------
		读取USB时所用各种BUFF大小的设置
-----------------------------------------------------*/
#define UARTBUF_LENGTH  	520//520//
#define BUFFER_LENGTH		520//520 //
#define MAX_READ_LENGTH 	0xffffffff//1024//
//#define MAX_WRITE_LENGTH 	1024//1024//
#define WAVLEN				20480 //BUF的大小

typedef unsigned char       INT8;
typedef unsigned short      INT16;
typedef unsigned long       INT32;

typedef union __FLAGS
{
	struct _FLAGS
	{
		unsigned char   SLAVE_IS_ATTACHED	;
		unsigned char   SLAVE_REMOVED		;
		unsigned char  	SLAVE_FOUND		;	// Slave USB device found
		unsigned char  	SLAVE_ENUMERATED	;	// slave USB device enumeration done
		unsigned char   SLAVE_ONLINE		;
		unsigned char 	TIMEOUT_ERR		;	// timeout error during data endpoint transfer
		unsigned char	DATA_STOP		;					// device unplugged during data transfer
		unsigned char 	bData1			;
		unsigned char 	bUartInDone		;		
		unsigned char 	bMassDevice		;
		
	} bits;
	
} FLAGS;

/*------------------------------------------------------
				中断函数申明
------------------------------------------------------*/
void IRQ_UART0(void) __irq;		  //for 232test
void IRQ_EINT0(void) __irq;		  //for 487
void IRQ_EINT1(void) __irq;		  //for SL811
void IRQ_EINT3(void) __irq;		  //for CON
void IRQ_EINT2(void) __irq;

⌨️ 快捷键说明

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