123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- ///##############################################################################
- //
- // FILE: BMS_CAN2_Tools.c
- //
- // TITLE: CAN 2
- // CAN_Tx_BMU_DICO
- // CAN_Tx_BMU1_EVCU1
- // 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
- //------------------------------------------------------------------------------
- // 31.07.13 | TM | 1.0 | New Build | 000
- //==============================================================================
- //==============================================================================
- // Comment Change / Cause:
- //==============================================================================
- // Change: 003 // 003
- //----------------------
- //
- //
- //==============================================================================
- // Change: 002 // 002
- //----------------------
- //
- //
- //==============================================================================
- // Change: 001 // 001
- //----------------------
- //
- //
- //==============================================================================
- #include "BMS_Master.h"
- extern asm void __startup(register int argc, register char **argv, register char **envp);
- // ***** CAN_Tx_BMU1_EVCU1 *******************************************************
- uint16_t CAN_Tx_BMU1_EVCU1( void )
- {
- uint8_t Data[4];
- uint16_t ReturnResult = CAN_OK;
- uint16_t gISO_R_Dummy;
-
-
- Data[0] = MF__STANDBY; // Default Mode: StandBy
-
- if( gEvent >= EV__DRIVE_START_1 )
- if( gEvent <= EV__SHUT_DOWN_DRIVE )
- Data[0] = MF__DRIVE; // Drive
-
- if( gEvent >= EV__CHARGE )
- if( gEvent <= EV__SHUT_DOWN_CHARGE )
- Data[0] = MF__CHARGE; // Charge
-
- if( gErrorEvent )
- Data[0] = MF__ERROR; // Error
-
- Data[1] = 0;
- if( gBSD.BlockVoltage[gBSD.r_UI] > 4608 ) // 70% MAX_UI_VOLTAGE
- Data[1] |= MF__END_OF_CHARGE; // End of Charge
- // Erweiterung ISO in BMUI_EVCU
-
- gISO_R_Dummy = (unsigned short)(gISO_R >> 1); // ISO/2 cause 2^17 Bit
- Data[2] = (unsigned char)gISO_R_Dummy; // Low Byte first
- Data[3] = (unsigned char)(gISO_R_Dummy >> 8); // High Byte second
-
- //ReturnResult = CAN_Write( &CAN_TxMB_BMU1_EVCU1_18FF9E1E, &Data[0] );
- return ReturnResult;
- }
- // ***** check_and_save_DICO1_EVCU *********************************************
- uint16_t check_and_save_DICO1_EVCU( CAN_MAILBOX *p_MBox )
- {
- uint8_t Data[8]; // Receive Dummy
- DICO1_EVCU_t DICO1_EVCU;
-
- if( CAN_Read(p_MBox, &Data[0] ) != CAN_ERROR )
- {
- DICO1_EVCU.b_StatusByte_1_DCU.R = Data[0];
- DICO1_EVCU.b_StatusByte_2_DCU.R = Data[1];
- DICO1_EVCU.rpmSys = (uint16_t)((Data[2]<<8) + Data[3]);
- DICO1_EVCU.tqRefSys = Data[4];
- DICO1_EVCU.tqSys = Data[5];
- DICO1_EVCU.powerBR_fb = Data[6];
- DICO1_EVCU.b_ErrorBufferIndication.R = Data[7];
-
- if( gEvent == EV__STAND_BY ) // switch out of StandBy only
- {
- if( DICO1_EVCU.b_StatusByte_2_DCU.B.b_PC_Rq ) // PreCharge Contractor Request
- gEvent = EV__DRIVE_START_1;
-
- if( DICO1_EVCU.b_StatusByte_2_DCU.B.b_MC_Rq ) // Main Contractor Request
- gEvent = EV__DRIVE_START_3;
- }
- }
- }
- // ***** check_and_save_DICO2_EVCU *********************************************
- uint16_t check_and_save_DICO2_EVCU( CAN_MAILBOX *p_MBox )
- {
- uint8_t Data[8]; // Receive Dummy
- DICO2_EVCU_t DICO2_EVCU;
-
- if( CAN_Read(p_MBox, &Data[0] ) != CAN_ERROR )
- {
- DICO2_EVCU.b_DiagnosticInverter1.R = Data[0];
- DICO2_EVCU.b_DiagnosticInverter2.R = Data[1];
- DICO2_EVCU.b_DiagnosticInverter3.R = Data[2];
- DICO2_EVCU.b_Current_HEV_Mode.R = Data[3];
- DICO2_EVCU.powerGenerator1Fb = (uint16_t)((Data[4]<<8) + Data[5]);
- DICO2_EVCU.rpmGenerator1Fb = (uint16_t)((Data[6]<<8) + Data[7]);
-
- if( DICO2_EVCU.b_DiagnosticInverter2.B.emergency_MC_Off ) // Emergency Main Contractor Off
- {
- gErrorEvent |= EEV__SHUT_DOWN_EMERGENCY;
- }
- }
- }
- // ***** check_and_save_EVCU1_BMU *********************************************
- uint16_t check_and_save_EVCU1_BMU( CAN_MAILBOX *p_MBox )
- {
- uint8_t Data[8]; // Receive Dummy
-
- if( CAN_Read(p_MBox, &Data[0] ) != CAN_ERROR )
- {
- if(Data[7])
- gCANErrorInsert = Data[7]; //!! 1.5-3
- else
- {
- gCANErrorInsert = 0;
-
- Data[0] &= 0x03; // Mask first two Bit for Mode Request
-
- switch( Data[0] )
- {
- case MR__STANDBY :
- if( gEvent > EV__INITIALISE )
- {
- if( gEvent < EV__CHARGE )
- gEvent = EV__SHUT_DOWN_DRIVE;
- else
- gEvent = EV__SHUT_DOWN_CHARGE;
- }
- if( gEvent == EV__STAND_BY)
- {
- if( READ_INPIN( PIN_REGNR_RELAIS_PRECHA ))
- gEvent = EV__SHUT_DOWN_DRIVE;
- if( READ_INPIN( PIN_REGNR_RELAIS_SLAVE ))
- gEvent = EV__SHUT_DOWN_CHARGE;
- }
- break;
-
- case MR__DRIVE :
- if( gEvent == EV__STAND_BY ) // switch out of StandBy only
- if( READ_INPIN( PIN_REGNR_RELAIS_PRECHA ))
- gEvent = EV__DRIVE_START_3;
- else
- gEvent = EV__DRIVE_START_1;
- break;
-
- case MR__CHARGE :
- if( gEvent == EV__STAND_BY ) // switch out of StandBy only
- {
- if( !READ_INPIN( PIN_REGNR_RELAIS_PRECHA )) // not during DRIVE Start Sequence
- gEvent = EV__CHARGE;
- }
- break;
-
- default :
- break;
- }
- if( Data[1] )
- {
- ME.MCTL.R = 0x00005AF0; // Software Reset (Functional Reset)
- ME.MCTL.R = 0x0000A50F;
- while (ME.IS.B.I_MTC != 1) {} /* Wait Until transition completed */
- ME.IS.B.I_MTC = 1; /* Clear flag */
- }
- }
- }
- }
- // ***** End BMS_CAN2_Tools.c **************************************************
|