📄 lpc213xdef.h
字号:
#define EXTWAKE1 1//EXTWAKE.1//该位为1时,使能EINT1将处理器从掉电模式唤醒。
#define EXTWAKE2 2//EXTWAKE.2//该位为1时,使能EINT2将处理器从掉电模式唤醒。
#define EXTWAKE3 3//EXTWAKE.3//该位为1时,使能EINT3将处理器从掉电模式唤醒。
#define BODWAKE 14//EXTWAKE.14//该位为1时,BOD中断产生时可将处理器从掉电模式唤醒。
#define RTCWAKE 15//EXTWAKE.15//该位为1时,RTC中断产生时可将处理器从掉电模式唤醒。
/*---------------------------------------------------------------------------------------
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
#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
/*------------------------------------------------------------------------
结构指针在ARM之应用(愚人节版)
------------------------------------------------------------------------*/
typedef struct _LPCS_VIC {
LPC_REG IRQStatus;//IRQ 状态寄存器
LPC_REG FIQStatus;//FIQ 状态请求
LPC_REG RawIntr;//所有中断的状态寄存器
LPC_REG IntSelect;//中断选择寄存器
LPC_REG IntEnable;//中断使能寄存器
LPC_REG IntEnClr;//中断使能清零寄存器
LPC_REG SoftInt;//软件中断寄存器
LPC_REG SoftIntClr;//软件中断清零寄存器
LPC_REG Protection;//保护使能寄存器
LPC_REG Reserved1[3]; //保留3个空位
LPC_REG VectAddr;//向量地址寄存器
LPC_REG DefVectAddr;//默认向量地址寄存器
LPC_REG Reserved2[2]; //保留2个空位
LPC_REG Reserved3[48];//保留48个空位
LPC_REG VectAddrs[16];//向量地址寄存器,VICVectAddr0~VICVectAddr15
LPC_REG Reserved4[48];//保留48个空位
LPC_REG VectCntls[16];//向量控制寄存器,VICVectCntl0~VICVectCntl15
}LPCS_VIC, *LPCPS_VIC;
#define LPC_BASE_VIC ((LPCPS_VIC) 0xFFFFF000)//定义硬件结构指针(硬件地址)
const LPCPS_VIC VIC = LPC_BASE_VIC;//定义全局结构指针变量
typedef struct _LPCS_PINSEL {
LPC_REG PIN_SEL0;//管脚功能选择寄存器0
LPC_REG PIN_SEL1;//管脚功能选择寄存器1
LPC_REG Reserved[4]; //保留4个空位
LPC_REG PIN_SEL2;//管脚功能选择寄存器2
}LPCS_PINSEL, *LPCPS_PINSEL;
#define LPC_BASE_PINSEL ((LPCPS_PINSEL) 0xE002C000)//定义硬件结构指针(硬件地址)
const LPCPS_PINSEL PINSEL = LPC_BASE_PINSEL;//定义全局结构指针变量PINSEL
typedef struct _LPCS_MAM {
LPC_REG MAM_CR;//存储器加速器模块控制寄存器
LPC_REG MAM_TIM;//存储器加速器定时控制
}LPCS_MAM, *LPCPS_MAM;
#define LPC_BASE_MAM ((LPCPS_MAM) 0xE01FC000)//定义硬件结构指针(硬件地址)
const LPCPS_MAM MAM = LPC_BASE_MAM;//定义全局结构指针变量MAM
typedef struct _LPCS_PLL {//锁相环
LPC_REG PLL_CON;//PLL 控制寄存器
LPC_REG PLL_CFG;//PLL 配置寄存器
LPC_REG PLL_STAT;//PLL 状态寄存器
LPC_REG PLL_FEED;//PLL 愦送寄存器
}LPCS_PLL, *LPCPS_PLL;
#define LPC_BASE_PLL ((LPCPS_PLL) 0xE01FC080)//定义硬件结构指针(硬件地址)
const LPCPS_PLL PLL = LPC_BASE_PLL;//定义全局结构指针变量PLL
typedef struct _LPCS_GPIO {//通用I/O口
LPC_REG IOPIN;//GPIO管脚值寄存器
LPC_REG IOSET;//GPIO输出置位寄存器
LPC_REG IODIR;//GPIO方向寄存器
LPC_REG IOCLR;//GPIO输出清零寄存器
}LPCS_GPIO, *LPCPS_GPIO;
#define LPC_BASE_GPIO0 ((LPCPS_GPIO) 0xE0028000)//定义硬件结构指针(硬件地址)
#define LPC_BASE_GPIO1 ((LPCPS_GPIO) 0xE0028010)//定义硬件结构指针(硬件地址)
const LPCPS_GPIO P0 = LPC_BASE_GPIO0;//定义全局结构指针变量P0
const LPCPS_GPIO P1 = LPC_BASE_GPIO1;//定义全局结构指针变量P1
/*--------------------------------------------------------------------
应用示例
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -