//***************************************************************************** // (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 CddLed.cpp /// /// \brief /// /// \descr /// /// \author Alex Mertic (f98665c) /// mailTo:alexandru-laurentiu.mertic(at)marelli.com //----------------------------------------------------------------------------- //============================================================================= // includes //============================================================================= #include #include //============================================================================= // variables //============================================================================= //============================================================================= // functions //============================================================================= //----------------------------------------------------------------------------- // \brief read_write_reg // // \descr This function is responsible writing and reading the BOOST/BUCK registers // based on existing configuration // // \param LedID - BOOST/BUCK ID configured in CddLed_Cfg.h // spi_request - type of request Read - 0, Write - 1 // puc_addr - pointer to Stp reg addr // puc_tx_data - pointer to data to be sent ovet SPI, discarded if read request // pun_rx_data - pinter to received data over SPI // // \return ucRet - error code //----------------------------------------------------------------------------- uint8 cdd::led::read_write_reg(te_cdd_led_id led_id, te_cdd_led_spi_req_type spi_request, uint8 puc_addr, void *puc_tx_data, uint16 *pun_rx_data) { uint8 ucRet = 0xff; static volatile uint8 idx = 0; for (idx = 0; idx < CDDLED_NR_OF_IC; idx++) { if (device_config[idx].ic_spi_identifier == led_id) { ucRet = device_config[idx].type == e_ic_buck ? cdd::led::tps92520::read_write_reg(led_id, spi_request, puc_addr, (uint8 *)puc_tx_data, pun_rx_data) : cdd::led::ncv7870::read_write_reg(spi_request, puc_addr, (uint16 *)puc_tx_data, pun_rx_data); break; } } return ucRet; } //----------------------------------------------------------------------------- // \brief read_write_reg // // \descr This function is responsible writing and reading the All BOOST/BUCK registers // based on existing configuration // // \param LedID - BOOST/BUCK ID configured in CddLed_Cfg.h // spi_request - type of request Read - 0, Write - 1 // puc_addr - pointer to Stp reg addr // puc_tx_data - pointer to data to be sent ovet SPI, discarded if read request // pun_rx_data - pinter to received data over SPI // // \return ucRet - error code //----------------------------------------------------------------------------- uint8 cdd::led::read_write_reg_all(te_cdd_led_id led_id, te_cdd_led_spi_req_type spi_request, void *puc_tx_data, uint16 *pun_rx_data, uint16* response_len) { uint8 ucRet = 0xff; for (uint8 idx = 0; idx < CDDLED_NR_OF_IC; idx++) { if (device_config[idx].ic_spi_identifier == led_id) { ucRet = device_config[idx].type == e_ic_buck ? cdd::led::tps92520::read_write_reg_all(led_id, spi_request, (uint8 *)puc_tx_data, pun_rx_data, response_len) : cdd::led::ncv7870::read_write_reg_all(spi_request, (uint16 *)puc_tx_data, pun_rx_data, response_len); } } return ucRet; } //----------------------------------------------------------------------------- // \brief led::init // // \descr This function is responsible initializing both boost and buck registers // based on existing defines // \return void //----------------------------------------------------------------------------- void cdd::led::init() { #ifdef CDDLED_NCV7870 cdd::led::ncv7870::init(); #endif #ifdef CDDLED_TPS92520 cdd::led::tps92520::init(); #endif }