DSP库函数—gpio.h

本文介绍了GPIO接口的基本操作,包括设置方向、读写引脚状态、配置中断触发方式及清除中断等。通过这些函数,可以实现对GPIO引脚的精确控制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GPIODirModeSet

函数名GPIODirModeSet
原函数void GPIODirModeSet(unsigned int baseAdd,
unsigned int pinNumber, unsigned int pinDir)
功能configures the direction of a pin as input or output.
参数baseAdd:The memory address of the GPIO instance being used.
pinNumber:The serial number of the GPIO pin.
pinDir:The direction to be set for the pin.This can take the values:
GPIO_DIR_INPUT, for configuring the pin as input.
GPIO_DIR_OUTPUT, for configuring the pin as output.
返回值None
备注Here we write to the DIRn register. Writing a logic 1 configures
the pin as input and writing logic 0 as output.
By default, all the pins are set as input pins.



GPIODirModeGet

函数名GPIODirModeGet
原函数unsigned int GPIODirModeGet(unsigned int baseAdd,
unsigned int pinNumber)
功能gets the direction of a pin which has been configured as
an input or an output pin.
参数baseAdd:The memory address of the GPIO instance being used.
pinNumber:The serial number of the GPIO pin.
返回值pinDir:The direction to be set for the pin.This can take the values:
GPIO_DIR_INPUT, for configuring the pin as input.
GPIO_DIR_OUTPUT, for configuring the pin as output.
备注



GPIOPinWrite

函数名GPIOPinWrite
原函数GPIOPinWrite(unsigned int baseAdd,
unsigned int pinNumber, unsigned int bitValue)
功能writes a logic 1 or a logic 0 to the specified pin.
参数baseAdd:The memory address of the GPIO instance being used.
pinNumber:The serial number of the GPIO pin.
bitValue This signifies whether to write a logic 0 or logic 1 to the
specified pin.This variable can take any of the following two value:
GPIO_PIN_LOW, which indicates to clear(logic 0) the bit.
GPIO_PIN_HIGH, which indicates to set(logic 1) the bit.
返回值none
备注



GPIOPinRead

函数名GPIOPinRead
原函数int GPIOPinRead(unsigned int baseAdd, unsigned int pinNumber)
功能reads the value(logic level) of an input or an output pin.
参数baseAdd:The memory address of the GPIO instance being used.
pinNumber:The serial number of the GPIO pin.
返回值This signifies whether to write a logic 0 or logic 1 to the
specified pin.This variable can take any of the following two value:
GPIO_PIN_LOW, which indicates to clear(logic 0) the bit.
GPIO_PIN_HIGH, which indicates to set(logic 1) the bit.
备注Configuring the trigger level type for generating interrupts
is not enough for the GPIO module to generate interrupts.
The user should also enable the interrupt generation
capability for the bank to which the pin belongs to.
Use the function GPIOBankIntEnable() to do the same.



GPIOIntTypeSet

函数名GPIOIntTypeSet
原函数void GPIOIntTypeSet(unsigned int baseAdd,
unsigned int pinNumber, unsigned int intType)
功能configures the trigger level type for which an interrupt is
required to occur.
参数baseAdd:The memory address of the GPIO instance being used.
pinNumber:The serial number of the GPIO pin.
intType:This specifies the trigger level type. This can take
one of the following four values:
GPIO_INT_TYPE_NOEDGE, to not generate any interrupts.
GPIO_INT_TYPE_FALLEDGE, to generate an interrupt on
the falling edge of a signal on that pin.
GPIO_INT_TYPE_RISEDGE, to generate an interrupt on
the rising edge of a signal on that pin.
GPIO_INT_TYPE_BOTHEDGE, to generate interrupts on
both rising and falling edges of a signal on that pin.
返回值none
备注Configuring the trigger level type for generating interrupts
is not enough for the GPIO module to generate interrupts.
The user should also enable the interrupt generation
capability for the bank to which the pin belongs to.
Use the function GPIOBankIntEnable() to do the same.



GPIOIntTypeGet

函数名GPIOIntTypeGet
原函数unsigned int GPIOIntTypeGet(unsigned int baseAdd,
unsigned int pinNumber)
功能reads the trigger level type being set for interrupts to be generated.
参数baseAdd:The memory address of the GPIO instance being used.
pinNumber:The serial number of the GPIO pin.
返回值This returns a value which indicates the type of trigger
level type being set. One of the following values is returned:
GPIO_INT_TYPE_NOEDGE, to not generate any interrupts.
GPIO_INT_TYPE_FALLEDGE, to generate an interrupt on
the falling edge of a signal on that pin.
GPIO_INT_TYPE_RISEDGE, to generate an interrupt on
the rising edge of a signal on that pin.
GPIO_INT_TYPE_BOTHEDGE, to generate interrupts on
both rising and falling edges of a signal on that pin.
备注



GPIOPinIntStatus

函数名GPIOPinIntStatus
原函数unsigned int GPIOPinIntStatus(unsigned int baseAdd,
unsigned int pinNumber)
功能determines the status of interrupt on a specified pin.
参数baseAdd:The memory address of the GPIO instance being used.
pinNumber:The serial number of the GPIO pin.
返回值This returns a value which expresses the status of an interrupt
raised over the specified pin.
GPIO_INT_NOPEND, if no interrupts are left to be serviced.
GPIO_INT_PEND, if the interrupt raised over that pin is yet
to be cleared and serviced.
备注



GPIOPinIntClear

函数名GPIOPinIntClear
原函数void GPIOPinIntClear(unsigned int baseAdd,
unsigned int pinNumber)
功能clears the interrupt status of the pin being accessed.
参数baseAdd:The memory address of the GPIO instance being used.
pinNumber:The serial number of the GPIO pin.
返回值none
备注



GPIOBankIntEnable

函数名GPIOBankIntEnable
原函数void GPIOBankIntEnable(unsigned int baseAdd,
unsigned int bankNumber)
功能enables the interrupt generation capability for the bank of GPIO
pins specified.
参数baseAdd:The memory address of the GPIO instance being used.
bankNumber:This is the bank for whose pins interrupt generation
capability needs to be enabled.
返回值none
备注



GPIOBankIntDisable

函数名GPIOBankIntDisable
原函数void GPIOBankIntDisable(unsigned int baseAdd,
unsigned int bankNumber)
功能disables the interrupt generation capability for the bank of GPIO
pins specified.
参数baseAdd:The memory address of the GPIO instance being used.
bankNumber:This is the bank for whose pins interrupt generation
capability needs to be disabled.
返回值none
备注



GPIOBankPinsWrite

函数名GPIOBankPinsWrite
原函数void GPIOBankPinsWrite(unsigned int baseAdd,
unsigned int bankNumber, unsigned int setPins,
unsigned int clrPins)
功能is used to collectively set and collectively clear the specified bits.
参数baseAdd:The memory address of the GPIO instance being used.
bankNumber:This is the bank for whose pins interrupt generation
capability needs to be modified.
setPins:The bit-mask of the pins whose values have to be set.
This could be the bitwise OR of the following macros:
GPIO_BANK_PIN_n where n >= 0 and n <= 15.
clrPins:The bit-mask of the pins whose values have to be cleared.
This could be the bitwise OR of the following macros:
GPIO_BANK_PIN_n where n >= 0 and n <= 15.
返回值none
备注
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值