mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Merged in f5soh/librepilot/LP-233_OneShot42 (pull request #236)
LP-233 Support OneShot42
This commit is contained in:
commit
4cbd4ea926
@ -61,23 +61,25 @@ static int8_t counter;
|
||||
#endif
|
||||
|
||||
// Private constants
|
||||
#define MAX_QUEUE_SIZE 2
|
||||
#define MAX_QUEUE_SIZE 2
|
||||
|
||||
#if defined(PIOS_ACTUATOR_STACK_SIZE)
|
||||
#define STACK_SIZE_BYTES PIOS_ACTUATOR_STACK_SIZE
|
||||
#define STACK_SIZE_BYTES PIOS_ACTUATOR_STACK_SIZE
|
||||
#else
|
||||
#define STACK_SIZE_BYTES 1312
|
||||
#define STACK_SIZE_BYTES 1312
|
||||
#endif
|
||||
|
||||
#define TASK_PRIORITY (tskIDLE_PRIORITY + 4) // device driver
|
||||
#define FAILSAFE_TIMEOUT_MS 100
|
||||
#define MAX_MIX_ACTUATORS ACTUATORCOMMAND_CHANNEL_NUMELEM
|
||||
#define TASK_PRIORITY (tskIDLE_PRIORITY + 4) // device driver
|
||||
#define FAILSAFE_TIMEOUT_MS 100
|
||||
#define MAX_MIX_ACTUATORS ACTUATORCOMMAND_CHANNEL_NUMELEM
|
||||
|
||||
#define CAMERA_BOOT_DELAY_MS 7000
|
||||
#define CAMERA_BOOT_DELAY_MS 7000
|
||||
|
||||
#define ACTUATOR_ONESHOT125_CLOCK 2000000
|
||||
#define ACTUATOR_ONESHOT125_PULSE_SCALE 4
|
||||
#define ACTUATOR_PWM_CLOCK 1000000
|
||||
#define ACTUATOR_ONESHOT_CLOCK 12000000
|
||||
#define ACTUATOR_ONESHOT125_PULSE_FACTOR 1.5f
|
||||
#define ACTUATOR_ONESHOT42_PULSE_FACTOR 0.5f
|
||||
#define ACTUATOR_MULTISHOT_PULSE_FACTOR 0.24f
|
||||
#define ACTUATOR_PWM_CLOCK 1000000
|
||||
// Private types
|
||||
|
||||
|
||||
@ -938,8 +940,16 @@ static bool set_channel(uint8_t mixer_channel, uint16_t value)
|
||||
uint8_t mode = pinsMode[actuatorSettings.ChannelAddr[mixer_channel]];
|
||||
switch (mode) {
|
||||
case ACTUATORSETTINGS_BANKMODE_ONESHOT125:
|
||||
// Remap 1000-2000 range to 125-250
|
||||
PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value / ACTUATOR_ONESHOT125_PULSE_SCALE);
|
||||
// Remap 1000-2000 range to 125-250µs
|
||||
PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value * ACTUATOR_ONESHOT125_PULSE_FACTOR);
|
||||
break;
|
||||
case ACTUATORSETTINGS_BANKMODE_ONESHOT42:
|
||||
// Remap 1000-2000 range to 41,666-83,333µs
|
||||
PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value * ACTUATOR_ONESHOT42_PULSE_FACTOR);
|
||||
break;
|
||||
case ACTUATORSETTINGS_BANKMODE_MULTISHOT:
|
||||
// Remap 1000-2000 range to 5-25µs
|
||||
PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], (value * ACTUATOR_MULTISHOT_PULSE_FACTOR) - 180);
|
||||
break;
|
||||
default:
|
||||
PIOS_Servo_Set(actuatorSettings.ChannelAddr[mixer_channel], value);
|
||||
@ -991,8 +1001,10 @@ static void actuator_update_rate_if_changed(bool force_update)
|
||||
}
|
||||
switch (actuatorSettings.BankMode[i]) {
|
||||
case ACTUATORSETTINGS_BANKMODE_ONESHOT125:
|
||||
case ACTUATORSETTINGS_BANKMODE_ONESHOT42:
|
||||
case ACTUATORSETTINGS_BANKMODE_MULTISHOT:
|
||||
freq[i] = 100; // Value must be small enough so CCr isn't update until the PIOS_Servo_Update is triggered
|
||||
clock[i] = ACTUATOR_ONESHOT125_CLOCK; // Setup an 2MHz timer clock
|
||||
clock[i] = ACTUATOR_ONESHOT_CLOCK; // Setup an 12MHz timer clock
|
||||
break;
|
||||
case ACTUATORSETTINGS_BANKMODE_PWMSYNC:
|
||||
freq[i] = 100;
|
||||
|
@ -954,7 +954,9 @@ SystemAlarmsExtendedAlarmStatusOptions CopterControlConfigHook()
|
||||
if ((recmode == HWSETTINGS_CC_RCVRPORT_PPM_PIN8ONESHOT ||
|
||||
flexiMode == HWSETTINGS_CC_FLEXIPORT_PPM) &&
|
||||
(modes[3] == ACTUATORSETTINGS_BANKMODE_PWMSYNC ||
|
||||
modes[3] == ACTUATORSETTINGS_BANKMODE_ONESHOT125)) {
|
||||
modes[3] == ACTUATORSETTINGS_BANKMODE_ONESHOT125 ||
|
||||
modes[3] == ACTUATORSETTINGS_BANKMODE_ONESHOT42 ||
|
||||
modes[3] == ACTUATORSETTINGS_BANKMODE_MULTISHOT)) {
|
||||
return SYSTEMALARMS_EXTENDEDALARMSTATUS_UNSUPPORTEDCONFIG_ONESHOT;
|
||||
} else {
|
||||
return SYSTEMALARMS_EXTENDEDALARMSTATUS_NONE;
|
||||
@ -967,7 +969,9 @@ SystemAlarmsExtendedAlarmStatusOptions CopterControlConfigHook()
|
||||
case HWSETTINGS_CC_RCVRPORT_PWMNOONESHOT:
|
||||
for (uint8_t i = 0; i < ACTUATORSETTINGS_BANKMODE_NUMELEM; i++) {
|
||||
if (modes[i] == ACTUATORSETTINGS_BANKMODE_PWMSYNC ||
|
||||
modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT125) {
|
||||
modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT125 ||
|
||||
modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT42 ||
|
||||
modes[i] == ACTUATORSETTINGS_BANKMODE_MULTISHOT) {
|
||||
return SYSTEMALARMS_EXTENDEDALARMSTATUS_UNSUPPORTEDCONFIG_ONESHOT;;
|
||||
}
|
||||
|
||||
|
@ -893,7 +893,9 @@ SystemAlarmsExtendedAlarmStatusOptions RevoNanoConfigHook()
|
||||
case HWSETTINGS_RM_RCVRPORT_PWM:
|
||||
for (uint8_t i = 0; i < ACTUATORSETTINGS_BANKMODE_NUMELEM; i++) {
|
||||
if (modes[i] == ACTUATORSETTINGS_BANKMODE_PWMSYNC ||
|
||||
modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT125) {
|
||||
modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT125 ||
|
||||
modes[i] == ACTUATORSETTINGS_BANKMODE_ONESHOT42 ||
|
||||
modes[i] == ACTUATORSETTINGS_BANKMODE_MULTISHOT) {
|
||||
return SYSTEMALARMS_EXTENDEDALARMSTATUS_UNSUPPORTEDCONFIG_ONESHOT;;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
<object name="ActuatorSettings" singleinstance="true" settings="true" category="Control">
|
||||
<description>Settings for the @ref ActuatorModule that controls the channel assignments for the mixer based on AircraftType</description>
|
||||
<field name="BankUpdateFreq" units="Hz" type="uint16" elements="6" defaultvalue="50"/>
|
||||
<field name="BankMode" type="enum" units="" elements="6" options="PWM,PWMSync,OneShot125" defaultvalue="PWM"/>
|
||||
<field name="BankMode" type="enum" units="" elements="6" options="PWM,PWMSync,OneShot125,OneShot42,MultiShot" defaultvalue="PWM"/>
|
||||
<field name="ChannelMax" units="us" type="int16" elements="12" defaultvalue="1000"/>
|
||||
<field name="ChannelNeutral" units="us" type="int16" elements="12" defaultvalue="1000"/>
|
||||
<field name="ChannelMin" units="us" type="int16" elements="12" defaultvalue="1000"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user