Projet voilier 4IRA1 Arnaud Vergnet Marino Benassai Bastien Picco Yohan Simard
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GPIO.c 983B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "GPIO.h"
  2. #include "stm32f1xx_ll_gpio.h"
  3. void GPIO_conf(GPIO_TypeDef * gpio, uint32_t pin, uint32_t mode, uint32_t outputType, uint32_t pullMode)
  4. {
  5. LL_GPIO_InitTypeDef init;
  6. //Activation de l'horloge
  7. if (gpio == GPIOA) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
  8. else if (gpio == GPIOB) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
  9. else if (gpio == GPIOC) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);
  10. else if (gpio == GPIOD) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOD);
  11. //Configuration du PIN
  12. LL_GPIO_StructInit(&init);
  13. init.Pin = pin;
  14. init.Mode = mode;
  15. //init.Speed = ;
  16. init.OutputType = outputType;
  17. init.Pull = pullMode;
  18. LL_GPIO_Init(gpio, &init);
  19. }
  20. void GPIO_setPin(GPIO_TypeDef * gpio, uint32_t pin, int output)
  21. {
  22. if (output) {
  23. LL_GPIO_SetOutputPin(gpio, pin);
  24. } else {
  25. LL_GPIO_ResetOutputPin(gpio,pin);
  26. }
  27. };
  28. int GPIO_readPin(GPIO_TypeDef * gpio, uint32_t pin)
  29. {
  30. return LL_GPIO_IsOutputPinSet(gpio, pin);
  31. }