[4.4.2] Remove 15 m/s limit on estimated vario (#12788)
[betaflight.git] / src / main / build / debug_pin.c
blobc3017a00f084abfe5cd7a7da367d99f6cb90f0cd
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #include "platform.h"
23 #ifdef USE_DEBUG_PIN
25 #include "drivers/io.h"
26 #include "drivers/io_impl.h"
28 #include "debug_pin.h"
30 typedef struct dbgPinState_s {
31 GPIO_TypeDef *gpio;
32 uint32_t setBSRR;
33 uint32_t resetBSRR;
34 } dbgPinState_t;
36 dbgPinState_t dbgPinStates[DEBUG_PIN_COUNT] = { 0 };
38 extern dbgPin_t dbgPins[DEBUG_PIN_COUNT];
39 // Define this in the target definition as (and set DEBUG_PIN_COUNT to the correct value):
40 // dbgPin_t dbgPins[DEBUG_PIN_COUNT] = {
41 // { .tag = IO_TAG(<pin>) },
42 // };
43 #endif
45 void dbgPinInit(void)
47 #ifdef USE_DEBUG_PIN
48 for (unsigned i = 0; i < ARRAYLEN(dbgPins); i++) {
49 dbgPin_t *dbgPin = &dbgPins[i];
50 dbgPinState_t *dbgPinState = &dbgPinStates[i];
51 IO_t io = IOGetByTag(dbgPin->tag);
52 if (!io) {
53 continue;
55 IOInit(io, OWNER_SYSTEM, 0);
56 IOConfigGPIO(io, IOCFG_OUT_PP);
57 dbgPinState->gpio = IO_GPIO(io);
58 int pinSrc = IO_GPIO_PinSource(io);
59 dbgPinState->setBSRR = (1 << pinSrc);
60 dbgPinState->resetBSRR = (1 << (pinSrc + 16));
62 #endif
65 void dbgPinHi(int index)
67 #ifdef USE_DEBUG_PIN
68 if ((unsigned)index >= ARRAYLEN(dbgPins)) {
69 return;
72 dbgPinState_t *dbgPinState = &dbgPinStates[index];
73 if (dbgPinState->gpio) {
74 #if defined(STM32F7) || defined(STM32H7)
75 dbgPinState->gpio->BSRR = dbgPinState->setBSRR;
76 #else
77 dbgPinState->gpio->BSRRL = dbgPinState->setBSRR;
78 #endif
80 #else
81 UNUSED(index);
82 #endif
85 void dbgPinLo(int index)
87 #ifdef USE_DEBUG_PIN
88 if ((unsigned)index >= ARRAYLEN(dbgPins)) {
89 return;
92 dbgPinState_t *dbgPinState = &dbgPinStates[index];
94 if (dbgPinState->gpio) {
95 #if defined(STM32F7) || defined(STM32H7)
96 dbgPinState->gpio->BSRR = dbgPinState->resetBSRR;
97 #else
98 dbgPinState->gpio->BSRRL = dbgPinState->resetBSRR;
99 #endif
101 #else
102 UNUSED(index);
103 #endif