/* ***************************************************************************** (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. ***************************************************************************** */ /*============================================================================= includes ===============================================================================*/ #include "CddSbc_TLE9471.h" #include "spi_drv.h" /*============================================================================= macros =============================================================================*/ #define SPI_SBC_READ_FRAME(addr) ((uint16_t)(addr)<< 9U) #define SPI_SBC_READCLEAR_FRAME(addr) ((uint16_t)(addr) | (uint16_t)((uint16_t)1U << 7U) ) #define SPI_SBC_WRITE_FRAME(addr, regval) (((uint16_t)((uint16_t)(addr) << 9U) | (uint16_t)((uint16_t)1U << 8U)) | (uint16_t)(regval)) #define BitWiseMSB 0xFF00 #define BitWiseLSB 0xFF #define ShiftBitSeven 0x80 #define ShiftBitSix 0x40 #define ShiftBitFive 0x20 #define ShiftBitFour 0x10 #define ShiftBitThree 0x08 #define ShiftBitTwo 0x04 #define ShiftBitOne 0x02 #define ShiftBitZero 0x01 #define ShiftEightBit 8 #define ShiftSevenBit 7 #define ShiftFiveBit 5 #define ShiftThreeBit 3 #define ShiftOneBit 1 uint16_t u16SpiWriteVal[4] = {0x21C0,0x4120,0xC128,0x6120}; t_sbc_reg_info sbc_reg_init[TLE9471_INIT_REG] = { {CDD_SBC_TLE9471_REG_BUS_CTRL_0, 0x03}, {CDD_SBC_TLE9471_REG_HW_CTRL_0, 0x04}, {CDD_SBC_TLE9471_REG_WD_CTRL, 0x17} }; t_sbc_reg_info sbc_reg_test[TLE9471_TEST_REG] = { {CDD_SBC_TLE9471_REG_M_S_CTRL, 0x00}, {CDD_SBC_TLE9471_REG_HW_CTRL_0, 0x00}, {CDD_SBC_TLE9471_REG_WD_CTRL, 0x00}, {CDD_SBC_TLE9471_REG_BUS_CTRL_0, 0x00}, {CDD_SBC_TLE9471_REG_WK_CTRL_0, 0x00}, {CDD_SBC_TLE9471_REG_WK_CTRL_1, 0x00}, {CDD_SBC_TLE9471_REG_WK_PUPD_CTRL, 0x00}, {CDD_SBC_TLE9471_REG_BUS_CTRL_3, 0x00}, {CDD_SBC_TLE9471_REG_TIMER_CTRL, 0x00}, {CDD_SBC_TLE9471_REG_HW_CTRL_1, 0x00}, {CDD_SBC_TLE9471_REG_HW_CTRL_2, 0x00}, {CDD_SBC_TLE9471_REG_GPIO_CTRL, 0x00}, {CDD_SBC_TLE9471_REG_PWM_CTRL, 0x00}, {CDD_SBC_TLE9471_REG_PWM_FREQ_CTRL, 0x00}, {CDD_SBC_TLE9471_REG_HW_CTRL_3, 0x00}, {CDD_SBC_TLE9471_REG_SYS_STATUS_CTRL_0, 0x00}, {CDD_SBC_TLE9471_REG_SYS_STATUS_CTRL_1, 0x00}, /* General Status Registers */ {CDD_SBC_TLE9471_REG_SUP_STAT_1, 0x00}, {CDD_SBC_TLE9471_REG_SUP_STAT_0, 0x00}, {CDD_SBC_TLE9471_REG_THERM_STAT, 0x00}, {CDD_SBC_TLE9471_REG_DEV_STAT, 0x00}, {CDD_SBC_TLE9471_REG_BUS_STAT, 0x00}, {CDD_SBC_TLE9471_REG_WK_STAT_0, 0x00}, {CDD_SBC_TLE9471_REG_WK_LVL_STAT, 0x00}, {CDD_SBC_TLE9471_REG_GPIO_OC_STAT, 0x00}, {CDD_SBC_TLE9471_REG_GPIO_OL_STAT, 0x00}, {CDD_SBC_TLE9471_REG_FAM_PROD_STAT, 0x00} }; /*============================================================================= functions =============================================================================== ----------------------------------------------------------------------------- brief: sbcinit 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 sbcinit() { uint16_t u16RxData = 0U; for (uint8_t index = 0; index < TLE9471_INIT_REG; index++) { sbc_read_write_reg(eCddSbc_WriteReg, &sbc_reg_init[index].reg_addr, &sbc_reg_init[index].reg_data, &u16RxData); COMMON_Delay(0x3E8); } } uint8_t BitReversal(uint8_t u8Reversedata,teCddSbcShiftType ShiftRequest) { uint8_t BitReverseOut; if (ShiftRequest == eCddSbc_Addr) { u8Reversedata = u8Reversedata>>1; } BitReverseOut = (u8Reversedata & ShiftBitSeven)>>ShiftSevenBit | \ (u8Reversedata & ShiftBitSix)>>ShiftFiveBit | \ (u8Reversedata & ShiftBitFive)>>ShiftThreeBit | \ (u8Reversedata & ShiftBitFour)>>ShiftOneBit | \ (u8Reversedata & ShiftBitThree)<>ShiftEightBit,eCddSbc_Addr))<>ShiftEightBit,eCddSbc_Addr))<