led.c 506 B

1234567891011121314151617181920212223242526
  1. #include "led.h"
  2. #include "gd32e230_gpio.h"
  3. #include "SysTick.h"
  4. unsigned char led_flash_flag;
  5. void led_init(void)
  6. {
  7. rcu_periph_clock_enable(RCU_GPIOA);
  8. gpio_mode_set(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_8);
  9. gpio_output_options_set(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_8);
  10. gpio_bit_set(GPIOA, GPIO_PIN_8);
  11. led_flash_flag = 0;
  12. }
  13. void led_flash(unsigned char id)
  14. {
  15. if(led_flash_flag)
  16. {
  17. gpio_bit_toggle(GPIOA,GPIO_PIN_8);
  18. led_flash_flag = 0;
  19. }
  20. }