/******************************************************************
 * @file  Receiver_Bit_Init.s.c
 * @brief:    [file description] 
 * @author: HUOHUO
 * @Date 2024年10月30日
 * COPYRIGHT NOTICE: ITTC
 * Change_date         Owner         Change_content
 * 2024年10月30日        HUOHUO       create file

*****************************************************************/
#include "receiver_bit_func.h"


 /*!   
 * @brief:  Receiver任务启动前的初始化工作
 *          初始化全局参数，ddr查找表搬入SM
 * @author:  HUOHUO
 * @Date:  2024年10月30日
 */
void Receiver_Bit_Init()
{
    int32_t  ret;
    uint32_t lutDdrAddr,idx;

    //DM0
    g_receiver_bit_table_param.LLRDemodulation_CFG1_Offset = 0;
    g_receiver_bit_table_param.ByteCopy_CFG1_Offset = g_receiver_bit_table_param.LLRDemodulation_CFG1_Offset + RECEIVER_LLRDemodulation_CFG1_LENGTH;
    g_receiver_bit_table_param.ByteShift_CFG1_Offset = g_receiver_bit_table_param.ByteCopy_CFG1_Offset + RECEIVER_ByteCopy_CFG1_LENGTH;
    g_receiver_bit_table_param.LdpcDecBG1AllZc_CFG1_Offset = g_receiver_bit_table_param.ByteShift_CFG1_Offset + RECEIVER_ByteShift_CFG1_LENGTH;
    g_receiver_bit_table_param.LdpcDecBG1AllZc_LUT1_Offset = g_receiver_bit_table_param.LdpcDecBG1AllZc_CFG1_Offset + RECEIVER_LdpcDecBG1AllZc_CFG1_LENGTH;
    g_receiver_bit_table_param.LdpcDecBG1AllZc_CFG2_Offset = g_receiver_bit_table_param.LdpcDecBG1AllZc_LUT1_Offset + RECEIVER_LdpcDecBG1AllZc_LUT1_LENGTH;
    //DM1
    g_receiver_bit_table_param.LdpcDecBG1AllZc_LUT2_Offset = 0;
    g_receiver_bit_table_param.LdpcDecBG1AllZc_CFG3_Offset = g_receiver_bit_table_param.LdpcDecBG1AllZc_LUT2_Offset + RECEIVER_LdpcDecBG1AllZc_LUT2_LENGTH;
    g_receiver_bit_table_param.LLRDemodulation_LUT1_Offset = g_receiver_bit_table_param.LdpcDecBG1AllZc_CFG3_Offset + RECEIVER_LdpcDecBG1AllZc_CFG3_LENGTH;
    //DM2
    g_receiver_bit_table_param.LdpcDecBG1AllZc_LUT3_Offset = 0;
    g_receiver_bit_table_param.LdpcDecBG1AllZc_CFG4_Offset = g_receiver_bit_table_param.LdpcDecBG1AllZc_LUT3_Offset + RECEIVER_LdpcDecBG1AllZc_LUT3_LENGTH;
    //DM3
    g_receiver_bit_table_param.ByteCopy_CFG2_Offset = 0;
    g_receiver_bit_table_param.LdpcDecBG1AllZc_CFG5_Offset = g_receiver_bit_table_param.ByteCopy_CFG2_Offset + RECEIVER_ByteCopy_CFG2_LENGTH;
    //SM



    //9. 微码配置文件ddr地址初始化
    ret = osp_get_cfgfile("Receiver_Bit_cfg_dm0.dat",
                          (uint32_t *)&(g_receiver_bit_table_param.receiver_bit_config0_ddr_ptr),
                          (int32_t *)&(g_receiver_bit_table_param.receiver_bit_config0_length));
    if(0 != ret)
    {
        //LOG_ERROR_S("Receiver_Bit_cfg_dm0.dat not found!\n");
    }  
    ret = osp_get_cfgfile("Receiver_Bit_cfg_dm1.dat",
                          (uint32_t *)&(g_receiver_bit_table_param.receiver_bit_config1_ddr_ptr),
                          (int32_t *)&(g_receiver_bit_table_param.receiver_bit_config1_length));
    if(0 != ret)
    {
        //LOG_ERROR_S("Receiver_Bit_cfg_dm1.dat not found!\n");
    }  
    ret = osp_get_cfgfile("Receiver_Bit_cfg_dm2.dat",
                          (uint32_t *)&(g_receiver_bit_table_param.receiver_bit_config2_ddr_ptr),
                          (int32_t *)&(g_receiver_bit_table_param.receiver_bit_config2_length));
    if(0 != ret)
    {
        //LOG_ERROR_S("Receiver_Bit_cfg_dm2.dat not found!\n");
    }  
    ret = osp_get_cfgfile("Receiver_Bit_cfg_dm3.dat",
                          (uint32_t *)&(g_receiver_bit_table_param.receiver_bit_config3_ddr_ptr),
                          (int32_t *)&(g_receiver_bit_table_param.receiver_bit_config3_length));
    if(0 != ret)
    {
        //LOG_ERROR_S("Receiver_Bit_cfg_dm3.dat not found!\n");
    }  
    //10.输入测试数据
	//uint32_t timedata_ptr;
	//int32_t timedata_len;
    //ret = osp_get_cfgfile("timedata.dat",
    //                      (uint32_t *)&(timedata_ptr),
    //                      (int32_t *)&(timedata_len));
    //if(0 != ret)
    //{
        //LOG_ERROR_S("timedata.dat not found!\n");
    //}  
//    uint32_t gain_mmse_test_ptr;
//    int32_t gain_mmse_test_len;
//    ret = osp_get_cfgfile("gain_test.dat",
//    					      (uint32_t *)&(gain_mmse_test_ptr),
// 						  (int32_t *)&(gain_mmse_test_len));
//     if(0 != ret)
//     {
//         //LOG_ERROR_S("gain_test.dat not found!\n");
//     }  
    // STORE_EX_W(RECV_BIT_OUT_DATA_FLAG_DDR_ADDR,0);
    // int* param_ptr = (int *)RECEIVER_BIT_CFG_BASE;
	//STORE_EX_W(param_ptr, timedata_ptr);
	//STORE_EX_W((param_ptr+1), timedata_len);
	// STORE_EX_W((param_ptr+2), gain_mmse_test_ptr);
	//STORE_EX_W((param_ptr+3), gain_mmse_test_len);
}
