鱼C论坛

 找回密码
 立即注册
查看: 1149|回复: 2

[已解决]stm32

[复制链接]
发表于 2023-10-27 21:40:08 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
问一下stm32 中的GPIO_ReadOutputDataBit() 和 GPIO_ReadInputDataBit() 有什么区别吗,各有什么使用场景
最佳答案
2023-10-27 21:40:49
GPIO_ReadOutputDataBit():
- This function is used to read the output data bit of a specific GPIO pin.
- It takes the GPIO port and the pin number as parameters and returns the current logic level (HIGH or LOW) of the specified pin.
- It is typically used when you want to check the current state of an output pin that you have previously configured.

GPIO_ReadInputDataBit():
- This function is used to read the input data bit of a specific GPIO pin.
- It takes the GPIO port and the pin number as parameters and returns the current logic level (HIGH or LOW) of the specified pin.
- It is typically used when you want to read the state of an input pin connected to an external device or sensor.

Usage scenarios:
- GPIO_ReadOutputDataBit() is useful when you need to verify the current state of an output pin that you have set in your code. For example, if you have configured a pin to control an LED, you can use this function to check whether the LED is currently turned on or off.
- GPIO_ReadInputDataBit() is commonly used when you want to read the state of an input pin connected to a sensor or any external device. For instance, if you have a push-button connected to a GPIO pin, you can use this function to check if the button is pressed or released.

It's important to note that these functions are specific to the STM32 microcontroller family and their usage may vary depending on the specific microcontroller model and the development framework you are using (e.g., STM32Cube HAL, CMSIS, etc.). Make sure to consult the relevant documentation for accurate information on these functions in your specific context.

球一个最佳答案谢谢啦!这对我非常重要!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2023-10-27 21:40:40 | 显示全部楼层
GPIO_ReadOutputDataBit() 和 GPIO_ReadInputDataBit() 是 STM32 中的两个函数,用于读取 GPIO 的输出和输入状态。

GPIO_ReadOutputDataBit() 函数用于读取指定 GPIO 的输出状态。它接受一个参数,即要读取的 GPIO 端口和引脚号。该函数返回指定 GPIO 引脚的输出状态,即该引脚的电平状态。

GPIO_ReadInputDataBit() 函数用于读取指定 GPIO 的输入状态。它接受一个参数,即要读取的 GPIO 端口和引脚号。该函数返回指定 GPIO 引脚的输入状态,即该引脚的电平状态。

两个函数的区别在于它们读取的 GPIO 状态不同。GPIO_ReadOutputDataBit() 读取的是 GPIO 的输出状态,即该引脚输出的电平状态;而 GPIO_ReadInputDataBit() 读取的是 GPIO 的输入状态,即该引脚输入的电平状态。

使用场景上,GPIO_ReadOutputDataBit() 可以用于读取自己设置的输出状态,例如在控制 LED 灯的情况下,可以通过该函数读取 LED 灯的亮灭状态。而 GPIO_ReadInputDataBit() 则可以用于读取外部设备输入的电平状态,例如读取按键的按下状态。

总之,这两个函数是用于读取 GPIO 状态的,但读取的是不同的状态,根据实际需求选择使用。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-10-27 21:40:49 | 显示全部楼层    本楼为最佳答案   
GPIO_ReadOutputDataBit():
- This function is used to read the output data bit of a specific GPIO pin.
- It takes the GPIO port and the pin number as parameters and returns the current logic level (HIGH or LOW) of the specified pin.
- It is typically used when you want to check the current state of an output pin that you have previously configured.

GPIO_ReadInputDataBit():
- This function is used to read the input data bit of a specific GPIO pin.
- It takes the GPIO port and the pin number as parameters and returns the current logic level (HIGH or LOW) of the specified pin.
- It is typically used when you want to read the state of an input pin connected to an external device or sensor.

Usage scenarios:
- GPIO_ReadOutputDataBit() is useful when you need to verify the current state of an output pin that you have set in your code. For example, if you have configured a pin to control an LED, you can use this function to check whether the LED is currently turned on or off.
- GPIO_ReadInputDataBit() is commonly used when you want to read the state of an input pin connected to a sensor or any external device. For instance, if you have a push-button connected to a GPIO pin, you can use this function to check if the button is pressed or released.

It's important to note that these functions are specific to the STM32 microcontroller family and their usage may vary depending on the specific microcontroller model and the development framework you are using (e.g., STM32Cube HAL, CMSIS, etc.). Make sure to consult the relevant documentation for accurate information on these functions in your specific context.

球一个最佳答案谢谢啦!这对我非常重要!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-5 17:19

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表