Skip to content

Commit

Permalink
adbms cleaning up balancing and removing LTC driver from make file
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabramz committed Dec 26, 2024
1 parent 6791c57 commit 93379f0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
11 changes: 0 additions & 11 deletions Core/Inc/segment.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef SEGMENT_H
#define SEGMENT_H

#include "ltc68041.h"
#include "bmsConfig.h"
#include "datastructs.h"

Expand All @@ -24,16 +23,6 @@ void segment_retrieve_data(acc_data_t *bmsdata);
*/
void segment_disable_balancing(cell_asic chips[NUM_CHIPS]);

/**
* @brief Enables/disables balancing for a specific cell
*
* @param chip_num
* @param cell_num
* @param balance_enable
*/
void cell_enable_balancing(uint8_t chip_num, uint8_t cell_num,
bool balance_enable);

/**
* @brief Set the cell balancing configuration and send it to the segments.
*
Expand Down
13 changes: 12 additions & 1 deletion Core/Src/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,8 @@ void segment_retrieve_data(acc_data_t *bmsdata)
bool segment_is_balancing(cell_asic chips[NUM_CHIPS])
{
for (int chip = 0; chip < NUM_CHIPS; chip++) {
if (chips[chip].tx_cfga.mute_st != MUTE_ACTIVATED_DISCHARGE_DISABLED) {
if (chips[chip].tx_cfga.mute_st !=
MUTE_ACTIVATED_DISCHARGE_DISABLED) {
return true;
}
}
Expand All @@ -625,6 +626,9 @@ void segment_disable_balancing(cell_asic chips[NUM_CHIPS])
{
// Initializes all array elements to zero
bool discharge_config[NUM_CHIPS][NUM_CELLS_PER_CHIP] = { 0 };
for (int chip = 0; chip < NUM_CHIPS; chip++) {
chips[chip].tx_cfga.mute_st = MUTE_ACTIVATED_DISCHARGE_DISABLED;
}
segment_configure_balancing(chips, discharge_config);
}

Expand All @@ -642,6 +646,13 @@ void segment_configure_balancing(
for (int cell = 0; cell < NUM_CELLS_PER_CHIP; cell++) {
set_cell_discharge(&chips[chip], cell,
discharge_config[chip][cell]);

// Enable balancing for a chip if a cell is to be discharged
if (chips[chip].tx_cfga.mute_st ==
MUTE_ACTIVATED_DISCHARGE_DISABLED &&
discharge_config[chip][cell]) {
chips[chip].tx_cfga.mute_st = DISCHARGE_ENABLED;
}
}
}
write_config_regs(chips);
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Core/Src/stm32f4xx_it.c \
Core/Src/stm32f4xx_hal_msp.c \
Drivers/Embedded-Base/platforms/stm32f405/src/can.c \
Drivers/Embedded-Base/general/src/m24c32.c \
Drivers/Embedded-Base/general/src/ltc68041.c \
Drivers/Embedded-Base/general/src/sht30.c \
Drivers/Embedded-Base/middleware/src/timer.c \
Drivers/Embedded-Base/middleware/src/ringbuffer.c \
Expand Down

0 comments on commit 93379f0

Please sign in to comment.