//***************************************************************************** // (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 CddNcv78702.c /// /// \brief /// /// \author OTT, Peter ALDE-RT/EES6 //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- // standard includes #include #include #include // module API (include path) #include #include // module includes (relative to API) #include <../Cfg/CddNcv78702_Cfg.h> #include <../Cfg/CddNcv78702_RoutCfg.h> #include <../Gen/CddNcv78702_Types.h> #include <../Gen/CddNcv78702_Com.h> //----------------------------------------------------------------------------- // Start declaration or definitions of functions //----------------------------------------------------------------------------- #define ctadCddBoost_START_SEC_CODE #include <../Cfg/CddNcv78702_MemMap.h> //----------------------------------------------------------------------------- // Function definitions //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- /// \brief Set GPIOs BOOST_ENABLE and BOOST_FSO pin /// /// \descr Control GPIOs enable pins of booster depending on EFT parameters /// /// \param boBoostEnable: TRUE or FALSE /// /// \return void //----------------------------------------------------------------------------- void CddNcv78702_SetBoostEnableGpio(const boolean boBoostEnable) { CDDNCV78702_SetBoosterEn(boBoostEnable); } //----------------------------------------------------------------------------- /// \brief Set the duty cycle of BSTSYNC PWM signal /// /// \descr Control the duty cycle of BSTSYNC signal /// /// \param unBstSyncDuty_1_32768 /// /// \return void //----------------------------------------------------------------------------- void CddNcv78702_SetBoostBstSyncDuty(const uint16 unBstSyncDuty_1_32768) { boolean boEnable = (unBstSyncDuty_1_32768 != 0u) ? TRUE : FALSE; CDDNCV78702_SetBoosterPwm(boEnable); } //----------------------------------------------------------------------------- /// \brief /// /// \descr /// /// \param - /// /// \return void //----------------------------------------------------------------------------- void CddNcv78702_SetBoosterVoltage(const uint32 ulIdx, const uint16 unVBoostTarget_mV) { uint8 ucBoostVsetpoint = 0u; sint32 slVBoostTargetAdjusted; sint16 snCalibBoostVoffset = CDDNCV78702_CALIB_nVOffset(0); uint16 unCalibBoostVfactor = CDDNCV78702_CALIB_unVFactor(0); (void)ulIdx; // for future use if (unCalibBoostVfactor == 0xFFFFu) // if booster is not explicitely calibrated { snCalibBoostVoffset = CDDNCV78702_ECUVARCFG_nVOffset(0); unCalibBoostVfactor = CDDNCV78702_ECUVARCFG_unVFactor(0); } //Guard to avoid any division by 0. if (unCalibBoostVfactor != 0u) { uint16 unVBoostLim = UTIL_MIN(unVBoostTarget_mV, CDDNCV78702_Cfg_VboostMax); // upper limit unVBoostLim = UTIL_MAX(unVBoostLim, CDDNCV78702_Cfg_VboostMin); // lower limit slVBoostTargetAdjusted = (sint32)unVBoostLim - snCalibBoostVoffset; // calculate according to EFT data ucBoostVsetpoint = (uint8)((uint32)(slVBoostTargetAdjusted) / unCalibBoostVfactor); ucBoostVsetpoint = UTIL_MIN(ucBoostVsetpoint, CDDNCV78702_Cfg_BOOST_VSETPOINT_Max); // upper limit ucBoostVsetpoint = UTIL_MAX(ucBoostVsetpoint, CDDNCV78702_Cfg_BOOST_VSETPOINT_Min); // lower limit } if (CDDNCV78702_EftDataValid() != FALSE) // end of line data available { CddNcv78702_SetBoostVsetpoint(ucBoostVsetpoint); } } //----------------------------------------------------------------------------- /// \brief /// /// \descr /// /// \param boEFTIsValid /// /// \return void //----------------------------------------------------------------------------- void CddNcv78702_Init(void) { CddNcv78702_SetBoostEnableGpio(TRUE); } //----------------------------------------------------------------------------- /// \brief /// /// \descr This function may be called only if SPI cyclic mode is stopped /// /// \param - /// /// \return void //----------------------------------------------------------------------------- void CddNcv78702_Shutdown(void) { CddNcv78702_SetBoostBstSyncDuty(0u); CddNcv78702_SetBoostEnableGpio(FALSE); CddNcv78702_SetBoostSleep(); } #define ctadCddBoost_STOP_SEC_CODE #include <../Cfg/CddNcv78702_MemMap.h> //----------------------------------------------------------------------------- // End declaration or definitions of functions //-----------------------------------------------------------------------------