//***************************************************************************** // (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 CddMlcInd8308_.h /// /// \brief header file of CddMlcInd8308_.c /// /// \descr interface definitions of CddMlcInd8308_.c /// /// \author Bodian Bianca ALRO-CJ (F40898C) /// mailTo:bianca-dorina.bodian[at]magnetimarelli.com /// //----------------------------------------------------------------------------- #ifndef CDD_MLC_Ind8308_2023_03_02_H_ #define CDD_MLC_Ind8308_2023_03_02_H_ //============================================================================= // includes //============================================================================= #include #include <../Cdd/CddMlc/Cfg/CddMlcGen_Cfg.h> #include <../Cdd/CddMlc/Gen/CddMlcGen_Types.h> #include "CddMlcInd8308_Cfg.h" #include "CddMlcInd8308Uart.h" #if (CDDMLCInd8308_RTE_INTERFACES == CDD_LMM_FEATURE_ON) //#include "Rte_CDD_MLC.h" #endif #include "../../../../Cfg/BSW_Cfg/AN/AN012/Callout/Rte_Type.h" //============================================================================= // global defines //============================================================================= // Number of segments for each Mlc Device #define CDDMLCInd8308_LEDS 12u #define Parity_p0(command) (uint8)((((command & 0x01) >> 0) + ((command & 0x02) >> 1) + ((command & 0x04) >> 2) + ((command & 0x10) >> 4)) & 0x01) #define Parity_p1(command) (uint8)((~((((command & 0x02) >> 1) + ((command & 0x08) >> 3) + ((command & 0x10) >> 4) + ((command & 0x20) >> 5)) & 0x01)) & 0x01) #define Parity_check(id) id | (Parity_p0(id)<<6) | (Parity_p1(id)<<7) //============================================================================= // type definitions //============================================================================= //#if (CDDMLCInd8308_RTE_INTERFACES == CDDMLCInd8308_FEATURE_OFF) typedef struct { uint32 unLedFaultOpen : 16; uint32 unLedFaultShort : 16; } tsCddMlcInd8308_LedStatus; typedef enum { CDDMLCInd8308_QLTY_INVALID = 0, // Invalid Value (Init value or Timeout) CDDMLCInd8308_QLTY_SNA = 1, // Signal Not Available (Keep Last Value) CDDMLCInd8308_QLTY_VALID = 2 // Valid Signal (Up-to-Date) } teCddMlcInd8308_AdcQuality; typedef struct { uint16 ucADC1Value; // Value of 8-Bit ADC uint16 ucADC2Value; // Value of 8-Bit ADC teCddMlcInd8308_AdcQuality eQlty; // Quality Factor } tsCddMlcInd8308_AdcResult; typedef enum // States of the Mlc Matrix { CddMlcInd8308_SystemMode_Powerup = 0, // Unconfigured Chips, CddMlcInd8308_SystemMode_CfgComm, // Set default communication Settings, CddMlcInd8308_SystemMode_CfgChips, // Configure Chip Settings, CddMlcInd8308_SystemMode_CfgPhases, // Configure Phase Shifts, // CddMlcInd8308_SystemMode_CfgLeds, // Configure LED Settings, CddMlcInd8308_SystemMode_ExitFailSafe, // Exits fail safe mode to enable normal operation, CddMlcInd8308_SystemMode_ClrFlts, // Broadcast Clear Faults CddMlcInd8308_SystemMode_Normal, // Set DutyCyles + Read FAULTS/ADCs + Monitor Chips, CddMlcInd8308_SystemMode_Inactive, // No commands are sent but driver is configured. CddMlcInd8308_SystemMode_Length } teCddMlcInd8308_SystemMode; //#else // //typedef tieCddMlcInd8308_SystemMode tCddMlcInd8308_SystemMode; // //#endif typedef struct { uint8 SLEWRATE; // Slew Rate Register uint8 OVLMT; // Over Voltage Limit Register uint8 PARLED; // Parallel LED String Register uint8 DEFWIDTH02_01; // Default Pulse Width Register for Segment 02 and 01 uint8 DEFWIDTH04_03; // Default Pulse Width Register for Segment 04 and 03 uint8 DEFWIDTH06_05; // Default Pulse Width Register for Segment 06 and 05 uint8 DEFWIDTH08_07; // Default Pulse Width Register for Segment 08 and 07 uint8 DEFWIDTH10_09; // Default Pulse Width Register for Segment 10 and 09 uint8 DEFWIDTH12_11; // Default Pulse Width Register for Segment 12 and 11 uint8 SYSCFG; // System Configuration Register uint8 CMWTAP; // Communications Watchdog Timer Tap Point Register uint8 PWMTICK; // PWM Tick Period Register uint8 ADCID; // ADC ID Register } tsCddMlcInd8308_RegisterConfig; // Mlc Configuration Registers typedef struct { uint16 OV : 1; uint16 SC : 1; uint16 OT : 1; uint16 VCPP_ERROR : 1; uint16 MTP_ERROR : 1; uint16 LHM_MODE : 1; uint16 PWM_RUNNING : 1; uint16 WDT_RUNNING : 1; uint16 BOR_1V5_FLAG : 1; uint16 POR_FLAG : 1; uint16 RESERVED_EX : 6; }tsCddMlcInd8308_StatusBits; typedef union { uint16 ucStatusRegister; tsCddMlcInd8308_StatusBits BitStatus; } tuCddMlcInd8308_StatusRegister; typedef struct { uint32 ulMlcStatus; // Global Communication Status for each Mlc device uint32 ulPowerCycleOccurred; // Global Power Cycle Flag for each Mlc device uint32 ulUartErrorsOccurred; // UART Communication Errors Occurrence Counter uint32 ulTxCommandOverrun; // Counter of Commands not sent during a Mlc cycle uint32 ulAckChipSetting; // Acknowledged Chip Setting Configuration uint32 ulAckPhaseShifts; // Acknowledged Phase Shifts Configuration uint32 ulAckLedSegments; // Acknowledged LED Segments Configuration uint32 ulAckExitFailsafe; // Acknowledged Exit Failsafe Configuration uint8 aucMatrixIcID_List[CFG_MAX_NO_OF_MLC]; // Matrix Chip ID for each device uint8 aucTimeoutCounter_List[CFG_MAX_NO_OF_MLC]; // Reception failed counter for each device uint8 aucCrcFltOccurrence_List[CFG_MAX_NO_OF_MLC]; // CRC ERROR count for each device } tsCddMlcInd8308_ComStatus; // Debug ---------------------------------------------------------------------- #ifndef UNIT_TEST #define CddMlcInd8308_ActivateHooks 0u//CDDMLCInd8308_FEATURE_OFF #define CddMlcInd8308_Cfg_Simulation CddMlcInd8308_ActivateHooks #else #undef CddMlcInd8308_Cfg_Simulation #endif // CddMlcInd8308_MT #if (CddMlcInd8308_Cfg_Simulation == 1u) //simulation support typedef struct { uint8 ucMlcChipNumber; // used to override the current chip uint8 ucLowByteFault; // used to store first 8 leds simulated status uint8 ucHighByteFault; //used to store last 4 leds simulated status // boEnableSimulation; // used to enable testing on all chips or on the current }tsCddMlcInd8308_SimulationData; #endif //============================================================================= // functions //============================================================================= //----------------------------------------------------------------------------- /// \brief CddMlcInd8308_Init /// /// \descr The function initializes the Led Matrix Manager driver /// /// \param none /// /// \return none //----------------------------------------------------------------------------- void CddMlcInd8308_Init(void); //----------------------------------------------------------------------------- /// \brief CddMlcInd8308_Cycle /// /// \descr Led Matrix Manager Cyclic Handler /// /// \param none /// /// \return none //----------------------------------------------------------------------------- void CddMlcInd8308_Cycle(void); //----------------------------------------------------------------------------- /// \brief CddMlcInd8308_SetTargetValues /// /// \descr Set the LED intensities for the current Mlc chip /// /// \param uint8 Mlc device number /// \param uint16 pointer to the desired PWM DutyCycles buffer /// /// \return none //----------------------------------------------------------------------------- void CddMlcInd8308_SetTargetValues(uint8 ucDevNbr, uint16 unTargetWidths_List[]); //----------------------------------------------------------------------------- /// \brief CddMlcInd8308_GetActualValues /// /// \descr Get the LED intensities for the current Mlc chip /// /// \param uint8 Mlc device number /// \param uint16 pointer to the desired PWM DutyCycles buffer /// /// \return pointer to the actual PWM DutyCycles buffer //----------------------------------------------------------------------------- void CddMlcInd8308_GetActualValues(uint8 ucDevNbr, uint16 unActualWidths_List[]); //----------------------------------------------------------------------------- /// \brief CddMlcInd8308_SetTransmissionActive /// /// \descr Set the Mlc transmission to desired state /// /// \param boolean Transmission Active Flag /// /// \return none //----------------------------------------------------------------------------- void CddMlcInd8308_SetTransmissionActive(boolean boDriverActive); #if (CDDMLCInd8308_RTE_INTERFACES == CDD_LMM_FEATURE_OFF) //----------------------------------------------------------------------------- /// \brief CddMlcInd8308_GetChipConfig /// /// \descr Returns the Chip Register Configuration of selected Mlc device /// /// \param uint8 Mlc device number /// \param uint8 pointer to the desired buffer to save data /// /// \return none //----------------------------------------------------------------------------// PRQA S 1505 //The Function is called from external modules tCddMlcInd8308_RegisterConfig CddMlcInd8308_GetChipConfig(uint8 ucDevNbr); //----------------------------------------------------------------------------- /// \brief CddMlcInd8308_GetADCResult /// /// \descr Returns the ADC results and quality flag on selected Mlc device /// /// \param uint8 Mlc device number /// /// \return tCddMlcInd8308_AdcResult the value of ADC1, ADC2 and the quality flag //----------------------------------------------------------------------------- tCddMlcInd8308_AdcResult CddMlcInd8308_GetADCResult(uint8 ucDevNbr); //----------------------------------------------------------------------------- /// \brief CddMlcInd8308_GetLedsStatus /// /// \descr Returns the status of LEDs on selected Mlc device /// /// \param uint8 device number /// /// \return CddMlcInd8308_LedStatus the status of selected LED device //----------------------------------------------------------------------------- tCddMlcInd8308_LedStatus CddMlcInd8308_GetLedsStatus(uint8 ucDevNbr); //----------------------------------------------------------------------------- /// \brief CddMlcInd8308_GetComStatus /// /// \descr Returns the communication status of all Mlc chips /// /// \param none /// /// \return CddMlcInd8308_ComStatus the communication status of all Mlcs //----------------------------------------------------------------------------- tCddMlcInd8308_ComStatus CddMlcInd8308_GetComStatus(void); //----------------------------------------------------------------------------- /// \brief CddMlcInd8308_GetActualState /// /// \descr Returns the state of Mlc Driver /// /// \param none /// /// \return tCddMlcInd8308_SystemMode the Status of the Mlc driver //----------------------------------------------------------------------------- tCddMlcInd8308_SystemMode CddMlcInd8308_GetActualState(void); #endif //----------------------------------------------------------------------------- /// \brief CddMlcInd8308_ClearLedsStatus /// /// \descr Function trigger reseting of LED Fault Status registers /// and CRC Error Count Registers for all Mlc chips /// /// \param none /// /// \return none //----------------------------------------------------------------------------- void CddMlcInd8308_ClearLedsStatus(void); //----------------------------------------------------------------------------- /// \brief CddMlcInd8308_ResetMlcSettings /// /// \descr Function triggers to broadcast the configuration settings for all Mlc chips /// /// \param none /// /// \return none //----------------------------------------------------------------------------- void CddMlcInd8308_ResetMlcSettings(void); // RTE Interfaces Enabled START =============================================== #if (CDDMLCInd8308_RTE_INTERFACES == CDD_LMM_FEATURE_ON) // RTE Interfaces Enabled? //Write Outputs //void CddMlcInd8308_RteWrite_SystemMode(teCddMlcInd8308_SystemMode *sSysMode); //void CddMlcInd8308_RteWrite_ComStatus(tsCddMlcInd8308_ComStatus *sComStatus); //void CddMlcInd8308_RteWrite_LedStatus(tsCddMlcInd8308_LedStatus *sLedStatus); //void CddMlcInd8308_RteWrite_AdcResult(tsCddMlcInd8308_AdcResult *sAdcResult); //void CddMlcInd8308_RteWrite_AckLedPwms(uint16 *unAckLedPwms); //void CddMlcInd8308_RteWrite_TgtLedPwms(uint16 *punTgtLedPwms); //Read Inputs //void CddMlcInd8308_RteRead_TgtLedPwms(uint16 *punTgtLedPwms); #endif // RTE Interfaces Enabled END ================================================= /*ToDo Use correct namespace: CddMlcTPS9266x*/ uint16* CddMlcInd8308_GetTargetBufAddress(void); void CddMlcInd8308_SetTransmissionToInactive(void); void CddMlcInd8308_SetTransmissionToNormal(void); void CddMlcInd8308_GetSensorInfo(tisMlcSensorInput* pucExtResistor, uint8 ucDevCnt); void CddMlcInd8308_GetDeviceStatusFault(tsCddMlcDeviceStatusFault* pusDevStatusFault, uint8 ucDevCnt); boolean CddMlcInd8308_GetBusComError(void); void CddMlcInd8308_GetSwitchsFault(tsCddMlcSwitchFaultArray asSwitchFaultArray, uint8 ucDevCnt, uint8 ucSwitchCnt); void CddLmm_SendBreak_ALAD(void); uint8 CddMlcInd8308_GetFamilyDevConnected(void); STATIC_AL void CddMlcInd8308_Broadcast_CfgPWMs(void); STATIC_AL void CddLmm_Broadcast_EnablePWMs_ALAD(void); STATIC_AL void CddLmm_Broadcast_CfgBaudrateACK_ALAD(void); STATIC_AL void CddLmm_Broadcast_EnableCfgAcess_ALAD(void); STATIC_AL void CddLmm_Broadcast_IOCfg_ALAD(void); STATIC_AL void CddLmm_Broadcast_SlewRate_ALAD(void); STATIC_AL void CddLmm_Broadcast_WDTimeout_ALAD(void); STATIC_AL void CddLmm_Broadcast_ConfigDefwidth_ALAD(void); STATIC_AL void CddLmm_Broadcast_ExitLPH_ALAD(void); STATIC_AL void CddLmm_Broadcast_SARCfg_ALAD(void); STATIC_AL void CddLmm_Broadcast_SARInit_ALAD(void); STATIC_AL void CddLmm_Broadcast_ADC_Ctrl_Init(void); uint8 iND8308X_CHECK_EXISTED_DEVICES(uint8 ucDevNbr); // EOF #endif // CDD_MLC_Ind8308_2023_03_02_H_