Add dummy SoC, replace ID

This commit is contained in:
Dmitriy Semenov
2023-04-06 21:23:19 +03:00
parent 9c2667bbe5
commit 8ea5166aa1
6 changed files with 37 additions and 10 deletions

View File

@@ -39,6 +39,8 @@ static volatile CAN_MSG_t can2_tx_buf = {0,}; // Buf for 1 TX packet
extern modPowerElectronicsPackStateTypedef packState;
extern modConfigGeneralConfigStructTypedef *generalConfig;
static volatile bool dummy_soc = 0;
static volatile bool threshold_request = 0;
static volatile bool active_request = 0;
@@ -47,6 +49,18 @@ void can_msgr_init() {
RingBuf_Init((void *) &can2_transmit_q_msg, 10, sizeof(CAN_MSG_t), (RINGBUF_t *) &can2_ring);
}
/**
* @brief Make SoC for charging = 100%
*/
void can_set_dummy_soc(void){
dummy_soc = 1;
}
bool get_dummy_soc(void){
return dummy_soc;
}
void transmitCan1Packet() {
if ((TIM_Clock - can1_transmit_clock) < 1000) {
return;
@@ -178,7 +192,7 @@ int getIndexByTemperature() {
u16_t get_table_current() {
// sending table current and end-of-charge current command
const int socIndex = getIndexBySoc();
const int socIndex = dummy_soc ? 10 : getIndexBySoc();
const int temperatureIndex = getIndexByTemperature();
float tableCurrent = 0;
if (socIndex != -1 && temperatureIndex != -1) {

View File

@@ -5,6 +5,7 @@
#ifndef BMS_V3_CAN_MESSENGER_H
#define BMS_V3_CAN_MESSENGER_H
#include <stdbool.h>
#include "../Core/Inc/main.h"
/**
@@ -23,6 +24,9 @@ typedef enum CAN_BMS_ID {
void can_msgr_init();
void can_set_dummy_soc(void);
bool get_dummy_soc(void);
void transmitCan1Packet();
int getIndexBySoc();
int getIndexByTemperature();