配置 IO 的模式
我们使用的收发 IO 口是 PA11 和 PA12。在这里我们要把 PA11 设置为上
拉 输 入 : GPIO_Mode_IPD , PA12 设 置 为 复 用 推 挽 输 出 :
GPIO_Mode_AF_PP。代码为:
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; //PA12
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //上拉输入
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; //PA11
GPIO_Init(GPIOA, &GPIO_InitStructure);
|