52 lines
1.8 KiB
C
52 lines
1.8 KiB
C
/*---------------------------------------------------------------------*/
|
|
/* --- STC MCU Limited ------------------------------------------------*/
|
|
/* --- STC 1T Series MCU Demo Programme -------------------------------*/
|
|
/* --- Mobile: (86)13922805190 ----------------------------------------*/
|
|
/* --- Fax: 86-0513-55012956,55012947,55012969 ------------------------*/
|
|
/* --- Tel: 86-0513-55012928,55012929,55012966 ------------------------*/
|
|
/* --- Web: www.STCMCU.com --------------------------------------------*/
|
|
/* --- Web: www.STCMCUDATA.com ---------------------------------------*/
|
|
/* --- QQ: 800003751 -------------------------------------------------*/
|
|
/* 如果要在程序中使用此代码,请在程序中注明使用了STC的资料及程序 */
|
|
/*---------------------------------------------------------------------*/
|
|
|
|
#ifndef __GPIO_H
|
|
#define __GPIO_H
|
|
|
|
#include "config.h"
|
|
|
|
#define GPIO_PullUp 0 //上拉准双向口
|
|
#define GPIO_HighZ 1 //浮空输入
|
|
#define GPIO_OUT_OD 2 //开漏输出
|
|
#define GPIO_OUT_PP 3 //推挽输出
|
|
|
|
#define GPIO_Pin_0 0x01 //IO引脚 Px.0
|
|
#define GPIO_Pin_1 0x02 //IO引脚 Px.1
|
|
#define GPIO_Pin_2 0x04 //IO引脚 Px.2
|
|
#define GPIO_Pin_3 0x08 //IO引脚 Px.3
|
|
#define GPIO_Pin_4 0x10 //IO引脚 Px.4
|
|
#define GPIO_Pin_5 0x20 //IO引脚 Px.5
|
|
#define GPIO_Pin_6 0x40 //IO引脚 Px.6
|
|
#define GPIO_Pin_7 0x80 //IO引脚 Px.7
|
|
#define GPIO_Pin_All 0xFF //IO所有引脚
|
|
|
|
#define GPIO_P0 0 //
|
|
#define GPIO_P1 1
|
|
#define GPIO_P2 2
|
|
#define GPIO_P3 3
|
|
#define GPIO_P4 4
|
|
#define GPIO_P5 5
|
|
#define GPIO_P6 6
|
|
#define GPIO_P7 7
|
|
|
|
|
|
typedef struct
|
|
{
|
|
u8 Mode; //IO模式, GPIO_PullUp,GPIO_HighZ,GPIO_OUT_OD,GPIO_OUT_PP
|
|
u8 Pin; //要设置的端口
|
|
} GPIO_InitTypeDef;
|
|
|
|
u8 GPIO_Inilize(u8 GPIO, GPIO_InitTypeDef *GPIOx);
|
|
|
|
#endif
|