api-hal-gpio.c 706 B

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