projet_voilier/MyDrivers/GPIO.c
Arnaud Vergnet 4e69b9b112 improve doc
2020-11-15 16:53:55 +01:00

37 lines
983 B
C

#include "GPIO.h"
#include "stm32f1xx_ll_gpio.h"
void GPIO_conf(GPIO_TypeDef * gpio, uint32_t pin, uint32_t mode, uint32_t outputType, uint32_t pullMode)
{
LL_GPIO_InitTypeDef init;
//Activation de l'horloge
if (gpio == GPIOA) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
else if (gpio == GPIOB) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
else if (gpio == GPIOC) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);
else if (gpio == GPIOD) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOD);
//Configuration du PIN
LL_GPIO_StructInit(&init);
init.Pin = pin;
init.Mode = mode;
//init.Speed = ;
init.OutputType = outputType;
init.Pull = pullMode;
LL_GPIO_Init(gpio, &init);
}
void GPIO_setPin(GPIO_TypeDef * gpio, uint32_t pin, int output)
{
if (output) {
LL_GPIO_SetOutputPin(gpio, pin);
} else {
LL_GPIO_ResetOutputPin(gpio,pin);
}
};
int GPIO_readPin(GPIO_TypeDef * gpio, uint32_t pin)
{
return LL_GPIO_IsOutputPinSet(gpio, pin);
}