STM32_GPIO
来源:互联网 发布:微博显示网络异常 编辑:程序博客网 时间:2024/06/05 02:30
一.1.加入库文件:时钟(rcc)、中断(nvic)、Flash、系统(lib)、GPIO
2.在stm32f10x_cong.h,开启相关宏定义
3.GPIO_Init(GPIOD, &GPIO_InitStructure),初始化指定GPIO口
4.RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE),开启外设D的时钟
5.如有中断,需配置NVIC,中断优先级,及在stm32f10x_it.c加入相关执行语句。
二.库函数
1.GPIO_Init(GPIO_TypeDef * GPIOx, GPIO_InitTypeDef * GPIO_InitStructure);//Init GPIOx
2.GPIO_SetBit(GPIO_TypeDef * GPIOx, u16 GPIO_Pin);//Set GPIOx_BITn
3.GPIO_ResetBit(GPIO_TypeDef * GPIOx, u16 GPIO_Pin);//Clear
4.GPIO_WriteBit(GPIO_TypeDef * GPIOx, u16 GPIO_Pin, BitAction BitVal);//Write
5.GPIO_Write(GPIO_TypeDef * GPIOx, u16 PortVal);//Write data to GPIOx
6.GPIO_ReadOutputDataBit(GPIO_TypeDef * GPIOx, u16 GPIO_Pin);//Read Pin Value
7.GPIO_ReadOutputData(GPIO_TypeDef * GPIOx,);//Read GPIOx data
8.GPIO_ReadInputDataBit(GPIO_TypeDef * GPIOx, u16 GPIO_Pin);//Read Pin Value
eg:
#include <stm32f10x_lib.h>
int main(void)
{
RCC_Configuration();//Configure System Clock
NVIC_Configuration();//Configure NVIC
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);//Enable GPIOD Clock
GPIO_InitStructure.GPIO_Pin = GPIO_Pin7;//Select Pin
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//Output Mode
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHZ;
GPIO_Init(GPIOD, &GPIO_InitStructure);//Init GPIOD
while(1)
{
GPIO_SetBit(GPIOD, GPIO_Pin7);//Set GPIOD_BIT7
delay();
GPIO_ResetBit(GPIOD, GPIO_Pin7);//Clear GPIOD_BIT7
delay();
}
}
- STM32_GPIO
- STM32_GPIO
- STM32_GPIO
- STM32_GPIO使用
- stm32_GPIO模拟I2c读写EEPROM
- 关于STM32_GPIO的BSRR和BRR寄存器
- STM32_GPIO配置及库函数讲解—独立按键(受启发,前进一点点)
- android 调用另一个apk中的Activity
- 什么是字节对齐,为什么要对齐
- Java 1.7 新功能
- Java获取当前路径
- jbpm深入pvm
- STM32_GPIO
- 开源免费天气预报接口API以及全国所有地区代码!!(国家气象局提供)
- ORACLE_存储过程一
- 配置java反编译工具及添加源码
- Oracle Data Guard 10g R2概念和理论
- wp7 toolkit编译错误 Xap packaging failed
- IO流-04
- PHP的三种安装模式的比较
- repo使用