mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Generalize brushed ESC auto detection
Used for all AlienFlight and SPRACINGF3EVO targets
This commit is contained in:
parent
678d2f81ba
commit
590b01a77e
17 changed files with 65 additions and 155 deletions
|
@ -24,6 +24,7 @@
|
|||
#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)
|
||||
|
@ -280,3 +281,28 @@ 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