ST官方库函数之GPIO口读写函数
来源:互联网 发布:js思维导图插件 编辑:程序博客网 时间:2024/06/14 18:08
GPIO口读写函数有如下8个;
uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);
uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx);
void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);
void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);
这几个函数结构比较简单,一个个来看
uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{
uint8_t bitstatus = 0x00;
if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)Bit_RESET)
{
bitstatus = (uint8_t)Bit_SET;
}
else
{
bitstatus = (uint8_t)Bit_RESET;
}
return bitstatus;
}
此函数为读取GPIO端口输入寄存器IDR某一位的状态,返回一个8位的值;
uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx)
{
return ((uint16_t)GPIOx->IDR);
}
此函数为读取一组GPIO端口输入寄存器IDR的值,返回一个16位的值;
uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{
uint8_t bitstatus = 0x00;
if ((GPIOx->ODR & GPIO_Pin) != (uint32_t)Bit_RESET)
{
bitstatus = (uint8_t)Bit_SET;
}
else
{
bitstatus = (uint8_t)Bit_RESET;
}
return bitstatus;
}
此函数为读取GPIO端口输出寄存器ODR某一位的状态,返回一个8位的值;
uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx)
{
return ((uint16_t)GPIOx->ODR);
}
此函数为读取一组GPIO端口输出寄存器ODR的值,返回一个16位的值;
void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{
GPIOx->BSRR = GPIO_Pin;
}
此函数为对GPIO端口某一位进行置位操作,通过BSRR寄存器实现;
void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{
GPIOx->BRR = GPIO_Pin;
}
此函数为对GPIO端口某一位进行复位操作,通过BRR寄存器实现;
void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
{
if (BitVal != Bit_RESET)
{
GPIOx->BSRR = GPIO_Pin;
}
else
{
GPIOx->BRR = GPIO_Pin;
}
}
此函数为对GPIO端口某一位进行写操作,输入参数有3个值,其中参数BitVal可为整型值0或者1,
其中关于BitAction,见如下定义typedef enum
{ Bit_RESET = 0,
Bit_SET
}BitAction;
void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal)
{
GPIOx->ODR = PortVal;
}
此函数为对某一组GPIO口进行写操作,输入参数PortVal为一个16位的值,同过直接操作ODR寄存器来实现
- ST官方库函数之GPIO口读写函数
- ST官方库函数之GPIO复位函数void GPIO_DeInit(GPIO_TypeDef* GPIOx) 的理解
- ST之GPIO使用之理解
- 如何从ST官网下载官方库函数(更新版)
- GPIO库函数
- GPIO库函数
- STM8库函数学习笔记之GPIO
- STM32库函数之GPIO初始化代码分析
- GPIO读写
- 库函数读写!
- 内核GPIO操作库函数
- STM32 GPIO之 GPIO_Init() 函数
- STM32之GPIO函数一览
- 【库函数】linux之access函数
- STM32之GPIO口
- STC15官方库函数
- InstallShield内部库函数之2 用户界面函数
- InstallShield内部库函数之3 信息函数
- Java中的对象和对象引用
- Python对象和JSON对象的相互转化
- Android的IPC通信之-SOCKET方式
- 阿里云ESC服务器的端口启用
- ofbiz数据类型映射
- ST官方库函数之GPIO口读写函数
- asyne,await,task.wait,task.result用法
- 关于比尔盖茨的几点思考
- C面试题(2017.10.15)
- Tensorflow实现卷积神经网络,用于人脸关键点识别
- nodejs+redis以最少的代码实现消息队列
- 在Unity中通过The touch screen implements the rotation and scaling of the model
- android 7.0 调用系统相机崩溃问题
- AIX系统lv扩容