//***************************************************************************** // (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 CddSbc.c /// /// \brief SBC complex device driver /// /// \descr System Basic Chip /// /// Additional information can be found in the design description (Link: /// doors://ITTOR47DOORSAL.mmemea.marelliad.net:36693/?version=2&prodID=0&urn=urn:telelogic::1-43eb3f040fd3425e-M-00045927) /// /// \author Kai Zhao ALDE-RT (zhk2rt) /// mailTo: Kai.Zhao[at]marelli.com //----------------------------------------------------------------------------- //============================================================================= // Standard / system header file includes //============================================================================= //#include //============================================================================= // Project-specific header file includes //============================================================================= //#include #include #include #include #include #include #if (CDD_SBC_CFG_STORE_RESETREASON == STD_ON) #include #endif //----------------------------------------------------------------------------- // Start definitions of non initialized structures and unions or arrays variables //----------------------------------------------------------------------------- #define ctadCddSbc_START_SEC_VAR_NO_INIT_UNSPECIFIED #include #if (CDD_SBC_CFG_STORE_RESETREASON == STD_ON) //STATIC_AL uint8 CddSbc_ucFirstCycle; STATIC_AL tieResetReason CddSbc_tResetReason; #ifndef UNIT_TEST volatile uint16* CddSbc_ECCResetReason; // PRQA S 3408 1 //volatile uint16 CddTle94x1_WdgResetReason; // PRQA S 3408 1 #else STATIC_AL uint16* CddSbc_ECCResetReason; //STATIC_AL uint16 CddTle94x1_WdgResetReason; #endif #endif #define ctadCddSbc_STOP_SEC_VAR_NO_INIT_UNSPECIFIED #include //----------------------------------------------------------------------------- // End definitions of non initialized structures and unions or arrays variables //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Start declaration or definitions of functions //----------------------------------------------------------------------------- #define ctadCddSbc_START_SEC_CODE #include <../Cfg/CddSbc_MemMap.h> //----------------------------------------------------------------------------- /// \brief API function to initialize SBC complex device driver. /// /// \descr Calls the hardware specific function to initialize SBC. /// /// \param void /// /// \return void //----------------------------------------------------------------------------- #if (CDD_SBC_CFG_INIT_OPERATION == STD_ON) void CddSbc_Init(void) { CddSbc_Rou_Init(); #ifndef UNIT_TEST CddSbc_ECCResetReason = (volatile uint16*)&ECC_RET_RAM_VAR; #endif } void riCddSbcInit(void) { (void)CddSbc_GetResetReason(); } FUNC(void, ctadCddSbc_CODE) ctadCddSbc_riCddSbcInit(void) { /* riCddSbcInit_Start User Code start*/ /* riCddSbcInit_Start User Code end*/ } FUNC(void, ctadCddSbc_CODE) ctadCddSbc_rdCddSbcDeInit ( void ) { /* rdCddSbcDeInit_Start User Code start*/ /* rdCddSbcDeInit_Start User Code end*/ } #endif #if (CDD_SBC_CFG_INIT_OPERATION == STD_ON) //----------------------------------------------------------------------------- /// \brief API function to de-initialize SBC complex device driver. /// /// \descr Calls the hardware specific de-init function. /// /// \param void /// /// \return void //----------------------------------------------------------------------------- void CddSbc_DeInit(void) { CddSbc_Rou_DeInit(); } #endif #if (CDD_SBC_CFG_CYCLIC_OPERATION == STD_ON) //void CddSbc_Cycle20ms(void) //{ //if (CddSbc_ucFirstCycle == 0u) //{ // CddSbc_tResetReason = CddSbc_GetResetReason(); // if (CddSbc_tResetReason == (tieResetReason)eRESET_WATCHDOG) // { // //set DTC watchdog reset // // (void)Rte_Call_Dtc430110_SetEventStatus(DEM_EVENT_STATUS_FAILED); // } // //else if (CddTle94x1_ErrorType.boErrorReset != FALSE) // //{ // //set DTC error reset // //(void)Rte_Call_Dtc430111_SetEventStatus(DEM_EVENT_STATUS_FAILED); // //} // else if ((CddSbc_tResetReason == (tieResetReason)eRESET_POWER_ON) || (CddSbc_tResetReason == (tieResetReason)eRESET_CAN_WAKEUP) || (CddSbc_tResetReason == (tieResetReason)RESET_WAKEUP_HW)) // { // //reset DTC watchdog reset // //(void)Rte_Call_Dtc430110_SetEventStatus(DEM_EVENT_STATUS_PASSED); // //reset DTC error reset // //(void)Rte_Call_Dtc430111_SetEventStatus(DEM_EVENT_STATUS_PASSED); // } // else // { // // do nothing // } // CddSbc_ucFirstCycle = 0xFF; //} //} #if (CDD_SBC_CFG_WK_INPUT == STD_ON) //----------------------------------------------------------------------------- /// \brief API function to get wakeup pin pegel /// /// \descr Calls the hardware specific function to get wakeup pin pegel /// \param void /// /// \return boolean //----------------------------------------------------------------------------- boolean CddSbc_GetWakeUpStatus(void) { return CddSbc_Rou_GetWakeUpStatus(); } #endif //CDD_SBC_CFG_WK_INPUT == STD_ON #endif //CDD_SBC_CFG_CYCLIC_OPERATION == STD_ON #if (CDD_SBC_CFG_SLEEPMODE == STD_ON) //----------------------------------------------------------------------------- /// \brief API function to set SBC into Sleep Mode. /// /// \descr Calls the hardware specific function to set SBC into Sleep Mode. /// /// \param void /// /// \return void //----------------------------------------------------------------------------- void CddSbc_SetSleepMode(void) { CddSbc_Rou_SetSleepMode(); } #endif #if (CDD_SBC_CFG_CAN_OPERATION == STD_ON) //----------------------------------------------------------------------------- /// \brief API function to set specific SBC CAN transceiver to different modes /// /// \descr Calls the hardware specific function to set specific CAN transceiver to a certain function mode /// /// \param uint8 ucCanChannel - indicates SBC CAN channel /// uint8 ucCanMode - indicates SBC CAN transceiver mode /// /// \return void //----------------------------------------------------------------------------- void CddSbc_SetCanMode(uint8 ucCanChannel, uint8 ucCanMode) { CddSbc_Rou_SetCanMode(ucCanChannel, ucCanMode); } #endif #if (CDD_SBC_CFG_CAN_OPERATION == STD_ON) //----------------------------------------------------------------------------- /// \brief API function to get specific SBC CAN transceiver to different modes /// /// \descr Calls the hardware specific function to get can mode of specific CAN transceiver /// /// \param uint8 ucCanChannel - indicates SBC CAN channel /// /// \return uint8 ucCanMode - indicates SBC CAN transceiver mode //----------------------------------------------------------------------------- uint8 CddSbc_GetCanMode(uint8 ucCanChannel) { return CddSbc_Rou_GetCanMode(ucCanChannel); } #endif #if (CDD_SBC_CFG_CAN_OPERATION == STD_ON) //----------------------------------------------------------------------------- /// \brief CddSbc_GetCanUV /// /// \descr API function to get the undervoltage bit of CAN bus /// /// \param void /// /// \return uint8 ucCanMode - indicates SBC CAN transceiver mode //----------------------------------------------------------------------------- uint8 CddSbc_GetCanUV(void) { return CddSbc_Rou_GetCanUV(); } #endif #if (CDD_SBC_CFG_STORE_RESETREASON == STD_ON) //----------------------------------------------------------------------------- /// \brief API function to get the reset reason /// /// \descr Calls the hardware specific function to get the reset reason /// /// \param tieResetReason peResetReason /// /// \return void //----------------------------------------------------------------------------- tieResetReason CddSbc_GetResetReason(void) { Mcu_ResetType tMCUResetReason; tieResetReason tResetReason = (tieResetReason)RESET_SNA; uint8 tSBCResetReason; //tisCddSbcStatus tCddSbcStatus; // get MCU reset reason tMCUResetReason = Mcu_GetResetReason(); // get SBC reset reason tSBCResetReason = CddSbc_Rou_GetSBCResetReason(); switch (tMCUResetReason) { case MCU_SW_RESET: if ((*CddSbc_ECCResetReason) == (uint16)ERROR_ACTIVE) { tResetReason = (tieResetReason)RESET_ECC_ERROR; #ifndef UNIT_TEST (*CddSbc_ECCResetReason) = 0U; //delete the retention RAM #endif } // else if (CddSbc9471_MPUSelfTestResetReason == (uint16)ERROR_ACTIVE) // { // CddSbc_eMCUResetReason = eMCUSelfTestReset; // CddSbc_tResetReason = (tieResetReason)eRESET_MPU_SELFTEST_ERROR; // CddSbc9471_ErrorType.boErrorReset = TRUE; // } else { tResetReason = (tieResetReason)RESET_SOFTWARE; } break; default: tResetReason = (tieResetReason)RESET_UNDEFINED; break; } CddSbc_tResetReason = tResetReason; if (CddSbc_tResetReason == (tieResetReason)RESET_WATCHDOG) { //set DTC watchdog reset // (void)Rte_Call_Dtc430110_SetEventStatus(DEM_EVENT_STATUS_FAILED); } //else if (CddTle94x1_ErrorType.boErrorReset != FALSE) //{ //set DTC error reset //(void)Rte_Call_Dtc430111_SetEventStatus(DEM_EVENT_STATUS_FAILED); //} else if ((CddSbc_tResetReason == (tieResetReason)RESET_POWER_ON) || (CddSbc_tResetReason == (tieResetReason)RESET_WAKEUP) || (CddSbc_tResetReason == (tieResetReason)RESET_WAKEUP_HW)) { //reset DTC watchdog reset //(void)Rte_Call_Dtc430110_SetEventStatus(DEM_EVENT_STATUS_PASSED); //reset DTC error reset //(void)Rte_Call_Dtc430111_SetEventStatus(DEM_EVENT_STATUS_PASSED); } else { // do nothing } //tCddSbcStatus.eResetReason = CddSbc_tResetReason; // (void)Rte_Write_ppaseCddSbcStatus_sStatus(&tCddSbcStatus); return tResetReason; } //PRQA S 5336 1 // program architecture and readability #endif #if (CDD_SBC_CFG_WATCHDOG == STD_ON) //----------------------------------------------------------------------------- /// \brief CddSbc_SetWdgWindowModeAnd10ms /// /// \descr API function to set the watchdog with window mode and 10ms /// /// \param void /// /// \return void //----------------------------------------------------------------------------- void CddSbc_SetWdgWindowModeAnd10ms(void) { CddSbc_Rou_SetWdgWindowModeAnd10ms(); } #endif #if (CDD_SBC_CFG_WATCHDOG == STD_ON) //----------------------------------------------------------------------------- /// \brief CddSbc_SetWdgWindowModeAnd200ms /// /// \descr API function to set the watchdog with window mode and 200ms /// /// \param void /// /// \return void //----------------------------------------------------------------------------- void CddSbc_SetWdgWindowModeAnd200ms(void) { static unsigned int i = 0; if(i==0) { CddSbc_Rou_SetWdgWindowModeAnd200ms(); } i++; i=i%30; } #endif #if (CDD_SBC_CFG_WATCHDOG == STD_ON) //----------------------------------------------------------------------------- /// \brief CddSbc_SetWdgTimeoutModeAnd200ms /// /// \descr API function to set the watchdog with timeout mode and 200ms /// /// \param void /// /// \return void //----------------------------------------------------------------------------- void CddSbc_SetWdgTimeoutModeAnd200ms(void) { static unsigned int i = 0; if(i==0) { CddSbc_Rou_SetWdgTimeoutModeAnd200ms(); } i++; i=i%30; } #endif #define ctadCddSbc_STOP_SEC_CODE #include <../Cfg/CddSbc_MemMap.h> //----------------------------------------------------------------------------- // End declaration or definitions of functions //-----------------------------------------------------------------------------