//***************************************************************************** // (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 CddMlcGen.c /// /// \brief Generic interface for the MLC driver /// //----------------------------------------------------------------------------- //============================================================================= // Includes //============================================================================= #define E2E_Remove #include #include #include #include #include #include "CddMlcGenPrivate.h" #include #include "CddMlcGen_Coding.h" #include //#include //#include "Dio.h" //#include //#include //#include //============================================================================= // Globals //============================================================================= // PRQA S 3408 EOF // Program architecture and code readability //ToDo: Name space must be consistent. CddMlc_x prefix prefered used //STATIC_AL tsRteCodingParameters CodingParameters; STATIC_AL eCddMlcGenDeviceType CddMlcGen_ConnectedDevice = eMlcDeviceMax; STATIC_AL boolean CddMlc_boActionToExecuteAfterNewConfig = FALSE; STATIC_AL boolean CddMlc_boOperationEnabled = FALSE; STATIC_AL tisMlcSensorInput CddMlcGen_Sensor[CFG_MAX_NO_OF_MLC] = {0U}; STATIC_AL tisMxMlcStatusFault CddMlcGen_asDeviceStatusFault[CFG_MAX_NO_OF_MLC] = {0U}; // Refers to MLC Device //STATIC_AL tsCddMlcRegReadRequestHandler CddMlc_sRegReadRequestHandler = {FALSE, 0U}; F82099D: unused variable removed STATIC_AL tisAllMlcTargets CddMlc_sAllMlcTargets; STATIC_AL uint16 CddMlc_sTestMlcTargets[CDD_MLC_MAX_SUPPORTED_ELEMENTS]; STATIC_AL uint8 CddMlc_ucCycleFrame = 0U; #ifndef E2E_Remove //E2E Protection STATIC_AL uint8 CddMlc_E2E_Read_DebounceCounter; STATIC_AL uint8 CddMlc_E2E_Write_DebounceCounter; STATIC_AL boolean CddMlc_E2E_Read_faultActive = FALSE; STATIC_AL boolean CddMlc_E2E_Write_faultActive = FALSE; #endif STATIC_AL uint8 ucQtyStsBits; //ToDo: Analyze why this variable has external access #ifndef UNIT_TEST sCddMlcGenCodingData CddMlcGenCodingDataValue; #else extern sCddMlcGenCodingData CddMlcGenCodingDataValue; #endif //============================================================================= // Macros //============================================================================= #define CDD_MLC_GEN_PWM_CONVERT_TI_PERCENT_TO_RAW(x) \ (uint16)((0x3FFUL * (x)) / 0x8000UL) //10 bit resolution #define CDD_MLC_GEN_PWM_CONVERT_DIAG_TI_PERCENT_TO_RAW(x) \ (uint16)((0x3FFUL * (x)) / 100U) //10 bit resolution #define CDD_MLC_GEN_PWM_CONVERT_NXP_PERCENT_TO_RAW(x) \ (uint16)((0xFFFUL * (x)) / 0x8000UL) //12 bit resolution #define CDD_MLC_GEN_PWM_CONVERT_DIAG_NXP_PERCENT_TO_RAW(x) \ (uint16)((0xFFFUL * (x)) / 100U) //12 bit resolution #define CDD_MLC_GEN_PWM_CONVERT_IND_PERCENT_TO_RAW(x) \ (uint16)((0xFFFUL * (x)) / 0x8000UL) //12 bit resolution #define CDD_MLC_GEN_PWM_CONVERT_DIAG_IND_PERCENT_TO_RAW(x) \ (uint16)((0xFFFUL * (x)) / 100U) //12 bit resolution //E2E Wrapper #define FAULT_THRESH 19U //check if 19 or /*#define CDDMLC_POWER_ON() \ Dio_WriteChannel(DioConf_DioChannel_DioChannel_HSS_IN2, STD_HIGH) #define CDDMLC_POWER_OFF() \ Dio_WriteChannel(DioConf_DioChannel_DioChannel_HSS_IN2, STD_LOW) #define CDDMLC_IS_HSS2_ENABLED() \ (STD_HIGH == Dio_ReadChannel(DioConf_DioChannel_DioChannel_HSS_IN2)) */ //============================================================================= // Defines //============================================================================= //============================================================================= // Private prototypes //============================================================================= STATIC_AL void CddMlc_UpdateRuntimeStatus(void); STATIC_AL void CddMlc_UpdateInitStatus(void); STATIC_AL void CddMlc_fill_target_buffer(void); //STATIC_AL void CddMlc_RegWrite(uint8 ucDev, uint8 ucReg, uint8 ucData); F82099D: unused function removed //STATIC_AL void CddMlc_RegSetReadAdr(uint8 ucDev, uint8 ucReg); //STATIC_AL void CddMlc_ProvideReadAdrInfo(void); #ifndef E2E_Remove //E2E wrapper STATIC_AL inline boolean CddMlc_ReadE2E_ErrorCheck(uint32 E2E_ReadReturnVal); STATIC_AL inline boolean CddMlc_WriteE2E_ErrorCheck(uint32 E2E_WriteReturnVal); #endif //----------------------------------------------------------------------------- /// \brief CddMlcGen_Init /// /// \descr This function calls the correct init function assigned to the /// MLC device type /// /// \param eDeviceId : MLC device type /// /// \return void //----------------------------------------------------------------------------- void CddMlcGen_Init(eCddMlcGenDeviceType eDeviceId) { /* call the appropriate MLC init function */ if((eDeviceId < eMlcDeviceMax) && (gCddMlcGenAPIs[eDeviceId].init != NULL_PTR)) { gCddMlcGenAPIs[eDeviceId].init(); } } //----------------------------------------------------------------------------- /// \brief CddMlcGen_Cyclic /// /// \descr This function calls the correct cyclic function assigned to the /// MLC device type /// /// \param eDeviceId : MLC device type /// /// \return void //----------------------------------------------------------------------------- void CddMlcGen_Cyclic(eCddMlcGenDeviceType eDeviceId) { /* call the appropriate MLC cyclic function */ if((eDeviceId < eMlcDeviceMax) && (gCddMlcGenAPIs[eDeviceId].cyclic != NULL_PTR)) { gCddMlcGenAPIs[eDeviceId].cyclic(); } } //----------------------------------------------------------------------------- /// \brief CddMlcGen_GetCodingParam /// /// \descr Read coding parameters and extract useful information for MLC devices /// /// \param void /// /// \return eCddMlcGenDeviceType : MLC device type //----------------------------------------------------------------------------- eCddMlcGenDeviceType CddMlcGen_GetCodingParam(void) { eCddMlcGenDeviceType eReturnValue; uint8 ucDeviceIdx; /* get mlc chip type */ CDDMLC_CODING_GET_MLC_TYPE(&CddMlcGenCodingDataValue); /* get mlc bus interface */ CDDMLC_CODING_GET_MLC_CAN_UART_INTERFACE(&CddMlcGenCodingDataValue); /* get mlc addresses */ CDDMLC_CODING_GET_MLC_CAN_UART_ADDRESS(&(CddMlcGenCodingDataValue)); CddMlcGenCodingDataValue.ucMlcMatrixType = CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_IND; #if 0 //debug purpose /* ------ BEGIN : hard coded values for Gen 4 family until coding is provided --------- */ CddMlcGenCodingDataValue.ucMlcMatrixType = CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_TPS9266x; if (CddMlcGenCodingDataValue.ucMlcMatrixType == CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_TPS92662A) { CddMlcGenCodingDataValue.ucMlcCanUartAddress[0] = 7;//7u; // TI // ok, working CddMlcGenCodingDataValue.ucMlcCanUartAddress[1] = 1;//6u; // DRL1 // ok, working CddMlcGenCodingDataValue.ucMlcCanUartAddress[2] = 2;//2u; // DRL2 // ok, working CddMlcGenCodingDataValue.ucMlcCanUartAddress[3] = 3;//3u; // DRL2 CddMlcGenCodingDataValue.ucMlcCanUartAddress[4] = 4;//4u; // DRL2 CddMlcGenCodingDataValue.ucMlcCanUartAddress[5] = 5;//5u; // DRL2 } else if (CddMlcGenCodingDataValue.ucMlcMatrixType == CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_TPS92664) { CddMlcGenCodingDataValue.ucMlcCanUartAddress[0] = 15u; // TI - write 255 and chip will be disabled <=> MLC 1 (ID15) CddMlcGenCodingDataValue.ucMlcCanUartAddress[1] = 5u; // DRL1 <=> MLC 2 (ID01) CddMlcGenCodingDataValue.ucMlcCanUartAddress[2] = 10u; // DRL2 <=> MLC 3 (ID02) } else if (CddMlcGenCodingDataValue.ucMlcMatrixType == CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_TPS9266x) { CddMlcGenCodingDataValue.ucMlcCanUartAddress[0] = 7; // TI // ok, working CddMlcGenCodingDataValue.ucMlcCanUartAddress[1] = 1; // DRL1 // ok, working CddMlcGenCodingDataValue.ucMlcCanUartAddress[2] = 2; // DRL2 // ok, working CddMlcGenCodingDataValue.ucMlcCanUartAddress[3] = 3; // DRL2 CddMlcGenCodingDataValue.ucMlcCanUartAddress[4] = 4; // DRL2 CddMlcGenCodingDataValue.ucMlcCanUartAddress[5] = 5; // DRL2 CddMlcGenCodingDataValue.ucMlcCanUartAddress[6] = 0u; // TPS664 - 15u; // HB CddMlcGenCodingDataValue.ucMlcCanUartAddress[7] = 255u; // TPS664 - 10u; // HB } else {} /* ------ END : hard coded values for Gen 4 family until coding is provided --------- */ #endif /* get total number of connected mlc chips */ //check if matrix is connected if (CddMlcGenCodingDataValue.ucMlcMatrixType != CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_DISABLED) { CddMlcGenCodingDataValue.ucMlcMatrixCount = 0U; //counter must reset befour starting counting again /* get total number of connected mlc chips */ for (ucDeviceIdx = 0U; ucDeviceIdx < CDDMLC_SUPPORTED_MLCs; ucDeviceIdx++) { if (CddMlcGenCodingDataValue.ucMlcCanUartAddress[ucDeviceIdx] != MLC_DEV_ADDR_NOT_CONNECTED) { CddMlcGenCodingDataValue.ucMlcMatrixCount++; } else { //Do nothing } } } else { //recoding has happened, reset no of mlcs CddMlcGenCodingDataValue.ucMlcMatrixCount = (uint8)CDD_MLC_ZERO; } switch (CddMlcGenCodingDataValue.ucMlcMatrixType) { case CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_IND: CddMlcGenCodingDataValue.ucMlcSwitchsSupported = CDDMLCInd8308_MAX_SWITCHS_PER_DEVICE; eReturnValue = MLC_DEVICE(MLC_DEVICE_IND); break; default: eReturnValue = eMlcDeviceMax; // undefined break; } return eReturnValue; } //----------------------------------------------------------------------------- /// \brief riCddMlcInit /// /// \descr Initialization runnable /// /// \param - /// /// \return void //----------------------------------------------------------------------------- void riCddMlcInit(void) { //ENTER_INIT_RUNNABLE(RICDDMLCINIT); #ifndef E2E_Remove (void)E2EPW_WriteInit_ppaseCddMlcMxSwitchAndSensorStatus0_sAllMlcSwitchAndAllSensorStatus(); (void)E2EPW_ReadInit_ppareSysMonMxTarget0_sAllMlcTargets(); #endif CddMlc_UpdateInitStatus(); #if (CDDMLC_DEBUG_ITM_ENABLE == STD_ON) ITM_TRACE_ENABLE(0xFFFFFFFF); #endif //EXIT_INIT_RUNNABLE(RICDDMLCINIT); //architecture specific return; } //----------------------------------------------------------------------------- /// \brief riCddMlcDeInit /// /// \descr Deinitialization runnable /// /// \param - /// /// \return void //----------------------------------------------------------------------------- void rdCddMlcDeInit(void) { //ENTER_DE_INIT_RUNNABLE(RICDDMLCDEINIT); //Empty until Shutdown process is clear //ENTER_DE_INIT_RUNNABLE(RICDDMLCDEINIT); //architecture specific return; } #if 0 //----------------------------------------------------------------------------- /// \brief roCddMlcRegWrite /// /// \descr /// /// \param ucDevArr /// \param ucRegAdr /// \param ucData /// /// \return FUNC(void, ctacCddMlc_CODE) //----------------------------------------------------------------------------- FUNC(void, ctacCddMlc_CODE) roCddMlcRegWrite( uint8 ucDevArr, uint8 ucRegAdr, uint8 ucData) { CddMlc_RegWrite(ucDevArr, ucRegAdr, ucData); } //----------------------------------------------------------------------------- /// \brief /// /// \descr /// /// \param ucDevAdr /// \param ucRegAdr /// /// \return FUNC(void, ctacCddMlc_CODE) //----------------------------------------------------------------------------- FUNC(void, ctacCddMlc_CODE) roCddMlcSetReadAdr( uint8 ucDevAdr, uint8 ucRegAdr) { CddMlc_RegSetReadAdr(ucDevAdr, ucRegAdr); } #endif //----------------------------------------------------------------------------- /// \brief CddMlc_EvaluateCoding /// /// \descr Function checks if we have already read the coding data. If not, then /// read the specific coding parameters and check if MLCs are enabled /// /// \param - /// /// \return STATIC_AL void //----------------------------------------------------------------------------- STATIC_AL void CddMlc_EvaluateCoding(void) { STATIC_UT(tieDataStatus, eCodingPrevStatus, tieDataStatus_Invalid); tieDataStatus eCodingStatus; //Check if Coding Data need to be reloaded (void)Rte_Read_ppareCodMCodingDataStatus0_eCompleteCodingDataStatus(&eCodingStatus); //eCodingStatus = tieDataStatus_Valid; if((eCodingStatus == tieDataStatus_Valid) && (eCodingPrevStatus == tieDataStatus_Invalid)) { //Check which device is connected from the CodingM CddMlcGen_ConnectedDevice = CddMlcGen_GetCodingParam(); //Check if the MLC driver is enabled or not if(CddMlcGenCodingDataValue.ucMlcMatrixCount > 0U) { CddMlc_boOperationEnabled = TRUE; } else { CddMlc_boOperationEnabled = FALSE; } //Reset flag -> new coding requires new once executed actions CddMlc_boActionToExecuteAfterNewConfig = TRUE; } eCodingPrevStatus = eCodingStatus; } //----------------------------------------------------------------------------- /// \brief rpCddMlc_Cycle /// /// \descr Cyclic runnable for MLC devices /// /// \param - /// /// \return void //----------------------------------------------------------------------------- // for compile, 2024.01.31 #define CDDMLC_IS_POWERED() TRUE void rpCddMlc1ms(void) { //Measurement purposes //ENTER_CYCLIC_RUNNABLE(RPCDDMLC10MS); #if (CDDMLC_DEBUG_ITM_ENABLE == STD_ON) ITM_TRACE_D8(0, 0); #endif #ifndef E2E_Remove uint32 E2E_ReadReturnVal, E2E_WriteReturnVal; boolean boReadError, boWriteError; #endif if ((CddMlc_ucCycleFrame % 13U) == 0U) { CddMlc_ucCycleFrame = 0U; CddMlc_EvaluateCoding(); //Step 1: read RTE port #ifndef E2E_Remove //Step 1: read RTE port E2E_ReadReturnVal = E2EPW_Read_ppareSysMonMxTarget0_sAllMlcTargets(&CddMlc_sAllMlcTargets); boReadError = CddMlc_ReadE2E_ErrorCheck(E2E_ReadReturnVal); if (boReadError != FALSE) { //ucQtyStsBits = 1u; } else { //no CRC error, read target values CddMlc_fill_target_buffer(); //ucQtyStsBits = 0u; } ucQtyStsBits = (CddMlc_E2E_Read_faultActive == TRUE) ? INVALID_VALUE_ERROR : 0x00; #else (void)Rte_Read_ppareSysMonMxTarget0_sAllMlcTargets(&CddMlc_sAllMlcTargets); //no CRC error, read target values CddMlc_fill_target_buffer(); //ucQtyStsBits = 0u; ucQtyStsBits = 0x00; #endif // // Cycle routine performed depending on if MLC is present or not // in the ECU configuration (coding data) // // OperationEnabled: At least 1 MLC is connected // OperationDisabled: No MLC connected // // Devices are connected according to Coding Data // MLC Operation must be enabled if (CddMlc_boOperationEnabled == TRUE) { // static boolean CddMlcGen_boMlcPoweredUP = FALSE; STATIC_UT(boolean, CddMlcGen_boMlcPoweredUP, FALSE); // static uint8 CddMlcGen_ucPowerUpGuard = 0U; STATIC_UT(uint8, CddMlcGen_ucPowerUpGuard, 0U); //Call the appropriate init function if (CddMlc_boActionToExecuteAfterNewConfig == TRUE) { CddMlc_UpdateInitStatus(); CddMlcGen_Init(CddMlcGen_ConnectedDevice); CddMlc_boActionToExecuteAfterNewConfig = FALSE; } /* Power Up Delay, before sending any command to MLCs */ if ((CDDMLC_IS_POWERED() == TRUE) && (CddMlcGen_boMlcPoweredUP == FALSE)) { /* Introduce some delay till the HSS2 output became stable before starting the initialization sequence of the MLC driver */ if (CddMlcGen_ucPowerUpGuard >= CDDMLC_POWERUP_CYCLE_GUARD) { CddMlcGen_boMlcPoweredUP = TRUE; /* init the MLC driver state machine */ CddMlcGen_SetTransmissionToNormal(); } CddMlcGen_ucPowerUpGuard++; } /* reset the flag */ if (CDDMLC_IS_POWERED() == FALSE) { /* reset the flag */ CddMlcGen_boMlcPoweredUP = FALSE; CddMlcGen_ucPowerUpGuard = 0U; /* stop the driver */ CddMlcGen_SetTransmissionToInactive(); } /* call the appropriate cyclic function */ if (CddMlcGen_boMlcPoweredUP == TRUE) { CddMlcGen_Cyclic(CddMlcGen_ConnectedDevice); } //Provide MLC Status to RTE CddMlc_UpdateRuntimeStatus(); #if 0 //currently implemented only for NXP, for TI is empty - H5 USES ONLY TI - do not call for the moment //Provide ReadReg Info if requested CddMlc_ProvideReadAdrInfo(); #endif } else { //Do Nothing } } // end if // handle communication loss /* in ZhiXin platform, uartcan is not finished and has not communication loss function yet 2024.01.31 */ //increment CycleFrame to call the content of the ciclic function every 10 ms CddMlc_ucCycleFrame++; #if (CDDMLC_DEBUG_ITM_ENABLE == STD_ON) ITM_TRACE_D8(0, 1); #endif //(void)Rte_Call_ctadCddMlc_ppaclWdgMCheckPointReachedForCddMlc1ms_WdgMCheckPointReached(Wdgm_ALive_Supervision_Checkpoint); //EXIT_CYCLIC_RUNNABLE(RPCDDMLC10MS); } //----------------------------------------------------------------------------- /// \brief rpCddMlc10ms /// /// \descr Cyclic 10 ms runnable for MLC devices /// /// \param - /// /// \return void //----------------------------------------------------------------------------- FUNC(void, ctadCddMlc_CODE) rpCddMlc10ms(void) { //(void)Rte_Call_ctadCddMlc_ppaclWdgMCheckPointReachedForCddMlc10ms_WdgMCheckPointReached(Wdgm_ALive_Supervision_Checkpoint); } //----------------------------------------------------------------------------- /// \brief CddMlcGen_GetTargetBufAddress /// /// \descr Returns the PWMs values assigned to the device type /// /// \param - /// /// \return uint16 * //----------------------------------------------------------------------------- uint16* CddMlcGen_GetTargetBufAddress(void) { uint16* unReturnValue = NULL_PTR; unReturnValue = ((uint16*)CddMlcInd8308_GetTargetBufAddress()); return unReturnValue; } //----------------------------------------------------------------------------- /// \brief CddMlcGen_SetTransmissionToInactive /// /// \descr Sets the state of the MLC device to Inactive (communication OFF) /// /// \param /// /// \return //----------------------------------------------------------------------------- void CddMlcGen_SetTransmissionToInactive(void) { CddMlcInd8308_SetTransmissionToInactive(); } //----------------------------------------------------------------------------- /// \brief CddMlcGen_SetTransmissionToNormal /// /// \descr Sets the state of the MLC device to Normal Mode (communication ON) /// /// \param /// /// \return //----------------------------------------------------------------------------- void CddMlcGen_SetTransmissionToNormal(void) { CddMlcInd8308_SetTransmissionToNormal(); } //----------------------------------------------------------------------------- /// \brief CddMlcGen_ConvertToRawValue /// /// \descr Converts the received PWM values to the correct resolution depending /// on the MLC device type /// /// \param - /// /// \return uint16 * //----------------------------------------------------------------------------- uint16 CddMlcGen_ConvertToRawValue(uint16 ValueInPercent) { uint16 unReturnValue = 0u; unReturnValue = ((uint16)CDD_MLC_GEN_PWM_CONVERT_IND_PERCENT_TO_RAW(ValueInPercent)); return unReturnValue; } //----------------------------------------------------------------------------- /// \brief CddMlcGen_ConvertDiagToRawValue /// /// \descr /// /// \param - /// /// \return uint16 * //----------------------------------------------------------------------------- uint16 CddMlcGen_ConvertDiagToRawValue(uint16 ValueInPercent) { uint16 unReturnValue = 0u; unReturnValue = ((uint16)CDD_MLC_GEN_PWM_CONVERT_DIAG_IND_PERCENT_TO_RAW(ValueInPercent)); return unReturnValue; } #if 0 //unused code //----------------------------------------------------------------------------- /// \brief CddMlc_RegWrite /// /// \descr /// /// \param ucDev /// \param ucReg /// \param ucData /// /// \return boolean //----------------------------------------------------------------------------- STATIC_AL void CddMlc_RegWrite(uint8 ucDev, uint8 ucReg, uint8 ucData) { if (ucDev < CddMlcGenCodingDataValue.ucMlcMatrixCount) { switch (CddMlcGenCodingDataValue.ucMlcMatrixType) { case CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_NXP: CddMlcNxp_RegWriteRequest(ucDev, ucReg, ucData); break; case CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_TPS92662A: case CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_TPS92663A: //Placeholder for TI break; default: break; } } } //----------------------------------------------------------------------------- /// \brief CddMlc_RegSetReadAdr /// /// \descr Trigger Reg Read command to underlaying module /// /// \param ucDevAdr /// \param ucRegAdr /// /// \return void //----------------------------------------------------------------------------- STATIC_AL void CddMlc_RegSetReadAdr(uint8 ucDev, uint8 ucReg) { boolean boPerformed = FALSE; if (ucDev < CddMlcGenCodingDataValue.ucMlcMatrixCount) { switch (CddMlcGenCodingDataValue.ucMlcMatrixType) { case CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_NXP: boPerformed = CddMlcNxp_RegReadRequest(ucDev, ucReg); break; case CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_TPS92662A: case CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_TPS92663A: //Placeholder for TI break; default: break; } } //if(boPerformed == TRUE) //{ // CddMlc_sRegReadRequestHandler.boRequested = TRUE; // CddMlc_sRegReadRequestHandler.ucTimeOutCnt = 0U; // (void)Rte_Write_ppCddMlcRegRead_ucDevAdr(ucDev); // (void)Rte_Write_ppCddMlcRegRead_ucRegAdr(ucReg); // (void)Rte_Write_ppCddMlcRegRead_eErrMlcRegRead(ERR_SNA); //} //else //{ // (void)Rte_Write_ppCddMlcRegRead_eErrMlcRegRead(ERR_YES); //} } //----------------------------------------------------------------------------- /// \brief CddMlc_ProvideReadAdrInfo /// /// \descr /// /// \param - /// /// \return void //----------------------------------------------------------------------------- STATIC_AL void CddMlc_ProvideReadAdrInfo(void) { if (CddMlc_sRegReadRequestHandler.boRequested == TRUE) { uint8 boPerformed = FALSE; uint8 ucVal = 0U; switch (CddMlcGenCodingDataValue.ucMlcMatrixType) { case CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_NXP: boPerformed = CddMlcNxp_GetRegRead(&ucVal); break; case CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_TPS92662A: case CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_TPS92663A: //Placehoder for TI break; default: break; } //if (boPerformed == TRUE) //{ // (void)Rte_Write_ppCddMlcRegRead_eErrMlcRegRead(ERR_NO); // (void)Rte_Write_ppCddMlcRegRead_ucData(ucVal); // CddMlc_sRegReadRequestHandler.boRequested = FALSE; //} //else //{ // CddMlc_sRegReadRequestHandler.ucTimeOutCnt++; // if (CddMlc_sRegReadRequestHandler.ucTimeOutCnt >= CDDMLC_READREG_REQUEST_TIMEOUT) // { // (void)Rte_Write_ppCddMlcRegRead_eErrMlcRegRead(ERR_YES); // CddMlc_sRegReadRequestHandler.boRequested = FALSE; // //Timeout will be reset in new ReadReg request // } //} } } #endif //----------------------------------------------------------------------------- /// \brief CddMlc_UpdateInitStatus /// /// \descr This function updates the initial status /// /// \param - /// /// \return STATIC_AL void //----------------------------------------------------------------------------- STATIC_AL void CddMlc_UpdateInitStatus(void) { for (uint8 ucDevIdx = 0U; ucDevIdx < CFG_MAX_NO_OF_MLC ; ucDevIdx++) { CddMlcGen_asDeviceStatusFault[ucDevIdx].eStatSupported = ((ucDevIdx < CddMlcGenCodingDataValue.ucMlcMatrixCount)) ? SUPPORT_YES : SUPPORT_NO; CddMlcGen_asDeviceStatusFault[ucDevIdx].eFltCom = ((ucDevIdx < CddMlcGenCodingDataValue.ucMlcMatrixCount)) ? FLT_SNA : FLT_DISABLED; CddMlcGen_asDeviceStatusFault[ucDevIdx].eFltThermalWarning = ((ucDevIdx < CddMlcGenCodingDataValue.ucMlcMatrixCount)) ? FLT_SNA : FLT_DISABLED; CddMlcGen_asDeviceStatusFault[ucDevIdx].boStatReset = TRUE; for (uint8 ucSwitchIdx = 0U; ucSwitchIdx < CDDMLC_MAX_SEGMENT_PER_DEVICE; ucSwitchIdx++) //Segments supported in the application { CddMlcGen_asDeviceStatusFault[ucDevIdx].asMxStatusFault[ucSwitchIdx].eStatSupported = (((ucDevIdx < CddMlcGenCodingDataValue.ucMlcMatrixCount) && (ucSwitchIdx < CddMlcGenCodingDataValue.ucMlcSwitchsSupported) )) ? SUPPORT_YES : SUPPORT_NO; CddMlcGen_asDeviceStatusFault[ucDevIdx].asMxStatusFault[ucSwitchIdx].eFltLsOpen = (((ucDevIdx < CddMlcGenCodingDataValue.ucMlcMatrixCount) && (ucSwitchIdx < CddMlcGenCodingDataValue.ucMlcSwitchsSupported) )) ? FLT_SNA : FLT_DISABLED; CddMlcGen_asDeviceStatusFault[ucDevIdx].asMxStatusFault[ucSwitchIdx].eFltLsShort = (((ucDevIdx < CddMlcGenCodingDataValue.ucMlcMatrixCount) && (ucSwitchIdx < CddMlcGenCodingDataValue.ucMlcSwitchsSupported) )) ? FLT_SNA : FLT_DISABLED;; } } //Update status to RTE // (void)Rte_Write_ppaseCddMlcMxSwitchStatusError0_asVal ((const tisMxMlcStatusFault *)CddMlcGen_asDeviceStatusFault); //(void)Rte_Write_ppaseCddMlcMxSwitchStatusError0_eMlcComStatus ((CddMlcGenCodingDataValue.ucMlcMatrixCount != 0U) ? eStatusOnOff_STAT_ON : eStatusOnOff_DISABLED); #ifndef UNIT_TEST CddMlc_Rte_Write_MxSwitchAndSensorStatus(CddMlcGen_asDeviceStatusFault, CddMlcGen_Sensor, FLT_SNA, ((CddMlcGenCodingDataValue.ucMlcMatrixCount != 0U) ? eStatusOnOff_STAT_ON : eStatusOnOff_DISABLED), ucQtyStsBits); #else (void)Rte_Write_ppaseCddMlcMxSwitchAndSensorStatus0_sAllMlcSwitchAndAllSensorStatus(0); #endif } //----------------------------------------------------------------------------- /// \brief CddMlc_UpdateRuntimeStatus /// /// \descr Get Status from under layer and send to RTE /// /// \param /// /// \return void //----------------------------------------------------------------------------- STATIC_AL void CddMlc_UpdateRuntimeStatus (void) { //Get Data from underliying module boolean boBusComError = FALSE; tsCddMlcDeviceStatusFault asDeviceStatusFault[CFG_MAX_NO_OF_MLC]; tsCddMlcSwitchFault asSwitchFault[CFG_MAX_NO_OF_MLC][CDDMLC_MAX_SEGMENT_PER_DEVICE]; switch (CddMlcGenCodingDataValue.ucMlcMatrixType) { case CDDMLC_GEN_CODING_MATRIX_MLC_TYPE_IND: CddMlcInd8308_GetDeviceStatusFault((tsCddMlcDeviceStatusFault*)asDeviceStatusFault, CddMlcGenCodingDataValue.ucMlcMatrixCount); CddMlcInd8308_GetSwitchsFault(asSwitchFault, CddMlcGenCodingDataValue.ucMlcMatrixCount, CddMlcGenCodingDataValue.ucMlcSwitchsSupported); CddMlcInd8308_GetSensorInfo((tisMlcSensorInput*)CddMlcGen_Sensor, CddMlcGenCodingDataValue.ucMlcMatrixCount); boBusComError = CddMlcInd8308_GetBusComError(); break; default: break; } for (uint8 ucDevIdx = 0U; ucDevIdx < CFG_MAX_NO_OF_MLC ; ucDevIdx++) // fix for HQGIF-1278 - shall be CFG_MAX_NO_OF_MLC, not CddMlcGenCodingDataValue.ucMlcMatrixCount { /*check for valid MLC address from coding parameter*/ if (CddMlcGenCodingDataValue.ucMlcCanUartAddress[ucDevIdx] != CDD_MLC_INVALID_ADDR) {/*Check uart interface is of type private CAN and verify priavte CAN populated */ if ( 0U == (CddMlcGenCodingDataValue.ucMlcCanUartInterface & (uint8)(1U << ucDevIdx)) ) { CddMlcGen_asDeviceStatusFault[ucDevIdx].eStatSupported = SUPPORT_YES; } /*Check uart interface is of type Sat CAN and verify Sat CAN populated */ else if ( 1U == (CddMlcGenCodingDataValue.ucMlcCanUartInterface & (uint8)(1U << ucDevIdx)) ) { CddMlcGen_asDeviceStatusFault[ucDevIdx].eStatSupported = SUPPORT_YES; } /*Check uart interface is of type private CAN and verify private CAN populated */ else { CddMlcGen_asDeviceStatusFault[ucDevIdx].eStatSupported = SUPPORT_NO; } } else { CddMlcGen_asDeviceStatusFault[ucDevIdx].eStatSupported = SUPPORT_NO; } //save the received error status CddMlcGen_asDeviceStatusFault[ucDevIdx].eFltCom = ((asDeviceStatusFault[ucDevIdx].boCommunicationError & (uint8)0x01) == (uint8)0x01) ? COMM_ERR : (((asDeviceStatusFault[ucDevIdx].boCommunicationError & (uint8)0x02) == (uint8)0x02) ? CRC_ERR : NO_COM_CRCERR); CddMlcGen_asDeviceStatusFault[ucDevIdx].eFltThermalWarning = (asDeviceStatusFault[ucDevIdx].boTemperatureWarning == TRUE ) ? FLT_YES : FLT_NO; CddMlcGen_asDeviceStatusFault[ucDevIdx].boStatReset = asDeviceStatusFault[ucDevIdx].boReset; for (uint8 ucSwitchIdx = 0U; ucSwitchIdx < CddMlcGenCodingDataValue.ucMlcSwitchsSupported ; ucSwitchIdx++) { if (CddMlcGen_asDeviceStatusFault[ucDevIdx].eFltCom == NO_COM_CRCERR) { CddMlcGen_asDeviceStatusFault[ucDevIdx].asMxStatusFault[ucSwitchIdx].eFltLsOpen = (asSwitchFault[ucDevIdx][ucSwitchIdx].boOpenCircuit == TRUE) ? FLT_YES : FLT_NO; //For TI, short and open are detected together CddMlcGen_asDeviceStatusFault[ucDevIdx].asMxStatusFault[ucSwitchIdx].eFltLsShort = (asSwitchFault[ucDevIdx][ucSwitchIdx].boShortCircuit == TRUE) ? FLT_YES : FLT_NO; CddMlcGen_asDeviceStatusFault[ucDevIdx].asMxStatusFault[ucSwitchIdx].eStatSupported = SUPPORT_YES; } else { CddMlcGen_asDeviceStatusFault[ucDevIdx].asMxStatusFault[ucSwitchIdx].eStatSupported = SUPPORT_NO; } } } //Update status to RTE // (void)Rte_Write_ppaseCddMlcMxSwitchStatusError0_asVal ((const tisMxMlcStatusFault*)CddMlcGen_asDeviceStatusFault); //(void)Rte_Write_ppaseCddMlcSensorInput0_sActual ((const tisMlcSensorInput* )CddMlcGen_Sensor); //(void)Rte_Write_ppaseCddMlcMxSwitchAndSensorStatus0_eMlcComError (( boBusComError == TRUE) ? ERR_YES : ERR_NO); #ifndef UNIT_TEST CddMlc_Rte_Write_MxSwitchAndSensorStatus(CddMlcGen_asDeviceStatusFault, CddMlcGen_Sensor, ((boBusComError == TRUE) ? ERR_YES : ERR_NO), ((CddMlcGenCodingDataValue.ucMlcMatrixCount != 0U) ? eStatusOnOff_STAT_ON : eStatusOnOff_DISABLED), ucQtyStsBits); #else (void)Rte_Write_ppaseCddMlcMxSwitchAndSensorStatus0_sAllMlcSwitchAndAllSensorStatus(0); #endif } //#define CDD_MLC_LED_CONTROL_TEST #ifdef CDD_MLC_LED_CONTROL_TEST STATIC_AL uint16 CddMlc_unTestDuty[36][36] = { \ /* frame 1 */ { 4095, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0},\ /* frame 2 */ { 0, 4095, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0},\ /* frame 3 */ { 0, 0, 4095, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0},\ /* frame 4 */ { 0, 0, 0, 4095, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0},\ /* frame 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, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 4095, 0, 0,0, 0, 0, 0},\ /* frame 31 */ { 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 4095, 0,0, 0, 0, 0},\ /* frame 32 */ { 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 4095,0, 0, 0, 0},\ /* frame 33 */ { 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,4095, 0, 0, 0},\ /* frame 34 */ { 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 4095, 0, 0},\ /* frame 35 */ { 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 4095, 0},\ /* frame 36 */ { 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 4095}\ }; #endif //----------------------------------------------------------------------------- /// \brief CddMlc_fill_target_buffer /// /// \descr Fill duty to mlc : copy the intensities received via RTE to the /// matrix type chip used from coding /// /// \param - /// /// \return void //----------------------------------------------------------------------------- STATIC_AL void CddMlc_fill_target_buffer(void) { uint16* pCddMlcData = (uint16*)CddMlcGen_GetTargetBufAddress(); uint16* pCtrlPxlData = (uint16*)CddMlc_sAllMlcTargets.aunDutyCycle; uint16 unOffset; uint16 unIdx; uint16 unChipIdx; #ifdef CDD_MLC_LED_CONTROL_TEST static uint16 ucFrameCunt = 0; #endif if ((pCddMlcData != NULL) && (pCtrlPxlData != NULL)) { //SuspendAllInterrupts(); for (uint16 segment = 0U; segment < CDD_MLC_MAX_SUPPORTED_ELEMENTS; segment++) { unOffset = segment%16U; unChipIdx = segment / 16U; if( ( unOffset < 12U) && (unChipIdx < 7U) ) { unIdx = (unChipIdx)*12U + unOffset; pCddMlcData[unIdx] = CddMlcGen_ConvertToRawValue(pCtrlPxlData[segment]); #ifdef CDD_MLC_LED_CONTROL_TEST if ( unIdx < 24 ) { pCddMlcData[unIdx] = CddMlc_unTestDuty[ucFrameCunt/5][unIdx]; } else { pCddMlcData[unIdx] = 0; } #endif } } //ResumeAllInterrupts(); } #ifdef CDD_MLC_LED_CONTROL_TEST if ( ucFrameCunt/5 < 24) { ucFrameCunt = ucFrameCunt + 1; if ( ucFrameCunt/5 == 24 ) { ucFrameCunt = 0; } } else { ucFrameCunt = 0; } #endif } #ifndef E2E_Remove //----------------------------------------------------------------------------- /// \brief CddMlc_ReadE2E_ErrorCheck /// /// \descr check error when using e2e protection on reading data /// /// \param E2E_ReadReturnVal /// /// \return boolean //----------------------------------------------------------------------------- STATIC_AL inline boolean CddMlc_ReadE2E_ErrorCheck(uint32 E2E_ReadReturnVal) { boolean boRetVal; uint32 StatusByte0_2, StatusByte3; StatusByte0_2 = (uint32)(((uint32)E2E_ReadReturnVal) & ((uint32)0x00FFFFFFU) ); StatusByte3 = (uint32)((((uint32)E2E_ReadReturnVal) >> 24U) & ((uint32)0x000000FFU) ); if ( ( (E2E_ReadReturnVal == (uint32)E2E_E_OK) || (StatusByte3 == (uint32)E2E_P04STATUS_REPEATED || StatusByte3 == (uint32)E2E_P04STATUS_OKSOMELOST) ) && ( StatusByte0_2 == (uint32)0x00U ) && ( CddMlc_E2E_Read_faultActive == FALSE) && ( CddMlc_E2E_Read_DebounceCounter < FAULT_THRESH) ) { // step 2 : check E2E return value CddMlc_E2E_Read_DebounceCounter = (StatusByte3 == (uint32)E2E_P04STATUS_REPEATED) ? (CddMlc_E2E_Read_DebounceCounter + 1U) : \ ((CddMlc_E2E_Read_DebounceCounter > 0U) ? (CddMlc_E2E_Read_DebounceCounter - 1U) : (CddMlc_E2E_Read_DebounceCounter)); //step 3: update status if (CddMlc_E2E_Read_DebounceCounter <= 0x00U) { CddMlc_E2E_Read_faultActive = FALSE; CddMlc_E2E_Read_DebounceCounter = 0U; } boRetVal = FALSE; } else { //step 1: check return value if ( ( (E2E_ReadReturnVal == (uint32)E2E_E_OK) || (StatusByte3 == (uint32)E2E_P04STATUS_OKSOMELOST) && StatusByte0_2 == 0x00U) == FALSE ) { if (CddMlc_E2E_Read_DebounceCounter < FAULT_THRESH) { CddMlc_E2E_Read_DebounceCounter++; } else { CddMlc_E2E_Read_DebounceCounter = FAULT_THRESH; CddMlc_E2E_Read_faultActive = TRUE; } boRetVal = TRUE; } else { if (CddMlc_E2E_Read_DebounceCounter > 0U) { CddMlc_E2E_Read_DebounceCounter--; boRetVal = TRUE; } else { CddMlc_E2E_Read_faultActive = FALSE; boRetVal = FALSE; } } } return boRetVal; } //----------------------------------------------------------------------------- /// \brief CddMlc_WriteE2E_ErrorCheck /// /// \descr check the result of e2e write /// /// \param E2E_WriteReturnVal /// /// \return boolean (TRUE = error; FALSE = no error) //----------------------------------------------------------------------------- STATIC_AL inline boolean CddMlc_WriteE2E_ErrorCheck(uint32 E2E_WriteReturnVal) { boolean boRetVal; // uint32 StatusByte0_2, StatusByte3; F82099D: unused variable removed if ((E2E_WriteReturnVal == (uint32)E2E_E_OK) || CddMlc_E2E_Write_DebounceCounter < FAULT_THRESH) { //no action CddMlc_E2E_Write_faultActive = FALSE; } else { //step 1: check return valye CddMlc_E2E_Write_DebounceCounter = (E2E_WriteReturnVal != (uint32)E2E_PHSTATUS_OK) ? (CddMlc_E2E_Write_DebounceCounter + 1) : (CddMlc_E2E_Write_DebounceCounter - 1); //step 2: check debounce counter CddMlc_E2E_Write_DebounceCounter = (CddMlc_E2E_Write_DebounceCounter > FAULT_THRESH) ? FAULT_THRESH : CddMlc_E2E_Write_DebounceCounter; //step 3: fault reaction if (CddMlc_E2E_Write_DebounceCounter == FAULT_THRESH) { CddMlc_E2E_Write_faultActive = TRUE; boRetVal = TRUE; } else if (CddMlc_E2E_Write_DebounceCounter <= 0x00) { CddMlc_E2E_Write_faultActive = FALSE; CddMlc_E2E_Write_DebounceCounter = 0x00; //reset counter } else { } } boRetVal = CddMlc_E2E_Write_faultActive; return boRetVal; } #endif