27 lines
564 B
C
27 lines
564 B
C
/*
|
|
* gpio.c
|
|
*
|
|
* Created on: Oct 24, 2021
|
|
* Author: wuwenfeng
|
|
*/
|
|
#include "gpio.h"
|
|
|
|
void change_io_function(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin,char a)
|
|
{
|
|
GPIO_InitTypeDef GPIO_InitStruct;
|
|
GPIO_InitStruct.Pin = GPIO_Pin;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
if(a==1)
|
|
{
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
}
|
|
if(a==0)
|
|
{
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
}
|
|
HAL_GPIO_Init(GPIOx, &GPIO_InitStruct);
|
|
}
|