mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
Move Brushed ESC auto detection into seperate source files
pwm_output.c and pwm_output_hal.c are used aternativly
This commit is contained in:
parent
d93224be06
commit
07f7b20aec
10 changed files with 90 additions and 38 deletions
|
@ -24,7 +24,6 @@
|
|||
#include "io.h"
|
||||
#include "timer.h"
|
||||
#include "pwm_output.h"
|
||||
#include "system.h"
|
||||
|
||||
#define MULTISHOT_5US_PW (MULTISHOT_TIMER_MHZ * 5)
|
||||
#define MULTISHOT_20US_MULT (MULTISHOT_TIMER_MHZ * 20 / 1000.0f)
|
||||
|
@ -281,28 +280,3 @@ void servoInit(const servoConfig_t *servoConfig)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BRUSHED_ESC_AUTODETECT
|
||||
uint8_t hardwareMotorType = MOTOR_UNKNOWN;
|
||||
|
||||
void detectBrushedESC(void)
|
||||
{
|
||||
int i = 0;
|
||||
while (!(timerHardware[i].usageFlags & TIM_USE_MOTOR) && (i < USABLE_TIMER_CHANNEL_COUNT)) {
|
||||
i++;
|
||||
}
|
||||
|
||||
IO_t MotorDetectPin = IOGetByTag(timerHardware[i].tag);
|
||||
IOInit(MotorDetectPin, OWNER_SYSTEM, 0);
|
||||
IOConfigGPIO(MotorDetectPin, IOCFG_IPU);
|
||||
|
||||
delayMicroseconds(10); // allow configuration to settle
|
||||
|
||||
// Check presence of brushed ESC's
|
||||
if (IORead(MotorDetectPin)) {
|
||||
hardwareMotorType = MOTOR_BRUSHLESS;
|
||||
} else {
|
||||
hardwareMotorType = MOTOR_BRUSHED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue