소스 검색

wait voltage down when charge insert

Signed-off-by: FuangCao <cavan.cao@foxmail.com>
FuangCao 5 년 전
부모
커밋
914142726e
5개의 변경된 파일37개의 추가작업 그리고 10개의 파일을 삭제
  1. 1 1
      Project/version.txt
  2. 22 2
      Source/app.c
  3. 11 6
      Source/drv_io.c
  4. 2 0
      Source/drv_io.h
  5. 1 1
      Source/sw_build_info.h

+ 1 - 1
Project/version.txt

@@ -1 +1 @@
-PS100XX_V11_12181836
+PS100XX_V11_12191912

+ 22 - 2
Source/app.c

@@ -123,11 +123,31 @@ shark_bool battery_wait_voltage_parallel(void)
 	voltage_min = voltage_max - SHARK_BATT_VOLTAGE_FUZZ;
 
 	if (shark_charger_state != SHARK_CHG_REMOVE) {
+		voltage_max = SHARK_CHARGER_VOLTAGE_MAX;
+
 		if (QD_Dect() == 0) {
+			time1 = shark_get_mseconds() + 2000;
+
+			while (shark_get_mseconds() < time1 && Measure_Vol() > voltage_max) {
+				if (ACC2_Is_On() == 0) {
+					ACC2_Enable_Force(1);
+				}
+
+				gpio_bit_set(GPIOB, GPIO_PIN_0);
+				gpio_bit_set(GPIOB, GPIO_PIN_1);
+				gpio_bit_set(GPIOC, GPIO_PIN_6);
+				gpio_bit_set(GPIOC, GPIO_PIN_7);
+
+				fwdgt_counter_reload();
+			}
+
+			gpio_bit_reset(GPIOB, GPIO_PIN_0);
+			gpio_bit_reset(GPIOB, GPIO_PIN_1);
+			gpio_bit_reset(GPIOC, GPIO_PIN_6);
+			gpio_bit_reset(GPIOC, GPIO_PIN_7);
+
 			return shark_true;
 		}
-
-		voltage_max = SHARK_CHARGER_VOLTAGE_MAX;
 	} else {
 		voltage_max += SHARK_BATT_VOLTAGE_FUZZ;
 	}

+ 11 - 6
Source/drv_io.c

@@ -97,13 +97,8 @@ void ACC2_PWM(void)
 #endif
 }
 
-void ACC2_Enable(uint8_t on)
+void ACC2_Enable_Force(uint8_t on)
 {
-	if (shark_battery_switch_busy && on) {
-		println("acc2 busy");
-		return;
-	}
-
 	println("acc2: %d", on);
 
 	shark_bms_acc2_enabled = on;
@@ -114,6 +109,16 @@ void ACC2_Enable(uint8_t on)
 	gpio_bit_write(GPIO_PORT_ACC2_EN, GPIO_PIN_ACC2_EN, (bit_status) on);
 }
 
+void ACC2_Enable(uint8_t on)
+{
+	if (shark_battery_switch_busy && on) {
+		println("acc2 busy");
+		return;
+	}
+
+	ACC2_Enable_Force(on);
+}
+
 void E_CTR_Dec_IRQ_Initial(void)
 {
 	rcu_periph_clock_enable(RCU_AF);

+ 2 - 0
Source/drv_io.h

@@ -102,6 +102,8 @@ void E_CTR_Initial(void);
 
 void ACC2_PWM(void);
 
+void ACC2_Enable_Force(uint8_t on);
+
 void ACC2_Enable(uint8_t on);
 
 void QD_Enable_From(uint8_t on,uint8_t from);

+ 1 - 1
Source/sw_build_info.h

@@ -1,3 +1,3 @@
 #pragma once
 
-#define CONFIG_VERSION "PS100XX_V11_12181836"
+#define CONFIG_VERSION "PS100XX_V11_12191912"