Led.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*********************************************************************************************************
  2. * Module : Led.c
  3. * Abstract : Led modules,while be flashing which determing of running normally !
  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 "Led.h"
  11. #include "gd32e230x_conf.h"
  12. #include "main.h"
  13. static void ConfigLEDGPIO(void);
  14. #define USR_LED GPIO_PIN_14
  15. static void ConfigLEDGPIO(void)
  16. {
  17. rcu_periph_clock_enable(RCU_GPIOC);
  18. gpio_mode_set(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, USR_LED);
  19. gpio_output_options_set(GPIOC, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, USR_LED);
  20. gpio_bit_reset(GPIOC, USR_LED);
  21. }
  22. void InitLED(void)
  23. {
  24. ConfigLEDGPIO();
  25. sts_data_t *data = get_sts();
  26. data->led_flash = LEDFlicker2;
  27. }
  28. void LEDFlicker1(unsigned short cnt)
  29. {
  30. static unsigned short s_iCnt;
  31. s_iCnt++;
  32. if(s_iCnt >= cnt)
  33. {
  34. s_iCnt = 0;
  35. gpio_bit_write(GPIOC, USR_LED, 1-gpio_output_bit_get(GPIOC, USR_LED));
  36. }
  37. }
  38. void LEDFlicker2(void)
  39. {
  40. gpio_bit_toggle(GPIOC, USR_LED);
  41. }