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

📄 common.h

📁 ARM的串口源码
💻 H
📖 第 1 页 / 共 2 页
字号:
///////////////////////////////////////////////////////

#define NULL		0
#define TRUE   		1
#define FALSE  		0

typedef volatile unsigned long LPC_REG;// Hardware register definition
/*---------------------------------------------------------------------
                 P0口链接配置位定义
----------------------------------------------------------------------*/
#define P0_0   0//P0.0
  #define TXD0    P0_0//UART0的发送器输出
  #define PWM1    P0_0//脉宽调制器输出1
#define P0_1   1//P0.1
  #define RXD0    P0_1//UART0的接收器输入
  #define PWM3    P0_1//脉宽调制器输出3
#define P0_2   2//P0.2
  #define SCL0    P0_2//I2C0时钟输入/输出。开漏输出(符合I2C规范)
#define P0_3   3//P0.3
  #define SDA0    P0_3//I2C0数据输入/输出。开漏输出(符合I2C规范)
#define P0_4   4//P0.4
  #define SCK0    P0_4//SPI0的串行时钟。SPI时钟从主机输出,从机输入
  #define AD0_6   P0_4//A/D转换器0输入6。该模拟输入总是连接到相应的管脚
#define P0_5   5//P0.5
  #define MISO0   P0_5//SPI0主机输入从机输出端。从机到主机的数据传输
  #define AD0_7   P0_5//A/D转换器0输入7。该模拟输入总是连接到相应的管脚
#define P0_6   6//P0.6
  #define MOSI0   P0_6//SPI0主机输出从机输入端。主机到从机的数据传输
  #define AD1_0   P0_6//A/D转换器1输入0。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_7   7//P0.7
  #define SSEL0   P0_7//SPI0从机选择。选择SPI接口用作从机
  #define PWM2    P0_7//脉宽调制器输出2
#define P0_8   8//P0.8
  #define TXD1    P0_8//UART1的发送器输出
  #define PWM4    P0_8//脉宽调制器输出4
  #define AD1_1   P0_8//A/D转换器1输入1。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_9   9//P0.9
  #define RXD1    P0_9//UART1的接收器输入
  #define PWM6    P0_9//脉宽调制器输出6
#define P0_10 10//P0.10
  #define RTS1    P0_10//UART1请求发送出端(仅用于LP138)
  #define CAP1_0  P0_10//定时器1的捕获输入通道0
  #define AD1_2   P0_10//A/D转换器1输入2。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_11 11//P0.11
  #define CTS1    P0_11//UART1清除发送入端(仅用于LP138)
  #define CAP1_1  P0_11//定时器1的捕获输入通道1
  #define SCL1    P0_11//I2C1时钟输入/输。开漏输出(符合I2C规范)
#define P0_12 12//P0.12
  #define DSR1    P0_12//UART1数据设置就绪端(仅用于 LPC2138)
  #define MAT1_0  P0_12//定时器1的匹配输出通道0
  #define AD1_3   P0_12//A/D转换器1输入3。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_13 13//P0.13
  #define DTR1    P0_13//UART1数据终端就绪
  #define MAT1_1  P0_13//定时器1的匹配输出通道1
  #define AD1_4   P0_13//A/D转换器1输入4。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_14 14//P0.14
  #define DCD1    P0_14//UART1数据载波检测输入(仅用于 LPC2138)
  #define SDA1    P0_14//I2C1数据输入/输出。开漏输出(符合I2C规范)
#define P0_15 15//P0.15
  #define RI1     P0_15//UART1铃响指示输入(仅用于 LPC2138)
  #define AD1_5   P0_15//A/D转换器1输入5。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_16 16//P0.16
#define P0_17 17//P0.17
  #define SCK1    P0_17//SPI1的串行时钟。SPI时钟从主机输出,从机输入
#define P0_18 18//P0.18
  #define MISO1   P0_18//SPI1主机输入从机输出端。从机到主机的数据传输
#define P0_19 19//P0.19
  #define MOSI1   P0_19//SPI1主机输出从机输入端。主机到从机的数据传输
