You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.9 KiB

4 years ago
4 years ago
  1. #include "port.h"
  2. static void led_gpio_init(void) {
  3. GPIO_InitSettingType x;
  4. x.Signal = GPIO_Pin_Signal_Digital;
  5. x.Dir = GPIO_Direction_Output;
  6. x.Func = GPIO_Reuse_Func0;
  7. x.ODE = GPIO_ODE_Output_Disable;
  8. x.DS = GPIO_DS_Output_Normal;
  9. x.PUE = GPIO_PUE_Input_Disable;
  10. x.PDE = GPIO_PDE_Input_Disable;
  11. GPIO_Init(GPIO_Pin_A3, &x);
  12. GPIO_Init(GPIO_Pin_B13, &x);
  13. GPIO_Init(GPIO_Pin_A5, &x);
  14. GPIO_Init(GPIO_Pin_A6, &x);
  15. GPIO_Init(GPIO_Pin_A7, &x);
  16. GPIO_Init(GPIO_Pin_A8, &x);
  17. GPIO_Init(GPIO_Pin_A9, &x);
  18. GPIO_Init(GPIO_Pin_B1, &x);
  19. GPIO_Init(GPIO_Pin_A28, &x);
  20. }
  21. static void key_gpio_init(void) {
  22. /**
  23. * @brief PA11~PA13?????? ????? ??????
  24. *
  25. */
  26. GPIO_InitSettingType x;
  27. x.Signal = GPIO_Pin_Signal_Digital;
  28. x.Dir = GPIO_Direction_Input;
  29. x.Func = GPIO_Reuse_Func0;
  30. x.PUE = GPIO_PUE_Input_Disable;
  31. x.PDE = GPIO_PDE_Input_Enable;
  32. GPIO_Init(GPIO_Pin_A11, &x); //??H
  33. GPIO_Init(GPIO_Pin_A16, &x); //??M
  34. GPIO_Init(GPIO_Pin_A13, &x);
  35. }
  36. void gpio_init(void) {
  37. led_gpio_init();
  38. key_gpio_init();
  39. }
  40. void port_debug_set(bool state) { GPIO_SET(A, 28, !, state); }
  41. void port_fan_set(bool state) { GPIO_SET(B, 1, !!, state); }
  42. void port_led0_set(bool state) { GPIO_SET(A, 3, !, state); }
  43. void port_led1_set(bool state) { GPIO_SET(B, 13, !, state); }
  44. void port_led2_set(bool state) { GPIO_SET(A, 5, !, state); }
  45. void port_led3_set(bool state) { GPIO_SET(A, 6, !, state); }
  46. void port_led_r_set(bool state) { GPIO_SET(A, 7, !, state); }
  47. void port_led_g_set(bool state) { GPIO_SET(A, 8, !, state); }
  48. void port_led_b_set(bool state) { GPIO_SET(A, 9, !, state); }
  49. bool port_gpio_get_timer_key_state(void) { return GPIO_GET(A, 11, !!); } //??H
  50. bool port_gpio_get_gears_key_state(void) { return GPIO_GET(A, 16, !!); } //??M
  51. bool port_gpio_get_interval_key_state(void) { return GPIO_GET(A, 13, !!); }