From 7b8aae1d31da802439ac096ebbed619943230b9d Mon Sep 17 00:00:00 2001 From: bkleiner Date: Wed, 5 Jul 2023 20:47:40 +0200 Subject: [PATCH] eliminate pwm_failsafe_time --- src/driver/at32/motor_dshot.c | 4 ---- src/driver/motor_dshot.c | 16 ---------------- src/driver/stm32/motor_dshot.c | 4 ---- 3 files changed, 24 deletions(-) diff --git a/src/driver/at32/motor_dshot.c b/src/driver/at32/motor_dshot.c index c19978237..a39225f68 100644 --- a/src/driver/at32/motor_dshot.c +++ b/src/driver/at32/motor_dshot.c @@ -36,7 +36,6 @@ typedef struct { } dshot_gpio_port_t; extern uint16_t dshot_packet[MOTOR_PIN_MAX]; -extern uint32_t pwm_failsafe_time; extern motor_direction_t motor_dir; volatile uint32_t dshot_dma_phase = 0; // 0: idle, 1 - (gpio_port_count + 1): handle port n @@ -168,9 +167,6 @@ void motor_dshot_init() { } tmr_counter_enable(TMR1, TRUE); - - // set failsafetime so signal is off at start - pwm_failsafe_time = time_micros() - 100000; motor_dir = MOTOR_FORWARD; } diff --git a/src/driver/motor_dshot.c b/src/driver/motor_dshot.c index aba232e35..f1d00358d 100644 --- a/src/driver/motor_dshot.c +++ b/src/driver/motor_dshot.c @@ -16,7 +16,6 @@ typedef enum { } dir_change_state_t; uint16_t dshot_packet[MOTOR_PIN_MAX]; // 16bits dshot data for 4 motors -uint32_t pwm_failsafe_time = 1; motor_direction_t motor_dir = MOTOR_FORWARD; static bool dir_change_done = true; @@ -46,27 +45,12 @@ void motor_dshot_write(float *values) { if (dir_change_done) { for (uint32_t i = 0; i < MOTOR_PIN_MAX; i++) { uint16_t value = 0; - if (values[i] >= 0.0f) { const float pwm = constrainf(values[i], 0.0f, 1.0f); value = mapf(pwm, 0.0f, 1.0f, 48, 2047); } else { value = 0; } - - if (flags.failsafe && !flags.motortest_override) { - if (!pwm_failsafe_time) { - pwm_failsafe_time = time_micros(); - } else if (time_micros() - pwm_failsafe_time > 4000000) { - // 1s after failsafe we turn off the signal for safety - // this means the escs won't rearm correctly after 2 secs of signal lost - // usually the quad should be gone by then - value = 0; - } - } else { - pwm_failsafe_time = 0; - } - dshot_make_packet(profile.motor.motor_pins[i], value, false); } diff --git a/src/driver/stm32/motor_dshot.c b/src/driver/stm32/motor_dshot.c index 71e864d51..9914171f7 100644 --- a/src/driver/stm32/motor_dshot.c +++ b/src/driver/stm32/motor_dshot.c @@ -36,7 +36,6 @@ typedef struct { } dshot_gpio_port_t; extern uint16_t dshot_packet[MOTOR_PIN_MAX]; -extern uint32_t pwm_failsafe_time; extern motor_direction_t motor_dir; volatile uint32_t dshot_dma_phase = 0; // 0: idle, 1 - (gpio_port_count + 1): handle port n @@ -198,9 +197,6 @@ void motor_dshot_init() { } LL_TIM_EnableCounter(TIM1); - - // set failsafetime so signal is off at start - pwm_failsafe_time = time_micros() - 100000; motor_dir = MOTOR_FORWARD; }