mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 12:55:19 +03:00
Added facility to use GPIO pins for fast debugging. (#8809)
Added facility to use GPIO pins for fast debugging.
This commit is contained in:
commit
33c2ccecf1
6 changed files with 124 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
COMMON_SRC = \
|
COMMON_SRC = \
|
||||||
build/build_config.c \
|
build/build_config.c \
|
||||||
build/debug.c \
|
build/debug.c \
|
||||||
|
build/debug_pin.c \
|
||||||
build/version.c \
|
build/version.c \
|
||||||
$(TARGET_DIR_SRC) \
|
$(TARGET_DIR_SRC) \
|
||||||
main.c \
|
main.c \
|
||||||
|
|
88
src/main/build/debug_pin.c
Normal file
88
src/main/build/debug_pin.c
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight and Betaflight.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are free software. You can redistribute
|
||||||
|
* this software and/or modify this software under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are distributed in the hope that they
|
||||||
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this software.
|
||||||
|
*
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#ifdef USE_DEBUG_PIN
|
||||||
|
|
||||||
|
#include "drivers/io.h"
|
||||||
|
#include "drivers/io_impl.h"
|
||||||
|
|
||||||
|
typedef struct dbgPin_s {
|
||||||
|
ioTag_t tag;
|
||||||
|
GPIO_TypeDef *gpio;
|
||||||
|
uint32_t setBSRR;
|
||||||
|
uint32_t resetBSRR;
|
||||||
|
} dbgPin_t;
|
||||||
|
|
||||||
|
dbgPin_t dbgPins[] = {
|
||||||
|
{ .tag = IO_TAG(NONE) },
|
||||||
|
};
|
||||||
|
|
||||||
|
void dbgPinInit(void)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < ARRAYLEN(dbgPins); i++) {
|
||||||
|
dbgPin_t *dbgPin = &dbgPins[i];
|
||||||
|
IO_t io = IOGetByTag(dbgPin->tag);
|
||||||
|
if (!io) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
IOConfigGPIO(io, IOCFG_OUT_PP);
|
||||||
|
dbgPin->gpio = IO_GPIO(io);
|
||||||
|
int pinSrc = IO_GPIO_PinSource(io);
|
||||||
|
dbgPin->setBSRR = (1 << pinSrc);
|
||||||
|
dbgPin->resetBSRR = (1 << (pinSrc + 16));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbgPinHi(int index)
|
||||||
|
{
|
||||||
|
if ((unsigned)index >= ARRAYLEN(dbgPins)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbgPin_t *dbgPin = &dbgPins[index];
|
||||||
|
if (dbgPin->gpio) {
|
||||||
|
#if defined(STM32F7)
|
||||||
|
dbgPin->gpio->BSRR = dbgPin->setBSRR;
|
||||||
|
#else
|
||||||
|
dbgPin->gpio->BSRRL = dbgPin->setBSRR;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbgPinLo(int index)
|
||||||
|
{
|
||||||
|
if ((unsigned)index > ARRAYLEN(dbgPins)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbgPin_t *dbgPin = &dbgPins[index];
|
||||||
|
|
||||||
|
if (dbgPins->gpio) {
|
||||||
|
#if defined(STM32F7)
|
||||||
|
dbgPin->gpio->BSRR = dbgPin->resetBSRR;
|
||||||
|
#else
|
||||||
|
dbgPin->gpio->BSRRL = dbgPin->resetBSRR;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
25
src/main/build/debug_pin.h
Normal file
25
src/main/build/debug_pin.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight and Betaflight.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are free software. You can redistribute
|
||||||
|
* this software and/or modify this software under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are distributed in the hope that they
|
||||||
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this software.
|
||||||
|
*
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void dbgPinInit(void);
|
||||||
|
void dbgPinHi(int index);
|
||||||
|
void dbgPinLo(int index);
|
|
@ -46,10 +46,13 @@
|
||||||
|
|
||||||
#include "pg/motor.h"
|
#include "pg/motor.h"
|
||||||
|
|
||||||
//TODO: Change these to be only used if USE_DEBUG_PIN is not defined once the debug_pin functionality has been merged
|
#if defined(USE_DEBUG_PIN)
|
||||||
|
#include "build/debug_pin.h"
|
||||||
|
#else
|
||||||
#define dbgPinInit()
|
#define dbgPinInit()
|
||||||
#define dbgPinHi(x)
|
#define dbgPinHi(x)
|
||||||
#define dbgPinLo(x)
|
#define dbgPinLo(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
FAST_RAM_ZERO_INIT bbPacer_t bbPacers[MAX_MOTOR_PACERS]; // TIM1 or TIM8
|
FAST_RAM_ZERO_INIT bbPacer_t bbPacers[MAX_MOTOR_PACERS]; // TIM1 or TIM8
|
||||||
FAST_RAM_ZERO_INIT int usedMotorPacers = 0;
|
FAST_RAM_ZERO_INIT int usedMotorPacers = 0;
|
||||||
|
|
|
@ -44,10 +44,13 @@
|
||||||
|
|
||||||
#include "pg/motor.h"
|
#include "pg/motor.h"
|
||||||
|
|
||||||
//TODO: Change these to be only used if USE_DEBUG_PIN is not defined once the debug_pin functionality has been merged
|
#if defined(USE_DEBUG_PIN)
|
||||||
|
#include "build/debug_pin.h"
|
||||||
|
#else
|
||||||
#define dbgPinInit()
|
#define dbgPinInit()
|
||||||
#define dbgPinHi(x)
|
#define dbgPinHi(x)
|
||||||
#define dbgPinLo(x)
|
#define dbgPinLo(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
void bbGpioSetup(bbMotor_t *bbMotor)
|
void bbGpioSetup(bbMotor_t *bbMotor)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#define USBD_PRODUCT_STRING "NucleoF722"
|
#define USBD_PRODUCT_STRING "NucleoF722"
|
||||||
|
|
||||||
|
#define USE_DEBUG_PIN
|
||||||
|
|
||||||
//#define USE_ESC_TELEMETRY
|
//#define USE_ESC_TELEMETRY
|
||||||
|
|
||||||
#define LED0_PIN PB7 // blue
|
#define LED0_PIN PB7 // blue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue