api-hal-gpio.c 807 B

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