#define P0_20 20//P0.20
  #define SSEL1   P0_20//SPI1从机选择。选择SPI接口用作从机
#define P0_21 21//P0.21
  #define PWM5    P0_21//脉宽调制器输出5
  #define AD1_6   P0_21//A/D转换器1输入6。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_22 22//P0.22
  #define AD1_7   P0_22//A/D转换器1输入7。该模拟输入总是连接到相应的管脚(仅用于 LPC2138)
#define P0_23 23//P0.23
#define P0_24 24//P0.24
#define P0_25 25//P0.25
  #define AD0_4   P0_25//A/D转换器0输入4。该模拟输入总是连接到相应的管脚.D/A 转换器输出(仅用于 LPC2138)
#define P0_26 26//P0.26
  #define AD0_5   P0_26//A/D转换器0输入5。该模拟输入总是连接到相应的管脚
#define P0_27 27//P0.27
  #define AD0_0   P0_27//A/D转换器0输入0。该模拟输入总是连接到相应的管脚
#define P0_28 28//P0.28
  #define AD0_1   P0_28//A/D转换器0输入1。该模拟输入总是连接到相应的管脚
#define P0_29 29//P0.29
  #define AD0_2   P0_29//A/D转换器0输入2。该模拟输入总是连接到相应的管脚
  #define CAP0_3  P0_29//定时器0的捕获输入通道3
  #define MAT0_3  P0_29//定时器0的匹配输出通道3
#define P0_30 30//P0.30
  #define AD0_3   P0_30//A/D转换器0输入3。该模拟输入总是连接到相应的管脚
#define P0_31 31//P0.31
/*------------------------------------------
        P1口GPIO位寻址位定义
-------------------------------------------*/
#define P1_0   0//P1.0
#define P1_1   1//P1.1
#define P1_2   2//P1.2
#define P1_3   3//P1.3
#define P1_4   4//P1.4
#define P1_5   5//P1.5
#define P1_6   6//P1.6
#define P1_7   7//P1.7
#define P1_8   8//P1.8
#define P1_9   9//P1.9
#define P1_10 10//P1.10
#define P1_11 11//P1.11
#define P1_12 12//P1.12
#define P1_13 13//P1.13
#define P1_14 14//P1.14
#define P1_15 15//P1.15
#define P1_16 16//P1.16
#define P1_17 17//P1.17
#define P1_18 18//P1.18
#define P1_19 19//P1.19
#define P1_20 20//P1.20
#define P1_21 21//P1.21
#define P1_22 22//P1.22
#define P1_23 23//P1.23
#define P1_24 24//P1.24
#define P1_25 25//P1.25
#define P1_26 26//P1.26
#define P1_27 27//P1.27
#define P1_28 28//P1.28
#define P1_29 29//P1.29
#define P1_30 30//P1.30
#define P1_31 31//P1.31
 
