change slave_monitoring header to new battery header
This commit is contained in:
parent
babea2e805
commit
ccf0c3f665
15
AMS_Master_Code/Core/Inc/battery.h
Normal file
15
AMS_Master_Code/Core/Inc/battery.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#ifndef __BATTERY_H
|
||||
#define __BATTERY_H
|
||||
#include "config_ADBMS6830.h"
|
||||
#include "stm32h7xx_hal.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
extern uint16_t min_voltage;
|
||||
extern int16_t max_temp;
|
||||
|
||||
void battery_init(SPI_HandleTypeDef* hspi);
|
||||
void battery_update();
|
||||
|
||||
#endif // __BATTERY_H
|
29
AMS_Master_Code/Core/Src/battery.c
Normal file
29
AMS_Master_Code/Core/Src/battery.c
Normal file
@ -0,0 +1,29 @@
|
||||
#include "battery.h"
|
||||
#include "ADBMS_Driver.h"
|
||||
|
||||
uint16_t min_voltage = 0xFFFF;
|
||||
int16_t max_temp = -1;
|
||||
|
||||
void battery_init(SPI_HandleTypeDef* hspi) {
|
||||
AMS_Init(hspi);
|
||||
}
|
||||
|
||||
void battery_update() {
|
||||
if (AMS_Idle_Loop().status != ADBMS_NO_ERROR
|
||||
) {
|
||||
// Handle error
|
||||
return;
|
||||
}
|
||||
for (size_t i = 0; i < N_BMS; i++) {
|
||||
for (size_t j = 0; j < N_CELLS; j++) {
|
||||
if (modules[i].cellVoltages[j] > min_voltage) {
|
||||
min_voltage = modules[i].cellVoltages[j];
|
||||
}
|
||||
if (modules[i].cellTemps[0] > max_temp) {
|
||||
//refactor this to use ntc_mv_to_celsius
|
||||
// max_temp = ntc_mv_to_celsius(modules[i].auxVoltages[j]);
|
||||
max_temp = modules[i].cellTemps[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
#include "imd_monitoring.h"
|
||||
#include "main.h"
|
||||
#include "shunt_monitoring.h"
|
||||
//#include "slave_monitoring.h"
|
||||
#include "battery.h"
|
||||
#include "soc_estimation.h"
|
||||
#include "ts_state_machine.h"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "soc_estimation.h"
|
||||
|
||||
#include "shunt_monitoring.h"
|
||||
#include "slave_monitoring.h"
|
||||
#include "battery.h"
|
||||
|
||||
#include "stm32h7xx_hal.h"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user