Beep.c 1022 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*********************************************************************************************************
  2. * Module : Beep.c
  3. * Abstract : Beep modules is generated alarms!
  4. * Version : 1.0.0
  5. * Author : Leopul(COPYRIGHT 2025 - 2027 Leopul. All rights reserved.)
  6. * Complete : 2025-02-16
  7. * Content : None
  8. * Note : None
  9. *********************************************************************************************************/
  10. #include "Beep.h"
  11. #include "gd32e230x_conf.h"
  12. #include "main.h"
  13. static void beep(void)
  14. {
  15. gpio_bit_toggle(GPIOB, GPIO_PIN_1);
  16. }
  17. static void clear_beep(void)
  18. {
  19. gpio_bit_reset(GPIOB, GPIO_PIN_1);
  20. }
  21. void beep_init(void)
  22. {
  23. rcu_periph_clock_enable(RCU_GPIOB);
  24. gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_1);
  25. gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_1);
  26. gpio_bit_reset(GPIOB, GPIO_PIN_1);
  27. sts_data_t *data = get_sts();
  28. data->beep = beep;
  29. data->clear_beep = clear_beep;
  30. }