mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Fix board wedging if motor DMA is undefined for Dshot.
This commit is contained in:
parent
b310f9b348
commit
a77f658b22
5 changed files with 35 additions and 25 deletions
|
@ -179,22 +179,26 @@ motorDevice_t *dshotPwmDevInit(const motorDevConfig_t *motorConfig, uint16_t idl
|
|||
const ioTag_t tag = motorConfig->ioTags[motorIndex];
|
||||
const timerHardware_t *timerHardware = timerAllocate(tag, OWNER_MOTOR, RESOURCE_INDEX(motorIndex));
|
||||
|
||||
if (timerHardware == NULL) {
|
||||
/* not enough motors initialised for the mixer or a break in the motors */
|
||||
dshotPwmDevice.vTable.write = motorWriteNull;
|
||||
dshotPwmDevice.vTable.updateComplete = motorUpdateCompleteNull;
|
||||
/* TODO: block arming and add reason system cannot arm */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (timerHardware != NULL) {
|
||||
motors[motorIndex].io = IOGetByTag(tag);
|
||||
IOInit(motors[motorIndex].io, OWNER_MOTOR, RESOURCE_INDEX(motorIndex));
|
||||
|
||||
pwmDshotMotorHardwareConfig(timerHardware,
|
||||
if (pwmDshotMotorHardwareConfig(timerHardware,
|
||||
motorIndex,
|
||||
motorConfig->motorPwmProtocol,
|
||||
motorConfig->motorPwmInversion ? timerHardware->output ^ TIMER_OUTPUT_INVERTED : timerHardware->output);
|
||||
motorConfig->motorPwmInversion ? timerHardware->output ^ TIMER_OUTPUT_INVERTED : timerHardware->output)) {
|
||||
motors[motorIndex].enabled = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* not enough motors initialised for the mixer or a break in the motors */
|
||||
dshotPwmDevice.vTable.write = motorWriteNull;
|
||||
dshotPwmDevice.vTable.updateComplete = motorUpdateCompleteNull;
|
||||
|
||||
/* TODO: block arming and add reason system cannot arm */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &dshotPwmDevice;
|
||||
|
|
|
@ -161,7 +161,7 @@ motorDmaOutput_t *getMotorDmaOutput(uint8_t index);
|
|||
bool isMotorProtocolDshot(void);
|
||||
|
||||
void pwmWriteDshotInt(uint8_t index, uint16_t value);
|
||||
void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, motorPwmProtocolTypes_e pwmProtocolType, uint8_t output);
|
||||
bool pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, motorPwmProtocolTypes_e pwmProtocolType, uint8_t output);
|
||||
#ifdef USE_DSHOT_TELEMETRY
|
||||
bool pwmStartDshotMotorUpdate(void);
|
||||
#endif
|
||||
|
|
|
@ -205,7 +205,7 @@ static void motor_DMA_IRQHandler(dmaChannelDescriptor_t *descriptor)
|
|||
}
|
||||
}
|
||||
|
||||
void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, motorPwmProtocolTypes_e pwmProtocolType, uint8_t output)
|
||||
bool pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, motorPwmProtocolTypes_e pwmProtocolType, uint8_t output)
|
||||
{
|
||||
#ifdef USE_DSHOT_TELEMETRY
|
||||
#define OCINIT motor->ocInitStruct
|
||||
|
@ -247,7 +247,7 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
|
|||
#endif
|
||||
|
||||
if (dmaRef == NULL) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
motorDmaOutput_t * const motor = &dmaMotors[motorIndex];
|
||||
|
@ -423,6 +423,8 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
|
|||
}
|
||||
#endif
|
||||
motor->configured = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -181,7 +181,7 @@ static void motor_DMA_IRQHandler(dmaChannelDescriptor_t* descriptor)
|
|||
}
|
||||
}
|
||||
|
||||
void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, motorPwmProtocolTypes_e pwmProtocolType, uint8_t output)
|
||||
bool pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, motorPwmProtocolTypes_e pwmProtocolType, uint8_t output)
|
||||
{
|
||||
#ifdef USE_DSHOT_TELEMETRY
|
||||
#define OCINIT motor->ocInitStruct
|
||||
|
@ -215,7 +215,7 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
|
|||
#endif
|
||||
|
||||
if (dmaRef == NULL) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
motorDmaOutput_t * const motor = &dmaMotors[motorIndex];
|
||||
|
@ -381,5 +381,7 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
|
|||
}
|
||||
#endif
|
||||
motor->configured = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -233,7 +233,7 @@ static void motor_DMA_IRQHandler(dmaChannelDescriptor_t* descriptor)
|
|||
}
|
||||
}
|
||||
|
||||
void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, motorPwmProtocolTypes_e pwmProtocolType, uint8_t output)
|
||||
bool pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t motorIndex, motorPwmProtocolTypes_e pwmProtocolType, uint8_t output)
|
||||
{
|
||||
dmaResource_t *dmaRef = NULL;
|
||||
uint32_t dmaChannel;
|
||||
|
@ -266,7 +266,7 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
|
|||
#endif
|
||||
|
||||
if (dmaRef == NULL) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
motorDmaOutput_t * const motor = &dmaMotors[motorIndex];
|
||||
|
@ -298,7 +298,7 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
|
|||
|
||||
if (result != HAL_OK) {
|
||||
/* Initialization Error */
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -334,7 +334,7 @@ P - High - High -
|
|||
|
||||
if (result != HAL_OK) {
|
||||
/* Configuration Error */
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// DMA setup
|
||||
|
@ -347,7 +347,7 @@ P - High - High -
|
|||
|
||||
if (!configureTimer) {
|
||||
motor->configured = true;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
|
@ -418,7 +418,7 @@ P - High - High -
|
|||
|
||||
if (result != HAL_OK) {
|
||||
/* Initialization Error */
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
dmaIdentifier_e identifier = dmaGetIdentifier(dmaRef);
|
||||
|
@ -444,9 +444,11 @@ P - High - High -
|
|||
|
||||
if (result != HAL_OK) {
|
||||
/* Starting PWM generation Error */
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
motor->configured = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue