54 lines
1.1 KiB
C
54 lines
1.1 KiB
C
|
/*
|
||
|
* BQ_Abstraction_Layer.h
|
||
|
*
|
||
|
* Created on: 29.01.2022
|
||
|
* Author: max
|
||
|
*/
|
||
|
|
||
|
#ifndef INC_BQ_ABSTRACTION_LAYER_H_
|
||
|
#define INC_BQ_ABSTRACTION_LAYER_H_
|
||
|
|
||
|
#include "common_defs.h"
|
||
|
#include "main.h"
|
||
|
|
||
|
#include "stm32f4xx_hal.h"
|
||
|
|
||
|
#define WAKEUP_PIN BQ_Wakeup_Pin
|
||
|
#define WAKEUP_PORT BQ_Wakeup_GPIO_Port
|
||
|
|
||
|
#define CELL_OV_THRESHOLD 55100 // 4.2V
|
||
|
#define CELL_UV_THRESHOLD 34100 // 2.6V
|
||
|
|
||
|
#define BQ_RDY 1
|
||
|
#define BQ_STDBY 2
|
||
|
#define BQ_OFF 0
|
||
|
#define BQ_INIT_PHASE 3
|
||
|
#define BQ_ERROR 4
|
||
|
|
||
|
extern uint16_t cell_voltages[N_CELLS];
|
||
|
|
||
|
extern uint8_t bq_status;
|
||
|
extern uint32_t lastmeasurementtime;
|
||
|
|
||
|
void afe_init(UART_HandleTypeDef* uarthandle);
|
||
|
void afe_shutdown();
|
||
|
void afe_measure();
|
||
|
void afe_selftest();
|
||
|
void afe_wakeup();
|
||
|
void afe_init_fault_thresholds();
|
||
|
|
||
|
void afe_clear_all_faults();
|
||
|
void afe_check_faults();
|
||
|
|
||
|
void afe_update_Checksum();
|
||
|
|
||
|
void afe_config_measurement_channels();
|
||
|
void afe_config_communication();
|
||
|
void afe_config_balancing();
|
||
|
void afe_balance_channels(uint16_t channelstobalance);
|
||
|
|
||
|
void afe_config_gpios();
|
||
|
void afe_activate_LED();
|
||
|
|
||
|
#endif /* INC_BQ_ABSTRACTION_LAYER_H_ */
|