| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- #include "core/config_pins.h"
- #include "core/debugpins.h"
- #include "core/gpio.h"
- #if CONFIG_MAINC_DEBUGPIN_1
- static void InitDebugPin_1()
- {
- GPIO_InitTypeDef GPIO_InitStruct = {0};
-
- // Configure GPIO pins for debug: CONFIG_PIN__DBGPIN1
- GPIO_InitStruct.Pin = CONFIG_PIN__DBGPIN1;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- HAL_GPIO_Init(CONFIG_PORT__DBGPIN1, &GPIO_InitStruct);
- }
- static void DeInitDebugPin_1()
- {
- GPIO_InitTypeDef GPIO_InitStruct = {0};
-
- // Configure GPIO pins for debug: CONFIG_PIN__DBGPIN1
- GPIO_InitStruct.Pin = CONFIG_PIN__DBGPIN1;
- GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(CONFIG_PORT__DBGPIN1, &GPIO_InitStruct);
- }
- #endif
- #if CONFIG_MAINC_DEBUGPIN_2
- static void InitDebugPin_2()
- {
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- // Configure GPIO pins for debug: CONFIG_PIN__DBGPIN2
- GPIO_InitStruct.Pin = CONFIG_PIN__DBGPIN2;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- HAL_GPIO_Init(CONFIG_PORT__DBGPIN2, &GPIO_InitStruct);
- }
- static void DeInitDebugPin_2()
- {
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- // Configure GPIO pins for debug: CONFIG_PIN__DBGPIN2
- GPIO_InitStruct.Pin = CONFIG_PIN__DBGPIN2;
- GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(CONFIG_PORT__DBGPIN2, &GPIO_InitStruct);
- }
- #endif
- #if CONFIG_MAINC_DEBUGPIN_3
- static void InitDebugPin_3()
- {
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- // Configure GPIO pins for debug: CONFIG_PIN__DBGPIN3
- GPIO_InitStruct.Pin = CONFIG_PIN__DBGPIN3;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- HAL_GPIO_Init(CONFIG_PORT__DBGPIN3, &GPIO_InitStruct);
- }
- static void DeInitDebugPin_3()
- {
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- // Configure GPIO pins for debug: CONFIG_PIN__DBGPIN3
- GPIO_InitStruct.Pin = CONFIG_PIN__DBGPIN3;
- GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(CONFIG_PORT__DBGPIN3, &GPIO_InitStruct);
- }
- #endif
- void DebugPins_Init()
- {
- #if CONFIG_MAINC_DEBUGPIN_1
- InitDebugPin_1();
- #endif
- #if CONFIG_MAINC_DEBUGPIN_2
- InitDebugPin_2();
- #endif
- #if CONFIG_MAINC_DEBUGPIN_3
- InitDebugPin_3();
- #endif
- }
- void DebugPins_DeInit()
- {
- #if CONFIG_MAINC_DEBUGPIN_1
- DeInitDebugPin_1();
- #endif
- #if CONFIG_MAINC_DEBUGPIN_2
- DeInitDebugPin_2();
- #endif
- #if CONFIG_MAINC_DEBUGPIN_3
- DeInitDebugPin_3();
- #endif
- }
- #if CONFIG_MAINC_DEBUGPIN_1
- void debugpin_1_pulse()
- {
- CONFIG_PORT__DBGPIN2->BSRR = CONFIG_PIN__DBGPIN1;
- CONFIG_PORT__DBGPIN2->BSRR = (CONFIG_PIN__DBGPIN1)<<16;
- }
- void debugpin_1_set()
- {
- CONFIG_PORT__DBGPIN1->BSRR = CONFIG_PIN__DBGPIN1;
- }
- void debugpin_1_clr()
- {
- CONFIG_PORT__DBGPIN1->BSRR = (CONFIG_PIN__DBGPIN1)<<16;
- }
- #endif
- #if CONFIG_MAINC_DEBUGPIN_2
- void debugpin_2_pulse()
- {
- CONFIG_PORT__DBGPIN2->BSRR = CONFIG_PIN__DBGPIN2;
- CONFIG_PORT__DBGPIN2->BSRR = (CONFIG_PIN__DBGPIN2)<<16;
- }
- void debugpin_2_set()
- {
- CONFIG_PORT__DBGPIN2->BSRR = (CONFIG_PIN__DBGPIN2);
- }
- void debugpin_2_clr()
- {
- CONFIG_PORT__DBGPIN2->BSRR = (CONFIG_PIN__DBGPIN2)<<16;
- }
- #endif
- #if CONFIG_MAINC_DEBUGPIN_3
- void debugpin_3_pulse()
- {
- CONFIG_PORT__DBGPIN3->BSRR = (CONFIG_PIN__DBGPIN3);
- CONFIG_PORT__DBGPIN3->BSRR = (CONFIG_PIN__DBGPIN3)<<16;
- }
- void debugpin_3_set()
- {
- CONFIG_PORT__DBGPIN3->BSRR = (CONFIG_PIN__DBGPIN3);
- }
- void debugpin_3_clr()
- {
- CONFIG_PORT__DBGPIN3->BSRR = (CONFIG_PIN__DBGPIN3)<<16;
- }
- #endif
|