📄 lpc213xdef.h
字号:
#ifndef __LPC213xDEF_H
#define __LPC213xDEF_H
typedef volatile unsigned long LPC_REG;// Hardware register definition
#define __noinit__ __attribute__((zero_init))//变量不初始化为0
typedef unsigned char uint8; //无符号8位整型变量
typedef signed char int8; //有符号8位整型变量
typedef unsigned short uint16;//无符号16位整型变量
typedef signed short int16; //有符号16位整型变量
typedef unsigned int uint32;//无符号32位整型变量
typedef signed int int32; //有符号32位整型变量
typedef float fp32; //单精度浮点数(32位长度
typedef double fp64; //双精度浮点数(64位长度)
/*--------------------------------------------------------------------
应用示例(屏蔽郁闷的警告)
P0->IODIR |= (__1 << P0_31);//设置P0.31为输出
P0->IOSET = (__1 << P0_31);//P0.31输出高电平
P0->IOCLR = (__1 << P0_31);//P0.31输出低电平
P0->IOPIN ^= (__1 << P0_31);//P0.31输出电平翻转
或(屏蔽郁闷的警告)
P0->IODIR |= (__1 << 31);//设置P0.31为输出
P0->IOSET = (__1 << 31);//P0.31输出高电平
P0->IOCLR = (__1 << 31);//P0.31输出低电平
P0->IOPIN ^= (__1 << 31);//P0.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//使能向量中断
/*--------------------------------------------------------------------
应用示例
VIC->VectCntls[0] = VICIntSel_Enable//使能IRQ中断
| VICIntSel_EINT0;//获取EINT0的IRQ级别
VIC->VectAddrs[0] = (long) IRQ_Eint0;//取INT0中断服务地址
VIC->IntEnable = (1 << VICIntSel_EINT0); //使能EINT0中断
VIC->IntEnClr = (1 << VICIntSel_EINT0); //禁止EINT0中断
----------------------------------------------------------------------*/
/*---------------------------------------------------------------------
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
/*---------------------------------------
RTC中断位置寄存器ILR位定义
----------------------------------------*/
#define RTCCIF 0//为1时,计数器增量中断模块产生中断。向该位写入1清除计数器增量中断。
#define RTCALF 1//为1时,报警寄存器产生中断。向该位写入1清除报警中断。
/*---------------------------------------
RTC时钟控制寄存器CCR位定义
----------------------------------------*/
#define CLKEN 0//时钟使能当该位为1 时,时间计数器使能。
#define CTCRST 1//CTC 复位为1 时,时钟节拍计数器复位。
#define CLKSRC 4//如果该位为1,CTC 计数连接在RTCX1 和RTCX2 两端的32kHz振荡器信号。
/*---------------------------------------
RTC计数器增量中断寄存器CIIR位定义
----------------------------------------*/
#define IMSEC 0//为1时,秒值的增加产生一次中断。
#define IMMIN 1//为1时,分值的增加产生一次中断。
#define IMHOUR 2//为1时,小时值的增加产生一次中断。
#define IMDOM 3//为1时,日期(月)值的增加产生一次中断。
#define IMDOW 4//为1时,星期值的增加产生一次中断。
#define IMDOY 5//为1时,日期(年)值的增加产生一次中断。
#define IMMON 6//为1时,月值的增加产生一次中断。
#define IMYEAR 7//为1时,年值的增加产生一次中断。
/*---------------------------------------
RTC报警屏蔽寄存器位AMR位定义
----------------------------------------*/
#define AMRSEC 0//为1 时,秒值不与报警寄存器比较。
#define AMRMIN 1//为1 时,分值不与报警寄存器比较。
#define AMRHOUR 2//为1 时,小时值不与报警寄存器比较。
#define AMRDOM 3//为1 时,日期(月)值不与报警寄存器比较。
#define AMRDOW 4//为1 时,星期值不与报警寄存器比较。
#define AMRDOY 5//为1 时,日期(年)值不与报警寄存器比较。
#define AMRMON 6//为1 时,月值不与报警寄存器比较。
#define AMRYEAR 7//为1 时,年值不与报警寄存器比较。
/*---------------------------------------
TX中断寄存器TXIR位定义
----------------------------------------*/
#define MR0 0//匹配通道0中断标志
#define MR1 1//匹配通道1中断标志
#define MR2 2//匹配通道2中断标志
#define MR3 3//匹配通道3中断标志
#define CR0 4//捕获通道0事件中断标志
#define CR1 5//捕获通道0事件中断标志
#define CR2 6//捕获通道0事件中断标志
#define CR3 7//捕获通道0事件中断标志
/*---------------------------------------
UARTX标识中断寄存器UXIIR
----------------------------------------*/
#define IIR0 0//中断挂起 0:至少有1个中断被挂起(挂起的中断可通过UXIER3:1确定)
#define IIR1 1//中断标识1
#define IIR2 2//中断标识2
#define IIR3 3//中断标识3
/*---------------------------------------
UARTX线状态寄存器UXLSR
----------------------------------------*/
#define RDR 0//接收数据就绪
#define OE 1//溢出错误
#define PE 2//奇偶错误
#define FE 3//帧错误
#define BI 4//间隔中断
#define THRE 5//发送保持寄存器空
#define TEMT 6//发送器空
#define RXFE 7//Rx FIFO错误
/*---------------------------------------
I2C控制置位寄存器I2CONSET位定义
----------------------------------------*/
#define AA 2//应答标志。
#define SI 3//I2C中断标志。
#define STO 4//停止标志。
#define STA 5//起始标志。
#define I2EN 6//I2C接口使能。
/*---------------------------------------
I2C控制清零寄存器I2CONCLR位定义
----------------------------------------*/
#define AAC 2//应答标志。
#define SIC 3//I2C中断标志。
#define STAC 5//起始标志。
#define I2ENC 6//I2C接口使能。
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -