|
|
@@ -12,6 +12,7 @@ static float _start_v, _end_v;
|
|
|
static bool _auto_detect_sv = true;
|
|
|
static int _auto_detect_sv_cnt = 0;
|
|
|
static float _auto_detect_sv_totle = 0;
|
|
|
+static int _detect_release_cnt = 0;
|
|
|
#define CONFIG_SAFE_INV_V 0.06f
|
|
|
|
|
|
void throttle_init(void) {
|
|
|
@@ -95,6 +96,22 @@ bool throttle_is_released(void) {
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
+bool throttle_not_released_err(void)
|
|
|
+{
|
|
|
+ return ((err_mask & THRO_NOT_RELEASED) != 0);
|
|
|
+}
|
|
|
+
|
|
|
+void throttle_force_detect(void) {
|
|
|
+ u32 mask = cpu_enter_critical();
|
|
|
+ throttle_init();
|
|
|
+ _auto_detect_sv = true;
|
|
|
+ _auto_detect_sv_cnt = 0;
|
|
|
+ _auto_detect_sv_totle = 0;
|
|
|
+ _detect_release_cnt = 0;
|
|
|
+ err_mask = 0; //clear err mask
|
|
|
+ cpu_exit_critical(mask);
|
|
|
+}
|
|
|
+
|
|
|
void throttle_detect(bool ready) {
|
|
|
float thr_5v = get_thro_5v_float();
|
|
|
float thr_sig = get_throttle_float();
|
|
|
@@ -120,9 +137,16 @@ void throttle_detect(bool ready) {
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
+ if (!ready && throttle_get_signal() > _start_v) {
|
|
|
+ if (_detect_release_cnt < 500) {
|
|
|
+ _detect_release_cnt ++;
|
|
|
+ }else {
|
|
|
+ err_mask |= THRO_NOT_RELEASED;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (ready) {
|
|
|
_auto_detect_sv = false;
|
|
|
- }else if (!throttle_is_all_error() && !ready && _auto_detect_sv) {
|
|
|
+ }else if (!throttle_is_all_error() && !throttle_not_released_err() && !ready && _auto_detect_sv) {
|
|
|
float v = throttle_get_signal();
|
|
|
if (v < _start_v) {
|
|
|
_auto_detect_sv_totle += v;
|