change slave_monitoring header to new battery header

This commit is contained in:
Kilian Bracher 2025-04-11 14:29:12 +02:00
parent babea2e805
commit ccf0c3f665
Signed by: k.bracher
SSH Key Fingerprint: SHA256:mXpyZkK7RDiJ7qeHCKJX108woM0cl5TrCvNBJASu6lM
4 changed files with 46 additions and 2 deletions

View 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

View 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];
}
}
}
}

View File

@ -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"

View File

@ -1,7 +1,7 @@
#include "soc_estimation.h"
#include "shunt_monitoring.h"
#include "slave_monitoring.h"
#include "battery.h"
#include "stm32h7xx_hal.h"