/*----------------------------------------------------
			连接到向量中断控制器的中断源
------------------------------------------------------*/
#define __0                  (LPC_REG)0 
#define __1                  (LPC_REG)1 
#define __2                  (LPC_REG)2 
#define __3                  (LPC_REG)3 
#define __4                  (LPC_REG)4 
#define __5                  (LPC_REG)5 
#define __6                  (LPC_REG)6 
#define __7                  (LPC_REG)7 
#define __8                  (LPC_REG)8 
#define __9                  (LPC_REG)9 
#define __10                 (LPC_REG)10
#define __11                 (LPC_REG)11
#define __12                 (LPC_REG)12
#define __13                 (LPC_REG)13
#define __14                 (LPC_REG)14
#define __15                 (LPC_REG)15
#define __16                 (LPC_REG)16
#define __17                 (LPC_REG)17
#define __18                 (LPC_REG)18
#define __19                 (LPC_REG)19
#define __20                 (LPC_REG)20
#define __21                 (LPC_REG)21
#define __22                 (LPC_REG)22
#define __23                 (LPC_REG)23
#define __24                 (LPC_REG)24
#define __25                 (LPC_REG)25
#define __26                 (LPC_REG)26
#define __27                 (LPC_REG)27
#define __28                 (LPC_REG)28
#define __29                 (LPC_REG)29
#define __30                 (LPC_REG)30
#define __31                 (LPC_REG)31
#define VICIntSel_Watchdog   0//看门狗中断(WDINT)
#define VICIntSel_SoftInt1   1//保留给软件中断
#define VICIntSel_DbgCommRx  2//ARM内核中断
#define VICIntSel_DbgCommTx  3//ARM内核中断
#define VICIntSel_Time0      4//定时器0中断
#define VICIntSel_Time1      5//定时器1中断
#define VICIntSel_UART0      6//UART0中断
#define VICIntSel_UART1      7//UART1中断
#define VICIntSel_PWM0       8//PWM0中断
#define VICIntSel_I2C0       9//I2C0中断
#define VICIntSel_SPI0      10//SPI0中断
#define VICIntSel_SSP       11//SSP中断
#define VICIntSel_SPI1      11//SPI1中断
#define VICIntSel_PLL       12//PLL中断
#define VICIntSel_RTC       13//RTC中断
#define VICIntSel_EINT0     14//系统控制外部中断0
#define VICIntSel_EINT1     15//系统控制外部中断1
#define VICIntSel_EINT2     16//系统控制外部中断2
#define VICIntSel_EINT3     17//系统控制外部中断3
#define VICIntSel_ADC0      18//A/D转换器0中断
#define VICIntSel_I2C1      19//I2C1中断
#define VICIntSel_BOD       20//掉电检测中断
#define VICIntSel_ADC1      21//A/D转换器1中断
#define VICIntSel_SoftInt22 22//保留给软件中断
#define VICIntSel_SoftInt23 23//保留给软件中断
#define VICIntSel_SoftInt24 24//保留给软件中断
#define VICIntSel_SoftInt25 25//保留给软件中断
#define VICIntSel_SoftInt26 26//保留给软件中断
#define VICIntSel_SoftInt27 27//保留给软件中断
#define VICIntSel_SoftInt28 28//保留给软件中断
#define VICIntSel_SoftInt29 29//保留给软件中断
#define VICIntSel_SoftInt30 30//保留给软件中断
#define VICIntSel_SoftInt31 31//保留给软件中断
#define VICIntSel_Enable    32//使能向量中断
/*--------------------------------------------------
        外部中断标志寄存器EXTINT位定义
---------------------------------------------------*/
#define EINT0  0//EXTINT.0//写'1'清除EINT0中断标志
#define EINT1  1//EXTINT.1//写'1'清除EINT1中断标志
#define EINT2  2//EXTINT.2//写'1'清除EINT2中断标志
#define EINT3  3//EXTINT.3//写'1'清除EINT3中断标志

/*---------------------------------------------------------------------------------------
  GPIO管脚功能配置
应用示例:
  PINSEL->PIN_SEL0  |= (P0_0_TXD0 << P0_0_PINSEL) | (P0_1_RXD0 << P0_1_PINSEL);
                   //选择P0.0和P0.1为UART0的输出输入引脚
  PINSEL->PIN_SEL0  |= (P0_3_EINT1 << P0_3_PINSEL); //选择P0.3为INT1外部中断引脚
  PINSEL->PIN_SEL0  |= (P0_14_EINT1 << P0_14_PINSEL); //选择P0.14也可为INT1外部中断引脚
  PINSEL->PIN_SEL0  |= (P0_1_EINT0 << P0_1_PINSEL)   //选择P0.1为INT0外部中断引脚
  PINSEL->PIN_SEL1  |= (P0_16_EINT0 << P0_16_PINSEL); //选择P0.16也可为INT0外部中断引脚
------------------------------------------------------------------------------------------*/
#define P0_0_GPIO      __0//通用数字输入输出管脚
  #define P0_0_TXD0    __1//UART0的发送器输出
  #define P0_0_PWM1    __2//脉宽调制器输出1

⌨️ 快捷键说明

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