|
楼主 |
发表于 2015-9-6 10:59:40
|
显示全部楼层
GPIO.h
/*************************************************************
Copyright (C), 2009-2015, C&IIL
File name: GPIO.h
Description:
NULL
Compiler:
IDE: Keil C51 9.51, 9.52
OS: win8,win8.1
Function List:
NULL
History:
Author: Liang Zhen Version: 0.1 Date: 2015/07/22 Email: liangzhen##foxmail.com
Description: Created
*************************************************************/
#ifndef __GPIO_H__
#define __GPIO_H__
#include "config.h"
#include "exmath.h"
//设置Port端口为上拉准双向口。例如:PORT_PullUp(1) 设置P1口为上拉准双向口。
#define _PORT_PullUp(Port) {P##Port##M1 = 0; P##Port##M0 = 0; }
#define PORT_PullUp(Port) _PORT_PullUp(Port)
//设置Port端口为强推挽输出。例如:PORT_PP(1) 设置P1口为强推挽输出
#define _PORT_PP(Port) {P##Port##M1 = 0; P##Port##M0 = 1; }
#define PORT_PP(Port) _PORT_PP(Port)
//设置Port端口为高阻态。例如:PORT_PP(1) 设置P1口为高阻态
#define _PORT_HighZ(Port) {P##Port##M1 = 1; P##Port##M0 = 0; }
#define PORT_HighZ(Port) _PORT_HighZ(Port)
//设置Port端口为开漏输出。例如:PORT_PP(1) 设置P1口为开漏输出
#define _PORT_OD(Port) {P##Port##M1 = 1; P##Port##M0 = 1; }
#define PORT_OD(Port) _PORT_OD(Port)
//设置Port端口的Pin引脚为上拉准双向口。例如:PIN_PullUp(1,2) 设置P12引脚为上拉准双向口。
#define _PIN_PullUp(Port,Pin) {clrBit(P##Port##M1,Pin);clrBit(P##Port##M0,Pin);}
#define PIN_PullUp(Port,Pin) _PIN_PullUp(Port,Pin)
//设置Port端口的Pin引脚为强推挽输出。例如:PIN_PP(1,2) 设置P12引脚为强推挽输出。
#define _PIN_PP(Port,Pin) {clrBit(P##Port##M1,Pin);setBit(P##Port##M0,Pin);}
#define PIN_PP(Port,Pin) _PIN_PP(Port,Pin)
//设置Port端口的Pin引脚为高阻态。例如:PIN_HighZ(1,2) 设置P12引脚为高阻态。
#define _PIN_HighZ(Port,Pin) {setBit(P##Port##M1,Pin);clrBit(P##Port##M0,Pin);}
#define PIN_HighZ(Port,Pin) _PIN_HighZ(Port,Pin)
//设置Port端口的Pin引脚为开漏输出。例如:PIN_OD(1,2) 设置P12引脚为开漏输出。
#define _PIN_OD(Port,Pin) {setBit(P##Port##M1,Pin);setBit(P##Port##M0,Pin);}
#define PIN_OD(Port,Pin) _PIN_OD(Port,Pin)
#endif |
|