api-hal-gpio.c 890 B

123456789101112131415161718192021222324252627282930313233343536
  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. void enable_cc1101_irq() {
  20. HAL_NVIC_SetPriority(EXTI4_IRQn, 5, 0);
  21. HAL_NVIC_EnableIRQ(EXTI4_IRQn);
  22. }
  23. extern COMP_HandleTypeDef hcomp1;
  24. bool get_rfid_in_level() {
  25. #ifdef INVERT_RFID_IN
  26. return (HAL_COMP_GetOutputLevel(&hcomp1) == COMP_OUTPUT_LEVEL_LOW);
  27. #else
  28. return (HAL_COMP_GetOutputLevel(&hcomp1) == COMP_OUTPUT_LEVEL_HIGH);
  29. #endif
  30. }