PWM:Add Channel mask to up_pwm_servo_arm & up_pwm_servo_deinit

This commit is contained in:
David Sidrane
2021-05-05 20:48:06 +02:00
committed by Lorenz Meier
parent 19fa5cfe25
commit 3d166d3279
7 changed files with 46 additions and 32 deletions
+14 -2
View File
@@ -317,8 +317,14 @@ __EXPORT extern int up_pwm_servo_init(uint32_t channel_mask);
/**
* De-initialise the PWM servo outputs.
*
* @param channel_mask Bitmask of channels (LSB = channel 0) to enable.
* This allows some of the channels to remain configured
* as GPIOs or as another function.
* A value of 0 is ALL channels
*
*/
__EXPORT extern void up_pwm_servo_deinit(void);
__EXPORT extern void up_pwm_servo_deinit(uint32_t channel_mask);
/**
* Arm or disarm servo outputs.
@@ -330,8 +336,14 @@ __EXPORT extern void up_pwm_servo_deinit(void);
*
* @param armed If true, outputs are armed; if false they
* are disarmed.
*
* @param channel_mask Bitmask of channels (LSB = channel 0) to enable.
* This allows some of the channels to remain configured
* as GPIOs or as another function.
* A value of 0 is ALL channels
*
*/
__EXPORT extern void up_pwm_servo_arm(bool armed);
__EXPORT extern void up_pwm_servo_arm(bool armed, uint32_t channel_mask);
/**
* Set the servo update rate for all rate groups.
+10 -8
View File
@@ -69,7 +69,7 @@ PWMOut::PWMOut(int instance, uint8_t output_base) :
PWMOut::~PWMOut()
{
/* make sure servos are off */
up_pwm_servo_deinit(); // TODO: review for multi
up_pwm_servo_deinit(_pwm_mask);
/* clean up the alternate device node */
unregister_class_devname(PWM_OUTPUT_BASE_DEVICE_PATH, _class_instance);
@@ -331,18 +331,20 @@ int PWMOut::set_mode(Mode mode)
_num_outputs = 0;
_mixing_output.setMaxNumOutputs(_num_outputs);
update_params();
if (old_mask != _pwm_mask) {
/* disable servo outputs - no need to set rates */
up_pwm_servo_deinit(); // TODO: review for multi
}
break;
default:
return -EINVAL;
}
if (old_mask != _pwm_mask) {
/* disable servo outputs - no need to set rates */
if (old_mask != 0) {
up_pwm_servo_deinit(old_mask);
_pwm_on = false;
}
}
_mode = mode;
return OK;
}
@@ -563,7 +565,7 @@ void PWMOut::update_pwm_out_state(bool on)
_pwm_initialized = true;
}
up_pwm_servo_arm(on);
up_pwm_servo_arm(on, _pwm_mask);
}
bool PWMOut::updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS],