123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627 |
- ///##############################################################################
- //
- // FILE: BMS_CAN0_Tools.c
- //
- // TITLE: CAN 0
- // CAN_Tx_Balance
- // check_and_save_Voltage
- // check_and_save_Status
- // check_and_save_UI
- // check_and_save_Temperature
- // check_Voltage_Border
- // check_Status_Border
- // check_UI_Border
- // check_Temperature_Border
- // Sum_Cell_Voltage
- // Test_MAX_LOAD_CELL_VOLTAGE
- // Search_MIN_CELL_VOLTAGE
- // Test_Slave_Presents
- //
- //
- //##############################################################################
- //
- //==============================================================================
- // Change History:
- //==============================================================================
- // Datum: | Name | Version:| Change / Cause: | No
- //------------------------------------------------------------------------------
- // | | | | 002
- //------------------------------------------------------------------------------
- // | | | | 001
- //------------------------------------------------------------------------------
- // 20.04.12 | TM | 1.0 | New Build | 000
- //==============================================================================
- //==============================================================================
- // Comment Change / Cause:
- //==============================================================================
- // Change: 003 // 003
- //----------------------
- //
- //
- //==============================================================================
- // Change: 002 // 002
- //----------------------
- //
- //
- //==============================================================================
- // Change: 001 // 001
- //----------------------
- //
- //
- //==============================================================================
- #include "BMS_Master.h"
- // ***** Functions for startup *********************************************
- uint16_t CAN_Tx_MasterX_BMS(MASTER_CAN0_STRUCT_t* s, uint8_t SlaveNummer, uint8_t MasterAlive, uint8_t SetMode, uint32_t Balancer )
- {
- uint8_t Data[MAX_SLAVES];
- uint16_t ReturnResult = CAN_OK;
-
- Balancer++;
-
- Data[0] = SetMode + (MasterAlive<<5);
- Data[1] = 0;
- Data[2] = 0;
- Data[3] = 0;
- Data[4] = 0;
- Data[5] = 0;
- Data[6] = 0;
- Data[7] = 0;
-
- ReturnResult = CAN_Write(s->Slave[SlaveNummer].TxMailbox_ptr , &Data[0] );
- return ReturnResult;
- }
- // ***** CAN_Tx_System300 ********************************************************
- uint16_t CAN_Tx_System300( uint16_t IDSEARCH )
- {
- uint8_t cIDSEARCH[8] = {'I','D','S','E','A','R','C','H'};
- uint8_t cSERNRPRG[8] = {'S','E','R','N','R','P','R','G'};
-
- uint16_t ReturnResult = CAN_OK;
-
- if(IDSEARCH)
- ReturnResult = CAN_Write( &CAN_TxMB_System300, &(cIDSEARCH[0]) );
- else
- ReturnResult = CAN_Write( &CAN_TxMB_System300, &cSERNRPRG[0] );
-
- return ReturnResult;
- }
- // ***** Functions for normal operation ************************************
- uint16_t CAN_Rx_readout_Mailbox(CAN_MAILBOX *p_MBox,uint8_t *eight_byte_field) {
-
-
- if( CAN_Read(p_MBox, eight_byte_field) != CAN_ERROR ) {
- return 1;
- }
- else {
- return 0;
- }
-
- }
- // ***** CAN_Tx_MasterXA ********************************************************
- uint16_t CAN_Tx_MasterXA()
- {
- uint8_t Data[8] = {0,0,0,0,0,0,0,0};
- uint16_t ReturnResult = CAN_OK;
-
- ReturnResult = CAN_Write( &CAN_TxMB_Master0A, &Data[0] );
-
- return ReturnResult;
- }
- //uint16_t CAN0_tx_send_request_telegram(uint8_t slaveNr) {
- // MASTER_X_BMS_TELEGRAM* tel_ptr=&TelegramTxContainer[slaveNr];
- // CAN_MAILBOX* mailbox_ptr=MB_Container[slaveNr];
- //
- // CAN_Write(mailbox_ptr,&(tel_ptr->Byte[0]));
- // tel_ptr->Values.MasterAlive++;
- //}
- uint16_t CAN0_tx_send_request_telegram(BMS_CAN0_SLAVE_t* Slave,uint8_t MasterAlive) {
- // create Slave Tx Telegram
- Slave->TxTelegram_ptr->Values.BalancingCell0_7=Slave->Balance_Cell_0_7;
- Slave->TxTelegram_ptr->Values.BalancingCell8_15=Slave->Balance_Cell_8_15;
- Slave->TxTelegram_ptr->Values.BalancingCell16_23=Slave->Balance_Cell_16_23;
- Slave->TxTelegram_ptr->Values.MasterAlive= MasterAlive;
- Slave->TxTelegram_ptr->Values.SetMode=Slave->Set_Mode;
- //
-
-
-
- CAN_Write(Slave->TxMailbox_ptr,&(Slave->TxTelegram_ptr->Byte[0]));
-
- }
- uint16_t CAN0_is_state_active(uint8_t* activeSlaves,uint8_t nrOfActiveSlaves,uint8_t nrOfCurrentSlave) {
- uint8_t i;
- for(i=0;i<nrOfActiveSlaves;i++) {
- if(activeSlaves[i] == nrOfCurrentSlave) {
- return TRUE;
- }
- }
- return FALSE;
-
- }
- // ***** CAN_Tx_Balance ********************************************************
- uint16_t CAN_Tx_Balance( uint16_t i)
- {
- uint32_t Buffer;
- uint8_t Data[MAX_SLAVES];
- uint16_t ReturnResult = CAN_OK;
-
- Buffer = gBSD.Balancer.Balancing_OnOff_Flags[i];
- Data[0] = (uint8_t)(Buffer & 0xFF); //Balancing 0-7
- Buffer >>= 8;
- Data[1] = (uint8_t)(Buffer & 0xFF); //Balancing 8-15
- Buffer >>= 8;
- Data[2] = (uint8_t)(Buffer & 0xFF); //Balancing 16-20
-
- Data[3] = gBSD.Balancer.FanCtrl.R[i]; //Luefter
-
- Data[4] = gBSD.Balancer.Relais_OnOff[i]; //Relais
-
- //ReturnResult = CAN_Write( &CAN_TxMB_BalancingCtrl_100+i, &Data[0] ); Turned off
- return ReturnResult;
- }
- // ***** check_and_save_Voltage ************************************************
- void check_and_save_Voltage( CAN_MAILBOX *p_MBox, uint16_t SlaveNr, uint16_t SlaveOffset )
- {
- uint8_t Data[8]; // Receive Dummy
- uint16_t i; // RowCounter
- uint16_t j; // CellOffset
-
-
- if( CAN_Read(p_MBox, &Data[0] ) != CAN_ERROR )
- {
- i = gBSD.w_Voltage; // RowCounter
- j = MAX_SLAVE_CELLS * SlaveNr + SlaveOffset * 4; // CellOffset
- gBSE.CountVoltage |= ( 1 << ( 6 * SlaveNr + SlaveOffset ) ); // MSG No Bit
-
-
- gBSD.CellVoltage[i][j] = (uint16_t)((Data[0]<<8) + Data[1]);
- gBSE.ErrorCell[j] = check_Voltage_Border( i, j ); j++;
-
- gBSD.CellVoltage[i][j] = (uint16_t)((Data[2]<<8) + Data[3]);
- gBSE.ErrorCell[j] = check_Voltage_Border( i, j ); j++;
-
- gBSD.CellVoltage[i][j] = (uint16_t)((Data[4]<<8) + Data[5]);
- gBSE.ErrorCell[j] = check_Voltage_Border( i, j ); j++;
-
- gBSD.CellVoltage[i][j] = (uint16_t)((Data[6]<<8) + Data[7]);
- gBSE.ErrorCell[j] = check_Voltage_Border( i, j );
-
- if( gBSE.CountVoltage >= MAX_COUNT_MSG_VOLTAGE ) // All Voltage MSG of all Slaves complete
- {
- gBSE.CountVoltage = 0; // restart Voltage MSG Scan
-
- gBSD.r_Voltage = i; // W will be new R
- i++; // fetch next row
- if( i >= MAX_COUNT_VOLTAGE ) // check Overrun write Index
- i = 0;
- gBSD.w_Voltage = i; // new W
- }
- }
- }
- // ***** check_and_save_Status *************************************************
- void check_and_save_Status( CAN_MAILBOX *p_MBox, uint16_t SlaveNr )
- {
- uint8_t Data[8];
- uint16_t i; // RowCounter
- uint16_t j; // CellOffset
-
-
- if( CAN_Read( p_MBox, &Data[0] ) != CAN_ERROR )
- {
- i = gBSD.w_Status; // RowCounter
- j = SlaveNr; // CellOffset
- gBSE.CountStatus |= ( 1 << SlaveNr ); // MSG No Bit
-
-
- gBSD.Slave_Status[i][j].StatusFlags.R = (uint16_t)((Data[0]<<8) + Data[1]);
- gBSD.Slave_Status[i][j].LTC_PEC_FailCount = Data[2];
- gBSD.Slave_Status[i][j].HeatSink_Temp = (int8_t)Data[3];
- gBSD.Slave_Status[i][j].SelfTest_Flags.R = (uint16_t)((Data[4]<<8) + Data[5]);
-
- gBSE.ErrorSlave[j] = check_Status_Border( i, j );
-
- if( gBSE.CountStatus >= MAX_COUNT_MSG_STATUS ) // All Status MSG of all Slaves complete
- {
- gBSE.CountStatus = 0; // restart Status MSG Scan
-
- gBSD.r_Status = i; // W will be new R
- i++; // fetch next row
- if( i >= MAX_COUNT_STATUS ) // check Overrun write Index
- i = 0;
- gBSD.w_Status = i; // new W
- }
- }
- }
- // ***** check_and_save_UI *****************************************************
- void check_and_save_UI( CAN_MAILBOX *p_MBox )
- {
- static uint8_t Data[8]; // Receive Dummy
- uint8_t CS; // Checksum
- uint16_t i; // RowCounter
-
-
- if( CAN_Read( p_MBox, Data ) != CAN_ERROR )
- {
- i = gBSD.w_UI; // RowCounter
-
- gBSD.BlockVoltage[i] = (uint16_t)((Data[0]<<8) + Data[1]);
- gBSD.BlockCurrent[i] = ( int16_t)((Data[2]<<8) + Data[3]);;
- gBSD.BlockCounter[i] = Data[6];
- CS = Data[0] ^ Data[1] ^ Data[2] ^ Data[3] ^ Data[4] ^ Data[5] ^ Data[6] ^ 0x00;
-
- gBSE.ErrorBMS = 0;
- if( Data[7] != CS )
- gBSE.ErrorBMS |= ERROR_UI_PEC_NOK;
-
- //!! gBSE.ErrorBMS |= check_UI_Border( i );
-
- if( !gBSE.ErrorBMS )
- {
- gBSD.BlockCurrentSum -= gBSD.BlockCurrent[i]; // Integral of Current
- Data[0] = (uint8_t)((gBSD.BlockCurrentSum & 0xFF000000)>> 24);
- Data[1] = (uint8_t)((gBSD.BlockCurrentSum & 0x00FF0000)>> 16);
- Data[2] = (uint8_t)((gBSD.BlockCurrentSum & 0x0000FF00)>> 8);
- Data[3] = (uint8_t) (gBSD.BlockCurrentSum & 0x000000FF);
- Fram_S.Flags.B.JobFinished = 0;
- FRAM_trigger_write(0, &Data[0], 4);
- }
-
- gBSD.r_UI = i; // W will be new R
- i++; // fetch next row
- if( i == MAX_COUNT_UI ) // check Overrun write Index
- i = 0;
- gBSD.w_UI = i; // new W
- }
- }
- // ***** check_and_save_Temperature ********************************************
- void check_and_save_Temperature( CAN_MAILBOX *p_MBox, uint16_t SlaveNr, uint16_t SlaveOffset)
- {
- uint8_t Data[8]; // Receive Dummy
- uint16_t i; // RowCounter
- uint16_t j; // CellOffset
-
- if( CAN_Read(p_MBox, Data ) != CAN_ERROR )
- {
- i = gBSD.w_Temperature; // RowCounter
- j = MAX_SLAVE_CELLS * SlaveNr + SlaveOffset * 8; // CellOffset
- gBSE.CountTemperature |= ( 1 << ( 3 * SlaveNr + SlaveOffset ) ); // MSG No Bit
-
- gBSD.CellTemperature[i][j] = (int8_t) Data[0];
- gBSE.ErrorCell[j] = check_Temperature_Border( i, j ); j++;
-
- gBSD.CellTemperature[i][j] = (int8_t) Data[1];
- gBSE.ErrorCell[j] = check_Temperature_Border( i, j ); j++;
-
- gBSD.CellTemperature[i][j] = (int8_t) Data[2];
- gBSE.ErrorCell[j] = check_Temperature_Border( i, j ); j++;
-
- gBSD.CellTemperature[i][j] = (int8_t) Data[3];
- gBSE.ErrorCell[j] = check_Temperature_Border( i, j ); j++;
-
- gBSD.CellTemperature[i][j] = (int8_t) Data[4];
- gBSE.ErrorCell[j] = check_Temperature_Border( i, j ); j++;
-
- gBSD.CellTemperature[i][j] = (int8_t) Data[5];
- gBSE.ErrorCell[j] = check_Temperature_Border( i, j ); j++;
-
- gBSD.CellTemperature[i][j] = (int8_t) Data[6];
- gBSE.ErrorCell[j] = check_Temperature_Border( i, j ); j++;
-
- gBSD.CellTemperature[i][j] = (int8_t) Data[7];
- gBSE.ErrorCell[j] = check_Temperature_Border( i, j );
-
- if( gBSE.CountTemperature >= MAX_COUNT_MSG_TEMPERATURE ) // All Temperature MSG of all Slaves complete
- {
- gBSE.CountTemperature = 0; // restart Temperature MSG Scan
-
- gBSD.r_Temperature = i; // W will be new R
- i++; // fetch next row
- if( i == MAX_COUNT_TEMPERATURE ) // check Overrun write Index
- i = 0;
- gBSD.w_Temperature = i; // new W
- }
- }
- }
- // ***** check_Voltage_Border **************************************************
- int16_t check_Voltage_Border( uint16_t Row, uint16_t Index )
- {
- int16_t ReturnResult = CAN_OK;
- uint16_t i;
- uint32_t Average = 0;
-
-
- if(gCANErrorInsert == 1) //!! 1.5-3
- gBSD.CellVoltage[Row][Index] = MIN_CELL_VOLTAGE_TEST;
-
- if(gCANErrorInsert == 2) //!! 1.5-3
- gBSD.CellVoltage[Row][Index] = MAX_CELL_VOLTAGE_TEST;
-
-
- if( gBSD.CellVoltage[Row][Index] < PRE_CELL_LOW_VOLTAGE )
- {
- ReturnResult += ERROR_PRE_CELL_LOW_VOLTAGE;
- gErrorEvent |= EEV__DEGRADATION;
- }
-
- if( gBSD.CellVoltage[Row][Index] > MAX_CELL_VOLTAGE )
- {
- ReturnResult += ERROR_MAX_CELL_VOLTAGE;
- gErrorEvent |= EEV__SHUT_DOWN_CHARGE;
- }
-
- if( gBSD.CellVoltage[Row][Index] < MIN_CELL_VOLTAGE )
- {
- ReturnResult += ERROR_MIN_CELL_VOLTAGE;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
-
- if( Row >= MAX_AVE) // after 4 Rows start delta check
- {
- for(i=0; i<MAX_AVE; i++)
- Average += gBSD.CellVoltage[Row-i-1][Index]; // add 4 Rows together
- Average = Average >> MAX_AVE_SHIFT; // Average of 4 Rows
-
- if(gCANErrorInsert == 3) //!! 1.5-3
- gBSD.CellVoltage[Row][Index] = DELTA_CELL_VOLTAGE_TEST;
-
- if(gBSD.CellVoltage[Row][Index] < ( Average - DELTA_CELL_VOLTAGE ))
- {
- ReturnResult += ERROR_DELTA_CELL_VOLTAGE;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
- else
- if( gBSD.CellVoltage[Row][Index] > ( Average + DELTA_CELL_VOLTAGE ) )
- {
- ReturnResult += ERROR_DELTA_CELL_VOLTAGE;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
- }
- return ReturnResult;
- }
- // ***** check_Status_Border ***************************************************
- int16_t check_Status_Border( uint16_t Row, uint16_t Index )
- {
- int16_t ReturnResult = CAN_OK;
- if(gCANErrorInsert == 7) //!! 1.5-3
- gBSD.Slave_Status[Row][Index].HeatSink_Temp = MAX_HEATSINK_TEMPERATURE_TEST;
-
- if( gBSD.Slave_Status[Row][Index].HeatSink_Temp > MAX_HEATSINK_TEMPERATURE )
- {
- ReturnResult += ERROR_MAX_HEATSINK_TEMPERATURE;
- gErrorEvent |= EEV__SHUT_DOWN_CHARGE;
- }
-
- if( gBSD.Slave_Status[Row][Index].StatusFlags.R & 0x7C00 ) // CAN Rx/Tx Overrun/Warning/Passiv
- {
- ReturnResult += ERROR_SLAVE_CAN;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
-
- if( gBSD.Slave_Status[Row][Index].StatusFlags.R & 0x0003 ) // LTC1/2 Temperature < -40°C
- {
- ReturnResult += ERROR_MIN_LTC_TEMP;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
-
- if( gBSD.Slave_Status[Row][Index].StatusFlags.R & 0x003C ) // LTC1/2 Temperature > +80°C / THSD
- {
- ReturnResult += ERROR_MAX_LTC_TEMP;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
-
- if( gBSD.Slave_Status[Row][Index].StatusFlags.R & 0x00C0 ) // LTC TimeOut / PEC_NOK
- {
- ReturnResult += ERROR_SLAVE_PEC;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
-
- if( gBSD.Slave_Status[Row][Index].SelfTest_Flags.R ) // Any SelfTest Error Flag
- {
- ReturnResult += ERROR_SLAVE_SELFTEST;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
- return ReturnResult;
- }
- // ***** check_UI_Border *******************************************************
- int16_t check_UI_Border( uint16_t Row )
- {
- uint16_t Vbat = 0;
- int16_t ReturnResult = CAN_OK;
- if(Global_1msCounter > (DELAY_START+DELAY_START) )
- Vbat = Sum_Cell_Voltage( Row );
- else
- Vbat = 4250;
-
- if(gCANErrorInsert == 8) //!! 1.5-3
- Vbat = MIN_UI_VOLTAGE_TEST;
-
- if(gCANErrorInsert == 9) //!! 1.5-3
- Vbat = MAX_UI_VOLTAGE_TEST;
-
- if( Vbat < MIN_UI_VOLTAGE )
- {
- ReturnResult += ERROR_MIN_UI_VOLTAGE;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
- else
- if( Vbat > MAX_UI_VOLTAGE )
- {
- ReturnResult += ERROR_MAX_UI_VOLTAGE;
- gErrorEvent |= EEV__SHUT_DOWN_CHARGE;
- }
-
- if( gBSD.BlockCurrent[Row] < MIN_UI_LOAD_CURRENT )
- {
- ReturnResult += ERROR_MIN_UI_CURRENT; // Load => +
- gErrorEvent |= EEV__SHUT_DOWN_CHARGE;
- }
- else
- if( gBSD.BlockCurrent[Row] > MAX_UI_DRIVE_CURRENT )
- {
- ReturnResult += ERROR_MAX_UI_CURRENT; // Drive => -
- gErrorEvent |= EEV__DEGRADATION;
- }
-
- if( Row )
- if( gBSD.BlockCounter[Row] )
- if( gBSD.BlockCounter[Row] != (gBSD.BlockCounter[Row-1] + 1) )
- {
- ReturnResult += ERROR_UI_PEC_NOK;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
- return ReturnResult;
- }
- // ***** check_Temperature_Border **********************************************
- int16_t check_Temperature_Border( uint16_t Row, uint16_t Index )
- {
- int16_t ReturnResult = CAN_OK;
-
-
- if(gCANErrorInsert == 4) //!! 1.5-3
- gBSD.CellTemperature[Row][Index] = MAX_CELL_TEMPERATURE_TEST;
-
- if(gCANErrorInsert == 5) //!! 1.5-3
- gBSD.CellTemperature[Row][Index] = MIN_CELL_TEMPERATURE_TEST;
-
- if( gBSD.CellTemperature[Row][Index] < MIN_CELL_TEMPERATURE )
- {
- ReturnResult += ERROR_MIN_CELL_TEMPERATURE;
- gErrorEvent |= EEV__SHUT_DOWN_CHARGE;
- }
-
- if( gBSD.CellTemperature[Row][Index] > PRE_CELL_OVERHEAT )
- {
- ReturnResult += ERROR_PRE_CELL_OVERHEAT;
- gErrorEvent |= EEV__DEGRADATION;
- }
-
- if( gBSD.CellTemperature[Row][Index] > MAX_CELL_TEMPERATURE )
- {
- ReturnResult += ERROR_MAX_CELL_TEMPERATURE;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
-
- if( Row ) // at last 2 Temperatures to compare
- {
- if(gCANErrorInsert == 6) //!! 1.5-3
- gBSD.CellTemperature[Row][Index-1] += DELTA_CELL_TEMPERATURE_TEST;
-
- if(gBSD.CellTemperature[Row][Index] < ( gBSD.CellTemperature[Row-1][Index] - DELTA_CELL_TEMPERATURE ))
- {
- ReturnResult += ERROR_DELTA_CELL_TEMPERATURE;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
- else
- if( gBSD.CellTemperature[Row][Index] > ( gBSD.CellTemperature[Row-1][Index] + DELTA_CELL_TEMPERATURE ) )
- {
- ReturnResult += ERROR_DELTA_CELL_TEMPERATURE;
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
- }
- return ReturnResult;
- }
- // ***** Sum_Cell_Voltage ******************************************************
- uint16_t Sum_Cell_Voltage( uint16_t Row )
- {
- uint32_t ReturnResult = 0;
- uint16_t i;
-
- for( i=0; i<MAX_CELLS; i++)
- ReturnResult += (uint32_t)gBSD.CellVoltage[Row][i];
-
- ReturnResult /= 100;
-
- return (uint16_t)ReturnResult;
- }
- // ***** Test_MAX_LOAD_CELL_VOLTAGE ********************************************
- uint16_t Test_MAX_LOAD_CELL_VOLTAGE( uint16_t Row )
- {
- uint16_t ReturnResult = CAN_OK;
- uint16_t i;
-
- for( i=0; i<MAX_CELLS; i++)
- {
- if( gBSD.CellVoltage[Row][i] > MAX_LOAD_CELL_VOLTAGE )
- {
- ReturnResult = ERROR_MAX_LOAD_CELL_VOLTAGE; // one Error is enough
- break;
- }
- }
-
- return ReturnResult;
- }
- // ***** Search_MIN_CELL_VOLTAGE ********************************************
- uint16_t Search_MIN_CELL_VOLTAGE( uint16_t Row )
- {
- uint16_t ReturnResult = MAX_CELL_VOLTAGE;
- uint16_t i;
-
- for( i=0; i<MAX_CELLS; i++)
- if( gBSD.CellVoltage[Row][i] < ReturnResult )
- ReturnResult = gBSD.CellVoltage[Row][i];
-
- return ReturnResult;
- }
- // ***** End BMS_CAN0_Tools.c **************************************************
|