api-hal-gpio.c 780 B

12345678910111213141516171819202122232425262728293031
  1. #include <api-hal-gpio.h>
  2. #include <api-hal-spi.h>
  3. #include <api-hal-resources.h>
  4. #include <api-hal-delay.h>
  5. // init GPIO
  6. void hal_gpio_init(
  7. const GpioPin* gpio,
  8. const GpioMode mode,
  9. const GpioPull pull,
  10. const GpioSpeed speed) {
  11. // TODO: Alternate Functions
  12. GPIO_InitTypeDef GPIO_InitStruct = {0};
  13. GPIO_InitStruct.Pin = gpio->pin;
  14. GPIO_InitStruct.Mode = mode;
  15. GPIO_InitStruct.Pull = pull;
  16. GPIO_InitStruct.Speed = speed;
  17. HAL_GPIO_Init(gpio->port, &GPIO_InitStruct);
  18. }
  19. extern COMP_HandleTypeDef hcomp1;
  20. bool get_rfid_in_level() {
  21. #ifdef INVERT_RFID_IN
  22. return (HAL_COMP_GetOutputLevel(&hcomp1) == COMP_OUTPUT_LEVEL_LOW);
  23. #else
  24. return (HAL_COMP_GetOutputLevel(&hcomp1) == COMP_OUTPUT_LEVEL_HIGH);
  25. #endif
  26. }