//***************************************************************************** // (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_TLE9471.cpp /// /// \brief /// /// \descr /// /// \author Alex Mertic (f98665c) /// mailTo:alexandru-laurentiu.mertic(at)marelli.com //----------------------------------------------------------------------------- //============================================================================= // includes //============================================================================= #include #include #include #include //============================================================================= // macros //============================================================================= #define SPI_SBC_READ_FRAME(addr) ((uint16)(addr)) #define SPI_SBC_WRITE_FRAME(addr, regval) (((uint16)((uint16)(regval) << 8U) | (uint16)((uint16)1U << 7U)) | (uint16)(addr)) //============================================================================= // functions //============================================================================= //----------------------------------------------------------------------------- // \brief cdd::led::tle9471::init // // \descr This function will initialize the SBC registers. // // \param bRegValType specifies if specifc initialization has to be performed // on the driver or the default values are used(no init) // // \return void //----------------------------------------------------------------------------- void cdd::sbc::tle9471::init() { uint16 u16RxData = 0U; for (uint8 index = 0; index < TLE9471_INIT_REG; index++) { cdd::sbc::tle9471::read_write_reg(eCddSbc_WriteReg, &sbc_reg_init[index].reg_addr, &sbc_reg_init[index].reg_data, &u16RxData); } } //----------------------------------------------------------------------------- // \brief read_write_reg // // \descr This function is responsible writing and reading the SBC registers // // \param SpiRequest - type of request Read - 0, Write - 1 // pucAddr - pointer to Sbc reg addr // pucTxData - pointer to data to be sent ovet SPI, discarded if read request // punRxData - pinter to received data over SPI // // \return ucRet - error code //----------------------------------------------------------------------------- uint8 cdd::sbc::tle9471::read_write_reg(teCddSbcSpiReqType SpiRequest, uint8 *pucAddr, uint8 *pucTxData, uint16 *punRxData) { uint8 unRet = 0; uint16 unSpiTx; if (SpiRequest == 0U) { unSpiTx = SPI_SBC_READ_FRAME(*pucAddr); // PRQA S 303 1 // correct usage (comes from the definition of SCB) spi_transmit(e_active_config_SBC, &unSpiTx, punRxData, 1U); } else { //Prepare SPI frame unSpiTx = SPI_SBC_WRITE_FRAME(*pucAddr, *pucTxData); // PRQA S 303 1 // correct usage (comes from the definition of SCB) spi_transmit(e_active_config_SBC, &unSpiTx, punRxData, 1U); } return unRet; } //----------------------------------------------------------------------------- // \brief set_params // // \descr This function is responsible setting SCB Register // // \param SpiId - Spi ID // status - enable or disable // // \return ucRet - error code //----------------------------------------------------------------------------- uint8 cdd::sbc::tle9471::set_params(uint8 SpiId, uint8 status) { (void)SpiId; (void)status; uint8 ucRet = 0xff; return ucRet; }