/*
 *******************************************************************************
 *
 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
 * ALL RIGHTS RESERVED
 *
 *******************************************************************************
 */

/*******************************************************************************
 *  INCLUDE FILES
 *******************************************************************************
 */
//#include <examples/tda2xx/include/chains.h>
#include <system_cfg.h>
#include <src/include/chains_common.h>
#include <ti/drv/vps/include/devices/bsp_device.h>

/**
 *  \brief Register address and value pair, with delay.
 */
typedef struct
{
    UInt8 nRegAddr;
    /**< Register Address */
    UInt8 nRegValue;
    /**< Slave Address */
    UInt32 nDelay;
    /**< Delay to be applied, after the register is programmed */
} BspUtils_Ub95xI2cParams;

static BspUtils_Ub95xI2cParams g954Cfg[] =
{
    {0x33, 0x01, 0x0},
    {0xB0, 0x00, 0x0},
    {0xB1, 0x01, 0x0},
    {0xB2, 0x01, 0x0},
    {0xB1, 0x02, 0x0},
    {0xB2, 0x33, 0x0},
    {0xB1, 0x03, 0x0},
    {0xB2, 0x24, 0x0},
    {0xB1, 0x04, 0x0},
    {0xB2, 0x0F, 0x0},
    {0xB1, 0x05, 0x0},
    {0xB2, 0x00, 0x0},
    {0xB1, 0x06, 0x0},
    {0xB2, 0x01, 0x0},
    {0xB1, 0x07, 0x0},
    {0xB2, 0xE0, 0x0},
    {0xB1, 0x08, 0x0},
    {0xB2, 0x02, 0x0},
    {0xB1, 0x09, 0x0},
    {0xB2, 0xD0, 0x0},
    {0xB1, 0x0A, 0x0},
    {0xB2, 0x04, 0x0},
    {0xB1, 0x0B, 0x0},
    {0xB2, 0x1A, 0x0},
    {0xB1, 0x0C, 0x0},
    {0xB2, 0x0C, 0x0},
    {0xB1, 0x0D, 0x0},
    {0xB2, 0x67, 0x0},
    {0xB1, 0x0E, 0x0},
    {0xB2, 0x21, 0x0},
    {0xB1, 0x0F, 0x0},
    {0xB2, 0x0A, 0x0},

};


void configDeser(void)
{
    Int32 retVal;
    Int32 idx;
    Int32 errCount = 0;

    for (idx = 0; idx < sizeof(g954Cfg) / sizeof(g954Cfg[0]); idx++)
    {
        retVal = Bsp_deviceWrite8(BSP_DEVICE_I2C_INST_ID_1,
                    0x30,
                    &(g954Cfg[idx].nRegAddr),
                    &(g954Cfg[idx].nRegValue),
                    (UInt32) 1U);
                
        if (retVal != BSP_SOK)
        {
            errCount++;
            Vps_printf("Error...\n");
        }
                
    }
    
    if (errCount == 0)
    {
        Vps_printf("Deser configuration OK!\n");
    }

}

