R_Led.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*********************************************************************************************************
  2. * Module : R_Led.c
  3. * Abstract : R_Led module displays the relay status!
  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 "R_Led.h"
  11. #include "gd32e230x_conf.h"
  12. void r_led_init(void)
  13. {
  14. rcu_periph_clock_enable(RCU_GPIOB);
  15. gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_2);
  16. gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_2);
  17. gpio_bit_reset(GPIOB, GPIO_PIN_2);
  18. gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_10);
  19. gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_10);
  20. gpio_bit_reset(GPIOB, GPIO_PIN_10);
  21. gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_11);
  22. gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_11);
  23. gpio_bit_reset(GPIOB, GPIO_PIN_11);
  24. }
  25. void in_r_led_on_off(unsigned char channel)
  26. {
  27. if(channel == 0)
  28. {
  29. gpio_bit_set(GPIOB, GPIO_PIN_2);
  30. gpio_bit_reset(GPIOB, GPIO_PIN_10);
  31. }else
  32. {
  33. gpio_bit_reset(GPIOB, GPIO_PIN_2);
  34. gpio_bit_set(GPIOB, GPIO_PIN_10);
  35. }
  36. }
  37. void out_r_led(unsigned char status)
  38. {
  39. if(status == 0)
  40. {
  41. gpio_bit_set(GPIOB, GPIO_PIN_11);
  42. }else
  43. {
  44. gpio_bit_reset(GPIOB, GPIO_PIN_11);
  45. }
  46. }