- 在工程中增加gpio lib.h和stm32头文件,如下:
#include “stm32f10x.h” // Device header
#include “stm32f10x_gpio.h” 调用lib配置gpio工作方式,先开启时钟,选GPIO,设置GPIO mode,gpio speed,主要看GPIO_InitTypeDef 结构体,芯片不同结构体不同,开始不清楚具体使用可以参考系统自带的example code,my setting如下:
void GPIO_Initmain(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure all unused GPIO port pins in Analog Input mode (floating input
trigger OFF), this will reduce the power consumption and increase the device
immunity against EMI/EMC ***************************************/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_3|GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(
stm32 起步 gpio操作
最新推荐文章于 2024-05-03 21:50:45 发布