fix: wrong syntax for accessing Cell_Module array
This commit is contained in:
parent
f3aa252b0e
commit
d6de68c358
@ -96,76 +96,77 @@ HAL_StatusTypeDef amsCellMeasurement(Cell_Module (*module)[N_BMS]) {
|
|||||||
|
|
||||||
HAL_StatusTypeDef amsAuxAndStatusMeasurement(Cell_Module (*module)[N_BMS]) {
|
HAL_StatusTypeDef amsAuxAndStatusMeasurement(Cell_Module (*module)[N_BMS]) {
|
||||||
uint8_t rxbuf[CMD_BUFFER_SIZE(STATUS_GROUP_C_SIZE)] = {};
|
uint8_t rxbuf[CMD_BUFFER_SIZE(STATUS_GROUP_C_SIZE)] = {};
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDSTATC, rxbuf, STATUS_GROUP_C_SIZE));
|
CHECK_RETURN(readCMD(RDSTATC, rxbuf, STATUS_GROUP_C_SIZE));
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, STATUS_GROUP_C_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, STATUS_GROUP_C_SIZE);
|
||||||
module[i]->status.CS_FLT = rxbuf[offset + 0] | (rxbuf[offset + 1] << 8);
|
(*module)[i].status.CS_FLT = rxbuf[offset + 0] | (rxbuf[offset + 1] << 8);
|
||||||
module[i]->status.CCTS = rxbuf[offset + 2] | (rxbuf[offset + 3] << 8);
|
(*module)[i].status.CCTS = rxbuf[offset + 2] | (rxbuf[offset + 3] << 8);
|
||||||
module[i]->status.VA_OV = (rxbuf[offset + 4] >> 7) & 0x01;
|
(*module)[i].status.VA_OV = (rxbuf[offset + 4] >> 7) & 0x01;
|
||||||
module[i]->status.VA_UV = (rxbuf[offset + 4] >> 6) & 0x01;
|
(*module)[i].status.VA_UV = (rxbuf[offset + 4] >> 6) & 0x01;
|
||||||
module[i]->status.VD_OV = (rxbuf[offset + 4] >> 5) & 0x01;
|
(*module)[i].status.VD_OV = (rxbuf[offset + 4] >> 5) & 0x01;
|
||||||
module[i]->status.VD_UV = (rxbuf[offset + 4] >> 4) & 0x01;
|
(*module)[i].status.VD_UV = (rxbuf[offset + 4] >> 4) & 0x01;
|
||||||
module[i]->status.CED = (rxbuf[offset + 4] >> 3) & 0x01;
|
(*module)[i].status.CED = (rxbuf[offset + 4] >> 3) & 0x01;
|
||||||
module[i]->status.CMED = (rxbuf[offset + 4] >> 2) & 0x01;
|
(*module)[i].status.CMED = (rxbuf[offset + 4] >> 2) & 0x01;
|
||||||
module[i]->status.SED = (rxbuf[offset + 4] >> 1) & 0x01;
|
(*module)[i].status.SED = (rxbuf[offset + 4] >> 1) & 0x01;
|
||||||
module[i]->status.SMED = (rxbuf[offset + 4] >> 0) & 0x01;
|
(*module)[i].status.SMED = (rxbuf[offset + 4] >> 0) & 0x01;
|
||||||
module[i]->status.VDEL = (rxbuf[offset + 5] >> 7) & 0x01;
|
(*module)[i].status.VDEL = (rxbuf[offset + 5] >> 7) & 0x01;
|
||||||
module[i]->status.VDE = (rxbuf[offset + 5] >> 6) & 0x01;
|
(*module)[i].status.VDE = (rxbuf[offset + 5] >> 6) & 0x01;
|
||||||
module[i]->status.COMPARE= (rxbuf[offset + 5] >> 5) & 0x01;
|
(*module)[i].status.COMPARE = (rxbuf[offset + 5] >> 5) & 0x01;
|
||||||
module[i]->status.SPIFLT = (rxbuf[offset + 5] >> 4) & 0x01;
|
(*module)[i].status.SPIFLT = (rxbuf[offset + 5] >> 4) & 0x01;
|
||||||
module[i]->status.SLEEP = (rxbuf[offset + 5] >> 3) & 0x01;
|
(*module)[i].status.SLEEP = (rxbuf[offset + 5] >> 3) & 0x01;
|
||||||
module[i]->status.THSD = (rxbuf[offset + 5] >> 2) & 0x01;
|
(*module)[i].status.THSD = (rxbuf[offset + 5] >> 2) & 0x01;
|
||||||
module[i]->status.TMODCHK= (rxbuf[offset + 5] >> 1) & 0x01;
|
(*module)[i].status.TMODCHK = (rxbuf[offset + 5] >> 1) & 0x01;
|
||||||
module[i]->status.OSCCHK = (rxbuf[offset + 5] >> 0) & 0x01;
|
(*module)[i].status.OSCCHK = (rxbuf[offset + 5] >> 0) & 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pollCMD(PLAUX) == HAL_BUSY) {
|
if (pollCMD(PLAUX) == HAL_BUSY) {
|
||||||
return HAL_BUSY;
|
return HAL_BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDAUXA, rxbuf, AUX_GROUP_A_SIZE)); //STATUS_GROUP_C_SIZE is the same as AUX_GROUP_A_SIZE, so we can reuse the buffer
|
CHECK_RETURN(
|
||||||
|
readCMD(RDAUXA, rxbuf,
|
||||||
|
AUX_GROUP_A_SIZE)); // STATUS_GROUP_C_SIZE is the same as AUX_GROUP_A_SIZE, so we can reuse the buffer
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, AUX_GROUP_A_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, AUX_GROUP_A_SIZE);
|
||||||
module[i]->auxVoltages[0] = mV_from_ADBMS6830(rxbuf[offset + 0] | (rxbuf[offset + 1] << 8));
|
(*module)[i].auxVoltages[0] = mV_from_ADBMS6830(rxbuf[offset + 0] | (rxbuf[offset + 1] << 8));
|
||||||
module[i]->auxVoltages[1] = mV_from_ADBMS6830(rxbuf[offset + 2] | (rxbuf[offset + 3] << 8));
|
(*module)[i].auxVoltages[1] = mV_from_ADBMS6830(rxbuf[offset + 2] | (rxbuf[offset + 3] << 8));
|
||||||
module[i]->auxVoltages[2] = mV_from_ADBMS6830(rxbuf[offset + 4] | (rxbuf[offset + 5] << 8));
|
(*module)[i].auxVoltages[2] = mV_from_ADBMS6830(rxbuf[offset + 4] | (rxbuf[offset + 5] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDAUXB, rxbuf, AUX_GROUP_B_SIZE));
|
CHECK_RETURN(readCMD(RDAUXB, rxbuf, AUX_GROUP_B_SIZE));
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, AUX_GROUP_B_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, AUX_GROUP_B_SIZE);
|
||||||
module[i]->auxVoltages[3] = mV_from_ADBMS6830(rxbuf[offset + 0] | (rxbuf[offset + 1] << 8));
|
(*module)[i].auxVoltages[3] = mV_from_ADBMS6830(rxbuf[offset + 0] | (rxbuf[offset + 1] << 8));
|
||||||
module[i]->auxVoltages[4] = mV_from_ADBMS6830(rxbuf[offset + 2] | (rxbuf[offset + 3] << 8));
|
(*module)[i].auxVoltages[4] = mV_from_ADBMS6830(rxbuf[offset + 2] | (rxbuf[offset + 3] << 8));
|
||||||
module[i]->auxVoltages[5] = mV_from_ADBMS6830(rxbuf[offset + 4] | (rxbuf[offset + 5] << 8));
|
(*module)[i].auxVoltages[5] = mV_from_ADBMS6830(rxbuf[offset + 4] | (rxbuf[offset + 5] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDAUXC, rxbuf, AUX_GROUP_C_SIZE));
|
CHECK_RETURN(readCMD(RDAUXC, rxbuf, AUX_GROUP_C_SIZE));
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, AUX_GROUP_C_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, AUX_GROUP_C_SIZE);
|
||||||
module[i]->auxVoltages[6] = mV_from_ADBMS6830(rxbuf[offset + 0] | (rxbuf[offset + 1] << 8));
|
(*module)[i].auxVoltages[6] = mV_from_ADBMS6830(rxbuf[offset + 0] | (rxbuf[offset + 1] << 8));
|
||||||
module[i]->auxVoltages[7] = mV_from_ADBMS6830(rxbuf[offset + 2] | (rxbuf[offset + 3] << 8));
|
(*module)[i].auxVoltages[7] = mV_from_ADBMS6830(rxbuf[offset + 2] | (rxbuf[offset + 3] << 8));
|
||||||
module[i]->auxVoltages[8] = mV_from_ADBMS6830(rxbuf[offset + 4] | (rxbuf[offset + 5] << 8));
|
(*module)[i].auxVoltages[8] = mV_from_ADBMS6830(rxbuf[offset + 4] | (rxbuf[offset + 5] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDAUXD, rxbuf, AUX_GROUP_D_SIZE));
|
CHECK_RETURN(readCMD(RDAUXD, rxbuf, AUX_GROUP_D_SIZE));
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, AUX_GROUP_D_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, AUX_GROUP_D_SIZE);
|
||||||
module[i]->auxVoltages[9] = mV_from_ADBMS6830(rxbuf[offset + 0] | (rxbuf[offset + 1] << 8));
|
(*module)[i].auxVoltages[9] = mV_from_ADBMS6830(rxbuf[offset + 0] | (rxbuf[offset + 1] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDSTATA, rxbuf, STATUS_GROUP_A_SIZE));
|
CHECK_RETURN(readCMD(RDSTATA, rxbuf, STATUS_GROUP_A_SIZE));
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, STATUS_GROUP_A_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, STATUS_GROUP_A_SIZE);
|
||||||
module[i]->internalDieTemp = rxbuf[offset + 2] | (rxbuf[offset + 3] << 8);
|
(*module)[i].internalDieTemp = rxbuf[offset + 2] | (rxbuf[offset + 3] << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDSTATB, rxbuf, STATUS_GROUP_B_SIZE));
|
CHECK_RETURN(readCMD(RDSTATB, rxbuf, STATUS_GROUP_B_SIZE));
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, STATUS_GROUP_B_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, STATUS_GROUP_B_SIZE);
|
||||||
module[i]->digitalSupplyVoltage = mV_from_ADBMS6830(rxbuf[offset + 0] | (rxbuf[offset + 1] << 8));
|
(*module)[i].digitalSupplyVoltage = mV_from_ADBMS6830(rxbuf[offset + 0] | (rxbuf[offset + 1] << 8));
|
||||||
module[i]->analogSupplyVoltage = mV_from_ADBMS6830(rxbuf[offset + 2] | (rxbuf[offset + 3] << 8));
|
(*module)[i].analogSupplyVoltage = mV_from_ADBMS6830(rxbuf[offset + 2] | (rxbuf[offset + 3] << 8));
|
||||||
module[i]->refVoltage = mV_from_ADBMS6830(rxbuf[offset + 4] | (rxbuf[offset + 5] << 8));
|
(*module)[i].refVoltage = mV_from_ADBMS6830(rxbuf[offset + 4] | (rxbuf[offset + 5] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RETURN(writeCMD(ADAX | ADAX_CONV_ALL, rxbuf, 0)); // start aux conversion for next iteration
|
CHECK_RETURN(writeCMD(ADAX | ADAX_CONV_ALL, rxbuf, 0)); // start aux conversion for next iteration
|
||||||
@ -232,7 +233,8 @@ HAL_StatusTypeDef amsConfigOverUnderVoltage(uint16_t overVoltage, uint16_t under
|
|||||||
return HAL_ERROR;
|
return HAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_log(LOG_LEVEL_INFO, "Configuring OV/UV thresholds to %f/%f", mV_from_ADBMS6830(overVoltage), mV_from_ADBMS6830(underVoltage));
|
debug_log(LOG_LEVEL_INFO, "Configuring OV/UV thresholds to %f/%f", mV_from_ADBMS6830(overVoltage),
|
||||||
|
mV_from_ADBMS6830(underVoltage));
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDCFGB, buffer, CFG_GROUP_B_SIZE));
|
CHECK_RETURN(readCMD(RDCFGB, buffer, CFG_GROUP_B_SIZE));
|
||||||
|
|
||||||
@ -261,15 +263,16 @@ HAL_StatusTypeDef amsCheckUnderOverVoltage(Cell_Module (*module)[N_BMS]) {
|
|||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, STATUS_GROUP_D_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, STATUS_GROUP_D_SIZE);
|
||||||
uint32_t ov_uv_data = 0;
|
uint32_t ov_uv_data = 0;
|
||||||
ov_uv_data = (regbuffer[offset + 0] << 0) | (regbuffer[offset + 1] << 8) |
|
ov_uv_data = (regbuffer[offset + 0] << 0) | (regbuffer[offset + 1] << 8) | (regbuffer[offset + 2] << 16) |
|
||||||
(regbuffer[offset + 2] << 16) | (regbuffer[offset + 3] << 24);
|
(regbuffer[offset + 3] << 24);
|
||||||
|
|
||||||
module[i]->overVoltage = 0;
|
(*module)[i].overVoltage = 0;
|
||||||
module[i]->underVoltage = 0;
|
(*module)[i].underVoltage = 0;
|
||||||
|
|
||||||
for (size_t j = 0; j < numberofCells; j++) { // ov/uv flags are 1-bit flags for each cell C0UV, C0OV, C1UV, C1OV, ...
|
for (size_t j = 0; j < numberofCells;
|
||||||
module[i]->underVoltage |= (ov_uv_data >> (j * 2)) & 0x01;
|
j++) { // ov/uv flags are 1-bit flags for each cell C0UV, C0OV, C1UV, C1OV, ...
|
||||||
module[i]->overVoltage |= (ov_uv_data >> (j * 2 + 1)) & 0x01;
|
(*module)[i].underVoltage |= (ov_uv_data >> (j * 2)) & 0x01;
|
||||||
|
(*module)[i].overVoltage |= (ov_uv_data >> (j * 2 + 1)) & 0x01;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,9 +284,7 @@ HAL_StatusTypeDef amsClearFlag() {
|
|||||||
return writeCMD(CLRFLAG, buffer, 6);
|
return writeCMD(CLRFLAG, buffer, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
HAL_StatusTypeDef amsClearAux() {
|
HAL_StatusTypeDef amsClearAux() { return writeCMD(CLRAUX, CMD_EMPTY_BUFFER, 0); }
|
||||||
return writeCMD(CLRAUX, CMD_EMPTY_BUFFER, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_StatusTypeDef amsReadCellVoltages(Cell_Module (*module)[N_BMS]) {
|
HAL_StatusTypeDef amsReadCellVoltages(Cell_Module (*module)[N_BMS]) {
|
||||||
uint8_t rxbuffer[CMD_BUFFER_SIZE(CV_GROUP_A_SIZE)] = {};
|
uint8_t rxbuffer[CMD_BUFFER_SIZE(CV_GROUP_A_SIZE)] = {};
|
||||||
@ -291,47 +292,47 @@ HAL_StatusTypeDef amsReadCellVoltages(Cell_Module (*module)[N_BMS]) {
|
|||||||
CHECK_RETURN(readCMD(RDCVA, rxbuffer, CV_GROUP_A_SIZE));
|
CHECK_RETURN(readCMD(RDCVA, rxbuffer, CV_GROUP_A_SIZE));
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, CV_GROUP_A_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, CV_GROUP_A_SIZE);
|
||||||
module[i]->cellVoltages[0] = mV_from_ADBMS6830(rxbuffer[offset + 0] | (rxbuffer[offset + 1] << 8));
|
(*module)[i].cellVoltages[0] = mV_from_ADBMS6830(rxbuffer[offset + 0] | (rxbuffer[offset + 1] << 8));
|
||||||
module[i]->cellVoltages[1] = mV_from_ADBMS6830(rxbuffer[offset + 2] | (rxbuffer[offset + 3] << 8));
|
(*module)[i].cellVoltages[1] = mV_from_ADBMS6830(rxbuffer[offset + 2] | (rxbuffer[offset + 3] << 8));
|
||||||
module[i]->cellVoltages[2] = mV_from_ADBMS6830(rxbuffer[offset + 4] | (rxbuffer[offset + 5] << 8));
|
(*module)[i].cellVoltages[2] = mV_from_ADBMS6830(rxbuffer[offset + 4] | (rxbuffer[offset + 5] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDCVB, rxbuffer, CV_GROUP_A_SIZE));
|
CHECK_RETURN(readCMD(RDCVB, rxbuffer, CV_GROUP_A_SIZE));
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, CV_GROUP_A_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, CV_GROUP_A_SIZE);
|
||||||
module[i]->cellVoltages[3] = mV_from_ADBMS6830(rxbuffer[offset + 0] | (rxbuffer[offset + 1] << 8));
|
(*module)[i].cellVoltages[3] = mV_from_ADBMS6830(rxbuffer[offset + 0] | (rxbuffer[offset + 1] << 8));
|
||||||
module[i]->cellVoltages[4] = mV_from_ADBMS6830(rxbuffer[offset + 2] | (rxbuffer[offset + 3] << 8));
|
(*module)[i].cellVoltages[4] = mV_from_ADBMS6830(rxbuffer[offset + 2] | (rxbuffer[offset + 3] << 8));
|
||||||
module[i]->cellVoltages[5] = mV_from_ADBMS6830(rxbuffer[offset + 4] | (rxbuffer[offset + 5] << 8));
|
(*module)[i].cellVoltages[5] = mV_from_ADBMS6830(rxbuffer[offset + 4] | (rxbuffer[offset + 5] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDCVC, rxbuffer, CV_GROUP_A_SIZE));
|
CHECK_RETURN(readCMD(RDCVC, rxbuffer, CV_GROUP_A_SIZE));
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, CV_GROUP_A_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, CV_GROUP_A_SIZE);
|
||||||
module[i]->cellVoltages[6] = mV_from_ADBMS6830(rxbuffer[offset + 0] | (rxbuffer[offset + 1] << 8));
|
(*module)[i].cellVoltages[6] = mV_from_ADBMS6830(rxbuffer[offset + 0] | (rxbuffer[offset + 1] << 8));
|
||||||
module[i]->cellVoltages[7] = mV_from_ADBMS6830(rxbuffer[offset + 2] | (rxbuffer[offset + 3] << 8));
|
(*module)[i].cellVoltages[7] = mV_from_ADBMS6830(rxbuffer[offset + 2] | (rxbuffer[offset + 3] << 8));
|
||||||
module[i]->cellVoltages[8] = mV_from_ADBMS6830(rxbuffer[offset + 4] | (rxbuffer[offset + 5] << 8));
|
(*module)[i].cellVoltages[8] = mV_from_ADBMS6830(rxbuffer[offset + 4] | (rxbuffer[offset + 5] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDCVD, rxbuffer, CV_GROUP_A_SIZE));
|
CHECK_RETURN(readCMD(RDCVD, rxbuffer, CV_GROUP_A_SIZE));
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, CV_GROUP_A_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, CV_GROUP_A_SIZE);
|
||||||
module[i]->cellVoltages[9] = mV_from_ADBMS6830(rxbuffer[offset + 0] | (rxbuffer[offset + 1] << 8));
|
(*module)[i].cellVoltages[9] = mV_from_ADBMS6830(rxbuffer[offset + 0] | (rxbuffer[offset + 1] << 8));
|
||||||
module[i]->cellVoltages[10] = mV_from_ADBMS6830(rxbuffer[offset + 2] | (rxbuffer[offset + 3] << 8));
|
(*module)[i].cellVoltages[10] = mV_from_ADBMS6830(rxbuffer[offset + 2] | (rxbuffer[offset + 3] << 8));
|
||||||
module[i]->cellVoltages[11] = mV_from_ADBMS6830(rxbuffer[offset + 4] | (rxbuffer[offset + 5] << 8));
|
(*module)[i].cellVoltages[11] = mV_from_ADBMS6830(rxbuffer[offset + 4] | (rxbuffer[offset + 5] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDCVE, rxbuffer, CV_GROUP_A_SIZE));
|
CHECK_RETURN(readCMD(RDCVE, rxbuffer, CV_GROUP_A_SIZE));
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, CV_GROUP_A_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, CV_GROUP_A_SIZE);
|
||||||
module[i]->cellVoltages[12] = mV_from_ADBMS6830(rxbuffer[offset + 0] | (rxbuffer[offset + 1] << 8));
|
(*module)[i].cellVoltages[12] = mV_from_ADBMS6830(rxbuffer[offset + 0] | (rxbuffer[offset + 1] << 8));
|
||||||
module[i]->cellVoltages[13] = mV_from_ADBMS6830(rxbuffer[offset + 2] | (rxbuffer[offset + 3] << 8));
|
(*module)[i].cellVoltages[13] = mV_from_ADBMS6830(rxbuffer[offset + 2] | (rxbuffer[offset + 3] << 8));
|
||||||
module[i]->cellVoltages[14] = mV_from_ADBMS6830(rxbuffer[offset + 4] | (rxbuffer[offset + 5] << 8));
|
(*module)[i].cellVoltages[14] = mV_from_ADBMS6830(rxbuffer[offset + 4] | (rxbuffer[offset + 5] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_RETURN(readCMD(RDCVF, rxbuffer, CV_GROUP_A_SIZE));
|
CHECK_RETURN(readCMD(RDCVF, rxbuffer, CV_GROUP_A_SIZE));
|
||||||
for (size_t i = 0; i < N_BMS; i++) {
|
for (size_t i = 0; i < N_BMS; i++) {
|
||||||
size_t offset = BUFFER_BMS_OFFSET(i, CV_GROUP_A_SIZE);
|
size_t offset = BUFFER_BMS_OFFSET(i, CV_GROUP_A_SIZE);
|
||||||
module[i]->cellVoltages[15] = mV_from_ADBMS6830(rxbuffer[offset + 0] | (rxbuffer[offset + 1] << 8));
|
(*module)[i].cellVoltages[15] = mV_from_ADBMS6830(rxbuffer[offset + 0] | (rxbuffer[offset + 1] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
return HAL_OK;
|
return HAL_OK;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user