//***************************************************************************** // (C) Automotive Lighting Reutlingen GmbH // Tuebinger Strasse 123, 72762 Reutlingen, Germany // // Automotive Lighting Reutlingen GmbH owns all the rights to this work. // This work shall not be copied, reproduced, used, modified, transferred // or its information shall not be disclosed without the prior written // authorization of Automotive Lighting Reutlingen GmbH. //***************************************************************************** //----------------------------------------------------------------------------- /// \file CddStp_Simulation.h /// /// \brief Simulation interface used for HIL test /// /// \author J. Kling ALRT-EES6 (f84304b) /// //----------------------------------------------------------------------------- #ifndef CDD_STP_SIMULATION_H_ #define CDD_STP_SIMULATION_H_ //============================================================================= // Defines and Typedef //============================================================================= #define CDDSTP_SIMULATION_PASSWORD 0xC0DE1234u // previously: '0xCAFEBABEu' #define CDDSTP_SIMULATION_DEACTIVATED 0xDEADC0DEu #define CDDSTP_SIMULATION_UNUSED_VALUE 0xFFFFu typedef enum { eSimuHandling_Inactive = 0xFFu, eSimuHandling_Active = 1u } tCddStp_SimuHndlng; // Pre-Evaluation Stall-Detection typedef struct { uint8 ucStallDtctn_Haltestrom; // 'CddStp_tCodingAreaLwr.Strom.ucHaltNT' - 3x the same: TT, NT, HT uint8 ucStallDtctn_Fahrstrom; // 'CddStp_tCodingAreaLwr.Strom.ucFahrNT' - 3x the same: TT, NT, HT uint8 ucStallDtctn_Ref3Strom; // 'CddStp_tCodingAreaLwr.Strom.ucRef3NT' - 3x the same: TT, NT, HT uint16 unStallDtctn_unResHsZeitU1; // uint16 unStallDtctn_unResHsZeitO1; // uint16 unStallDtctn_unResHsZeitU2; // uint16 unStallDtctn_unResHsZeitO2; // uint16 unStallDtctn_HsZeitRef1; // speed [Hs/s] = 1 / (time [s/Hs]) uint16 unStallDtctn_HsZeitRef2; // speed [Hs/s] = 1 / (time [s/Hs]) uint16 unStallDtctn_HsZeitRef3; // speed [Hs/s] = 1 / (time [s/Hs]) uint16 unStallDtctn_unHsAnzahlRef2; // uint16 unStallDtctn_Vmin; // 'CddStp_tCodingAreaLwr.Dynamik.unVmin' uint16 unStallDtctn_Vmax; // uint16 unStallDtctn_Acc; // uint16 unStallDtctn_Richtung; // boolean boStallDtctn_TestOlIgnor; // } tCddStp_Simulation_PreEvalStallDtctn_CodingParams; // Pre-Evaluation Stall-Detection typedef struct { uint8 ucStallDtctn_STALL_TH; // Stall - Detection threshold //boolean bStallDtctn_STL_LRN; // Stall learn boolean bStallDtctn_EN_STL; // Stall enable boolean bStallDtctn_STL_REP; // 1b = Stall detection is reported on nFAULT } tCddStp_Simulation_PreEvalStallDtctn_CtrlReg; typedef struct { uint32 ulSimActivated; // simulation active (password) uint16 unVBatt_EcuSupply_mV; // 'CddStpVolt_IoHwAbUser_GetECUSupply' / 'Rte_Read_ctacCddStp_ppIoHwAbUserEcuSupply0_ulActual' / 'Rte_Read_ppIoHwAbUserEcuSupply0_ulActual' tCddStp_SimuHndlng ucSim_DriverDefect; // G-SWRS.STP2.897: Set sCddStp_Simulation_Data.ulSimActivated to 0xC0DE1234u and sCddStp_Simulation_Data.ucSim_DriverDefect to 1. tCddStp_SimuHndlng ucSim_SPI_ERROR_SpiProtocolError; // Indicates SPI protocol errors, such as more SCLK pulses than are required or SCLK is absent even though nSCS is low.Becomes high in fault and the nFAULT pin is driven low.Normal operation resumes when the protocol error is removed and a clear faults command has been issued either through the CLR_FLT bit or an nSLEEP reset pulse. uint16 unSim_SPI_ERROR_SpiProtocolErrCnt; // Indicates SPI protocol errors, such as more SCLK pulses than are required or SCLK is absent even though nSCS is low.Becomes high in fault and the nFAULT pin is driven low.Normal operation resumes when the protocol error is removed and a clear faults command has been issued either through the CLR_FLT bit or an nSLEEP reset pulse. tCddStp_SimuHndlng ucSim_UVLO_UnderVoltageLockout; // Indicates an undervoltage lockout fault condition. tCddStp_SimuHndlng ucSim_UVLO_UnderVoltageLockout; // Indicates an undervoltage lockout fault condition. tCddStp_SimuHndlng ucSim_CPUV_ChargePumpUndervoltage; // Indicates charge pump undervoltage fault condition. tCddStp_SimuHndlng ucSim_OCP_OverCurrentProtection; // Indicates overcurrent fault condition tCddStp_SimuHndlng ucSim_OL_OpenLoad; // Indicates open-load condition //tCddStp_SimuHndlng ucSim_TF_ThermalFault; // Logic OR of the overtemperature warning, undertemperature warning and overtemperature shutdown. tCddStp_SimuHndlng ucSim_OTW_OverThermalWarning; // Over-Thermal-Warning: reducing of current - NO stop and NO error tCddStp_SimuHndlng ucSim_OTS_OverTemperatureShutdown; // Indicates overtemperature shutdown tCddStp_SimuHndlng ucSim_UTW_UnderTemperatureWarning; // Indicates undertemperature warning - currently NOT used tCddStp_SimuHndlng ucSim_LT_IsLowTemperature; // set Low-Temperature-Mode uint8 ucSim_StReg_Basic; // 1 1 UVLO CPUV OCP RSVD TF OL uint8 ucSim_StReg_Fault; // FAULT SPI_ERROR UVLO CPUV OCP RSVD TF OL uint8 ucSim_StReg_DiagStatus1; // OCP_LS2_B OCP_HS2_B OCP_LS1_B OCP_HS1_B OCP_LS2_A OCP_HS2_A OCP_LS1_A OCP_HS1_A uint8 ucSim_StReg_DiagStatus2; // UTW OTW OTS RSVD RSVD RSVD OL_B OL_A // Pre-Evaluation Stall-Detection // // https://jind.magnetimarelli.com/aljira/browse/FLMT-5039 // Es wird eine Software bereitgestellt, in der sich die unterschiedlichen Parameter einstellen lassen: // * Haltestrom ihold // * Fahrstrom irun // * Maximalgeschwindigkeit vmax // * Minimalgeschwindigkeit vmin // * Beschleunigung acc // * Stepmode // * Stall - Detection threshold STALL_TH // * Stall learn - STL_LRN ? // * Stall enable - EN_STL // * Motor stop @ Stall - gut wäre, wenn es eine Einstellmöglichkeit gibt, mit der die Software den Motor stoppt, wenn der TI - Treiber eine Blockade erkennt. // * Idealerweise lassen sich diese Parameter während der Laufzeit ändern // * DECAY(wobei ich verstanden habe, dass die Stall - Detection sowieso nur bei dem Modus „Smart Tune Ripple Decay“ aktiv ist – das ist also erst mal nicht so wichtig) // * Außerdem müssen folgende Werte aus dem Speicher des Treibers auslesbar sein : // * STL_LRN_OK // * STALL(STL_REP) // * TRQ_CNT(oder TRQ_DAC – je nachdem was besser zu interpretieren ist) // boolean bStallDtctn_ReadCodingOnce; // true = read (probably modified) coding ONCE and reset this var tCddStp_Simulation_PreEvalStallDtctn_CodingParams codingParams; // e.g. ucStallDtctn_Haltestrom / 'CddStp_tCodingAreaLwr.Strom.ucHaltNT', unStallDtctn_Vmax, ... tCddStp_Simulation_PreEvalStallDtctn_CtrlReg controlRegisters; // e.g. ucStallDtctn_STALL_TH, bStallDtctn_EN_STL, ... boolean bStallDtctn_WriteCReg6Once; // usually do READ CReg-6 - only on request do WRITE ONCE boolean bStallDtctn_WriteClrFltOnce; // usually 'CLR_FLT' in CReg4 is '0' - only on request do WRITE ONCE '1' boolean bStallDtctn_WriteStlLrn; // usually 'STL_LRN' in CReg5 is '0' - only on request do WRITE '1' //boolean bStallDtctn_WriteStlLrnOnce; // usually 'STL_LRN' in CReg5 is '0' - only on request do WRITE ONCE '1' boolean bStallDtctn_StopAtStall; // Motor stop @ Stall - gut wäre, wenn es eine Einstellmöglichkeit gibt, mit der die Software den Motor stoppt, wenn der TI - Treiber eine Blockade erkennt. sint32 lStallDtctn_PosAtStop; // Motor stop @ Stall - current position on last stall 'CddStp88XX_HalStp_StpInfoLwr.lActPos' uint16 unStallDtctn_SpeedViaTime; // '1506' is typicall 'Ref-Speed' - the smaller the faster } tCddStp_Simulation_Data; // simulation for validation purposes boolean CddStp_Simulation_IsSimActive(void); boolean CddStp_Simulation_HandleVBatt_EcuSupply(uint16 * punVoltage_mV); void CddStp_Simulation_HandleSpiRxStatusBits(boolean * pboSim_DriverDefect, boolean * pboSim_SPI_ERROR_SpiProtocolError , boolean * pboSim_UVLO_UnderVoltageLockout , boolean * pboSim_CPUV_ChargePumpUndervoltage, boolean * pboSim_OCP_OverCurrentProtection , boolean * pboSim_OL_OpenLoad /*, boolean * pboSim_TF_ThermalFault*/ , boolean * pboSim_OTW_OverThermalWarning , boolean * pboSim_OTS_OverTemperatureShutdown, boolean * pboSim_UTW_UnderTemperatureWarning); void CddStp_Simulation_HandleStatusRegisters(uint8 * pucBasic, uint8 * pucFault, uint8 * pucDiagStatus1, uint8 * pucDiagStatus2); boolean CddStp_Simulation_HandleDriverDefect_FatalError(void); boolean CddStp_Simulation_HandleLowTempMode(void); void CddStp_Simulation_PreEvalStallDtctn(void); boolean CddStp_Simulation_PreEvalStallDtctn_ReadCodingOnce(void); void CddStp_Simulation_PreEvalStallDtctn_SetCodingParams(tCddStp_Simulation_PreEvalStallDtctn_CodingParams * pCodingParams); void CddStp_Simulation_PreEvalStallDtctn_GetCodingParams(tCddStp_Simulation_PreEvalStallDtctn_CodingParams * pCodingParams); void CddStp_Simulation_PreEvalStallDtctn_GetControlRegs( tCddStp_Simulation_PreEvalStallDtctn_CtrlReg * pControlRegisters); void CddStp_Simulation_PreEvalStallDtctn_SetPosAtStall(sint32 lPosAtStop); sint32 CddStp_Simulation_PreEvalStallDtctn_GetPosAtStall(void); boolean CddStp_Simulation_PreEvalStallDtctn_GetWriteCReg6Once(void); boolean CddStp_Simulation_PreEvalStallDtctn_GetWriteClrFltOnce(void); // lean CddStp_Simulation_PreEvalStallDtctn_GetWriteStlLrnOnce(void); boolean CddStp_Simulation_PreEvalStallDtctn_GetWriteStlLrn(void); void CddStp_Simulation_PreEvalStallDtctn_ResetStlLrn(void); void CddStp_Simulation_PreEvalStallDtctn_GetStpSpeed(uint16 * punTmin); #endif // CDD_STP_SIMULATION_H_ // EOF