1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 08:15:30 +03:00

Debug - Initialise debug pins on startup, not as part of the dshot

bitbang code.
This commit is contained in:
Dominic Clifton 2021-08-18 15:26:24 +02:00
parent 04572eed13
commit 49869fa2bb
4 changed files with 17 additions and 25 deletions

View file

@ -20,6 +20,8 @@
#pragma once
#include <drivers/io.h>
typedef struct dbgPin_s {
ioTag_t tag;
} dbgPin_t;

View file

@ -27,6 +27,7 @@
#ifdef USE_DSHOT_BITBANG
#include "build/debug.h"
#include "build/debug_pin.h"
#include "drivers/io.h"
#include "drivers/io_impl.h"
@ -46,14 +47,6 @@
#include "pg/motor.h"
#if defined(USE_DEBUG_PIN)
#include "build/debug_pin.h"
#else
#define dbgPinInit()
#define dbgPinHi(x)
#define dbgPinLo(x)
#endif
FAST_DATA_ZERO_INIT bbPacer_t bbPacers[MAX_MOTOR_PACERS]; // TIM1 or TIM8
FAST_DATA_ZERO_INIT int usedMotorPacers = 0;
@ -300,7 +293,7 @@ static void bbAllocDma(bbPort_t *bbPort)
void bbDMAIrqHandler(dmaChannelDescriptor_t *descriptor)
{
dbgPinHi(0);
DEBUG_HI(0);
bbPort_t *bbPort = (bbPort_t *)descriptor->userParam;
@ -333,7 +326,7 @@ void bbDMAIrqHandler(dmaChannelDescriptor_t *descriptor)
}
}
#endif
dbgPinLo(0);
DEBUG_LO(0);
}
// Setup bbPorts array elements so that they each have a TIM1 or TIM8 channel
@ -693,9 +686,8 @@ dshotBitbangStatus_e dshotBitbangGetStatus()
motorDevice_t *dshotBitbangDevInit(const motorDevConfig_t *motorConfig, uint8_t count)
{
dbgPinInit();
dbgPinLo(0);
dbgPinLo(1);
DEBUG_LO(0);
DEBUG_LO(1);
motorPwmProtocol = motorConfig->motorPwmProtocol;
bbDevice.vTable = bbVTable;

View file

@ -28,6 +28,7 @@
#include "build/atomic.h"
#include "build/debug.h"
#include "build/debug_pin.h"
#include "drivers/io.h"
#include "drivers/io_impl.h"
@ -44,14 +45,6 @@
#include "pg/motor.h"
#if defined(USE_DEBUG_PIN)
#include "build/debug_pin.h"
#else
#define dbgPinInit()
#define dbgPinHi(x)
#define dbgPinLo(x)
#endif
void bbGpioSetup(bbMotor_t *bbMotor)
{
bbPort_t *bbPort = bbMotor->bbPort;
@ -142,7 +135,7 @@ static void bbSaveDMARegs(dmaResource_t *dmaResource, dmaRegCache_t *dmaRegCache
void bbSwitchToOutput(bbPort_t * bbPort)
{
dbgPinHi(1);
DEBUG_HI(1);
// Output idle level before switching to output
// Use BSRR register for this
// Normal: Use BR (higher half)
@ -173,13 +166,13 @@ void bbSwitchToOutput(bbPort_t * bbPort)
bbPort->direction = DSHOT_BITBANG_DIRECTION_OUTPUT;
dbgPinLo(1);
DEBUG_LO(1);
}
#ifdef USE_DSHOT_TELEMETRY
void bbSwitchToInput(bbPort_t *bbPort)
{
dbgPinHi(1);
DEBUG_HI(1);
// Set GPIO to input
@ -208,7 +201,7 @@ void bbSwitchToInput(bbPort_t *bbPort)
bbPort->direction = DSHOT_BITBANG_DIRECTION_INPUT;
dbgPinLo(1);
DEBUG_LO(1);
}
#endif

View file

@ -29,6 +29,7 @@
#include "build/build_config.h"
#include "build/debug.h"
#include "build/debug_pin.h"
#include "cms/cms.h"
#include "cms/cms_types.h"
@ -413,6 +414,10 @@ void init(void)
systemState |= SYSTEM_STATE_CONFIG_LOADED;
#ifdef USE_DEBUG_PIN
dbgPinInit();
#endif
#ifdef USE_SDCARD
// Ensure the SD card is initialised before the USB MSC starts to avoid a race condition
#if !defined(CONFIG_IN_SDCARD) && defined(STM32H7) && defined(USE_SDCARD_SDIO) // H7 only for now, likely should be applied to F4/F7 too