📄 gpio.h
字号:
/****************************************Copyright (c)**************************************************
** 广州周立功单片机发展有限公司
** 研 究 所
** 产品一部
**
** http://www.zlgmcu.com
**
**--------------文件信息--------------------------------------------------------------------------------
**文 件 名: GPIO.c
**创 建 人: zhangbin
**最后修改日期: 2007-3-20
**描 述: LPC2400通用GPIO操作软件包。
**
**--------------历史版本信息----------------------------------------------------------------------------
** 创建人: zhangbin
** 版 本: v1.00
** 日 期: 2007-3-20
** 描 述: GPIO操作软件包。
**
**------------------------------------------------------------------------------------------------------
** 修改人:
** 版 本:
** 日 期:
** 描 述:
**
**--------------当前版本修订------------------------------------------------------------------------------
** 修改人:
** 日 期:
** 描 述:
**
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#ifndef __GPIO_H
#define __GPIO_H
#include "config.h"
#define Fast_GPIO
#ifdef Fast_GPIO // 快速IO
#define P0_GPIOClr(PIN) FIO0CLR = PIN
#define P0_GPIOSet(PIN) FIO0SET = PIN
#define P1_GPIOClr(PIN) FIO1CLR = PIN
#define P1_GPIOSet(PIN) FIO1SET = PIN
#define Write_P0(Value) FIO0PIN = Value
#define Write_P1(Value) FIO1PIN = Value
#define Read_P0() FIO0PIN
#define Read_P1() FIO1PIN
#else // 慢速IO
#define P0_GPIOClr(PIN) IO0CLR = PIN
#define P0_GPIOSet(PIN) IO0SET = PIN
#define P1_GPIOClr(PIN) IO1CLR = PIN
#define P1_GPIOSet(PIN) IO1SET = PIN
#define Write_P0(Value) IO0PIN = Value
#define Write_P1(Value) IO1PIN = Value
#define Read_P0() IO0PIN
#define Read_P1() IO1PIN
#endif
#define P2_GPIOClr(PIN) FIO2CLR = PIN
#define P2_GPIOSet(PIN) FIO2SET = PIN
#define Write_P2(Value) FIO2PIN = Value
#define P3_GPIOClr(PIN) FIO3CLR = PIN
#define P3_GPIOSet(PIN) FIO3SET = PIN
#define Write_P3(Value) FIO3PIN = Value
#define P4_GPIOClr(PIN) FIO4CLR = PIN
#define P4_GPIOSet(PIN) FIO4SET = PIN
#define Write_P4(Value) FIO4PIN = Value
#define Read_P2() FIO2PIN
#define Read_P3() FIO3PIN
#define Read_P4() FIO4PIN
/*******************************************************************************************************
** 函数名称:GPIO0_Init
** 函数功能:初始化P0口为GPIO功能。
** 入口参数:PIN_No 引脚号,按位模式操作
type 引脚、输入输出类型
0 输入
非0 输出。
** 出口参数:0 成功
** 1 失败
** 调用示例:GPIO0_Init(1<<4, 1); // P0.4初始化为GPIO输出类型
********************************************************************************************************/
extern void GPIO0_Init(uint32 PIN, uint8 type);
/*******************************************************************************************************
** 函数名称:GPIO1_Init
** 函数功能:初始化P1口为GPIO功能。
** 入口参数:PIN_No 引脚号,按位模式操作
type 引脚、输入输出类型
0 输入
非0 输出。
** 出口参数:0 成功
** 1 失败
** 调用示例:GPIO1_Init(1<<4, 1); // P1.4初始化为GPIO输出类型
********************************************************************************************************/
extern void GPIO1_Init(uint32 PIN, uint8 type);
/*******************************************************************************************************
** 函数名称:GPIO2_Init
** 函数功能:初始化P2口为GPIO功能。
** 入口参数:PIN_No 引脚号,按位模式操作
type 引脚、输入输出类型
0 输入
非0 输出
** 出口参数:0 成功
** 1 失败
** 调用示例:GPIO2_Init(1<<4, 1); // P2.4初始化为GPIO输出类型
** 说 明:P2口只能使用快速IO操作。
********************************************************************************************************/
extern void GPIO2_Init(uint32 PIN, uint8 type);
/*******************************************************************************************************
** 函数名称:GPIO3_Init
** 函数功能:初始化P3口为GPIO功能。
** 入口参数:PIN_No 引脚号,按位模式操作
type 引脚、输入输出类型
0 输入
非0 输出
** 出口参数:0 成功
** 1 失败
** 调用示例:GPIO3_Init(1<<4, 1); // P3.4初始化为GPIO输出类型
** 说 明:P3口只能使用快速IO操作。
********************************************************************************************************/
extern void GPIO3_Init(uint32 PIN,uint8 type);
/*******************************************************************************************************
** 函数名称:GPIO4_Init
** 函数功能:初始化P4口为GPIO功能。
** 入口参数:PIN_No 引脚号,按位模式操作
type 引脚、输入输出类型
0 输入
非0 输出
** 出口参数:0 成功
** 1 失败
** 调用示例:GPIO4_Init(1<<4, 1); // P4.4初始化为GPIO输出类型
** 说 明:P4口只能使用快速IO操作。
********************************************************************************************************/
extern void GPIO4_Init(uint32 PIN ,uint8 type);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -