8051-ELL库  beta 1.1.6
8051-ELL library API Document Center
STC8x_GPIO.h 文件参考
#include "ELL_CORE.h"
#include "STC8Ax_REG.h"
STC8x_GPIO.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

宏定义

#define PER_LIB_MCU_MUODEL   STC8Ax
 如果没有定义这个宏,默认为STC8Ax。 If the mirco is undefined,select to STC8Ax 更多...
 
#define PER_LIB_GPIO_CTRL   1
 如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1" 更多...
 
#define PER_LIB_GPIO_INIT_CTRL   1
 如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1" 更多...
 
#define PER_LIB_GPIO_NVIC_CTRL   1
 如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1" 更多...
 
#define PER_LIB_GPIO_WORK_CTRL   1
 如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1" 更多...
 
#define GPIO_P0   0
 GPIO组号,是GPIO宏操作函数的第一个参数, 支持对这个宏进行再封装。 更多...
 
#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
 
#define Pin_0   0x01
 GPIO端口号,是GPIO宏操作函数的第二个参数, 支持多个宏进行或运算,以达到同时配置多个IO的效果。 更多...
 
#define Pin_1   0x02
 
#define Pin_2   0x04
 
#define Pin_3   0x08
 
#define Pin_4   0x10
 
#define Pin_5   0x20
 
#define Pin_6   0x40
 
#define Pin_7   0x80
 
#define Pin_Low   0x0F
 
#define Pin_High   0xF0
 
#define Pin_All   0xFF
 
#define GPIO_MODE_WEAK_PULL(gpio_x, pin)
 GPIO设置为准双向口(弱上拉)模式宏函数。 更多...
 
#define GPIO_MODE_IN_FLOATING(gpio_x, pin)
 GPIO设置为浮空输入模式宏函数。 更多...
 
#define GPIO_MODE_OUT_OD(gpio_x, pin)
 GPIO设置为开漏输出模式宏函数。 更多...
 
#define GPIO_MODE_OUT_PP(gpio_x, pin)
 GPIO设置为推挽输出模式宏函数。 更多...
 
#define GPIO_PULL_UP_ENABLE(gpio_x, pin)
 GPIO使能上拉电阻宏函数。 更多...
 
#define GPIO_PULL_UP_DISABLE(gpio_x, pin)
 GPIO不使能上拉电阻宏函数。 更多...
 
#define GPIO_ST_ENABLE(gpio_x, pin)
 GPIO使能施密特触发器宏函数。 更多...
 
#define GPIO_ST_DISABLE(gpio_x, pin)
 GPIO不使能施密特触发器宏函数。 更多...
 
#define GPIO_SPEED_LOW(gpio_x, pin)
 GPIO电平低速翻转宏函数。 更多...
 
#define GPIO_SPEED_HIGH(gpio_x, pin)
 GPIO电平高速翻转宏函数。 更多...
 
#define GPIO_DRIVE_MEDIUM(gpio_x, pin)
 GPIO普通驱动电流宏函数。 更多...
 
#define GPIO_DRIVE_HIGH(gpio_x, pin)
 GPIO高驱动电流宏函数。 更多...
 
#define GPIO_FLIP_PIN_LEVEL(gpio_x, pin)
 GPIO翻转端口电平状态宏函数。 更多...
 
#define NVIC_EXTI0_CTRL(run)   do{EX0 = run;}while(0)
 外部中断0控制中断开关宏函数。 更多...
 
#define NVIC_EXTI1_CTRL(run)   do{EX1 = run;}while(0)
 外部中断1控制中断开关宏函数。 更多...
 
#define NVIC_EXTI2_CTRL(run)   do{INTCLKO = (INTCLKO & 0xEF) | (run << 4);}while(0)
 外部中断2控制中断开关宏函数。 更多...
 
#define NVIC_EXTI0_PRI(pri)
 EXTI0选择中断优先级宏函数。 更多...
 
#define NVIC_EXTI1_PRI(pri)
 EXTI1选择中断优先级宏函数。 更多...
 
#define NVIC_EXTI4_PRI(pri)
 EXTI4选择中断优先级宏函数。 更多...
 
#define NVIC_EXTI3_CTRL(run)   do{INTCLKO = (INTCLKO & 0xDF) | (run << 5);}while(0)
 外部中断3控制中断开关宏函数。 更多...
 
#define NVIC_EXTI4_CTRL(run)   do{INTCLKO = (INTCLKO & 0xBF) | (run << 6);}while(0)
 外部中断4控制中断开关宏函数。 更多...
 

枚举

enum  EXTITri_Type { EXTI_Tri_Edge = 0x00 , EXTI_Tri_Falling = 0x01 }
 外部中断触发方式枚举体。 更多...
 

函数

FSCSTATE NVIC_EXTI0_Init (EXTITri_Type triMode, NVICPri_Type pri, BOOL run)
 外部中断0中断初始化函数。 更多...
 
FSCSTATE NVIC_EXTI1_Init (EXTITri_Type triMode, NVICPri_Type pri, BOOL run)
 外部中断1中断初始化函数。 更多...
 
FSCSTATE NVIC_EXTI2_Init (BOOL run)
 外部中断2中断初始化函数,固定下降沿触发。 更多...
 
FSCSTATE NVIC_EXTI3_Init (BOOL run)
 外部中断3中断初始化函数,固定下降沿触发。 更多...
 
FSCSTATE NVIC_EXTI4_Init (NVICPri_Type pri, BOOL run)
 外部中断4中断初始化函数,固定下降沿触发。 更多...
 

宏定义说明

◆ GPIO_DRIVE_HIGH

#define GPIO_DRIVE_HIGH (   gpio_x,
  pin 
)
值:
do{ \
EAXFR_ENABLE(); \
Px_DR(gpio_x) &= ~(pin); \
EAXFR_DISABLE(); \
}while(0)

GPIO高驱动电流宏函数。

GPIO high drive current macro function.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个,用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ GPIO_DRIVE_MEDIUM

#define GPIO_DRIVE_MEDIUM (   gpio_x,
  pin 
)
值:
do{ \
EAXFR_ENABLE(); \
Px_DR(gpio_x) |= (pin); \
EAXFR_DISABLE(); \
}while(0)

GPIO普通驱动电流宏函数。

GPIO general drive current macro function.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个,用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ GPIO_FLIP_PIN_LEVEL

#define GPIO_FLIP_PIN_LEVEL (   gpio_x,
  pin 
)
值:
do{ \
GPIO_Px(gpio_x) ^= pin; \
}while(0)

GPIO翻转端口电平状态宏函数。

GPIO flip port level state macro function.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个,用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ GPIO_MODE_IN_FLOATING

#define GPIO_MODE_IN_FLOATING (   gpio_x,
  pin 
)
值:
do{ \
Px_M1(gpio_x) |= (pin); Px_M0(gpio_x) &= ~(pin); \
}while(0)
#define Px_M0(x)
Definition: STC8Ax_REG.h:509

GPIO设置为浮空输入模式宏函数。

GPIO is set to float input mode macro function.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个,用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ GPIO_MODE_OUT_OD

#define GPIO_MODE_OUT_OD (   gpio_x,
  pin 
)
值:
do{ \
Px_M1(gpio_x) |= (pin); Px_M0(gpio_x) |= (pin); \
}while(0)

GPIO设置为开漏输出模式宏函数。

GPIO is set to open drain output mode macro function.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个,用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ GPIO_MODE_OUT_PP

#define GPIO_MODE_OUT_PP (   gpio_x,
  pin 
)
值:
do{ \
Px_M1(gpio_x) &= ~(pin); Px_M0(gpio_x) |= (pin); \
}while(0)

GPIO设置为推挽输出模式宏函数。

GPIO is set to push-pull output mode macro function.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个,用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ GPIO_MODE_WEAK_PULL

#define GPIO_MODE_WEAK_PULL (   gpio_x,
  pin 
)
值:
do{ \
Px_M1(gpio_x) &= ~(pin); Px_M0(gpio_x) &= ~(pin); \
}while(0)

GPIO设置为准双向口(弱上拉)模式宏函数。

GPIO is set as macro function in quasi bidirectional port (if pull-up) mode.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个, 用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ GPIO_P0

#define GPIO_P0   0

GPIO组号,是GPIO宏操作函数的第一个参数, 支持对这个宏进行再封装。

The GPIO group number is the first parameter of the GPIO macro operation function, Support for repackaging this macro. IO P0.

◆ GPIO_P1

#define GPIO_P1   1

IO P1.

◆ GPIO_P2

#define GPIO_P2   2

IO P2.

◆ GPIO_P3

#define GPIO_P3   3

IO P3.

◆ GPIO_P4

#define GPIO_P4   4

IO P4.

◆ GPIO_P5

#define GPIO_P5   5

IO P5.

◆ GPIO_P6

#define GPIO_P6   6

IO P6.

◆ GPIO_P7

#define GPIO_P7   7

IO P7.

◆ GPIO_PULL_UP_DISABLE

#define GPIO_PULL_UP_DISABLE (   gpio_x,
  pin 
)
值:
do{ \
EAXFR_ENABLE(); \
Px_PU(gpio_x) &= ~(pin); \
EAXFR_DISABLE(); \
}while(0)

GPIO不使能上拉电阻宏函数。

GPIO disable pull-up resistor macro function.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个,用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ GPIO_PULL_UP_ENABLE

#define GPIO_PULL_UP_ENABLE (   gpio_x,
  pin 
)
值:
do{ \
EAXFR_ENABLE(); \
Px_PU(gpio_x) |= (pin); \
EAXFR_DISABLE(); \
}while(0)

GPIO使能上拉电阻宏函数。

GPIO enable pull-up resistor macro function.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个,用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ GPIO_SPEED_HIGH

#define GPIO_SPEED_HIGH (   gpio_x,
  pin 
)
值:
do{ \
EAXFR_ENABLE(); \
Px_SR(gpio_x) &= ~(pin); \
EAXFR_DISABLE(); \
}while(0)

GPIO电平高速翻转宏函数。

GPIO level high speed flip macro function.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个,用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ GPIO_SPEED_LOW

#define GPIO_SPEED_LOW (   gpio_x,
  pin 
)
值:
do{ \
EAXFR_ENABLE(); \
Px_SR(gpio_x) |= (pin); \
EAXFR_DISABLE(); \
}while(0)

GPIO电平低速翻转宏函数。

GPIO level low speed flip macro function.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个,用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ GPIO_ST_DISABLE

#define GPIO_ST_DISABLE (   gpio_x,
  pin 
)
值:
do{ \
EAXFR_ENABLE(); \
Px_NCS(gpio_x) &= ~(pin); \
EAXFR_DISABLE(); \
}while(0)

GPIO不使能施密特触发器宏函数。

GPIO disable schmidt trigger macro function.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个,用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ GPIO_ST_ENABLE

#define GPIO_ST_ENABLE (   gpio_x,
  pin 
)
值:
do{ \
EAXFR_ENABLE(); \
Px_NCS(gpio_x) |= (pin); \
EAXFR_DISABLE(); \
}while(0)

GPIO使能施密特触发器宏函数。

GPIO enable schmidt trigger macro function.

参数
[in]gpio_xGPIO组,可以对这个宏的参数进行封装。 The GPIO group can encapsulate the parameters of this macro.
[in]pin端口号,可以同时传参多个,用或运算符号连接。 Port number, which can transfer multiple parameters at the same time and connect with or operation symbol.

◆ NVIC_EXTI0_CTRL

#define NVIC_EXTI0_CTRL (   run)    do{EX0 = run;}while(0)

外部中断0控制中断开关宏函数。

External interrupt 0 controls interrupt switch macro function.

参数
[in]run使能控制位。enable control.

◆ NVIC_EXTI0_PRI

#define NVIC_EXTI0_PRI (   pri)
值:
do{ \
IPH = (IPH & 0xFE) | ((pri & 0x02) >> 1); \
IP = (IP & 0xFE) | (pri & 0x01); \
}while(0)
sfr IPH
Definition: STC15x_REG.h:212
sfr IP
Definition: STC15x_REG.h:210

EXTI0选择中断优先级宏函数。

EXTI0 select interrupt priority macro function.

参数
[in]pri中断优先级。 Priority of interrupt.

◆ NVIC_EXTI1_CTRL

#define NVIC_EXTI1_CTRL (   run)    do{EX1 = run;}while(0)

外部中断1控制中断开关宏函数。

External interrupt 1 controls interrupt switch macro function.

参数
[in]run使能控制位。enable control.

◆ NVIC_EXTI1_PRI

#define NVIC_EXTI1_PRI (   pri)
值:
do{ \
IPH = (IPH & 0xFB) | ((pri & 0x02) << 1); \
IP = (IP & 0xFB) | ((pri & 0x01) << 2); \
}while(0)

EXTI1选择中断优先级宏函数。

EXTI1 select interrupt priority macro function.

参数
[in]pri中断优先级。 Priority of interrupt.

◆ NVIC_EXTI2_CTRL

#define NVIC_EXTI2_CTRL (   run)    do{INTCLKO = (INTCLKO & 0xEF) | (run << 4);}while(0)

外部中断2控制中断开关宏函数。

External interrupt 2 controls interrupt switch macro function.

参数
[in]run使能控制位。enable control.

◆ NVIC_EXTI3_CTRL

#define NVIC_EXTI3_CTRL (   run)    do{INTCLKO = (INTCLKO & 0xDF) | (run << 5);}while(0)

外部中断3控制中断开关宏函数。

External interrupt 3 controls interrupt switch macro function.

参数
[in]run使能控制位。enable control.

◆ NVIC_EXTI4_CTRL

#define NVIC_EXTI4_CTRL (   run)    do{INTCLKO = (INTCLKO & 0xBF) | (run << 6);}while(0)

外部中断4控制中断开关宏函数。

External interrupt 4 controls interrupt switch macro function.

参数
[in]run使能控制位。enable control.

◆ NVIC_EXTI4_PRI

#define NVIC_EXTI4_PRI (   pri)
值:
do{ \
IP2H = (IPH & 0xEF) | ((pri & 0x02) << 3); \
IP2 = (IP & 0xEF) | ((pri & 0x01) << 4); \
}while(0)

EXTI4选择中断优先级宏函数。

EXTI4 select interrupt priority macro function.

参数
[in]pri中断优先级。 Priority of interrupt.

◆ PER_LIB_GPIO_CTRL

#define PER_LIB_GPIO_CTRL   1

如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1"

◆ PER_LIB_GPIO_INIT_CTRL

#define PER_LIB_GPIO_INIT_CTRL   1

如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1"

◆ PER_LIB_GPIO_NVIC_CTRL

#define PER_LIB_GPIO_NVIC_CTRL   1

如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1"

◆ PER_LIB_GPIO_WORK_CTRL

#define PER_LIB_GPIO_WORK_CTRL   1

如果没有定义这个宏,默认为1。 If the mirco is undefined,select to "1"

◆ PER_LIB_MCU_MUODEL

#define PER_LIB_MCU_MUODEL   STC8Ax

如果没有定义这个宏,默认为STC8Ax。 If the mirco is undefined,select to STC8Ax

◆ Pin_0

#define Pin_0   0x01

GPIO端口号,是GPIO宏操作函数的第二个参数, 支持多个宏进行或运算,以达到同时配置多个IO的效果。

The GPIO port number is the second parameter of the GPIO macro operation function, Support multiple macros to perform OR operations to achieve the effect of configuring multiple IOs at the same time. IO Pin Px.0 .

◆ Pin_1

#define Pin_1   0x02

IO Pin Px.1 .

◆ Pin_2

#define Pin_2   0x04

IO Pin Px.2 .

◆ Pin_3

#define Pin_3   0x08

IO Pin Px.3 .

◆ Pin_4

#define Pin_4   0x10

IO Pin Px.4 .

◆ Pin_5

#define Pin_5   0x20

IO Pin Px.5 .

◆ Pin_6

#define Pin_6   0x40

IO Pin Px.6 .

◆ Pin_7

#define Pin_7   0x80

IO Pin Px.7 .

◆ Pin_All

#define Pin_All   0xFF

IO Pin All .

◆ Pin_High

#define Pin_High   0xF0

IO Pin Px.4~7 .

◆ Pin_Low

#define Pin_Low   0x0F

IO Pin Px.0~3 .

枚举类型说明

◆ EXTITri_Type

外部中断触发方式枚举体。

External interrupt Trigger enumerator.

枚举值
EXTI_Tri_Edge 

边沿触发。Both rising and falling edges triggered.

EXTI_Tri_Falling 

下降沿触发。Falling edge trigger.

函数说明

◆ NVIC_EXTI0_Init()

FSCSTATE NVIC_EXTI0_Init ( EXTITri_Type  triMode,
NVICPri_Type  pri,
BOOL  run 
)

外部中断0中断初始化函数。

EXTI0 NVIC function.

参数
[in]triMode触发模式。Trigger mode.
[in]pri中断优先级。interrupt priority.
[in]run使能控制位。enable control.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ NVIC_EXTI1_Init()

FSCSTATE NVIC_EXTI1_Init ( EXTITri_Type  triMode,
NVICPri_Type  pri,
BOOL  run 
)

外部中断1中断初始化函数。

EXTI1 NVIC function.

参数
[in]triMode触发模式。Trigger mode.
[in]pri中断优先级。interrupt priority.
[in]run使能控制位。enable control.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ NVIC_EXTI2_Init()

FSCSTATE NVIC_EXTI2_Init ( BOOL  run)

外部中断2中断初始化函数,固定下降沿触发。

EXTI2 NVIC function.

参数
[in]run使能控制位。enable control.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ NVIC_EXTI3_Init()

FSCSTATE NVIC_EXTI3_Init ( BOOL  run)

外部中断3中断初始化函数,固定下降沿触发。

EXTI3 NVIC function.

参数
[in]run使能控制位。enable control.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.

◆ NVIC_EXTI4_Init()

FSCSTATE NVIC_EXTI4_Init ( NVICPri_Type  pri,
BOOL  run 
)

外部中断4中断初始化函数,固定下降沿触发。

EXTI4 NVIC function.

参数
[in]pri中断优先级。interrupt priority.
[in]run使能控制位。enable control.
返回
FSC_SUCCESS 返回成功。Return to success.
FSC_FAIL 返回失败。Return to fail.