common_gpio.c 931 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "at32f403a_407.h"
  2. #include "common_gpio.h"
  3. #include "FreeRTOS.h"
  4. #include "task.h"
  5. #include <stdbool.h>
  6. //
  7. void cm_gpio_init(void)
  8. {
  9. gpio_init_type gpio_initstructure;
  10. crm_periph_clock_enable(CRM_GPIOC_PERIPH_CLOCK, TRUE);
  11. // WDT
  12. gpio_initstructure.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
  13. gpio_initstructure.gpio_pull = GPIO_PULL_NONE;
  14. gpio_initstructure.gpio_mode = GPIO_MODE_OUTPUT;
  15. gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
  16. gpio_initstructure.gpio_pins = GPIO_PINS_7;
  17. gpio_init(GPIOC, &gpio_initstructure);
  18. }
  19. //
  20. void extern_wdt_togle(void)
  21. {
  22. static bool toogle = false;
  23. if (!toogle) {
  24. toogle = true;
  25. gpio_bits_set(GPIOC, GPIO_PINS_7);
  26. }
  27. else {
  28. toogle = false;
  29. gpio_bits_reset(GPIOC, GPIO_PINS_7);
  30. }
  31. }