Add BQ soft reset function
This commit is contained in:
		@ -51,6 +51,7 @@ extern BQ_Error_Description bq_error;
 | 
				
			|||||||
extern uint32_t lastmeasurementtime;
 | 
					extern uint32_t lastmeasurementtime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void afe_init(UART_HandleTypeDef* uarthandle);
 | 
					void afe_init(UART_HandleTypeDef* uarthandle);
 | 
				
			||||||
 | 
					void afe_soft_reset();
 | 
				
			||||||
void afe_shutdown();
 | 
					void afe_shutdown();
 | 
				
			||||||
void afe_measure();
 | 
					void afe_measure();
 | 
				
			||||||
void afe_selftest();
 | 
					void afe_selftest();
 | 
				
			||||||
 | 
				
			|||||||
@ -188,6 +188,8 @@
 | 
				
			|||||||
#define EE_BURN_SIZE 0x01
 | 
					#define EE_BURN_SIZE 0x01
 | 
				
			||||||
#define MAGIC2_SIZE 0x04
 | 
					#define MAGIC2_SIZE 0x04
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DEV_CNTRL_SOFT_RESET (1 << 7)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define GPI_FAULT_SUM (1 << 6)
 | 
					#define GPI_FAULT_SUM (1 << 6)
 | 
				
			||||||
#define CHIP_FAULT_SUM (1 << 7)
 | 
					#define CHIP_FAULT_SUM (1 << 7)
 | 
				
			||||||
#define SYS_FAULT_SUM (1 << 8)
 | 
					#define SYS_FAULT_SUM (1 << 8)
 | 
				
			||||||
 | 
				
			|||||||
@ -44,8 +44,15 @@ void afe_init(UART_HandleTypeDef* uarthandle) {
 | 
				
			|||||||
  afe_wakeup();
 | 
					  afe_wakeup();
 | 
				
			||||||
  HAL_Delay(10);
 | 
					  HAL_Delay(10);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  afe_soft_reset();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void afe_soft_reset() {
 | 
				
			||||||
  bq_status = BQ_INIT_PHASE;
 | 
					  bq_status = BQ_INIT_PHASE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  BQ_Write_Register(DEV_CNTRL, DEV_CNTRL_SIZE, DEV_CNTRL_SOFT_RESET);
 | 
				
			||||||
 | 
					  HAL_Delay(10);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  afe_config_communication();
 | 
					  afe_config_communication();
 | 
				
			||||||
  afe_config_measurement_channels();
 | 
					  afe_config_measurement_channels();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user