mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-23 16:25:26 +03:00
Allow number of servos exceed pwm outputs, if servo protocol is sbus_pwm
This commit is contained in:
parent
265cd57c20
commit
ac03ee3c16
3 changed files with 12 additions and 3 deletions
|
@ -42,6 +42,7 @@
|
|||
#include "sensors/rangefinder.h"
|
||||
|
||||
#include "io/serial.h"
|
||||
#include "io/servo_sbus.h"
|
||||
|
||||
enum {
|
||||
MAP_TO_NONE,
|
||||
|
@ -442,15 +443,21 @@ static void pwmInitServos(timMotorServoHardware_t * timOutputs)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
// If mixer requests more servos than we have timer outputs - throw an error
|
||||
if (servoCount > timOutputs->maxTimServoCount) {
|
||||
uint16_t maxServos = timOutputs->maxTimServoCount;
|
||||
if(servoConfig()->servo_protocol == SERVO_TYPE_SBUS_PWM) {
|
||||
maxServos = MAX(SERVO_SBUS_MAX_SERVOS, timOutputs->maxTimServoCount);
|
||||
}
|
||||
|
||||
if (servoCount > maxServos) {
|
||||
pwmInitError = PWM_INIT_ERROR_NOT_ENOUGH_SERVO_OUTPUTS;
|
||||
LOG_ERROR(PWM, "Too many servos. Mixer requested %d, timer outputs %d", servoCount, timOutputs->maxTimServoCount);
|
||||
return;
|
||||
}
|
||||
|
||||
// Configure individual servo outputs
|
||||
for (int idx = 0; idx < servoCount; idx++) {
|
||||
for (int idx = 0; idx < MIN(servoCount, timOutputs->maxTimServoCount); idx++) {
|
||||
const timerHardware_t *timHw = timOutputs->timServos[idx];
|
||||
|
||||
if (!pwmServoConfig(timHw, idx, servoConfig()->servoPwmRate, servoConfig()->servoCenterPulse, feature(FEATURE_PWM_OUTPUT_ENABLE))) {
|
||||
|
|
|
@ -638,7 +638,7 @@ ioTag_t pwmGetMotorPinTag(int motorIndex)
|
|||
|
||||
static void pwmServoWriteStandard(uint8_t index, uint16_t value)
|
||||
{
|
||||
if (servos[index]) {
|
||||
if (index < MAX_SERVOS && servos[index]) {
|
||||
*servos[index]->ccr = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define SERVO_SBUS_MAX_SERVOS 18
|
||||
|
||||
bool sbusServoInitialize(void);
|
||||
void sbusServoUpdate(uint8_t index, uint16_t value);
|
||||
void sbusServoSendUpdate(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue