//***************************************************************************** // (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 CddBoost.c /// /// \brief /// /// \descr /// /// \author OTT, Peter ALDE-RT/EES6 //----------------------------------------------------------------------------- //============================================================================= // Includes //============================================================================= // standard includes #include #include // module API (include path) #include // module includes (relative to API) #include <../Cfg/CddBoost_Cfg.h> #include <../Cfg/CddBoost_RoutCfg.h> // chip header file #include "CddTps92682.h" #include "CddCpsq5453.h" //============================================================================= // Defines //============================================================================= #define CDDBOOST_VoffsetForStart 500u // [mV] offset to start booster at lower voltage than buck //----------------------------------------------------------------------------- // Start definitions of initialized structures and unions or arrays variables //----------------------------------------------------------------------------- #define ctadCddBoost_START_SEC_VAR_INIT_UNSPECIFIED #include <../Cfg/CddBoost_MemMap.h> STATIC_AL tCddBoostTarget CddBoost_sTarget = { 0u }; #define ctadCddBoost_STOP_SEC_VAR_INIT_UNSPECIFIED #include <../Cfg/CddBoost_MemMap.h> //----------------------------------------------------------------------------- // End definitions of initialized structures and unions or arrays variables //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Start declaration or definitions of functions //----------------------------------------------------------------------------- #define ctadCddBoost_START_SEC_CODE #include <../Cfg/CddBoost_MemMap.h> //----------------------------------------------------------------------------- /// \brief Startup initialization /// /// \descr /// /// \param - /// /// \return void //----------------------------------------------------------------------------- void CddBoost_Init(void) { if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_TPS92682) { CddTps92682_Init(); } else if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_CPSQ5453) { CddCpsq5453_Init(); } else { /* do nothing */ } } //----------------------------------------------------------------------------- /// \brief Startup initialization /// /// \descr /// /// \param - /// /// \return void //----------------------------------------------------------------------------- void CddBoost_IOInit(void) { if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_TPS92682) { CddTps92682_IOInit(); } else if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_CPSQ5453) { CddCpsq5453_IOInit(); } else { /* do nothing */ } } //----------------------------------------------------------------------------- /// \brief Function to update target values /// /// \descr /// /// \param - /// /// \return void //----------------------------------------------------------------------------- void CddBoost_SetTarget(tCddBoostTarget* pTarget) { // TODO: if CRC correct CddBoost_sTarget = *pTarget; for (uint32 ul = 0u; ul < CDDBOOST_Cfg_NbOfChannels; ul++) { if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_TPS92682) { CddTps92682_SetBoosterVoltage(ul, CddBoost_sTarget.aunBoostVolt_mV[ul]); } else if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_CPSQ5453) { CddCpsq5453_SetBoosterVoltage(ul, CddBoost_sTarget.aunBoostVolt_mV[ul]); } else { /* do nothing */ } } } //----------------------------------------------------------------------------- /// \brief Function to return status /// /// \descr /// /// \param - /// /// \return void //----------------------------------------------------------------------------- void CddBoost_GetStatus(tCddBoostStatus* pStatus) { for (uint32 ul = 0u; ul < CDDBOOST_Cfg_NbOfChannels; ul++) { pStatus->aStatus[ul] = eCddBoost_StatusOk; } pStatus->ucCrc = 0u; } //----------------------------------------------------------------------------- /// \brief Function to set parameters /// /// \descr /// /// \param - /// /// \return void //----------------------------------------------------------------------------- void CddBoost_SetPara(tCddBoostPara* pPara) { (void)pPara; } //----------------------------------------------------------------------------- /// \brief Cyclic function which execute requested action every 20ms /// /// \descr /// /// \param - /// /// \return void //----------------------------------------------------------------------------- void CddBoost_Cycle20ms(void) { if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_TPS92682) { } else if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_CPSQ5453) { CddCpsq5453_RTEwrite(); } else { /* do nothing */ } } //----------------------------------------------------------------------------- /// \brief Shutdown booster /// /// \descr This function sets the booster chip to sleep mode /// It may be called only after stop of SPI cyclic communication /// /// \param - /// /// \return void //----------------------------------------------------------------------------- void CddBoost_Shutdown(void) { if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_TPS92682) { CddTps92682_Shutdown(); } else if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_CPSQ5453) { CddCpsq5453_Shutdown(); } else { /* do nothing */ } } //----------------------------------------------------------------------------- /// \brief CddBoost_SpiRx /// /// \descr This function used for SPI module to call to receive response /// from boost /// /// \param unIx /// \param ulData : SPI Rx data (only 16 LSB valid) /// /// \return void //----------------------------------------------------------------------------- void CddBoost_SpiRx(const uint16 unIx, const uint32 ulData) { if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_TPS92682) { CddTps92682_SpiRx(unIx,ulData); } else if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_CPSQ5453) { CddCpsq5453_SpiRx(unIx,ulData); } else { /* do nothing */ } } //----------------------------------------------------------------------------- /// \brief CddBoost_SpiTx /// /// \descr This function used for SPI module to call to transmit command /// to boost /// /// \param unIx /// /// \return uint32 : Tx data (16 LSB are valid) //----------------------------------------------------------------------------- uint32 CddBoost_SpiTx(const uint16 unIx) { uint32 retData = 0u; if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_TPS92682) { retData = CddTps92682_SpiTx(unIx); } else if(CDDBOOST_CHIP_SELECT == CDDBOOST_CHIP_CPSQ5453) { retData = CddCpsq5453_SpiTx(unIx); } else { /* do nothing */ } return retData; } #define ctadCddBoost_STOP_SEC_CODE #include <../Cfg/CddBoost_MemMap.h> //----------------------------------------------------------------------------- // End declaration or definitions of functions //-----------------------------------------------------------------------------