mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Debug - Initialise debug pins on startup, not as part of the dshot
bitbang code.
This commit is contained in:
parent
04572eed13
commit
49869fa2bb
4 changed files with 17 additions and 25 deletions
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <drivers/io.h>
|
||||||
|
|
||||||
typedef struct dbgPin_s {
|
typedef struct dbgPin_s {
|
||||||
ioTag_t tag;
|
ioTag_t tag;
|
||||||
} dbgPin_t;
|
} dbgPin_t;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#ifdef USE_DSHOT_BITBANG
|
#ifdef USE_DSHOT_BITBANG
|
||||||
|
|
||||||
#include "build/debug.h"
|
#include "build/debug.h"
|
||||||
|
#include "build/debug_pin.h"
|
||||||
|
|
||||||
#include "drivers/io.h"
|
#include "drivers/io.h"
|
||||||
#include "drivers/io_impl.h"
|
#include "drivers/io_impl.h"
|
||||||
|
@ -46,14 +47,6 @@
|
||||||
|
|
||||||
#include "pg/motor.h"
|
#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 bbPacer_t bbPacers[MAX_MOTOR_PACERS]; // TIM1 or TIM8
|
||||||
FAST_DATA_ZERO_INIT int usedMotorPacers = 0;
|
FAST_DATA_ZERO_INIT int usedMotorPacers = 0;
|
||||||
|
|
||||||
|
@ -300,7 +293,7 @@ static void bbAllocDma(bbPort_t *bbPort)
|
||||||
|
|
||||||
void bbDMAIrqHandler(dmaChannelDescriptor_t *descriptor)
|
void bbDMAIrqHandler(dmaChannelDescriptor_t *descriptor)
|
||||||
{
|
{
|
||||||
dbgPinHi(0);
|
DEBUG_HI(0);
|
||||||
|
|
||||||
bbPort_t *bbPort = (bbPort_t *)descriptor->userParam;
|
bbPort_t *bbPort = (bbPort_t *)descriptor->userParam;
|
||||||
|
|
||||||
|
@ -333,7 +326,7 @@ void bbDMAIrqHandler(dmaChannelDescriptor_t *descriptor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
dbgPinLo(0);
|
DEBUG_LO(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup bbPorts array elements so that they each have a TIM1 or TIM8 channel
|
// 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)
|
motorDevice_t *dshotBitbangDevInit(const motorDevConfig_t *motorConfig, uint8_t count)
|
||||||
{
|
{
|
||||||
dbgPinInit();
|
DEBUG_LO(0);
|
||||||
dbgPinLo(0);
|
DEBUG_LO(1);
|
||||||
dbgPinLo(1);
|
|
||||||
|
|
||||||
motorPwmProtocol = motorConfig->motorPwmProtocol;
|
motorPwmProtocol = motorConfig->motorPwmProtocol;
|
||||||
bbDevice.vTable = bbVTable;
|
bbDevice.vTable = bbVTable;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "build/atomic.h"
|
#include "build/atomic.h"
|
||||||
#include "build/debug.h"
|
#include "build/debug.h"
|
||||||
|
#include "build/debug_pin.h"
|
||||||
|
|
||||||
#include "drivers/io.h"
|
#include "drivers/io.h"
|
||||||
#include "drivers/io_impl.h"
|
#include "drivers/io_impl.h"
|
||||||
|
@ -44,14 +45,6 @@
|
||||||
|
|
||||||
#include "pg/motor.h"
|
#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)
|
void bbGpioSetup(bbMotor_t *bbMotor)
|
||||||
{
|
{
|
||||||
bbPort_t *bbPort = bbMotor->bbPort;
|
bbPort_t *bbPort = bbMotor->bbPort;
|
||||||
|
@ -142,7 +135,7 @@ static void bbSaveDMARegs(dmaResource_t *dmaResource, dmaRegCache_t *dmaRegCache
|
||||||
|
|
||||||
void bbSwitchToOutput(bbPort_t * bbPort)
|
void bbSwitchToOutput(bbPort_t * bbPort)
|
||||||
{
|
{
|
||||||
dbgPinHi(1);
|
DEBUG_HI(1);
|
||||||
// Output idle level before switching to output
|
// Output idle level before switching to output
|
||||||
// Use BSRR register for this
|
// Use BSRR register for this
|
||||||
// Normal: Use BR (higher half)
|
// Normal: Use BR (higher half)
|
||||||
|
@ -173,13 +166,13 @@ void bbSwitchToOutput(bbPort_t * bbPort)
|
||||||
|
|
||||||
bbPort->direction = DSHOT_BITBANG_DIRECTION_OUTPUT;
|
bbPort->direction = DSHOT_BITBANG_DIRECTION_OUTPUT;
|
||||||
|
|
||||||
dbgPinLo(1);
|
DEBUG_LO(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_DSHOT_TELEMETRY
|
#ifdef USE_DSHOT_TELEMETRY
|
||||||
void bbSwitchToInput(bbPort_t *bbPort)
|
void bbSwitchToInput(bbPort_t *bbPort)
|
||||||
{
|
{
|
||||||
dbgPinHi(1);
|
DEBUG_HI(1);
|
||||||
|
|
||||||
// Set GPIO to input
|
// Set GPIO to input
|
||||||
|
|
||||||
|
@ -208,7 +201,7 @@ void bbSwitchToInput(bbPort_t *bbPort)
|
||||||
|
|
||||||
bbPort->direction = DSHOT_BITBANG_DIRECTION_INPUT;
|
bbPort->direction = DSHOT_BITBANG_DIRECTION_INPUT;
|
||||||
|
|
||||||
dbgPinLo(1);
|
DEBUG_LO(1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "build/debug.h"
|
#include "build/debug.h"
|
||||||
|
#include "build/debug_pin.h"
|
||||||
|
|
||||||
#include "cms/cms.h"
|
#include "cms/cms.h"
|
||||||
#include "cms/cms_types.h"
|
#include "cms/cms_types.h"
|
||||||
|
@ -413,6 +414,10 @@ void init(void)
|
||||||
|
|
||||||
systemState |= SYSTEM_STATE_CONFIG_LOADED;
|
systemState |= SYSTEM_STATE_CONFIG_LOADED;
|
||||||
|
|
||||||
|
#ifdef USE_DEBUG_PIN
|
||||||
|
dbgPinInit();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_SDCARD
|
#ifdef USE_SDCARD
|
||||||
// Ensure the SD card is initialised before the USB MSC starts to avoid a race condition
|
// 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
|
#if !defined(CONFIG_IN_SDCARD) && defined(STM32H7) && defined(USE_SDCARD_SDIO) // H7 only for now, likely should be applied to F4/F7 too
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue