debugpins.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #include "core/config_pins.h"
  2. #include "core/debugpins.h"
  3. #include "core/gpio.h"
  4. #if CONFIG_MAINC_DEBUGPIN_1
  5. static void InitDebugPin_1()
  6. {
  7. GPIO_InitTypeDef GPIO_InitStruct = {0};
  8. // Configure GPIO pins for debug: CONFIG_PIN__DBGPIN1
  9. GPIO_InitStruct.Pin = CONFIG_PIN__DBGPIN1;
  10. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  11. GPIO_InitStruct.Pull = GPIO_NOPULL;
  12. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  13. HAL_GPIO_Init(CONFIG_PORT__DBGPIN1, &GPIO_InitStruct);
  14. }
  15. static void DeInitDebugPin_1()
  16. {
  17. GPIO_InitTypeDef GPIO_InitStruct = {0};
  18. // Configure GPIO pins for debug: CONFIG_PIN__DBGPIN1
  19. GPIO_InitStruct.Pin = CONFIG_PIN__DBGPIN1;
  20. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  21. GPIO_InitStruct.Pull = GPIO_NOPULL;
  22. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  23. HAL_GPIO_Init(CONFIG_PORT__DBGPIN1, &GPIO_InitStruct);
  24. }
  25. #endif
  26. #if CONFIG_MAINC_DEBUGPIN_2
  27. static void InitDebugPin_2()
  28. {
  29. GPIO_InitTypeDef GPIO_InitStruct = {0};
  30. // Configure GPIO pins for debug: CONFIG_PIN__DBGPIN2
  31. GPIO_InitStruct.Pin = CONFIG_PIN__DBGPIN2;
  32. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  33. GPIO_InitStruct.Pull = GPIO_NOPULL;
  34. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  35. HAL_GPIO_Init(CONFIG_PORT__DBGPIN2, &GPIO_InitStruct);
  36. }
  37. static void DeInitDebugPin_2()
  38. {
  39. GPIO_InitTypeDef GPIO_InitStruct = {0};
  40. // Configure GPIO pins for debug: CONFIG_PIN__DBGPIN2
  41. GPIO_InitStruct.Pin = CONFIG_PIN__DBGPIN2;
  42. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  43. GPIO_InitStruct.Pull = GPIO_NOPULL;
  44. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  45. HAL_GPIO_Init(CONFIG_PORT__DBGPIN2, &GPIO_InitStruct);
  46. }
  47. #endif
  48. #if CONFIG_MAINC_DEBUGPIN_3
  49. static void InitDebugPin_3()
  50. {
  51. GPIO_InitTypeDef GPIO_InitStruct = {0};
  52. // Configure GPIO pins for debug: CONFIG_PIN__DBGPIN3
  53. GPIO_InitStruct.Pin = CONFIG_PIN__DBGPIN3;
  54. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  55. GPIO_InitStruct.Pull = GPIO_NOPULL;
  56. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  57. HAL_GPIO_Init(CONFIG_PORT__DBGPIN3, &GPIO_InitStruct);
  58. }
  59. static void DeInitDebugPin_3()
  60. {
  61. GPIO_InitTypeDef GPIO_InitStruct = {0};
  62. // Configure GPIO pins for debug: CONFIG_PIN__DBGPIN3
  63. GPIO_InitStruct.Pin = CONFIG_PIN__DBGPIN3;
  64. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  65. GPIO_InitStruct.Pull = GPIO_NOPULL;
  66. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  67. HAL_GPIO_Init(CONFIG_PORT__DBGPIN3, &GPIO_InitStruct);
  68. }
  69. #endif
  70. void DebugPins_Init()
  71. {
  72. #if CONFIG_MAINC_DEBUGPIN_1
  73. InitDebugPin_1();
  74. #endif
  75. #if CONFIG_MAINC_DEBUGPIN_2
  76. InitDebugPin_2();
  77. #endif
  78. #if CONFIG_MAINC_DEBUGPIN_3
  79. InitDebugPin_3();
  80. #endif
  81. }
  82. void DebugPins_DeInit()
  83. {
  84. #if CONFIG_MAINC_DEBUGPIN_1
  85. DeInitDebugPin_1();
  86. #endif
  87. #if CONFIG_MAINC_DEBUGPIN_2
  88. DeInitDebugPin_2();
  89. #endif
  90. #if CONFIG_MAINC_DEBUGPIN_3
  91. DeInitDebugPin_3();
  92. #endif
  93. }
  94. #if CONFIG_MAINC_DEBUGPIN_1
  95. void debugpin_1_pulse()
  96. {
  97. CONFIG_PORT__DBGPIN2->BSRR = CONFIG_PIN__DBGPIN1;
  98. CONFIG_PORT__DBGPIN2->BSRR = (CONFIG_PIN__DBGPIN1)<<16;
  99. }
  100. void debugpin_1_set()
  101. {
  102. CONFIG_PORT__DBGPIN1->BSRR = CONFIG_PIN__DBGPIN1;
  103. }
  104. void debugpin_1_clr()
  105. {
  106. CONFIG_PORT__DBGPIN1->BSRR = (CONFIG_PIN__DBGPIN1)<<16;
  107. }
  108. #endif
  109. #if CONFIG_MAINC_DEBUGPIN_2
  110. void debugpin_2_pulse()
  111. {
  112. CONFIG_PORT__DBGPIN2->BSRR = CONFIG_PIN__DBGPIN2;
  113. CONFIG_PORT__DBGPIN2->BSRR = (CONFIG_PIN__DBGPIN2)<<16;
  114. }
  115. void debugpin_2_set()
  116. {
  117. CONFIG_PORT__DBGPIN2->BSRR = (CONFIG_PIN__DBGPIN2);
  118. }
  119. void debugpin_2_clr()
  120. {
  121. CONFIG_PORT__DBGPIN2->BSRR = (CONFIG_PIN__DBGPIN2)<<16;
  122. }
  123. #endif
  124. #if CONFIG_MAINC_DEBUGPIN_3
  125. void debugpin_3_pulse()
  126. {
  127. CONFIG_PORT__DBGPIN3->BSRR = (CONFIG_PIN__DBGPIN3);
  128. CONFIG_PORT__DBGPIN3->BSRR = (CONFIG_PIN__DBGPIN3)<<16;
  129. }
  130. void debugpin_3_set()
  131. {
  132. CONFIG_PORT__DBGPIN3->BSRR = (CONFIG_PIN__DBGPIN3);
  133. }
  134. void debugpin_3_clr()
  135. {
  136. CONFIG_PORT__DBGPIN3->BSRR = (CONFIG_PIN__DBGPIN3)<<16;
  137. }
  138. #endif