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.

98 lines
3.2 KiB

4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
3 years ago
4 years ago
  1. #include "port.h"
  2. // �õ���io ���ڣ����� led��4+1 RGB:3 ���ȣ�1
  3. /**
  4. * @brief δʹõioΪģʽ̶ƽ
  5. *
  6. */
  7. void unused_gpio_init(void) {
  8. GPIO_InitSettingType x;
  9. x.Signal = GPIO_Pin_Signal_Digital;
  10. x.Dir = GPIO_Direction_Output; //����ģʽ
  11. // x.Dir = GPIO_Direction_Input;
  12. x.Func = GPIO_Reuse_Func0;
  13. x.ODE = GPIO_ODE_Output_Disable;
  14. x.DS = GPIO_DS_Output_Normal;
  15. x.PUE = GPIO_PUE_Input_Disable;
  16. x.PDE = GPIO_PDE_Input_Enable;
  17. GPIO_Init(GPIO_Pin_A10, &x);
  18. GPIO_Init(GPIO_Pin_A23, &x);
  19. GPIO_Init(GPIO_Pin_A27, &x); // �Լ�ԭ��ͼ����26
  20. GPIO_Init(GPIO_Pin_A28, &x); // �Լ�ԭ��ͼ����27
  21. GPIO_Init(GPIO_Pin_B0, &x);
  22. //����adc
  23. GPIO_Init(GPIO_Pin_B8, &x);
  24. GPIO_Init(GPIO_Pin_B9, &x);
  25. GPIO_Init(GPIO_Pin_A2, &x);
  26. GPIO_WriteBit(GPIO_Pin_A10, 0);
  27. GPIO_WriteBit(GPIO_Pin_A23, 0);
  28. GPIO_WriteBit(GPIO_Pin_A27, 0);
  29. GPIO_WriteBit(GPIO_Pin_A28, 0);
  30. GPIO_WriteBit(GPIO_Pin_B0, 0);
  31. GPIO_WriteBit(GPIO_Pin_B8, 0);
  32. GPIO_WriteBit(GPIO_Pin_B9, 0);
  33. GPIO_WriteBit(GPIO_Pin_A2, 0);
  34. }
  35. static void led_gpio_init(void) {
  36. GPIO_InitSettingType x;
  37. x.Signal = GPIO_Pin_Signal_Digital;
  38. x.Dir = GPIO_Direction_Output;
  39. x.Func = GPIO_Reuse_Func0;
  40. x.ODE = GPIO_ODE_Output_Disable;
  41. x.DS = GPIO_DS_Output_Normal;
  42. x.PUE = GPIO_PUE_Input_Disable;
  43. x.PDE = GPIO_PDE_Input_Enable;
  44. GPIO_Init(GPIO_Pin_A3, &x);
  45. GPIO_Init(GPIO_Pin_B13, &x);
  46. GPIO_Init(GPIO_Pin_A5, &x);
  47. GPIO_Init(GPIO_Pin_A6, &x);
  48. GPIO_Init(GPIO_Pin_A7, &x);
  49. GPIO_Init(GPIO_Pin_A8, &x);
  50. GPIO_Init(GPIO_Pin_A9, &x);
  51. GPIO_Init(GPIO_Pin_B1, &x); //����
  52. GPIO_Init(GPIO_Pin_A22, &x);
  53. }
  54. static void key_gpio_init(void) {
  55. /**
  56. * @brief PA11~PA13
  57. *
  58. */
  59. GPIO_InitSettingType x;
  60. x.Signal = GPIO_Pin_Signal_Digital;
  61. x.Dir = GPIO_Direction_Input;
  62. x.Func = GPIO_Reuse_Func0;
  63. x.PUE = GPIO_PUE_Input_Disable;
  64. x.PDE = GPIO_PDE_Input_Enable;
  65. GPIO_Init(GPIO_Pin_A11, &x); //
  66. GPIO_Init(GPIO_Pin_A16, &x); //
  67. GPIO_Init(GPIO_Pin_A13, &x);
  68. GPIO_Init(GPIO_Pin_A12, &x);
  69. }
  70. void gpio_init(void) {
  71. led_gpio_init();
  72. key_gpio_init();
  73. }
  74. void port_debug_set(bool state) { GPIO_SET(A, 22, !, state); }
  75. void port_fan_set(bool state) { GPIO_SET(B, 1, !!, state); }
  76. void port_led0_set(bool state) { GPIO_SET(A, 3, !, state); }
  77. void port_led1_set(bool state) { GPIO_SET(B, 13, !, state); }
  78. void port_led2_set(bool state) { GPIO_SET(A, 5, !, state); }
  79. void port_led3_set(bool state) { GPIO_SET(A, 6, !, state); }
  80. void port_led_r_set(bool state) { GPIO_SET(A, 7, !, state); }
  81. void port_led_g_set(bool state) { GPIO_SET(A, 8, !, state); }
  82. void port_led_b_set(bool state) { GPIO_SET(A, 9, !, state); }
  83. bool port_gpio_get_timer_key_state(void) { return GPIO_GET(A, 11, !!); } //??H
  84. bool port_gpio_get_gears_key_state(void) { return GPIO_GET(A, 16, !!); } //??M
  85. bool port_gpio_get_switch_key_state(void) { return GPIO_GET(A, 12, !!); }
  86. bool port_gpio_get_interval_key_state(void) { return GPIO_GET(A, 13, !!); }
  87. bool port_led0_get_state(void) { return GPIO_GET(A, 3, !); } //??H
  88. bool port_led1_get_state(void) { return GPIO_GET(B, 13, !); } //??M
  89. bool port_led2_get_state(void) { return GPIO_GET(A, 5, !); }
  90. bool port_led3_get_state(void) { return GPIO_GET(A, 6, !); }