more cleanup
This commit is contained in:
parent
975bc6ad58
commit
7f3eac554e
@ -65,7 +65,7 @@ typedef struct {
|
|||||||
|
|
||||||
uint8 amsReset();
|
uint8 amsReset();
|
||||||
|
|
||||||
uint8 initAMS(SPI_HandleTypeDef* hspi, uint8 numofcells, uint8 numofaux);
|
uint8 initAMS(SPI_HandleTypeDef* hspi);
|
||||||
uint8 amsWakeUp();
|
uint8 amsWakeUp();
|
||||||
|
|
||||||
uint8 amsCellMeasurement(Cell_Module* module);
|
uint8 amsCellMeasurement(Cell_Module* module);
|
||||||
|
@ -30,7 +30,6 @@ extern uint32_t balancedCells;
|
|||||||
extern bool BalancingActive;
|
extern bool BalancingActive;
|
||||||
|
|
||||||
extern uint8_t numberofCells;
|
extern uint8_t numberofCells;
|
||||||
extern uint8_t numberofAux;
|
|
||||||
|
|
||||||
void AMS_Init(SPI_HandleTypeDef* hspi);
|
void AMS_Init(SPI_HandleTypeDef* hspi);
|
||||||
|
|
||||||
|
@ -10,8 +10,7 @@
|
|||||||
#include "ADBMS_LL_Driver.h"
|
#include "ADBMS_LL_Driver.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
uint8 numberofcells;
|
extern uint8 numberofCells;
|
||||||
uint8 numberofauxchannels;
|
|
||||||
|
|
||||||
#define CHECK_RETURN(x) \
|
#define CHECK_RETURN(x) \
|
||||||
{ \
|
{ \
|
||||||
@ -38,11 +37,8 @@ uint8 amsReset() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 initAMS(SPI_HandleTypeDef* hspi, uint8 numofcells, uint8 numofaux) {
|
uint8 initAMS(SPI_HandleTypeDef* hspi) {
|
||||||
adbmsDriverInit(hspi);
|
adbmsDriverInit(hspi);
|
||||||
numberofcells = numofcells;
|
|
||||||
numberofauxchannels = numofaux;
|
|
||||||
|
|
||||||
return amsReset();
|
return amsReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,11 +53,6 @@ uint8 amsCellMeasurement(Cell_Module* module) {
|
|||||||
return amsReadCellVoltages(module);
|
return amsReadCellVoltages(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 amsConfigCellMeasurement(uint8 numberofChannels) {
|
|
||||||
numberofcells = numberofChannels;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8 amsAuxAndStatusMeasurement(Cell_Module* module) {
|
uint8 amsAuxAndStatusMeasurement(Cell_Module* module) {
|
||||||
uint8 rxbuf[AUX_GROUP_A_SIZE] = {};
|
uint8 rxbuf[AUX_GROUP_A_SIZE] = {};
|
||||||
|
|
||||||
@ -194,7 +185,7 @@ uint8 amsCheckUnderOverVoltage(Cell_Module* module) {
|
|||||||
module->overVoltage = 0;
|
module->overVoltage = 0;
|
||||||
module->underVoltage = 0;
|
module->underVoltage = 0;
|
||||||
|
|
||||||
for (size_t i = 0; i < numberofcells; i++) { // ov/uv flags are 1-bit flags for each cell C0UV, C0OV, C1UV, C1OV, ...
|
for (size_t i = 0; i < numberofCells; i++) { // ov/uv flags are 1-bit flags for each cell C0UV, C0OV, C1UV, C1OV, ...
|
||||||
module->underVoltage |= (ov_uv_data >> (i * 2)) & 0x01;
|
module->underVoltage |= (ov_uv_data >> (i * 2)) & 0x01;
|
||||||
module->overVoltage |= (ov_uv_data >> (i * 2 + 1)) & 0x01;
|
module->overVoltage |= (ov_uv_data >> (i * 2 + 1)) & 0x01;
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@
|
|||||||
#include "AMS_HighLevel.h"
|
#include "AMS_HighLevel.h"
|
||||||
#include "ADBMS_Abstraction.h"
|
#include "ADBMS_Abstraction.h"
|
||||||
#include "ADBMS_LL_Driver.h"
|
#include "ADBMS_LL_Driver.h"
|
||||||
|
#include "config_ADBMS6830.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
#include "stm32h7xx_hal.h"
|
#include "stm32h7xx_hal.h"
|
||||||
|
#include "swo_log.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -17,11 +19,7 @@ Cell_Module module = {};
|
|||||||
uint32_t balancedCells = 0;
|
uint32_t balancedCells = 0;
|
||||||
bool balancingActive = false;
|
bool balancingActive = false;
|
||||||
|
|
||||||
uint16_t amsuv = 0;
|
|
||||||
uint16_t amsov = 0;
|
|
||||||
|
|
||||||
uint8_t numberofCells = 15;
|
uint8_t numberofCells = 15;
|
||||||
uint8_t numberofAux = 0;
|
|
||||||
|
|
||||||
uint8_t packetChecksumFails = 0;
|
uint8_t packetChecksumFails = 0;
|
||||||
#define MAX_PACKET_CHECKSUM_FAILS 5
|
#define MAX_PACKET_CHECKSUM_FAILS 5
|
||||||
@ -29,9 +27,6 @@ uint8_t packetChecksumFails = 0;
|
|||||||
uint8_t deviceSleeps = 0;
|
uint8_t deviceSleeps = 0;
|
||||||
#define MAX_DEVICE_SLEEP 3 //TODO: change to correct value
|
#define MAX_DEVICE_SLEEP 3 //TODO: change to correct value
|
||||||
|
|
||||||
amsState currentAMSState = AMSDEACTIVE;
|
|
||||||
amsState lastAMSState = AMSDEACTIVE;
|
|
||||||
|
|
||||||
struct pollingTimes {
|
struct pollingTimes {
|
||||||
uint32_t S_ADC_OW_CHECK;
|
uint32_t S_ADC_OW_CHECK;
|
||||||
uint32_t TMP1075;
|
uint32_t TMP1075;
|
||||||
@ -40,13 +35,10 @@ struct pollingTimes {
|
|||||||
struct pollingTimes pollingTimes = {0, 0};
|
struct pollingTimes pollingTimes = {0, 0};
|
||||||
|
|
||||||
void AMS_Init(SPI_HandleTypeDef* hspi) {
|
void AMS_Init(SPI_HandleTypeDef* hspi) {
|
||||||
initAMS(hspi, numberofCells, numberofAux);
|
debug_log(LOG_LEVEL_INFO, "ADBMS6830B HAL - configured for %d controllers and %d cells per controller...", N_BMS, numberofCells);
|
||||||
amsov = DEFAULT_OV;
|
initAMS(hspi);
|
||||||
amsuv = DEFAULT_UV;
|
|
||||||
|
|
||||||
pollingTimes = (struct pollingTimes) {HAL_GetTick(), HAL_GetTick()};
|
pollingTimes = (struct pollingTimes) {HAL_GetTick(), HAL_GetTick()};
|
||||||
|
|
||||||
currentAMSState = AMSIDLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t AMS_Idle_Loop() {
|
uint8_t AMS_Idle_Loop() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user