/*
 * @file sensor_driver_intf.c
 *
 * @brief This file contains function definition to
 * poll the data from the sensors and handle the interrupts
 *
 * @copyright Copyright 2023 Antaris, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define GIO_INTF_ENB

#include "sensor_driver_intf.h"
#include "sensor_linux_simu.h"
#include "exo_io_al_rtc_common.h"
#include "exo_io_al_sos_timer.h"
#include "ds620_interface.h"
#include "adm1176_interface.h"
#include "ina230_interface.h"
#include "mcp9843_intf.h"
#include "ucd9081_interface.h"
#include "nvm.h"
#include "eps.h"
#include "eps_ctrlr.h"
#include "obc_tc_tm.h"
#include "mcp23008_gpio_expander.h"
#include "exo_ahw_al_gpio_exp_common.h"
#include "exo_tctm_ipc.h"
#include "tc_tm_mngr_buffer.h"
#include "exo_gpio.h"
#include "err_handler.h"


#ifndef LINUX_TEMP_PORT
#include "stm32f7xx_hal_ext.h"
#endif



static os_timer_handle_ptr sns_tmr_ref[MAX_AH_INST_ID];

os_timer_handle_ptr brd_restart_tmr_obc;
os_timer_handle_ptr brd_restart_tmr_ps;
os_timer_handle_ptr brd_restart_tmr_edge;
os_timer_handle_ptr brd_restart_tmr_gps;
os_timer_handle_ptr brd_restart_tmr_edge1;
os_timer_handle_ptr brd_restart_tmr_edge2;
os_timer_handle_ptr brd_restart_tmr_ps_gen2;
os_timer_handle_ptr brd_restart_tmr_nic1;
os_timer_handle_ptr brd_restart_tmr_ssd1;
os_timer_handle_ptr brd_restart_tmr_ssd2;
os_timer_handle_ptr brd_restart_tmr_ssd3;
os_timer_handle_ptr brd_restart_tmr_ssd4;

static uint8_t buff_entries_trace[MAX_AH_INST_ID];

#if defined(COREBOARD) || defined(LINUX_TEMP_PORT)
static uint8_t brd_act_sts[MAX_SAT_DEV_CNT];
#endif
static uint8_t edge_ssd_heat_sts;
static uint8_t ps_ssd_heat_sts;

static uint32_t edge_ssd_heat_coil_prdcty;      // in milli seconds
static uint32_t ps_ssd_heat_coil_prdcty;        // in milli seconds

extern void* ahw_inst_hdle_ptr[MAX_AH_INST_ID];
static os_itc_msg_handle_t sns_hdlr_ipc;

volatile uint8_t kernel_init_status=0;

ahw_al_dt_hdle hdt_ps;
ahw_al_dt_hdle hdt_edge;

ahw_al_psm_hdle ahw_hpsm_ps;
ahw_al_psm_hdle ahw_hpsm_obc;

/***** GEN2 PSM *****/
ahw_al_psm_hdle ahw_hpsm_ps_gen2;
ahw_al_psm_hdle ahw_hpsm_core_brd_a;
ahw_al_psm_hdle ahw_hpsm_core_brd_b;
ahw_al_psm_hdle ahw_hpsm_ps1;
ahw_al_psm_hdle ahw_hpsm_ps2;
ahw_al_psm_hdle ahw_hpsm_edge1;
ahw_al_psm_hdle ahw_hpsm_edge2_supply;
ahw_al_psm_hdle ahw_hpsm_io_supply;
/******/

ahw_al_hsc_hdl hsc_edge;
ahw_al_hsc_hdl hsc_ps_1;
ahw_al_hsc_hdl hsc_ps_2;

/***** GEN2 HSC *****/
ahw_al_hsc_hdl hsc_ps_brd_supply;
ahw_al_hsc_hdl hsc_ps1_supply;
ahw_al_hsc_hdl hsc_ps2_supply;
ahw_al_hsc_hdl hsc_edge1_supply;
ahw_al_hsc_hdl hsc_edge2_supply;
ahw_al_hsc_hdl hsc_edge1_heat_coil;
ahw_al_hsc_hdl hsc_edge2_heat_coil;
ahw_al_hsc_hdl hsc_io_brd_supply;
ahw_al_hsc_hdl hsc_io_brd_top1;
ahw_al_hsc_hdl hsc_io_brd_top2;
ahw_al_hsc_hdl hsc_io_brd_bot1;
ahw_al_hsc_hdl hsc_io_brd_bot2;

ahw_al_temp_sensor_hdl ahw_ts_ps;
ahw_al_temp_sensor_hdl ahw_ts_obc;
ahw_al_temp_sensor_hdl ahw_ts_edge;
ahw_al_temp_sensor_hdl ahw_ts_gps;

/******* GEN 2 *******/
ahw_al_temp_sensor_hdl ahw_ts_edge1_gen2;
ahw_al_temp_sensor_hdl ahw_ts_edge2_gen2;
ahw_al_temp_sensor_hdl ahw_ts_ps_gen2;
ahw_al_temp_sensor_hdl ahw_ts_nic1;
ahw_al_temp_sensor_hdl ahw_ts_ssd1;
ahw_al_temp_sensor_hdl ahw_ts_ssd2;
ahw_al_temp_sensor_hdl ahw_ts_ssd3;
ahw_al_temp_sensor_hdl ahw_ts_ssd4;
/*******/

ahw_al_dt_hdle ahw_ts_spe01;
ahw_al_dt_hdle ahw_ts_spe02;
ahw_al_dt_hdle ahw_ts_spb01;
ahw_al_dt_hdle ahw_ts_spw01;
ahw_al_dt_hdle ahw_ts_spw02;

hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_edge_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_ps_1_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_ps_2_data_buffer[SENSOR_MAX_BUFF_SIZE];

/***** GEN2 HSC *****/
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_ps_brd_supply_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_ps1_supply_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_ps2_supply_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_edge1_supply_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_edge2_supply_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_edge1_heat_coil_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_edge2_heat_coil_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_io_brd_supply_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_io_brd_top1_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_io_brd_top2_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_io_brd_bot1_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s PLACE_IN_EXT_RAM_MEM hsc_io_brd_bot2_data_buffer[SENSOR_MAX_BUFF_SIZE];

dt_data_s PLACE_IN_EXT_RAM_MEM dt_ps_data_buffer[SENSOR_MAX_BUFF_SIZE];
dt_data_s PLACE_IN_EXT_RAM_MEM dt_edge_data_buffer[SENSOR_MAX_BUFF_SIZE];

temp_data_s PLACE_IN_EXT_RAM_MEM temp_obc_data_buffer[SENSOR_MAX_BUFF_SIZE];
temp_data_s PLACE_IN_EXT_RAM_MEM temp_ps_data_buffer[SENSOR_MAX_BUFF_SIZE];
temp_data_s PLACE_IN_EXT_RAM_MEM temp_edge_data_buffer[SENSOR_MAX_BUFF_SIZE];
temp_data_s PLACE_IN_EXT_RAM_MEM temp_gps_data_buffer[SENSOR_MAX_BUFF_SIZE];

/***** GEN2 ******/
temp_data_s PLACE_IN_EXT_RAM_MEM temp_edge1_gen2_data_buffer[SENSOR_MAX_BUFF_SIZE];
temp_data_s PLACE_IN_EXT_RAM_MEM temp_edge2_gen2_data_buffer[SENSOR_MAX_BUFF_SIZE];
temp_data_s PLACE_IN_EXT_RAM_MEM temp_ps_gen2_data_buffer[SENSOR_MAX_BUFF_SIZE];
temp_data_s PLACE_IN_EXT_RAM_MEM temp_nic1_data_buffer[SENSOR_MAX_BUFF_SIZE];
temp_data_s PLACE_IN_EXT_RAM_MEM temp_ssd1_data_buffer[SENSOR_MAX_BUFF_SIZE];
temp_data_s PLACE_IN_EXT_RAM_MEM temp_ssd2_data_buffer[SENSOR_MAX_BUFF_SIZE];
temp_data_s PLACE_IN_EXT_RAM_MEM temp_ssd3_data_buffer[SENSOR_MAX_BUFF_SIZE];
temp_data_s PLACE_IN_EXT_RAM_MEM temp_ssd4_data_buffer[SENSOR_MAX_BUFF_SIZE];
/******/

dt_data_s PLACE_IN_EXT_RAM_MEM temp_spe01_data_buffer[SENSOR_MAX_BUFF_SIZE];
dt_data_s PLACE_IN_EXT_RAM_MEM temp_spe02_data_buffer[SENSOR_MAX_BUFF_SIZE];
dt_data_s PLACE_IN_EXT_RAM_MEM temp_spb01_data_buffer[SENSOR_MAX_BUFF_SIZE];
dt_data_s PLACE_IN_EXT_RAM_MEM temp_spw01_data_buffer[SENSOR_MAX_BUFF_SIZE];
dt_data_s PLACE_IN_EXT_RAM_MEM temp_spw02_data_buffer[SENSOR_MAX_BUFF_SIZE];

psm_data_s PLACE_IN_EXT_RAM_MEM psm_ps_data_buffer[SENSOR_MAX_BUFF_SIZE];
psm_data_s PLACE_IN_EXT_RAM_MEM psm_obc_data_buffer[SENSOR_MAX_BUFF_SIZE];
vsm_data_s PLACE_IN_EXT_RAM_MEM vsm_obc_data_buffer[SENSOR_MAX_BUFF_SIZE];

/***** GEN2 PSM *****/
psm_data_s PLACE_IN_EXT_RAM_MEM psm_ps_gen2_data_buffer[SENSOR_MAX_BUFF_SIZE];
psm_data_s PLACE_IN_EXT_RAM_MEM psm_core_brd_a_data_buffer[SENSOR_MAX_BUFF_SIZE];
psm_data_s PLACE_IN_EXT_RAM_MEM psm_core_brd_b_data_buffer[SENSOR_MAX_BUFF_SIZE];
psm_data_s PLACE_IN_EXT_RAM_MEM psm_ps1_data_buffer[SENSOR_MAX_BUFF_SIZE];
psm_data_s PLACE_IN_EXT_RAM_MEM psm_ps2_data_buffer[SENSOR_MAX_BUFF_SIZE];
psm_data_s PLACE_IN_EXT_RAM_MEM psm_edge1_data_buffer[SENSOR_MAX_BUFF_SIZE];
psm_data_s PLACE_IN_EXT_RAM_MEM psm_edge2_supply_data_buffer[SENSOR_MAX_BUFF_SIZE];
psm_data_s PLACE_IN_EXT_RAM_MEM psm_io_supply_data_buffer[SENSOR_MAX_BUFF_SIZE];
/*******/

static temp_sens_cfg PLACE_IN_EXT_RAM_MEM temp_sns_cfg_obc;
static temp_sens_cfg PLACE_IN_EXT_RAM_MEM temp_sns_cfg_ps;
static temp_sens_cfg PLACE_IN_EXT_RAM_MEM temp_sns_cfg_edge;
static temp_sens_cfg PLACE_IN_EXT_RAM_MEM temp_sns_cfg_gps;

static digital_thermostat_cfg PLACE_IN_EXT_RAM_MEM dgtl_thrmst_cfg_spe02;
static digital_thermostat_cfg PLACE_IN_EXT_RAM_MEM dgtl_thrmst_cfg_spw01;
static digital_thermostat_cfg PLACE_IN_EXT_RAM_MEM dgtl_thrmst_cfg_spe01;
static digital_thermostat_cfg PLACE_IN_EXT_RAM_MEM dgtl_thrmst_cfg_spw02;
static digital_thermostat_cfg PLACE_IN_EXT_RAM_MEM dgtl_thrmst_cfg_spb01;

static digital_thermostat_cfg PLACE_IN_EXT_RAM_MEM dgtl_thrmst_cfg_ps;
static digital_thermostat_cfg PLACE_IN_EXT_RAM_MEM dgtl_thrmst_cfg_edge;

static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_cfg_edge;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_cfg_ps_1;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_cfg_ps_2;

static power_sense_mntr_cfg PLACE_IN_EXT_RAM_MEM pwr_sns_mtr_cfg_obc;
static power_sense_mntr_cfg PLACE_IN_EXT_RAM_MEM pwr_sns_mtr_cfg_ps;

/***** GEN2 TEMP *****/
static temp_sens_cfg PLACE_IN_EXT_RAM_MEM temp_sns_cfg_edge1_gen2;
static temp_sens_cfg PLACE_IN_EXT_RAM_MEM temp_sns_cfg_edge2_gen2;
static temp_sens_cfg PLACE_IN_EXT_RAM_MEM temp_sns_cfg_ps_gen2;
static temp_sens_cfg PLACE_IN_EXT_RAM_MEM temp_sns_cfg_nic1;
static temp_sens_cfg PLACE_IN_EXT_RAM_MEM temp_sns_cfg_ssd1;
static temp_sens_cfg PLACE_IN_EXT_RAM_MEM temp_sns_cfg_ssd2;
static temp_sens_cfg PLACE_IN_EXT_RAM_MEM temp_sns_cfg_ssd3;
static temp_sens_cfg PLACE_IN_EXT_RAM_MEM temp_sns_cfg_ssd4;

/***** GEN2 HSC *****/
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_ps_brd_supply;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_ps1_supply;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_ps2_supply;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_edge1_supply;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_edge2_supply;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_edge1_heat_coil;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_edge2_heat_coil;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_io_brd_supply;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_io_brd_top1;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_io_brd_top2;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_io_brd_bot1;
static hotswap_cntlr_cfg PLACE_IN_EXT_RAM_MEM htswp_cntlr_io_brd_bot2;

/***** GEN2 PSM *****/
static power_sense_mntr_cfg PLACE_IN_EXT_RAM_MEM pwr_sns_mtr_cfg_ps_gen2;
static power_sense_mntr_cfg PLACE_IN_EXT_RAM_MEM pwr_sns_mtr_cfg_core_brd_a;
static power_sense_mntr_cfg PLACE_IN_EXT_RAM_MEM pwr_sns_mtr_cfg_core_brd_b;
static power_sense_mntr_cfg PLACE_IN_EXT_RAM_MEM pwr_sns_mtr_cfg_ps1;
static power_sense_mntr_cfg PLACE_IN_EXT_RAM_MEM pwr_sns_mtr_cfg_ps2;
static power_sense_mntr_cfg PLACE_IN_EXT_RAM_MEM pwr_sns_mtr_cfg_edge1;
static power_sense_mntr_cfg PLACE_IN_EXT_RAM_MEM pwr_sns_mtr_cfg_edge2_supply;
static power_sense_mntr_cfg PLACE_IN_EXT_RAM_MEM pwr_sns_mtr_cfg_io_supply;
/*********/

#if defined(COREBOARD) || defined(LINUX_TEMP_PORT)
/**
 * @brief API to initialize the on-board controller sensors
 * @retval no return
 */
static uint8_t coreboard_sensor_init();

/**
 * @brief API to initialize the sensor in payload server
 * @retval no return
 */
static uint8_t ps_brd_sensor_init();

/**
 * @brief API to initialize the edge board sensors
 * @retval no return
 */
static uint8_t edge_brd_sensor_init();
/**
 * @brief API to initialize the GPS board sensors
 * @retval no return
 */
static uint8_t gps_brd_sensor_init();

/**
 * @brief API to initialize the sensors in solar panel
 * @retval no return
 */
static uint8_t solar_panel_sns_init();

/**
 * @brief API to deinitialize the payload server sensors
 * @retval no return
 */
static uint8_t ps_brd_sensor_deinit();

/**
 * @brief API to deinitialize the edge board sensors
 * @retval no return
 */
static uint8_t edge_brd_sensor_deinit();

/**
 * @brief API to deinitialize the GPS board sensors
 * @retval no return
 */
static uint8_t gps_brd_sensor_deinit();

/**
 * @brief API to handle the sensor interrupt
 * @param[in]  ahw_id - application hardware ID
 * @retval no return
 */
static void sensor_interrupt_hdlr(uint32_t ahw_id);

/**
 * @brief API to handle the sensor polling timer expiry
 * @param[in]  ahw_id - application hardware ID
 * @retval no return
 */
static void sensor_tmr_expry_hdlr(uint32_t ahw_id, uint8_t buff_idx);

/**
 * @brief API to handle the sensor configuration event
 * @param[in]  ahw_id - application hardware ID
 * @retval no return
 */
static void sensor_cfg_hdlr(uint32_t ahw_id);

/**
 * @brief API to check the temperature sensor threshold
 * @param[in]  ahw_id - application hardware ID
 * @retval no return
 */
static uint8_t check_temp_sns_thrsld(uint32_t ahw_id);
static uint8_t send_sns_health_mntr_data();

/**
 * @brief API to check the power sense monitor threshold
 * @param[in]  ahw_id - application hardware ID
 * @retval no return
 */
#ifndef LINUX_TEMP_PORT

static uint8_t check_pwr_sns_thrsld(uint32_t ahw_id);
#endif
/**
 * @brief API to handle board restart timer expiry
 * @param[in]  brd_id - board ID
 * @retval no return
 */
static void brd_restart_hdlr(uint8_t brd_id);
static void send_sns_obc_ipc(uint8_t* type, uint16_t rsp_id);
#endif 
/**
 * @brief API to create board restart timers
 * @retval no return
 */
#ifndef LINUX_TEMP_PORT

static void brd_restart_tmr_create();
#endif

#if 0
static float sns_data_average(uint8_t ahw_id, uint8_t avg_count);
#endif

static void heat_coil_enable_control(uint8_t brd_id, uint8_t state)
{
	if(brd_id == 1) //PS
	{
		eps_set_chnl_state_pl_srvr(3,state);
	}
	else if(brd_id == 2)
	{
		eps_set_chnl_state_edge(4,state);
	}
}


uint8_t set_ssd_heat_coil_periodicity(uint8_t board_id, uint32_t ht_cl_prdcty)
{
	uint8_t ret;
    if(ht_cl_prdcty<MIN_HEAT_COIL_PRDCTY)
    {
    	ht_cl_prdcty= MIN_HEAT_COIL_PRDCTY;
    }
	if(board_id == 1) //PS
	{
      ret = nvm_parameter_write(NVM_DATA,NVM_PS_HEAT_COIL_PRDCTY,(uint8_t*)&ht_cl_prdcty);
      if(ret == 0)
      {
         ps_ssd_heat_coil_prdcty = ht_cl_prdcty;
         if(ps_ssd_heat_sts==1)
         {
             sensor_driver_start(ps_ssd_heat_coil_prdcty,DIGITAL_THERMOSTAT_DS620_PS);
         }
      }

	}
	else  //edge
	{
      ret = nvm_parameter_write(NVM_DATA,NVM_EDGE_HEAT_COIL_PRDCTY,(uint8_t*)&ht_cl_prdcty);
      if(ret == 0)
      {
         edge_ssd_heat_coil_prdcty = ht_cl_prdcty;
         if(edge_ssd_heat_sts==1)
         {
             sensor_driver_start(edge_ssd_heat_coil_prdcty,DIGITAL_THERMOSTAT_DS620_EDGE);
         }
      }
	}
	return ret;
}




uint8_t set_ssd_heat_coil_enable(uint8_t board_id, uint8_t enable_sts)
{
	uint8_t ret;

	if(board_id == 1) //PS
	{
      ret = nvm_parameter_write(NVM_DATA,NVM_SSD_PL_HEAT_CTRL,(uint8_t*)&enable_sts);
      if(ret == 0)
      {
    	  ps_ssd_heat_sts = enable_sts;
    	  heat_coil_enable_control(board_id,enable_sts);
      }

	}
	else  //edge
	{
      ret = nvm_parameter_write(NVM_DATA,NVM_SSD_EDGE_HEAT_CTRL,(uint8_t*)&enable_sts);
      if(ret == 0)
      {
    	  edge_ssd_heat_sts = enable_sts;
    	  heat_coil_enable_control(board_id,enable_sts);
      }
	}
	return ret;
}

uint32_t get_ssd_heat_coil_periodicity(uint8_t board_id)
{
	uint32_t ht_cl_prdcty;
	if(board_id == 1) //PS
	{
      nvm_parameter_read(NVM_DATA,NVM_PS_HEAT_COIL_PRDCTY,(uint8_t*)&ht_cl_prdcty);
	}
	else  //edge
	{
      nvm_parameter_read(NVM_DATA,NVM_EDGE_HEAT_COIL_PRDCTY,(uint8_t*)&ht_cl_prdcty);
	}
	return ht_cl_prdcty;
}


uint8_t get_ssd_heat_coil_sts(uint8_t board_id)
{
	uint8_t retval=0;
	if(board_id==1)
	{
		retval=ps_ssd_heat_sts;
	}
	else if (board_id==2)
	{
		retval=edge_ssd_heat_sts;
	}
	return retval;
}

/**
 * @brief API to get RTC time
 */
void get_rtc_tm(uint64_t *time)
{
#ifndef LINUX_TEMP_PORT   
    *time=get_rtc_tm_epoch();
#else    
    *time=get_crnt_time_date_in_epoch();
#endif
}
#if defined(COREBOARD) || defined(LINUX_TEMP_PORT)

/**
 * @brief API to send the IPC message from sensor task
 */
static void send_sns_obc_ipc(uint8_t* type, uint16_t rsp_id)
{
    os_itc_msg_handle_t sns_rsp_ipc;
    sns_rsp_ipc.Msg_id=rsp_id;
    sns_rsp_ipc.pld.pld_ptr=type;
    sns_rsp_ipc.src_entity=OBC_SENSOR_HDLR;
    os_itc_msg_send(&sns_rsp_ipc,OBC_MAIN,1000);
}
#endif

/**
 * @brief Sensor thread entry function
 */
void sensor_hdlr_thread(void* args)
{


  os_memset(hsc_edge_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_ps_1_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_ps_2_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));

  os_memset(dt_ps_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(dt_data_s));
  os_memset(dt_edge_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(dt_data_s));

  os_memset(temp_obc_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(temp_data_s));
  os_memset(temp_ps_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(temp_data_s));
  os_memset(temp_edge_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(temp_data_s));
  os_memset(temp_gps_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(temp_data_s));

  /***** GEN2 TEMP *****/
  os_memset(temp_edge1_gen2_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(temp_data_s));
  os_memset(temp_edge2_gen2_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(temp_data_s));
  os_memset(temp_ps_gen2_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(temp_data_s));
  os_memset(temp_nic1_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(temp_data_s));
  os_memset(temp_ssd1_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(temp_data_s));
  os_memset(temp_ssd2_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(temp_data_s));
  os_memset(temp_ssd3_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(temp_data_s));
  os_memset(temp_ssd4_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(temp_data_s));

  /***** GEN2 PSM *****/
  os_memset( psm_ps_gen2_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(psm_data_s));
  os_memset( psm_core_brd_a_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(psm_data_s));
  os_memset( psm_core_brd_b_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(psm_data_s));
  os_memset( psm_ps1_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(psm_data_s));
  os_memset( psm_ps2_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(psm_data_s));
  os_memset( psm_edge1_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(psm_data_s));
  os_memset( psm_edge2_supply_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(psm_data_s));
  os_memset( psm_io_supply_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(psm_data_s));

  /***** GEN2 HSC *****/
  os_memset(hsc_ps_brd_supply_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_ps1_supply_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_ps2_supply_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_edge1_supply_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_edge2_supply_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_edge1_heat_coil_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_edge2_heat_coil_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_io_brd_supply_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_io_brd_top1_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_io_brd_top2_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_io_brd_bot1_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));
  os_memset(hsc_io_brd_bot2_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(hsc_data_s));

  /******/

  os_memset(temp_spe01_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(dt_data_s));
  os_memset(temp_spe02_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(dt_data_s));
  os_memset(temp_spb01_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(dt_data_s));
  os_memset(temp_spw01_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(dt_data_s));
  os_memset(temp_spw02_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(dt_data_s));

  os_memset( psm_ps_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(psm_data_s));
  os_memset( psm_obc_data_buffer,0,SENSOR_MAX_BUFF_SIZE*sizeof(psm_data_s));
  

  /** TM buffering FW queue request for each health data */
  /** Size 12 * 5 *3 = 180*/
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE, HSC_EDGE_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE, HSC_PS1_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE, HSC_PS2_DATA_QUEUE_ID);

  /** Size 16 * 5 *2 = 160*/
  tc_buff_fw_req_queue(sizeof(dt_data_s), SENSOR_MAX_BUFF_SIZE, DT_PS_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(dt_data_s), SENSOR_MAX_BUFF_SIZE, DT_EDGE_DATA_QUEUE_ID);

  /** Size 24 * 5 * 2 = 240*/
  tc_buff_fw_req_queue(sizeof(psm_data_s), SENSOR_MAX_BUFF_SIZE, PSM_PS_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(psm_data_s), SENSOR_MAX_BUFF_SIZE, PSM_OBC_DATA_QUEUE_ID);

  /***** GEN2 PSM *****/
  tc_buff_fw_req_queue(sizeof(psm_data_s), SENSOR_MAX_BUFF_SIZE, PSM_PS_GEN2_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(psm_data_s), SENSOR_MAX_BUFF_SIZE, PSM_CORE_BRD_A_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(psm_data_s), SENSOR_MAX_BUFF_SIZE, PSM_CORE_BRD_B_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(psm_data_s), SENSOR_MAX_BUFF_SIZE, PSM_PS1_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(psm_data_s), SENSOR_MAX_BUFF_SIZE, PSM_PS2_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(psm_data_s), SENSOR_MAX_BUFF_SIZE, PSM_EDGE1_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(psm_data_s), SENSOR_MAX_BUFF_SIZE, PSM_EDGE1_SUPPLY_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(psm_data_s), SENSOR_MAX_BUFF_SIZE, PSM_IO_SUPPLY_DATA_QUEUE_ID);
  /************  GEN2 TEMP ************/
  tc_buff_fw_req_queue(sizeof(temp_data_s), SENSOR_MAX_BUFF_SIZE, TEMP_EDGE1_GEN2_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(temp_data_s), SENSOR_MAX_BUFF_SIZE, TEMP_EDGE2_GEN2_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(temp_data_s), SENSOR_MAX_BUFF_SIZE, TEMP_PS_GEN2_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(temp_data_s), SENSOR_MAX_BUFF_SIZE, TEMP_NIC1_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(temp_data_s), SENSOR_MAX_BUFF_SIZE, TEMP_SSD1_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(temp_data_s), SENSOR_MAX_BUFF_SIZE, TEMP_SSD2_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(temp_data_s), SENSOR_MAX_BUFF_SIZE, TEMP_SSD3_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(temp_data_s), SENSOR_MAX_BUFF_SIZE, TEMP_SSD4_DATA_QUEUE_ID);
  /****** GEN2 HSC ******/
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE,HSC_PS_BRD_SUPPLY_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE,HSC_PS1_SUPPLY_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE,HSC_PS2_SUPPLY_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE,HSC_EDGE1_SUPPLY_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE,HSC_EDGE2_SUPPLY_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE,HSC_EDGE1_HEAT_COIL_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE,HSC_EDGE2_HEAT_COIL_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE,HSC_IO_SUPPLY_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE,HSC_IO_BRD_TOP1_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE,HSC_IO_BRD_TOP2_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE,HSC_IO_BRD_BOT1_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(hsc_data_s), SENSOR_MAX_BUFF_SIZE,HSC_IO_BRD_BOT2_DATA_QUEUE_ID);


  /** Size 12 * 5 * 9 = 540*/
  tc_buff_fw_req_queue(sizeof(temp_data_s), SENSOR_MAX_BUFF_SIZE, TEMP_OBC_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(temp_data_s), SENSOR_MAX_BUFF_SIZE, TEMP_PS_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(temp_data_s), SENSOR_MAX_BUFF_SIZE, TEMP_ES_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(temp_data_s), SENSOR_MAX_BUFF_SIZE, TEMP_GPS_DATA_QUEUE_ID);

  tc_buff_fw_req_queue(sizeof(dt_data_s), SENSOR_MAX_BUFF_SIZE, DT_SPE01_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(dt_data_s), SENSOR_MAX_BUFF_SIZE, DT_SPE02_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(dt_data_s), SENSOR_MAX_BUFF_SIZE, DT_SPB01_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(dt_data_s), SENSOR_MAX_BUFF_SIZE, DT_SPW01_DATA_QUEUE_ID);
  tc_buff_fw_req_queue(sizeof(dt_data_s), SENSOR_MAX_BUFF_SIZE, DT_SPW02_DATA_QUEUE_ID);

#if defined(COREBOARD) || defined(LINUX_TEMP_PORT)
    uint32_t id;
uint8_t buff_idx=0;
    coreboard_sensor_init();
    solar_panel_sns_init();
#endif
#ifndef LINUX_TEMP_PORT    
    brd_restart_tmr_create();
#endif    
#ifdef HEAT_SINK_DISABLE
    edge_ssd_heat_sts=0;
    ps_ssd_heat_sts=0;
#else

    nvm_parameter_read(NVM_DATA,NVM_EDGE_HEAT_COIL_PRDCTY,(uint8_t*)&edge_ssd_heat_coil_prdcty);
    nvm_parameter_read(NVM_DATA,NVM_PS_HEAT_COIL_PRDCTY,(uint8_t*)&ps_ssd_heat_coil_prdcty);

    if(ps_ssd_heat_coil_prdcty<MIN_HEAT_COIL_PRDCTY)
    {
    	ps_ssd_heat_coil_prdcty= MIN_HEAT_COIL_PRDCTY;
    }
    if(edge_ssd_heat_coil_prdcty<MIN_HEAT_COIL_PRDCTY)
    {
    	edge_ssd_heat_coil_prdcty= MIN_HEAT_COIL_PRDCTY;
    }

#endif
    os_memset(buff_entries_trace,1,MAX_AH_INST_ID);
    kernel_init_status=1;

    while(1)
    {
        os_itc_msg_rcv(OBC_SENSOR_HDLR,&sns_hdlr_ipc,os_wait_forever);
#if defined(COREBOARD) || defined(LINUX_TEMP_PORT)
        if(sns_hdlr_ipc.Msg_id==SNS_TMR_EXPRY_EVNT)
        {
            id=sns_hdlr_ipc.pld.pld_data;
            if(id<MAX_AH_INST_ID)
            {
                buff_idx=buff_entries_trace[id];
            }
            sensor_tmr_expry_hdlr(id,buff_idx);

            (buff_entries_trace[id]>=(SENSOR_MAX_BUFF_SIZE-1))?buff_entries_trace[id]=0:buff_entries_trace[id]++;
        }
        else if(sns_hdlr_ipc.Msg_id==OBC_SEN_INIT_REQ)
        {
            uint8_t* init_brd_num=os_malloc(1);
            os_memcpy(init_brd_num,sns_hdlr_ipc.pld.pld_ptr,1);
            send_sns_obc_ipc(init_brd_num,SEN_OBC_INIT_RSP);
            if(brd_act_sts[*init_brd_num]!=SW_ACTIVE)
            {
                brd_act_sts[*init_brd_num]=SW_ACTIVE;
                switch(*init_brd_num)
                {
                    case HW_PL_SERVER:
                        ps_brd_sensor_init();
                        break;

                    case HW_GPS:
                        gps_brd_sensor_init();
                        break;

                    case HW_EDGE_BRD:
                        edge_brd_sensor_init();
                        break;
                }
            }
        }
        else if(sns_hdlr_ipc.Msg_id==OBC_SEN_DEINIT_REQ)
        {
            uint8_t* deinit_brd_num=os_malloc(1);
            os_memcpy(deinit_brd_num,sns_hdlr_ipc.pld.pld_ptr,1);
            send_sns_obc_ipc(deinit_brd_num,SEN_OBC_DEINIT_RSP);
            if(brd_act_sts[*deinit_brd_num]!=SW_INACTIVE)
            {
                brd_act_sts[*deinit_brd_num]=SW_INACTIVE;
                switch(*deinit_brd_num)
                {
                    case HW_PL_SERVER:
                        ps_brd_sensor_deinit();
                        break;

                    case HW_GPS:
                        gps_brd_sensor_deinit();
                        break;

                    case HW_EDGE_BRD:
                        edge_brd_sensor_deinit();
                        break;
                }
            }
        }
        else if(sns_hdlr_ipc.Msg_id==SNS_CFG_EVNT)
        {
            id=MAX_AH_INST_ID;
            os_memcpy(&id,sns_hdlr_ipc.pld.pld_ptr,4);
            sensor_cfg_hdlr(id);
        }
        else if(sns_hdlr_ipc.Msg_id==HEAT_COIL_ON_EVNT)
        {
                if(sns_hdlr_ipc.pld.pld_data == HW_PL_SERVER)
                {
                        sensor_driver_start(ps_ssd_heat_coil_prdcty,DIGITAL_THERMOSTAT_DS620_PS);
                        hsc_sns_init(&hsc_ps_2,&htswp_cntlr_cfg_ps_2);
                }
                else if(sns_hdlr_ipc.pld.pld_data == HW_EDGE_BRD)
                {
                        sensor_driver_start(ps_ssd_heat_coil_prdcty,DIGITAL_THERMOSTAT_DS620_EDGE);
                        hsc_sns_init(&hsc_edge,&htswp_cntlr_cfg_edge);
                }
        }
        else if(sns_hdlr_ipc.Msg_id==HEAT_COIL_OFF_EVNT)
        {
                if(sns_hdlr_ipc.pld.pld_data == HW_PL_SERVER)
                {
                    hsc_sns_deinit(HSC_ADM1176_PS_2);
                	err_cleared(ERR_GROUP_AHW_SET_1,ERR_HSC_ADM1176_PS_2);

                }
                else if(sns_hdlr_ipc.pld.pld_data == HW_EDGE_BRD)
                {
                    hsc_sns_deinit(HSC_ADM1176_EDGE);
                	err_cleared(ERR_GROUP_AHW_SET_1,ERR_HSC_ADM1176_EDGE);

                }
        }
        else if(sns_hdlr_ipc.Msg_id==SNS_INTERRUPT)
        {
            sensor_interrupt_hdlr(sns_hdlr_ipc.pld.pld_data);
        }
        else if(sns_hdlr_ipc.Msg_id==SNS_BRD_RESTART_TMR_EXPRY)
        {
            brd_restart_hdlr(sns_hdlr_ipc.pld.pld_data);
        }
        else if(sns_hdlr_ipc.Msg_id==SDR_APP_SEN_MH_REQ)
        {
        	send_sns_health_mntr_data();
        }
        /**  - Message response from buffering FW: Dummy handling need to impelement */
        else if(OBC_TC_TM_BUFFER_RSP == sns_hdlr_ipc.Msg_id)
        {
            if(TC_TM_BUFFER_SUCC == sns_hdlr_ipc.pld.pld_data)
            {
                DEBUG_CPRINT(("SENSOR BUFFER REQUEST FOR HEALTH DATA SUCCESS\n"));
            }
            else
            {
                DEBUG_CPRINT(("SENSOR BUFFER REQUEST FOR HEALTH DATA FAILED\n"));
            }
        }
#endif
        if(sns_hdlr_ipc.pld.pld_ptr)
        {
            os_free(sns_hdlr_ipc.pld.pld_ptr);
            sns_hdlr_ipc.pld.pld_ptr = NULL;
        }
    }
}

/**
 * @brief API to initialize the sensor
 */
void sensors_init()
{
    sns_nvm_init();
    os_thread_create(OBC_SENSOR_HDLR,T_SENSOR_STACK_SIZE, P_OBC_SENSOR_HDLR, "sns_pl_thd",sensor_hdlr_thread , NULL, NULL, NULL);
#ifdef LINUX_TEMP_PORT
    os_thread_create(OBC_SNS_SIMU,T_SENSOR_STACK_SIZE, P_OBC_SENSOR_SIMU, "sns_linux_simu",(app_entry_func_t)sensor_skt_simu , NULL, NULL, NULL);
#endif
}

/**
 * @brief Sensor timer event callback function
 */
#ifdef LINUX_TEMP_PORT
void sensor_timer_cb(size_t tm_id, void* args)
#else
void sensor_timer_cb(void* args)
#endif    
{
    os_itc_msg_handle_t sns_cb_ipc;
    sns_cb_ipc.src_entity=0xFF;
    sns_cb_ipc.pld.pld_ptr=NULL;
    sns_cb_ipc.Msg_id=SNS_TMR_EXPRY_EVNT;
    os_timer_handle_ptr* tmr_ref_cmp = (os_timer_handle_ptr*)args;
    if(*tmr_ref_cmp==sns_tmr_ref[DIGITAL_THERMOSTAT_DS620_EDGE])
    {
        sns_cb_ipc.pld.pld_data=DIGITAL_THERMOSTAT_DS620_EDGE;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[DIGITAL_THERMOSTAT_DS620_PS])
    {
        sns_cb_ipc.pld.pld_data=DIGITAL_THERMOSTAT_DS620_PS;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[IMU_BMX160_OBC_2])
    {
        sns_cb_ipc.pld.pld_data=IMU_BMX160_OBC_2;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[IMU_BMX160_OBC_1])
    {
        sns_cb_ipc.pld.pld_data=IMU_BMX160_OBC_1;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_EDGE])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_EDGE;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_PS_1])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_PS_1;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_PS_2])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_PS_2;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[TEMP_SENSOR_MCP9843_OBC])
    {
        sns_cb_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_OBC;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[TEMP_SENSOR_MCP9843_PS])
    {
        sns_cb_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_PS;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[TEMP_SENSOR_MCP9843_EDGE])
    {
        sns_cb_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_EDGE;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[TEMP_SENSOR_MCP9843_GPS])
    {
        sns_cb_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_GPS;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[PSM_INA230_OBC])
    {
        sns_cb_ipc.pld.pld_data=PSM_INA230_OBC;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[PSM_INA230_PS])
    {
        sns_cb_ipc.pld.pld_data=PSM_INA230_PS;
    }

    /***** GEN2 TEMP *****/
    else if(*tmr_ref_cmp==sns_tmr_ref[TEMP_SENSOR_MCP9843_EDGE_1])
        {
            sns_cb_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_EDGE_1;
        }
    else if(*tmr_ref_cmp==sns_tmr_ref[TEMP_SENSOR_MCP9843_EDGE_2])
        {
            sns_cb_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_EDGE_2;
        }
    else if(*tmr_ref_cmp==sns_tmr_ref[TEMP_SENSOR_MCP9843_PS_GEN_2])
        {
            sns_cb_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_PS_GEN_2;
        }
    else if(*tmr_ref_cmp==sns_tmr_ref[TEMP_SENSOR_MCP9843_NIC_1])
        {
            sns_cb_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_NIC_1;
        }
    else if(*tmr_ref_cmp==sns_tmr_ref[TEMP_SENSOR_MCP9843_SSD_1])
        {
            sns_cb_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_SSD_1;
        }
    else if(*tmr_ref_cmp==sns_tmr_ref[TEMP_SENSOR_MCP9843_SSD_2])
        {
            sns_cb_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_SSD_2;
        }
    else if(*tmr_ref_cmp==sns_tmr_ref[TEMP_SENSOR_MCP9843_SSD_3])
        {
            sns_cb_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_SSD_3;
        }
    else if(*tmr_ref_cmp==sns_tmr_ref[TEMP_SENSOR_MCP9843_SSD_4])
        {
            sns_cb_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_SSD_4;
        }
    /***** GEN2 PSM *****/
    else if(*tmr_ref_cmp==sns_tmr_ref[PSM_INA230_PS_GEN_2])
    {
    	sns_cb_ipc.pld.pld_data=PSM_INA230_PS_GEN_2;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[PSM_INA230_CORE_BRD_A])
    {
    	sns_cb_ipc.pld.pld_data=PSM_INA230_CORE_BRD_A;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[PSM_INA230_CORE_BRD_B])
    {
    	sns_cb_ipc.pld.pld_data=PSM_INA230_CORE_BRD_B;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[PSM_INA230_PS_1])
    {
    	sns_cb_ipc.pld.pld_data=PSM_INA230_PS_1;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[PSM_INA230_PS_2])
    {
    	sns_cb_ipc.pld.pld_data=PSM_INA230_PS_2;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[PSM_INA230_EDGE_1])
    {
    	sns_cb_ipc.pld.pld_data=PSM_INA230_EDGE_1;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[PSM_INA230_EDGE_2_IN_SUPPLY])
    {
    	sns_cb_ipc.pld.pld_data=PSM_INA230_EDGE_2_IN_SUPPLY;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[PSM_INA230_IO_BRD_IN_SUPPLY])
    {
    	sns_cb_ipc.pld.pld_data=PSM_INA230_IO_BRD_IN_SUPPLY;
    }
    /***** GEN2 HSC ******/
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_PS_1_IN_SUPPLY])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_PS_1_IN_SUPPLY;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_PS_2_IN_SUPPLY])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_PS_2_IN_SUPPLY;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_EDGE_1_IN_SUPPLY])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_EDGE_1_IN_SUPPLY;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_EDGE_1_HEAT_COIL])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_EDGE_1_HEAT_COIL;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_EDGE_2_IN_SUPPLY])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_EDGE_2_IN_SUPPLY;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_EDGE_2_HEAT_COIL])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_EDGE_2_HEAT_COIL;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_IO_BRD_IN_SUPPLY])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_IO_BRD_IN_SUPPLY;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2])
    {
        sns_cb_ipc.pld.pld_data=HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2;
    }
    /******/

    else if(*tmr_ref_cmp==sns_tmr_ref[DIGITAL_THERMOSTAT_DS620_SPE01])
    {
        sns_cb_ipc.pld.pld_data=DIGITAL_THERMOSTAT_DS620_SPE01;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[DIGITAL_THERMOSTAT_DS620_SPE02])
    {
        sns_cb_ipc.pld.pld_data=DIGITAL_THERMOSTAT_DS620_SPE02;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[DIGITAL_THERMOSTAT_DS620_SPB01])
    {
        sns_cb_ipc.pld.pld_data=DIGITAL_THERMOSTAT_DS620_SPB01;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[DIGITAL_THERMOSTAT_DS620_SPW01])
    {
        sns_cb_ipc.pld.pld_data=DIGITAL_THERMOSTAT_DS620_SPW01;
    }
    else if(*tmr_ref_cmp==sns_tmr_ref[DIGITAL_THERMOSTAT_DS620_SPW02])
    {
        sns_cb_ipc.pld.pld_data=DIGITAL_THERMOSTAT_DS620_SPW02;
    }
    else if(*tmr_ref_cmp==brd_restart_tmr_obc)
    {
        sns_cb_ipc.Msg_id=SNS_BRD_RESTART_TMR_EXPRY;
        sns_cb_ipc.pld.pld_data=MAX_SAT_DEV_CNT;
    }
    else if(*tmr_ref_cmp==brd_restart_tmr_ps)
    {
        sns_cb_ipc.Msg_id=SNS_BRD_RESTART_TMR_EXPRY;
        sns_cb_ipc.pld.pld_data=HW_PL_SERVER;
    }
    else if(*tmr_ref_cmp==brd_restart_tmr_gps)
    {
        sns_cb_ipc.Msg_id=SNS_BRD_RESTART_TMR_EXPRY;
        sns_cb_ipc.pld.pld_data=HW_GPS;
    }
    else if(*tmr_ref_cmp==brd_restart_tmr_edge)
    {
        sns_cb_ipc.Msg_id=SNS_BRD_RESTART_TMR_EXPRY;
        sns_cb_ipc.pld.pld_data=HW_EDGE_BRD;
    }
    os_itc_msg_send(&sns_cb_ipc,OBC_SENSOR_HDLR,1000);
}

/**
 * @brief API to initialize and start the polling timer of the sensor with given application hardware id
 */
void sensor_driver_start(uint32_t timer_index, uint32_t ahw_id)
{
    char id_s[10];
    if((timer_index < SENSOR_TIMER_MAX) && (timer_index != 0))
    {
        if(sns_tmr_ref[ahw_id]==NULL)
        {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat"
            sprintf(id_s,"%lu",ahw_id);
#pragma GCC diagnostic pop
            strcat(id_s,"s_p_tmr");
            os_timer_create(&sns_tmr_ref[ahw_id],id_s,PERIODIC,(ral_timer_cbfunc_t)sensor_timer_cb,&sns_tmr_ref[ahw_id]);
        }
        os_timer_start(sns_tmr_ref[ahw_id],timer_index);
    }
    else
    {
    }
}

/**
 * @brief API to stop the sensor with given application hardware id
 */
void sensor_driver_stop(uint8_t ahw_id)
{
    if(sns_tmr_ref[ahw_id]!=NULL)
    {
        os_timer_stop(sns_tmr_ref[ahw_id]);
    }
}

#if defined(COREBOARD) || defined(LINUX_TEMP_PORT)

/**
 * @brief API to initialize the on-board controller sensors
 */
static uint8_t coreboard_sensor_init()
{
    uint64_t tp_epoch_time = 0;
    tp_epoch_time=tp_epoch_time;
    temp_sns_init(&ahw_ts_obc,&temp_sns_cfg_obc);
#ifndef LINUX_TEMP_PORT
    uint8_t buff_idx = 0;
    temp_get_func(&temp_obc_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_OBC);
    get_rtc_tm(&tp_epoch_time);
    temp_obc_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;
#endif
    psm_sns_init(&ahw_hpsm_obc,&pwr_sns_mtr_cfg_obc);
#ifndef LINUX_TEMP_PORT
    psm_get_func(&psm_obc_data_buffer[buff_idx].pwr,PSM_INA230_OBC);
    get_rtc_tm(&tp_epoch_time);
    psm_obc_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;
#endif
    return 0;
}

/**
 * @brief API to initialize the sensor in payload server
 */
static uint8_t ps_brd_sensor_init()
{
	uint8_t buff_idx = 0;
    uint64_t tp_epoch_time;
    double tp_temperature;
    dt_sns_init(&hdt_ps,&dgtl_thrmst_cfg_ps);
    dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_PS);
    dt_ps_data_buffer[buff_idx].temperature=tp_temperature;
    get_rtc_tm(&tp_epoch_time);
    dt_ps_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;
    hsc_sns_init(&hsc_ps_1,&htswp_cntlr_cfg_ps_1);
    hsc_get_func(&hsc_ps_1_data_buffer[buff_idx].hsc_data,HSC_ADM1176_PS_1);
    get_rtc_tm(&tp_epoch_time);
    hsc_ps_1_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;
    temp_sns_init(&ahw_ts_ps,&temp_sns_cfg_ps);
    temp_get_func(&temp_ps_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_PS);
    get_rtc_tm(&tp_epoch_time);
    temp_ps_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;
    psm_sns_init(&ahw_hpsm_ps,&pwr_sns_mtr_cfg_ps);
    psm_get_func(&psm_ps_data_buffer[buff_idx].pwr,PSM_INA230_PS);
    get_rtc_tm(&tp_epoch_time);
    psm_ps_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;

    /***** GEN2 PSM *****/
    psm_sns_init(&ahw_hpsm_ps_gen2,&pwr_sns_mtr_cfg_ps_gen2);
    psm_get_func(&psm_ps_gen2_data_buffer[buff_idx].pwr,PSM_INA230_PS_GEN_2);
    get_rtc_tm(&tp_epoch_time);
    psm_ps_gen2_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;
    psm_sns_init(&ahw_hpsm_core_brd_a,&pwr_sns_mtr_cfg_core_brd_a);
    psm_get_func(&psm_core_brd_a_data_buffer[buff_idx].pwr,PSM_INA230_CORE_BRD_A);
    get_rtc_tm(&tp_epoch_time);
    psm_core_brd_a_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;
    psm_sns_init(&ahw_hpsm_core_brd_b,&pwr_sns_mtr_cfg_core_brd_b);
    psm_get_func(&psm_core_brd_b_data_buffer[buff_idx].pwr,PSM_INA230_CORE_BRD_B);
    get_rtc_tm(&tp_epoch_time);
    psm_core_brd_b_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;
    psm_sns_init(&ahw_hpsm_ps1,&pwr_sns_mtr_cfg_ps1);
    psm_get_func(&psm_ps1_data_buffer[buff_idx].pwr,PSM_INA230_PS_1);
    get_rtc_tm(&tp_epoch_time);
    psm_ps1_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;
    psm_sns_init(&ahw_hpsm_ps2,&pwr_sns_mtr_cfg_ps2);
    psm_get_func(&psm_ps2_data_buffer[buff_idx].pwr,PSM_INA230_PS_2);
    get_rtc_tm(&tp_epoch_time);
    psm_ps2_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;
    psm_sns_init(&ahw_hpsm_edge1,&pwr_sns_mtr_cfg_edge1);
    psm_get_func(&psm_edge1_data_buffer[buff_idx].pwr,PSM_INA230_EDGE_1);
    get_rtc_tm(&tp_epoch_time);
    psm_edge1_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;
    psm_sns_init(&ahw_hpsm_edge2_supply,&pwr_sns_mtr_cfg_edge2_supply);
    psm_get_func(&psm_edge2_supply_data_buffer[buff_idx].pwr,PSM_INA230_EDGE_2_IN_SUPPLY);
    get_rtc_tm(&tp_epoch_time);
    psm_edge2_supply_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;
    psm_sns_init(&ahw_hpsm_io_supply,&pwr_sns_mtr_cfg_io_supply);
    psm_get_func(&psm_io_supply_data_buffer[buff_idx].pwr,PSM_INA230_IO_BRD_IN_SUPPLY);
    get_rtc_tm(&tp_epoch_time);
    psm_io_supply_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;

    if(ps_ssd_heat_sts==1)
    {
#ifndef LINUX_TEMP_PORT            
    	heat_coil_enable_control(1,1);
#endif                
    }
    return 0;
}

/**
 * @brief API to initialize the sensors in solar panel
 */
static uint8_t solar_panel_sns_init()
{
    dt_sns_init(&ahw_ts_spe01,&dgtl_thrmst_cfg_spe01);
    dt_sns_init(&ahw_ts_spe02,&dgtl_thrmst_cfg_spe02);
    dt_sns_init(&ahw_ts_spb01,&dgtl_thrmst_cfg_spb01);
    dt_sns_init(&ahw_ts_spw01,&dgtl_thrmst_cfg_spw01);
    dt_sns_init(&ahw_ts_spw02,&dgtl_thrmst_cfg_spw02);
#ifndef LINUX_TEMP_PORT
	uint8_t buff_idx = 0;
    uint64_t tp_epoch_time;
    double tp_temperature;
    dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_SPE01);
    temp_spe01_data_buffer[buff_idx].temperature=tp_temperature;
    get_rtc_tm(&tp_epoch_time);
    temp_spe01_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;

    dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_SPE02);
    temp_spe02_data_buffer[buff_idx].temperature=tp_temperature;
    get_rtc_tm(&tp_epoch_time);
    temp_spe02_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;

    dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_SPB01);
    temp_spb01_data_buffer[buff_idx].temperature=tp_temperature;
    get_rtc_tm(&tp_epoch_time);
    temp_spb01_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;

    dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_SPW01);
    temp_spw01_data_buffer[buff_idx].temperature=tp_temperature;
    get_rtc_tm(&tp_epoch_time);
    temp_spw01_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;

    dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_SPW02);
    temp_spw02_data_buffer[buff_idx].temperature=tp_temperature;
    get_rtc_tm(&tp_epoch_time);
    temp_spw02_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;
#endif
    return 0;
}

/**
 * @brief API to initialize the edge board sensors
 */
static uint8_t edge_brd_sensor_init()
{
    uint8_t buff_idx = 0;
    uint64_t tp_epoch_time;
    double tp_temperature;
    dt_sns_init(&hdt_edge,&dgtl_thrmst_cfg_edge);
    dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_EDGE);
    dt_edge_data_buffer[buff_idx].temperature=tp_temperature;
    get_rtc_tm(&tp_epoch_time);

    dt_edge_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;
    temp_sns_init(&ahw_ts_edge,&temp_sns_cfg_edge);
    temp_get_func(&temp_edge_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_EDGE);
    get_rtc_tm(&tp_epoch_time);
    temp_edge_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;
#ifndef LINUX_TEMP_PORT                
    if(edge_ssd_heat_sts==1)
    {
    	heat_coil_enable_control(2,1);
    }
#endif
    return 0;
}

/**
 * @brief API to initialize the GPS board sensors
 */
static uint8_t gps_brd_sensor_init()
{
	uint8_t buff_idx = 0;
    uint64_t tp_epoch_time;
    temp_sns_init(&ahw_ts_gps,&temp_sns_cfg_gps);
    temp_get_func(&temp_gps_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_GPS);
    get_rtc_tm(&tp_epoch_time);
    temp_gps_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;
    return 0;
}

/**
 * @brief API to deinitialize the payload server sensors
 */
static uint8_t ps_brd_sensor_deinit()
{
    dt_sns_deinit(DIGITAL_THERMOSTAT_DS620_PS);
	err_cleared(ERR_GROUP_AHW_SET_1,ERR_DIGITAL_THERMOSTAT_DS620_PS);

    hsc_sns_deinit(HSC_ADM1176_PS_1);
	err_cleared(ERR_GROUP_AHW_SET_1,ERR_HSC_ADM1176_PS_1);

    temp_sns_deinit(TEMP_SENSOR_MCP9843_PS);
	err_cleared(ERR_GROUP_AHW_SET_1,ERR_TEMP_SENSOR_MCP9843_PS);

    psm_sns_deinit(PSM_INA230_PS);
	err_cleared(ERR_GROUP_AHW_SET_1,ERR_PSM_INA230_PS);

#ifndef LINUX_TEMP_PORT                
    ps_intr_deinit();
    if(ps_ssd_heat_sts==1)
    {
    	heat_coil_enable_control(1,0);
    }
#endif    
    return 0;
}

/**
 * @brief API to deinitialize the edge board sensors
 */
static uint8_t edge_brd_sensor_deinit()
{
    dt_sns_deinit(DIGITAL_THERMOSTAT_DS620_EDGE);
	err_cleared(ERR_GROUP_AHW_SET_1,ERR_DIGITAL_THERMOSTAT_DS620_EDGE);

    temp_sns_deinit(TEMP_SENSOR_MCP9843_EDGE);
	err_cleared(ERR_GROUP_AHW_SET_1,ERR_TEMP_SENSOR_MCP9843_EDGE);

#ifndef LINUX_TEMP_PORT
    edge_intr_deinit();
    if(edge_ssd_heat_sts==1)
    {
    	heat_coil_enable_control(2,0);
    }
#endif        
    return 0;
}

/**
 * @brief API to deinitialize the GPS board sensors
 */
static uint8_t gps_brd_sensor_deinit()
{
#ifndef LINUX_TEMP_PORT
    gps_intr_deinit();
#endif
    temp_sns_deinit(TEMP_SENSOR_MCP9843_GPS);
	err_cleared(ERR_GROUP_AHW_SET_1,ERR_TEMP_SENSOR_MCP9843_GPS);

    return 0;
}
#endif

/**
 * @brief API to initialize the temperature sensor with the given configuration
 */
uint8_t temp_sns_init(ahw_al_temp_sensor_hdl* tmp_hdl, temp_sens_cfg* t_sns_prm)
{
    hal_ret_sts sts;
    tmp_hdl->high_temp_threshold= t_sns_prm->high_temp_thrsld;
    tmp_hdl->low_temp_threshold = t_sns_prm->low_temp_thrsld;
    tmp_hdl->resolution = t_sns_prm->adc_resolution;
    tmp_hdl->intr_polarity = t_sns_prm->intr_pin_polarity;
    tmp_hdl->intr_mask=t_sns_prm->intr_mask;

    sts=ahw_al_temp_sensor_init(tmp_hdl,t_sns_prm->instance_id);
    if(sts==HAL_SCS)
    {
        sensor_driver_start(t_sns_prm->polling_tmr_prdcty,t_sns_prm->instance_id);
    }
    return sts;
}

/**
 * @brief API to initialize the digital thermostat with the given configuration
 */
uint8_t dt_sns_init(ahw_al_dt_hdle* dt_hdl,digital_thermostat_cfg* dt_sns_prm)
{
    hal_ret_sts sts;
    dt_hdl->high_temp_thrsld = dt_sns_prm->high_temp_thrsld;
    dt_hdl->low_temp_thrsld= dt_sns_prm->low_temp_thrsld;
    dt_hdl->resolution= dt_sns_prm->adc_resolution ;
    dt_hdl->thrmst_pin_polarity = dt_sns_prm->thrmst_pin_polarity;
    dt_hdl->conversion_type = dt_sns_prm->conversion_type;
    dt_hdl->thrmst_event_enable = dt_sns_prm->thrmst_enable;
    sts=ahw_al_dt_init(dt_hdl,dt_sns_prm->instance_id);
    if(sts==HAL_SCS)
    {
        sensor_driver_start(dt_sns_prm->polling_tmr_prdcty,dt_sns_prm->instance_id);
    }
    return sts;
}

/**
 * @brief API to initialize the power sense monitor with the given configuration
 */
uint8_t psm_sns_init(ahw_al_psm_hdle* psm_hdl, power_sense_mntr_cfg* psm_sns_prm)
{
    hal_ret_sts sts;
    psm_hdl->vbus_threshold = psm_sns_prm->vbus_thrsld;
    psm_hdl->current_threshold = psm_sns_prm->current_thrsld ;
    psm_hdl->power_threshold = psm_sns_prm->power_thrsld;
    psm_hdl->alert_pin_function = psm_sns_prm->intr_type;
    sts=ahw_al_psm_init(psm_hdl,psm_sns_prm->instance_id);
    if(sts==HAL_SCS)
    {
        sensor_driver_start(psm_sns_prm->polling_tmr_prdcty,psm_sns_prm->instance_id);
    }
    return sts;
}

/**
 * @brief API to initialize the hotswap controller with the given configuration
 */
uint8_t hsc_sns_init(ahw_al_hsc_hdl* hsc_hdl,hotswap_cntlr_cfg* hswp_sns_prm)
{
    hal_ret_sts sts;
    hsc_hdl->hot_swp_sts = hswp_sns_prm->hotswap_sts;
    sts=ahw_al_hsc_init(hsc_hdl,hswp_sns_prm->instance_id);
    if(sts==HAL_SCS)
    {
        sensor_driver_start(hswp_sns_prm->polling_tmr_prdcty,hswp_sns_prm->instance_id);
    }
    return sts;
}

/**
 * @brief API to deinitialize the temperature sensor
 */
uint8_t temp_sns_deinit(uint8_t ahw_id)
{
    ahw_al_temp_sensor_deinit(ahw_inst_hdle_ptr[ahw_id],ahw_id);
    sensor_driver_stop(ahw_id);
    return 0;
}

/**
 * @brief API to deinitialize the hotswap controller
 */
uint8_t hsc_sns_deinit(uint8_t ahw_id)
{
    ahw_al_hsc_deinit(ahw_inst_hdle_ptr[ahw_id],ahw_id);
    sensor_driver_stop(ahw_id);
    return 0;
}

/**
 * @brief API to deinitialize the power sense monitor
 */
uint8_t psm_sns_deinit(uint8_t ahw_id)
{
    ahw_al_psm_deinit(ahw_inst_hdle_ptr[ahw_id],ahw_id);
    sensor_driver_stop(ahw_id);
    return 0;
}

/**
 * @brief API to deinitialize the digital thermostat
 */
uint8_t dt_sns_deinit(uint8_t ahw_id)
{
    ahw_al_dt_deinit(ahw_inst_hdle_ptr[ahw_id],ahw_id);
    sensor_driver_stop(ahw_id);
    return 0;
}

/**
 * @brief API to initialize the sensor parameters from the NVM
 */
uint8_t sns_nvm_init()
{
    sns_nvm_read_cfg();
    return 0;
}

/**
 * @brief API to read the sensor configuration data from the NVM
 */
uint8_t sns_nvm_read_cfg()
{
    int8_t nvm_sts=NVM_UNKNOWN_ERROR;
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_GPS_CFG,(uint8_t*)&temp_sns_cfg_gps);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_PS_CFG,(uint8_t*)&temp_sns_cfg_ps);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_EDGE_CFG,(uint8_t*)&temp_sns_cfg_edge);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_OBC_CFG,(uint8_t*)&temp_sns_cfg_obc);
    /***** GEN2 *****/
//    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_EDGE1_GEN2_CFG,(uint8_t*)&temp_sns_cfg_edge1_gen2);
//    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_EDGE2_GEN2_CFG,(uint8_t*)&temp_sns_cfg_edge2_gen2);
//    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_PS_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ps_gen2);
//    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_NIC1_CFG,(uint8_t*)&temp_sns_cfg_nic1);
//    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_SSD1_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ssd1);
//    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_SSD2_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ssd2);
//    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_SSD3_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ssd3);
//    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_SSD4_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ssd4);

    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_DT_DS620_SPE01_CFG,(uint8_t*)&dgtl_thrmst_cfg_spe01);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_DT_DS620_SPE02_CFG,(uint8_t*)&dgtl_thrmst_cfg_spe02);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_DT_DS620_SPB01_CFG,(uint8_t*)&dgtl_thrmst_cfg_spb01);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_DT_DS620_SPW01_CFG,(uint8_t*)&dgtl_thrmst_cfg_spw01);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_DT_DS620_SPW02_CFG,(uint8_t*)&dgtl_thrmst_cfg_spw02);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_DT_DS620_PS_CFG,(uint8_t*)&dgtl_thrmst_cfg_ps);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_DT_DS620_EDGE_CFG,(uint8_t*)&dgtl_thrmst_cfg_edge);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_POWER_SENSE_MONITOR_OBC_CFG,(uint8_t*)&pwr_sns_mtr_cfg_obc);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_POWER_SENSE_MONITOR_PS_CFG,(uint8_t*)&pwr_sns_mtr_cfg_ps);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_HSC_ADM1176_EDGE_CFG,(uint8_t*)&htswp_cntlr_cfg_edge);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_HSC_ADM1176_PS_1_CFG,(uint8_t*)&htswp_cntlr_cfg_ps_1);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_HSC_ADM1176_PS_2_CFG,(uint8_t*)&htswp_cntlr_cfg_ps_2);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_SSD_EDGE_HEAT_CTRL,(uint8_t*)&edge_ssd_heat_sts);
    nvm_sts = nvm_parameter_read(NVM_DATA,NVM_SSD_PL_HEAT_CTRL,(uint8_t*)&ps_ssd_heat_sts);

#if 0
    DEBUG_CPRINT(("temp_sns_cfg_gps.instance_id = %d\n",temp_sns_cfg_gps.instance_id));
    DEBUG_CPRINT(("temp_sns_cfg_gps.polling_tmr_prdcty = %d\n",temp_sns_cfg_gps.polling_tmr_prdcty));
    DEBUG_CPRINT(("temp_sns_cfg_gps.high_temp_thrsld = %f\n",temp_sns_cfg_gps.high_temp_thrsld));
    DEBUG_CPRINT(("temp_sns_cfg_gps.low_temp_thrsld = %f\n",temp_sns_cfg_gps.low_temp_thrsld));
    DEBUG_CPRINT(("temp_sns_cfg_gps.adc_resolution = %d\n",temp_sns_cfg_gps.adc_resolution));
    DEBUG_CPRINT(("temp_sns_cfg_gps.intr_mask = %d\n",temp_sns_cfg_gps.intr_mask));
    DEBUG_CPRINT(("temp_sns_cfg_gps.conversion_type = %d\n",temp_sns_cfg_gps.conversion_type));
    DEBUG_CPRINT(("temp_sns_cfg_gps.intr_pin_polarity = %d\n",temp_sns_cfg_gps.intr_pin_polarity));

    DEBUG_CPRINT(("temp_sns_cfg_edge.instance_id = %d\n",temp_sns_cfg_edge.instance_id));
    DEBUG_CPRINT(("temp_sns_cfg_edge.polling_tmr_prdcty = %d\n",temp_sns_cfg_edge.polling_tmr_prdcty));
    DEBUG_CPRINT(("temp_sns_cfg_edge.high_temp_thrsld = %f\n",temp_sns_cfg_edge.high_temp_thrsld));
    DEBUG_CPRINT(("temp_sns_cfg_edge.low_temp_thrsld = %f\n",temp_sns_cfg_edge.low_temp_thrsld));
    DEBUG_CPRINT(("temp_sns_cfg_edge.adc_resolution = %d\n",temp_sns_cfg_edge.adc_resolution));
    DEBUG_CPRINT(("temp_sns_cfg_edge.intr_mask = %d\n",temp_sns_cfg_edge.intr_mask));
    DEBUG_CPRINT(("temp_sns_cfg_edge.conversion_type = %d\n",temp_sns_cfg_edge.conversion_type));
    DEBUG_CPRINT(("temp_sns_cfg_edge.intr_pin_polarity = %d\n",temp_sns_cfg_edge.intr_pin_polarity));

    DEBUG_CPRINT(("temp_sns_cfg_ps.instance_id = %d\n",temp_sns_cfg_ps.instance_id));
    DEBUG_CPRINT(("temp_sns_cfg_ps.polling_tmr_prdcty = %d\n",temp_sns_cfg_ps.polling_tmr_prdcty));
    DEBUG_CPRINT(("temp_sns_cfg_ps.high_temp_thrsld = %f\n",temp_sns_cfg_ps.high_temp_thrsld));
    DEBUG_CPRINT(("temp_sns_cfg_ps.low_temp_thrsld = %f\n",temp_sns_cfg_ps.low_temp_thrsld));
    DEBUG_CPRINT(("temp_sns_cfg_ps.adc_resolution = %d\n",temp_sns_cfg_ps.adc_resolution));
    DEBUG_CPRINT(("temp_sns_cfg_ps.intr_mask = %d\n",temp_sns_cfg_ps.intr_mask));
    DEBUG_CPRINT(("temp_sns_cfg_ps.conversion_type = %d\n",temp_sns_cfg_ps.conversion_type));
    DEBUG_CPRINT(("temp_sns_cfg_ps.intr_pin_polarity = %d\n",temp_sns_cfg_ps.intr_pin_polarity));

    DEBUG_CPRINT(("temp_sns_cfg_obc.instance_id = %d\n",temp_sns_cfg_obc.instance_id));
    DEBUG_CPRINT(("temp_sns_cfg_obc.polling_tmr_prdcty = %d\n",temp_sns_cfg_obc.polling_tmr_prdcty));
    DEBUG_CPRINT(("temp_sns_cfg_obc.high_temp_thrsld = %f\n",temp_sns_cfg_obc.high_temp_thrsld));
    DEBUG_CPRINT(("temp_sns_cfg_obc.low_temp_thrsld = %f\n",temp_sns_cfg_obc.low_temp_thrsld));
    DEBUG_CPRINT(("temp_sns_cfg_obc.adc_resolution = %d\n",temp_sns_cfg_obc.adc_resolution));
    DEBUG_CPRINT(("temp_sns_cfg_obc.intr_mask = %d\n",temp_sns_cfg_obc.intr_mask));
    DEBUG_CPRINT(("temp_sns_cfg_obc.conversion_type = %d\n",temp_sns_cfg_obc.conversion_type));
    DEBUG_CPRINT(("temp_sns_cfg_obc.intr_pin_polarity = %d\n",temp_sns_cfg_obc.intr_pin_polarity));

    /******************************************* GEN2 *******************************************/
     DEBUG_CPRINT(("temp_sns_cfg_edge1_gen2.instance_id = %d\n",temp_sns_cfg_edge1_gen2.instance_id));
     DEBUG_CPRINT(("temp_sns_cfg_edge1_gen2.polling_tmr_prdcty = %d\n",temp_sns_cfg_edge1_gen2.polling_tmr_prdcty));
     DEBUG_CPRINT(("temp_sns_cfg_edge1_gen2.high_temp_thrsld = %f\n",temp_sns_cfg_edge1_gen2.high_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_edge1_gen2.low_temp_thrsld = %f\n",temp_sns_cfg_edge1_gen2.low_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_edge1_gen2.adc_resolution = %d\n",temp_sns_cfg_edge1_gen2.adc_resolution));
     DEBUG_CPRINT(("temp_sns_cfg_edge1_gen2.intr_mask = %d\n",temp_sns_cfg_edge1_gen2.intr_mask));
     DEBUG_CPRINT(("temp_sns_cfg_edge1_gen2.conversion_type = %d\n",temp_sns_cfg_edge1_gen2.conversion_type));
     DEBUG_CPRINT(("temp_sns_cfg_edge1_gen2.intr_pin_polarity = %d\n",temp_sns_cfg_edge1_gen2.intr_pin_polarity));

     DEBUG_CPRINT(("temp_sns_cfg_edge2_gen2.instance_id = %d\n",temp_sns_cfg_edge2_gen2.instance_id));
     DEBUG_CPRINT(("temp_sns_cfg_edge2_gen2.polling_tmr_prdcty = %d\n",temp_sns_cfg_edge2_gen2.polling_tmr_prdcty));
     DEBUG_CPRINT(("temp_sns_cfg_edge2_gen2.high_temp_thrsld = %f\n",temp_sns_cfg_edge2_gen2.high_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_edge2_gen2.low_temp_thrsld = %f\n",temp_sns_cfg_edge2_gen2.low_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_edge2_gen2.adc_resolution = %d\n",temp_sns_cfg_edge2_gen2.adc_resolution));
     DEBUG_CPRINT(("temp_sns_cfg_edge2_gen2.intr_mask = %d\n",temp_sns_cfg_edge2_gen2.intr_mask));
     DEBUG_CPRINT(("temp_sns_cfg_edge2_gen2.conversion_type = %d\n",temp_sns_cfg_edge2_gen2.conversion_type));
     DEBUG_CPRINT(("temp_sns_cfg_edge2_gen2.intr_pin_polarity = %d\n",temp_sns_cfg_edge2_gen2.intr_pin_polarity));

     DEBUG_CPRINT(("temp_sns_cfg_ps_gen2.instance_id = %d\n",temp_sns_cfg_ps_gen2.instance_id));
     DEBUG_CPRINT(("temp_sns_cfg_ps_gen2.polling_tmr_prdcty = %d\n",temp_sns_cfg_ps_gen2.polling_tmr_prdcty));
     DEBUG_CPRINT(("temp_sns_cfg_ps_gen2.high_temp_thrsld = %f\n",temp_sns_cfg_ps_gen2.high_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_ps_gen2.low_temp_thrsld = %f\n",temp_sns_cfg_ps_gen2.low_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_ps_gen2.adc_resolution = %d\n",temp_sns_cfg_ps_gen2.adc_resolution));
     DEBUG_CPRINT(("temp_sns_cfg_ps_gen2.intr_mask = %d\n",temp_sns_cfg_ps_gen2.intr_mask));
     DEBUG_CPRINT(("temp_sns_cfg_ps_gen2.conversion_type = %d\n",temp_sns_cfg_ps_gen2.conversion_type));
     DEBUG_CPRINT(("temp_sns_cfg_ps_gen2.intr_pin_polarity = %d\n",temp_sns_cfg_ps_gen2.intr_pin_polarity));

     DEBUG_CPRINT(("temp_sns_cfg_nic1.instance_id = %d\n",temp_sns_cfg_nic1.instance_id));
     DEBUG_CPRINT(("temp_sns_cfg_nic1.polling_tmr_prdcty = %d\n",temp_sns_cfg_nic1.polling_tmr_prdcty));
     DEBUG_CPRINT(("temp_sns_cfg_nic1.high_temp_thrsld = %f\n",temp_sns_cfg_nic1.high_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_nic1.low_temp_thrsld = %f\n",temp_sns_cfg_nic1.low_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_nic1.adc_resolution = %d\n",temp_sns_cfg_nic1.adc_resolution));
     DEBUG_CPRINT(("temp_sns_cfg_nic1.intr_mask = %d\n",temp_sns_cfg_nic1.intr_mask));
     DEBUG_CPRINT(("temp_sns_cfg_nic1.conversion_type = %d\n",temp_sns_cfg_nic1.conversion_type));
     DEBUG_CPRINT(("temp_sns_cfg_nic1.intr_pin_polarity = %d\n",temp_sns_cfg_nic1.intr_pin_polarity));

     DEBUG_CPRINT(("temp_sns_cfg_ssd1.instance_id = %d\n",temp_sns_cfg_ssd1.instance_id));
     DEBUG_CPRINT(("temp_sns_cfg_ssd1.polling_tmr_prdcty = %d\n",temp_sns_cfg_ssd1.polling_tmr_prdcty));
     DEBUG_CPRINT(("temp_sns_cfg_ssd1.high_temp_thrsld = %f\n",temp_sns_cfg_ssd1.high_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_ssd1.low_temp_thrsld = %f\n",temp_sns_cfg_ssd1.low_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_ssd1.adc_resolution = %d\n",temp_sns_cfg_ssd1.adc_resolution));
     DEBUG_CPRINT(("temp_sns_cfg_ssd1.intr_mask = %d\n",temp_sns_cfg_ssd1.intr_mask));
     DEBUG_CPRINT(("temp_sns_cfg_ssd1.conversion_type = %d\n",temp_sns_cfg_ssd1.conversion_type));
     DEBUG_CPRINT(("temp_sns_cfg_ssd1.intr_pin_polarity = %d\n",temp_sns_cfg_ssd1.intr_pin_polarity));

     DEBUG_CPRINT(("temp_sns_cfg_ssd2.instance_id = %d\n",temp_sns_cfg_ssd2.instance_id));
     DEBUG_CPRINT(("temp_sns_cfg_ssd2.polling_tmr_prdcty = %d\n",temp_sns_cfg_ssd2.polling_tmr_prdcty));
     DEBUG_CPRINT(("temp_sns_cfg_ssd2.high_temp_thrsld = %f\n",temp_sns_cfg_ssd2.high_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_ssd2.low_temp_thrsld = %f\n",temp_sns_cfg_ssd2.low_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_ssd2.adc_resolution = %d\n",temp_sns_cfg_ssd2.adc_resolution));
     DEBUG_CPRINT(("temp_sns_cfg_ssd2.intr_mask = %d\n",temp_sns_cfg_ssd2.intr_mask));
     DEBUG_CPRINT(("temp_sns_cfg_ssd2.conversion_type = %d\n",temp_sns_cfg_ssd2.conversion_type));
     DEBUG_CPRINT(("temp_sns_cfg_ssd2.intr_pin_polarity = %d\n",temp_sns_cfg_ssd2.intr_pin_polarity));

     DEBUG_CPRINT(("temp_sns_cfg_ssd3.instance_id = %d\n",temp_sns_cfg_ssd3.instance_id));
     DEBUG_CPRINT(("temp_sns_cfg_ssd3.polling_tmr_prdcty = %d\n",temp_sns_cfg_ssd3.polling_tmr_prdcty));
     DEBUG_CPRINT(("temp_sns_cfg_ssd3.high_temp_thrsld = %f\n",temp_sns_cfg_ssd3.high_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_ssd3.low_temp_thrsld = %f\n",temp_sns_cfg_ssd3.low_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_ssd3.adc_resolution = %d\n",temp_sns_cfg_ssd3.adc_resolution));
     DEBUG_CPRINT(("temp_sns_cfg_ssd3.intr_mask = %d\n",temp_sns_cfg_ssd3.intr_mask));
     DEBUG_CPRINT(("temp_sns_cfg_ssd3.conversion_type = %d\n",temp_sns_cfg_ssd3.conversion_type));
     DEBUG_CPRINT(("temp_sns_cfg_ssd3.intr_pin_polarity = %d\n",temp_sns_cfg_ssd3.intr_pin_polarity));

     DEBUG_CPRINT(("temp_sns_cfg_ssd4.instance_id = %d\n",temp_sns_cfg_ssd4.instance_id));
     DEBUG_CPRINT(("temp_sns_cfg_ssd4.polling_tmr_prdcty = %d\n",temp_sns_cfg_ssd4.polling_tmr_prdcty));
     DEBUG_CPRINT(("temp_sns_cfg_ssd4.high_temp_thrsld = %f\n",temp_sns_cfg_ssd4.high_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_ssd4.low_temp_thrsld = %f\n",temp_sns_cfg_ssd4.low_temp_thrsld));
     DEBUG_CPRINT(("temp_sns_cfg_ssd4.adc_resolution = %d\n",temp_sns_cfg_ssd4.adc_resolution));
     DEBUG_CPRINT(("temp_sns_cfg_ssd4.intr_mask = %d\n",temp_sns_cfg_ssd4.intr_mask));
     DEBUG_CPRINT(("temp_sns_cfg_ssd4.conversion_type = %d\n",temp_sns_cfg_ssd4.conversion_type));
     DEBUG_CPRINT(("temp_sns_cfg_ssd4.intr_pin_polarity = %d\n",temp_sns_cfg_ssd4.intr_pin_polarity));
     /**********************************************************************************************/

    DEBUG_CPRINT(("dgtl_thrmst_cfg_spe01.instance_id = %d\n",dgtl_thrmst_cfg_spe01.instance_id));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spe01.polling_tmr_prdcty = %d\n",dgtl_thrmst_cfg_spe01.polling_tmr_prdcty));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spe01.high_temp_thrsld = %f\n",dgtl_thrmst_cfg_spe01.high_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spe01.low_temp_thrsld = %f\n",dgtl_thrmst_cfg_spe01.low_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spe01.adc_resolution = %d\n",dgtl_thrmst_cfg_spe01.adc_resolution));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spe01.conversion_type = %d\n",dgtl_thrmst_cfg_spe01.conversion_type));

    DEBUG_CPRINT(("dgtl_thrmst_cfg_spe02.instance_id = %d\n",dgtl_thrmst_cfg_spe02.instance_id));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spe02.polling_tmr_prdcty = %d\n",dgtl_thrmst_cfg_spe02.polling_tmr_prdcty));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spe02.high_temp_thrsld = %f\n",dgtl_thrmst_cfg_spe02.high_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spe02.low_temp_thrsld = %f\n",dgtl_thrmst_cfg_spe02.low_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spe02.adc_resolution = %d\n",dgtl_thrmst_cfg_spe02.adc_resolution));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spe02.conversion_type = %d\n",dgtl_thrmst_cfg_spe02.conversion_type));

    DEBUG_CPRINT(("dgtl_thrmst_cfg_spb01.instance_id = %d\n",dgtl_thrmst_cfg_spb01.instance_id));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spb01.polling_tmr_prdcty = %d\n",dgtl_thrmst_cfg_spb01.polling_tmr_prdcty));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spb01.high_temp_thrsld = %f\n",dgtl_thrmst_cfg_spb01.high_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spb01.low_temp_thrsld = %f\n",dgtl_thrmst_cfg_spb01.low_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spb01.adc_resolution = %d\n",dgtl_thrmst_cfg_spb01.adc_resolution));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spb01.conversion_type = %d\n",dgtl_thrmst_cfg_spb01.conversion_type));

    DEBUG_CPRINT(("dgtl_thrmst_cfg_spw01.instance_id = %d\n",dgtl_thrmst_cfg_spw01.instance_id));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spw01.polling_tmr_prdcty = %d\n",dgtl_thrmst_cfg_spw01.polling_tmr_prdcty));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spw01.high_temp_thrsld = %f\n",dgtl_thrmst_cfg_spw01.high_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spw01.low_temp_thrsld = %f\n",dgtl_thrmst_cfg_spw01.low_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spw01.adc_resolution = %d\n",dgtl_thrmst_cfg_spw01.adc_resolution));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spw01.conversion_type = %d\n",dgtl_thrmst_cfg_spw01.conversion_type));

    DEBUG_CPRINT(("dgtl_thrmst_cfg_spw02.instance_id = %d\n",dgtl_thrmst_cfg_spw02.instance_id));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spw02.polling_tmr_prdcty = %d\n",dgtl_thrmst_cfg_spw02.polling_tmr_prdcty));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spw02.high_temp_thrsld = %f\n",dgtl_thrmst_cfg_spw02.high_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spw02.low_temp_thrsld = %f\n",dgtl_thrmst_cfg_spw02.low_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spw02.adc_resolution = %d\n",dgtl_thrmst_cfg_spw02.adc_resolution));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_spw02.conversion_type = %d\n",dgtl_thrmst_cfg_spw02.conversion_type));

    DEBUG_CPRINT(("dgtl_thrmst_cfg_ps.instance_id = %d\n",dgtl_thrmst_cfg_ps.instance_id));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_ps.polling_tmr_prdcty = %d\n",dgtl_thrmst_cfg_ps.polling_tmr_prdcty));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_ps.high_temp_thrsld = %f\n",dgtl_thrmst_cfg_ps.high_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_ps.low_temp_thrsld = %f\n",dgtl_thrmst_cfg_ps.low_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_ps.conversion_type = %d\n",dgtl_thrmst_cfg_ps.conversion_type));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_ps.thrmst_pin_polarity = %d\n",dgtl_thrmst_cfg_ps.thrmst_pin_polarity));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_ps.thrmst_enable = %d\n",dgtl_thrmst_cfg_ps.thrmst_enable));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_ps.adc_resolution = %d\n",dgtl_thrmst_cfg_ps.adc_resolution));

    DEBUG_CPRINT(("dgtl_thrmst_cfg_edge.instance_id = %d\n",dgtl_thrmst_cfg_edge.instance_id));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_edge.polling_tmr_prdcty = %d\n",dgtl_thrmst_cfg_edge.polling_tmr_prdcty));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_edge.high_temp_thrsld = %f\n",dgtl_thrmst_cfg_edge.high_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_edge.low_temp_thrsld = %f\n",dgtl_thrmst_cfg_edge.low_temp_thrsld));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_edge.conversion_type = %d\n",dgtl_thrmst_cfg_edge.conversion_type));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_edge.thrmst_pin_polarity = %d\n",dgtl_thrmst_cfg_edge.thrmst_pin_polarity));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_edge.thrmst_enable = %d\n",dgtl_thrmst_cfg_edge.thrmst_enable));
    DEBUG_CPRINT(("dgtl_thrmst_cfg_edge.adc_resolution = %d\n",dgtl_thrmst_cfg_edge.adc_resolution));

    DEBUG_CPRINT(("htswp_cntlr_cfg_ps_1.instance_id = %d\n",htswp_cntlr_cfg_ps_1.instance_id));
    DEBUG_CPRINT(("htswp_cntlr_cfg_ps_1.polling_tmr_prdcty = %d\n",htswp_cntlr_cfg_ps_1.polling_tmr_prdcty));
    DEBUG_CPRINT(("htswp_cntlr_cfg_ps_1.hotswap_sts = %d\n",htswp_cntlr_cfg_ps_1.hotswap_sts));
    DEBUG_CPRINT(("htswp_cntlr_cfg_ps_1.voltage_thrsld = %f\n",htswp_cntlr_cfg_ps_1.voltage_thrsld));
    DEBUG_CPRINT(("htswp_cntlr_cfg_ps_1.current_thrsld = %f\n",htswp_cntlr_cfg_ps_1.current_thrsld));
    DEBUG_CPRINT(("htswp_cntlr_cfg_ps_1.intr_msk = %d\n",htswp_cntlr_cfg_ps_1.intr_msk));

    DEBUG_CPRINT(("htswp_cntlr_cfg_ps_2.instance_id = %d\n",htswp_cntlr_cfg_ps_2.instance_id));
    DEBUG_CPRINT(("htswp_cntlr_cfg_ps_2.polling_tmr_prdcty = %d\n",htswp_cntlr_cfg_ps_2.polling_tmr_prdcty));
    DEBUG_CPRINT(("htswp_cntlr_cfg_ps_2.hotswap_sts = %d\n",htswp_cntlr_cfg_ps_2.hotswap_sts));
    DEBUG_CPRINT(("htswp_cntlr_cfg_ps_2.voltage_thrsld = %f\n",htswp_cntlr_cfg_ps_2.voltage_thrsld));
    DEBUG_CPRINT(("htswp_cntlr_cfg_ps_2.current_thrsld = %f\n",htswp_cntlr_cfg_ps_2.current_thrsld));
    DEBUG_CPRINT(("htswp_cntlr_cfg_ps_2.intr_msk = %d\n",htswp_cntlr_cfg_ps_2.intr_msk));

    DEBUG_CPRINT(("htswp_cntlr_cfg_edge.instance_id = %d\n",htswp_cntlr_cfg_edge.instance_id));
    DEBUG_CPRINT(("htswp_cntlr_cfg_edge.polling_tmr_prdcty = %d\n",htswp_cntlr_cfg_edge.polling_tmr_prdcty));
    DEBUG_CPRINT(("htswp_cntlr_cfg_edge.hotswap_sts = %d\n",htswp_cntlr_cfg_edge.hotswap_sts));
    DEBUG_CPRINT(("htswp_cntlr_cfg_edge.voltage_thrsld = %f\n",htswp_cntlr_cfg_edge.voltage_thrsld));
    DEBUG_CPRINT(("htswp_cntlr_cfg_edge.current_thrsld = %f\n",htswp_cntlr_cfg_edge.current_thrsld));
    DEBUG_CPRINT(("htswp_cntlr_cfg_edge.intr_msk = %d\n",htswp_cntlr_cfg_edge.intr_msk));

    DEBUG_CPRINT(("pwr_sns_mtr_cfg_ps.instance_id = %d\n",pwr_sns_mtr_cfg_ps.instance_id));
    DEBUG_CPRINT(("pwr_sns_mtr_cfg_ps.polling_tmr_prdcty = %d\n",pwr_sns_mtr_cfg_ps.polling_tmr_prdcty));
    DEBUG_CPRINT(("pwr_sns_mtr_cfg_ps.current_thrsld = %f\n",pwr_sns_mtr_cfg_ps.current_thrsld));
    DEBUG_CPRINT(("pwr_sns_mtr_cfg_ps.vbus_thrsld = %f\n",pwr_sns_mtr_cfg_ps.vbus_thrsld));
    DEBUG_CPRINT(("pwr_sns_mtr_cfg_ps.power_thrsld = %d\n",pwr_sns_mtr_cfg_ps.power_thrsld));
    DEBUG_CPRINT(("pwr_sns_mtr_cfg_ps.intr_type = %d\n",pwr_sns_mtr_cfg_ps.intr_type));

    DEBUG_CPRINT(("pwr_sns_mtr_cfg_obc.instance_id = %d\n",pwr_sns_mtr_cfg_obc.instance_id));
    DEBUG_CPRINT(("pwr_sns_mtr_cfg_obc.polling_tmr_prdcty = %d\n",pwr_sns_mtr_cfg_obc.polling_tmr_prdcty));
    DEBUG_CPRINT(("pwr_sns_mtr_cfg_obc.current_thrsld = %f\n",pwr_sns_mtr_cfg_obc.current_thrsld));
    DEBUG_CPRINT(("pwr_sns_mtr_cfg_obc.vbus_thrsld = %f\n",pwr_sns_mtr_cfg_obc.vbus_thrsld));
    DEBUG_CPRINT(("pwr_sns_mtr_cfg_obc.power_thrsld = %d\n",pwr_sns_mtr_cfg_obc.power_thrsld));
    DEBUG_CPRINT(("pwr_sns_mtr_cfg_obc.intr_type = %d\n",pwr_sns_mtr_cfg_obc.intr_type));

#endif

    return nvm_sts;
}

/**
 * @brief API to write the sensor default values in NVM
 */
uint8_t sns_nvm_write_dft()
{
    int8_t nvm_sts=NVM_UNKNOWN_ERROR;
    temp_sns_cfg_edge.instance_id =TEMP_SENSOR_MCP9843_EDGE;
    temp_sns_cfg_edge.polling_tmr_prdcty=SENSOR_POLLING_TM;
    temp_sns_cfg_edge.high_temp_thrsld = 70;
    temp_sns_cfg_edge.low_temp_thrsld = 0;
    temp_sns_cfg_edge.adc_resolution = RES_0_25;
    temp_sns_cfg_edge.intr_mask=TEMP_SENSE_EVENT_MODE_ENABLE;
    temp_sns_cfg_edge.conversion_type =TEMP_SENSE_CONTINUOUS_CONVERSTION;
    temp_sns_cfg_edge.intr_pin_polarity =TEMP_SENSE_ACTIVE_LOW;

    temp_sns_cfg_obc.instance_id =TEMP_SENSOR_MCP9843_OBC;
    temp_sns_cfg_obc.polling_tmr_prdcty=SENSOR_POLLING_TM;
    temp_sns_cfg_obc.high_temp_thrsld = 70;
    temp_sns_cfg_obc.low_temp_thrsld = 0;
    temp_sns_cfg_obc.adc_resolution = RES_0_25;
    temp_sns_cfg_obc.intr_mask=TEMP_SENSE_EVENT_MODE_ENABLE;
    temp_sns_cfg_obc.conversion_type =TEMP_SENSE_CONTINUOUS_CONVERSTION;
    temp_sns_cfg_obc.intr_pin_polarity =TEMP_SENSE_ACTIVE_LOW;

    temp_sns_cfg_gps.instance_id =TEMP_SENSOR_MCP9843_GPS;
    temp_sns_cfg_gps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    temp_sns_cfg_gps.high_temp_thrsld = 70;
    temp_sns_cfg_gps.low_temp_thrsld = 0;
    temp_sns_cfg_gps.adc_resolution = RES_0_25;
    temp_sns_cfg_gps.intr_mask=TEMP_SENSE_EVENT_MODE_ENABLE;
    temp_sns_cfg_gps.conversion_type =TEMP_SENSE_CONTINUOUS_CONVERSTION;
    temp_sns_cfg_gps.intr_pin_polarity =TEMP_SENSE_ACTIVE_LOW;

    temp_sns_cfg_ps.instance_id =TEMP_SENSOR_MCP9843_PS;
    temp_sns_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    temp_sns_cfg_ps.high_temp_thrsld = 70;
    temp_sns_cfg_ps.low_temp_thrsld = 0;
    temp_sns_cfg_ps.adc_resolution = RES_0_25;
    temp_sns_cfg_ps.intr_mask=TEMP_SENSE_EVENT_MODE_ENABLE;
    temp_sns_cfg_ps.conversion_type =TEMP_SENSE_CONTINUOUS_CONVERSTION;
    temp_sns_cfg_ps.intr_pin_polarity =TEMP_SENSE_ACTIVE_LOW;

    /***************  GEN2  **************/
    temp_sns_cfg_ps.instance_id =TEMP_SENSOR_MCP9843_EDGE_1;
    temp_sns_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    temp_sns_cfg_ps.high_temp_thrsld = 70;
    temp_sns_cfg_ps.low_temp_thrsld = 0;
    temp_sns_cfg_ps.adc_resolution = RES_0_25;
    temp_sns_cfg_ps.intr_mask=TEMP_SENSE_EVENT_MODE_ENABLE;
    temp_sns_cfg_ps.conversion_type =TEMP_SENSE_CONTINUOUS_CONVERSTION;
    temp_sns_cfg_ps.intr_pin_polarity =TEMP_SENSE_ACTIVE_LOW;

    temp_sns_cfg_ps.instance_id =TEMP_SENSOR_MCP9843_EDGE_2;
    temp_sns_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    temp_sns_cfg_ps.high_temp_thrsld = 70;
    temp_sns_cfg_ps.low_temp_thrsld = 0;
    temp_sns_cfg_ps.adc_resolution = RES_0_25;
    temp_sns_cfg_ps.intr_mask=TEMP_SENSE_EVENT_MODE_ENABLE;
    temp_sns_cfg_ps.conversion_type =TEMP_SENSE_CONTINUOUS_CONVERSTION;
    temp_sns_cfg_ps.intr_pin_polarity =TEMP_SENSE_ACTIVE_LOW;

    temp_sns_cfg_ps.instance_id =TEMP_SENSOR_MCP9843_PS_GEN_2;
    temp_sns_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    temp_sns_cfg_ps.high_temp_thrsld = 70;
    temp_sns_cfg_ps.low_temp_thrsld = 0;
    temp_sns_cfg_ps.adc_resolution = RES_0_25;
    temp_sns_cfg_ps.intr_mask=TEMP_SENSE_EVENT_MODE_ENABLE;
    temp_sns_cfg_ps.conversion_type =TEMP_SENSE_CONTINUOUS_CONVERSTION;
    temp_sns_cfg_ps.intr_pin_polarity =TEMP_SENSE_ACTIVE_LOW;

    temp_sns_cfg_ps.instance_id =TEMP_SENSOR_MCP9843_NIC_1;
    temp_sns_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    temp_sns_cfg_ps.high_temp_thrsld = 70;
    temp_sns_cfg_ps.low_temp_thrsld = 0;
    temp_sns_cfg_ps.adc_resolution = RES_0_25;
    temp_sns_cfg_ps.intr_mask=TEMP_SENSE_EVENT_MODE_ENABLE;
    temp_sns_cfg_ps.conversion_type =TEMP_SENSE_CONTINUOUS_CONVERSTION;
    temp_sns_cfg_ps.intr_pin_polarity =TEMP_SENSE_ACTIVE_LOW;

    temp_sns_cfg_ps.instance_id =TEMP_SENSOR_MCP9843_SSD_1;
    temp_sns_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    temp_sns_cfg_ps.high_temp_thrsld = 70;
    temp_sns_cfg_ps.low_temp_thrsld = 0;
    temp_sns_cfg_ps.adc_resolution = RES_0_25;
    temp_sns_cfg_ps.intr_mask=TEMP_SENSE_EVENT_MODE_ENABLE;
    temp_sns_cfg_ps.conversion_type =TEMP_SENSE_CONTINUOUS_CONVERSTION;
    temp_sns_cfg_ps.intr_pin_polarity =TEMP_SENSE_ACTIVE_LOW;

    temp_sns_cfg_ps.instance_id =TEMP_SENSOR_MCP9843_SSD_2;
    temp_sns_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    temp_sns_cfg_ps.high_temp_thrsld = 70;
    temp_sns_cfg_ps.low_temp_thrsld = 0;
    temp_sns_cfg_ps.adc_resolution = RES_0_25;
    temp_sns_cfg_ps.intr_mask=TEMP_SENSE_EVENT_MODE_ENABLE;
    temp_sns_cfg_ps.conversion_type =TEMP_SENSE_CONTINUOUS_CONVERSTION;
    temp_sns_cfg_ps.intr_pin_polarity =TEMP_SENSE_ACTIVE_LOW;

    temp_sns_cfg_ps.instance_id =TEMP_SENSOR_MCP9843_SSD_3;
    temp_sns_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    temp_sns_cfg_ps.high_temp_thrsld = 70;
    temp_sns_cfg_ps.low_temp_thrsld = 0;
    temp_sns_cfg_ps.adc_resolution = RES_0_25;
    temp_sns_cfg_ps.intr_mask=TEMP_SENSE_EVENT_MODE_ENABLE;
    temp_sns_cfg_ps.conversion_type =TEMP_SENSE_CONTINUOUS_CONVERSTION;
    temp_sns_cfg_ps.intr_pin_polarity =TEMP_SENSE_ACTIVE_LOW;

    temp_sns_cfg_ps.instance_id =TEMP_SENSOR_MCP9843_SSD_4;
    temp_sns_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    temp_sns_cfg_ps.high_temp_thrsld = 70;
    temp_sns_cfg_ps.low_temp_thrsld = 0;
    temp_sns_cfg_ps.adc_resolution = RES_0_25;
    temp_sns_cfg_ps.intr_mask=TEMP_SENSE_EVENT_MODE_ENABLE;
    temp_sns_cfg_ps.conversion_type =TEMP_SENSE_CONTINUOUS_CONVERSTION;
    temp_sns_cfg_ps.intr_pin_polarity =TEMP_SENSE_ACTIVE_LOW;

    /************************/

    dgtl_thrmst_cfg_spe01.instance_id =DIGITAL_THERMOSTAT_DS620_SPE01;
    dgtl_thrmst_cfg_spe01.polling_tmr_prdcty=SENSOR_POLLING_TM;
    dgtl_thrmst_cfg_spe01.high_temp_thrsld = 70;
    dgtl_thrmst_cfg_spe01.low_temp_thrsld = 0;
    dgtl_thrmst_cfg_spe01.conversion_type =DT_CONTINOUS_CONV;
    dgtl_thrmst_cfg_spe01.thrmst_pin_polarity=DT_LOW;
    dgtl_thrmst_cfg_spe01.thrmst_enable=0;
    dgtl_thrmst_cfg_spe01.adc_resolution=DT_BIT_13;

	dgtl_thrmst_cfg_spe02.instance_id =DIGITAL_THERMOSTAT_DS620_SPE02;
    dgtl_thrmst_cfg_spe02.polling_tmr_prdcty=SENSOR_POLLING_TM;
    dgtl_thrmst_cfg_spe02.high_temp_thrsld = 70;
    dgtl_thrmst_cfg_spe02.low_temp_thrsld = 0;
    dgtl_thrmst_cfg_spe02.conversion_type =DT_CONTINOUS_CONV;
    dgtl_thrmst_cfg_spe02.thrmst_pin_polarity=DT_LOW;
    dgtl_thrmst_cfg_spe02.thrmst_enable=0;
    dgtl_thrmst_cfg_spe02.adc_resolution=DT_BIT_13;

	dgtl_thrmst_cfg_spb01.instance_id =DIGITAL_THERMOSTAT_DS620_SPB01;
    dgtl_thrmst_cfg_spb01.polling_tmr_prdcty=SENSOR_POLLING_TM;
    dgtl_thrmst_cfg_spb01.high_temp_thrsld = 70;
    dgtl_thrmst_cfg_spb01.low_temp_thrsld = 0;
    dgtl_thrmst_cfg_spb01.conversion_type =DT_CONTINOUS_CONV;
    dgtl_thrmst_cfg_spb01.thrmst_pin_polarity=DT_LOW;
	dgtl_thrmst_cfg_spb01.thrmst_enable=0;
	dgtl_thrmst_cfg_spb01.adc_resolution=DT_BIT_13;

	dgtl_thrmst_cfg_spw02.instance_id =DIGITAL_THERMOSTAT_DS620_SPW02;
    dgtl_thrmst_cfg_spw02.polling_tmr_prdcty=SENSOR_POLLING_TM;
    dgtl_thrmst_cfg_spw02.high_temp_thrsld = 70;
    dgtl_thrmst_cfg_spw02.low_temp_thrsld = 0;
    dgtl_thrmst_cfg_spw02.conversion_type =DT_CONTINOUS_CONV;
    dgtl_thrmst_cfg_spw02.thrmst_pin_polarity=DT_LOW;
	dgtl_thrmst_cfg_spw02.thrmst_enable=0;
	dgtl_thrmst_cfg_spw02.adc_resolution=DT_BIT_13;

	dgtl_thrmst_cfg_spw01.instance_id =DIGITAL_THERMOSTAT_DS620_SPW01;
    dgtl_thrmst_cfg_spw01.polling_tmr_prdcty=SENSOR_POLLING_TM;
    dgtl_thrmst_cfg_spw01.high_temp_thrsld = 70;
    dgtl_thrmst_cfg_spw01.low_temp_thrsld = 0;
    dgtl_thrmst_cfg_spw01.conversion_type =DT_CONTINOUS_CONV;
    dgtl_thrmst_cfg_spw01.thrmst_pin_polarity=DT_LOW;
    dgtl_thrmst_cfg_spw01.thrmst_enable=0;
    dgtl_thrmst_cfg_spw01.adc_resolution=DT_BIT_13;

    dgtl_thrmst_cfg_ps.instance_id = DIGITAL_THERMOSTAT_DS620_PS;
    dgtl_thrmst_cfg_ps.polling_tmr_prdcty   = SENSOR_POLLING_TM;
    dgtl_thrmst_cfg_ps.high_temp_thrsld =20;
    dgtl_thrmst_cfg_ps.low_temp_thrsld =0;
    dgtl_thrmst_cfg_ps.conversion_type =DT_CONTINOUS_CONV;
    dgtl_thrmst_cfg_ps.thrmst_pin_polarity=DT_LOW;
    dgtl_thrmst_cfg_ps.thrmst_enable=0;
    dgtl_thrmst_cfg_ps.adc_resolution=DT_BIT_13;

    dgtl_thrmst_cfg_edge.instance_id =DIGITAL_THERMOSTAT_DS620_EDGE;
    dgtl_thrmst_cfg_edge.polling_tmr_prdcty=SENSOR_POLLING_TM;
    dgtl_thrmst_cfg_edge.high_temp_thrsld =20;
    dgtl_thrmst_cfg_edge.low_temp_thrsld =0;
    dgtl_thrmst_cfg_edge.conversion_type =DT_CONTINOUS_CONV;
    dgtl_thrmst_cfg_edge.thrmst_pin_polarity=DT_LOW;
    dgtl_thrmst_cfg_edge.thrmst_enable=0;
    dgtl_thrmst_cfg_edge.adc_resolution=DT_BIT_13;

    htswp_cntlr_cfg_edge.instance_id =HSC_ADM1176_EDGE;
    htswp_cntlr_cfg_edge.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_cfg_edge.hotswap_sts =0;
    htswp_cntlr_cfg_edge.voltage_thrsld =13;
    htswp_cntlr_cfg_edge.current_thrsld = 4;
    htswp_cntlr_cfg_edge.intr_msk =0;

    htswp_cntlr_cfg_ps_1.instance_id =HSC_ADM1176_PS_1;
    htswp_cntlr_cfg_ps_1.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_cfg_ps_1.hotswap_sts =0;
    htswp_cntlr_cfg_ps_1.voltage_thrsld =13;
    htswp_cntlr_cfg_ps_1.current_thrsld = 4;
    htswp_cntlr_cfg_ps_1.intr_msk =0;

    htswp_cntlr_cfg_ps_2.instance_id =HSC_ADM1176_PS_2;
    htswp_cntlr_cfg_ps_2.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_cfg_ps_2.hotswap_sts =0;
    htswp_cntlr_cfg_ps_2.voltage_thrsld =13;
    htswp_cntlr_cfg_ps_2.current_thrsld = 4;
    htswp_cntlr_cfg_ps_2.intr_msk =0;

    /*** GEN2 HSC ***/
    htswp_cntlr_ps_brd_supply.instance_id =HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY;
    htswp_cntlr_ps_brd_supply.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_ps_brd_supply.hotswap_sts =0;
    htswp_cntlr_ps_brd_supply.voltage_thrsld =13;
    htswp_cntlr_ps_brd_supply.current_thrsld = 4;
    htswp_cntlr_ps_brd_supply.intr_msk =0;

    htswp_cntlr_ps1_supply.instance_id =HSC_ADM1176_PS_1_IN_SUPPLY;
    htswp_cntlr_ps1_supply.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_ps1_supply.hotswap_sts =0;
    htswp_cntlr_ps1_supply.voltage_thrsld =13;
    htswp_cntlr_ps1_supply.current_thrsld = 4;
    htswp_cntlr_ps1_supply.intr_msk =0;

    htswp_cntlr_ps2_supply.instance_id =HSC_ADM1176_PS_2_IN_SUPPLY;
    htswp_cntlr_ps2_supply.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_ps2_supply.hotswap_sts =0;
    htswp_cntlr_ps2_supply.voltage_thrsld =13;
    htswp_cntlr_ps2_supply.current_thrsld = 4;
    htswp_cntlr_ps2_supply.intr_msk =0;

    htswp_cntlr_edge1_supply.instance_id =HSC_ADM1176_EDGE_1_IN_SUPPLY;
    htswp_cntlr_edge1_supply.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_edge1_supply.hotswap_sts =0;
    htswp_cntlr_edge1_supply.voltage_thrsld =13;
    htswp_cntlr_edge1_supply.current_thrsld = 4;
    htswp_cntlr_edge1_supply.intr_msk =0;

    htswp_cntlr_edge2_supply.instance_id =HSC_ADM1176_EDGE_2_IN_SUPPLY;
    htswp_cntlr_edge2_supply.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_edge2_supply.hotswap_sts =0;
    htswp_cntlr_edge2_supply.voltage_thrsld =13;
    htswp_cntlr_edge2_supply.current_thrsld = 4;
    htswp_cntlr_edge2_supply.intr_msk =0;

    htswp_cntlr_edge1_heat_coil.instance_id =HSC_ADM1176_EDGE_1_HEAT_COIL;
    htswp_cntlr_edge1_heat_coil.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_edge1_heat_coil.hotswap_sts =0;
    htswp_cntlr_edge1_heat_coil.voltage_thrsld =13;
    htswp_cntlr_edge1_heat_coil.current_thrsld = 4;
    htswp_cntlr_edge1_heat_coil.intr_msk =0;

    htswp_cntlr_edge2_heat_coil.instance_id =HSC_ADM1176_EDGE_2_HEAT_COIL;
    htswp_cntlr_edge2_heat_coil.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_edge2_heat_coil.hotswap_sts =0;
    htswp_cntlr_edge2_heat_coil.voltage_thrsld =13;
    htswp_cntlr_edge2_heat_coil.current_thrsld = 4;
    htswp_cntlr_edge2_heat_coil.intr_msk =0;

    htswp_cntlr_io_brd_supply.instance_id =HSC_ADM1176_IO_BRD_IN_SUPPLY;
    htswp_cntlr_io_brd_supply.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_io_brd_supply.hotswap_sts =0;
    htswp_cntlr_io_brd_supply.voltage_thrsld =13;
    htswp_cntlr_io_brd_supply.current_thrsld = 4;
    htswp_cntlr_io_brd_supply.intr_msk =0;

    htswp_cntlr_io_brd_top1.instance_id =HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1;
    htswp_cntlr_io_brd_top1.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_io_brd_top1.hotswap_sts =0;
    htswp_cntlr_io_brd_top1.voltage_thrsld =13;
    htswp_cntlr_io_brd_top1.current_thrsld = 4;
    htswp_cntlr_io_brd_top1.intr_msk =0;

    htswp_cntlr_io_brd_top2.instance_id =HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2;
    htswp_cntlr_io_brd_top2.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_io_brd_top2.hotswap_sts =0;
    htswp_cntlr_io_brd_top2.voltage_thrsld =13;
    htswp_cntlr_io_brd_top2.current_thrsld = 4;
    htswp_cntlr_io_brd_top2.intr_msk =0;

    htswp_cntlr_io_brd_bot1.instance_id =HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1;
    htswp_cntlr_io_brd_bot1.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_io_brd_bot1.hotswap_sts =0;
    htswp_cntlr_io_brd_bot1.voltage_thrsld =13;
    htswp_cntlr_io_brd_bot1.current_thrsld = 4;
    htswp_cntlr_io_brd_bot1.intr_msk =0;

    htswp_cntlr_io_brd_bot2.instance_id =HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2;
    htswp_cntlr_io_brd_bot2.polling_tmr_prdcty=SENSOR_POLLING_TM;
    htswp_cntlr_io_brd_bot2.hotswap_sts =0;
    htswp_cntlr_io_brd_bot2.voltage_thrsld =13;
    htswp_cntlr_io_brd_bot2.current_thrsld = 4;
    htswp_cntlr_io_brd_bot2.intr_msk =0;

	/***/

    pwr_sns_mtr_cfg_obc.instance_id = PSM_INA230_OBC;
    pwr_sns_mtr_cfg_obc.polling_tmr_prdcty=SENSOR_POLLING_TM;
    pwr_sns_mtr_cfg_obc.current_thrsld=4;
    pwr_sns_mtr_cfg_obc.vbus_thrsld=13;
    pwr_sns_mtr_cfg_obc.power_thrsld=2600;
    pwr_sns_mtr_cfg_obc.intr_type=PSM_ALERT_FUNCTION_SOL;

    pwr_sns_mtr_cfg_ps.instance_id = PSM_INA230_PS;
    pwr_sns_mtr_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    pwr_sns_mtr_cfg_ps.current_thrsld=4;
    pwr_sns_mtr_cfg_ps.vbus_thrsld=13;
    pwr_sns_mtr_cfg_ps.power_thrsld=2600;
    pwr_sns_mtr_cfg_ps.intr_type=PSM_ALERT_FUNCTION_SOL;

    /***** GEN2 PSM *****/
    pwr_sns_mtr_cfg_ps.instance_id = PSM_INA230_PS_GEN_2;
    pwr_sns_mtr_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    pwr_sns_mtr_cfg_ps.current_thrsld=4;
    pwr_sns_mtr_cfg_ps.vbus_thrsld=13;
    pwr_sns_mtr_cfg_ps.power_thrsld=2600;
    pwr_sns_mtr_cfg_ps.intr_type=PSM_ALERT_FUNCTION_SOL;

    pwr_sns_mtr_cfg_ps.instance_id = PSM_INA230_CORE_BRD_A;
    pwr_sns_mtr_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    pwr_sns_mtr_cfg_ps.current_thrsld=4;
    pwr_sns_mtr_cfg_ps.vbus_thrsld=13;
    pwr_sns_mtr_cfg_ps.power_thrsld=2600;
    pwr_sns_mtr_cfg_ps.intr_type=PSM_ALERT_FUNCTION_SOL;

    pwr_sns_mtr_cfg_ps.instance_id = PSM_INA230_CORE_BRD_B;
    pwr_sns_mtr_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    pwr_sns_mtr_cfg_ps.current_thrsld=4;
    pwr_sns_mtr_cfg_ps.vbus_thrsld=13;
    pwr_sns_mtr_cfg_ps.power_thrsld=2600;
    pwr_sns_mtr_cfg_ps.intr_type=PSM_ALERT_FUNCTION_SOL;

    pwr_sns_mtr_cfg_ps.instance_id = PSM_INA230_PS_1;
    pwr_sns_mtr_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    pwr_sns_mtr_cfg_ps.current_thrsld=4;
    pwr_sns_mtr_cfg_ps.vbus_thrsld=13;
    pwr_sns_mtr_cfg_ps.power_thrsld=2600;
    pwr_sns_mtr_cfg_ps.intr_type=PSM_ALERT_FUNCTION_SOL;

    pwr_sns_mtr_cfg_ps.instance_id = PSM_INA230_PS_2;
    pwr_sns_mtr_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    pwr_sns_mtr_cfg_ps.current_thrsld=4;
    pwr_sns_mtr_cfg_ps.vbus_thrsld=13;
    pwr_sns_mtr_cfg_ps.power_thrsld=2600;
    pwr_sns_mtr_cfg_ps.intr_type=PSM_ALERT_FUNCTION_SOL;

    pwr_sns_mtr_cfg_ps.instance_id = PSM_INA230_EDGE_1;
    pwr_sns_mtr_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    pwr_sns_mtr_cfg_ps.current_thrsld=4;
    pwr_sns_mtr_cfg_ps.vbus_thrsld=13;
    pwr_sns_mtr_cfg_ps.power_thrsld=2600;
    pwr_sns_mtr_cfg_ps.intr_type=PSM_ALERT_FUNCTION_SOL;

    pwr_sns_mtr_cfg_ps.instance_id = PSM_INA230_EDGE_2_IN_SUPPLY;
    pwr_sns_mtr_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    pwr_sns_mtr_cfg_ps.current_thrsld=4;
    pwr_sns_mtr_cfg_ps.vbus_thrsld=13;
    pwr_sns_mtr_cfg_ps.power_thrsld=2600;
    pwr_sns_mtr_cfg_ps.intr_type=PSM_ALERT_FUNCTION_SOL;

    pwr_sns_mtr_cfg_ps.instance_id = PSM_INA230_IO_BRD_IN_SUPPLY;
    pwr_sns_mtr_cfg_ps.polling_tmr_prdcty=SENSOR_POLLING_TM;
    pwr_sns_mtr_cfg_ps.current_thrsld=4;
    pwr_sns_mtr_cfg_ps.vbus_thrsld=13;
    pwr_sns_mtr_cfg_ps.power_thrsld=2600;
    pwr_sns_mtr_cfg_ps.intr_type=PSM_ALERT_FUNCTION_SOL;


    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_GPS_CFG,(uint8_t*)&temp_sns_cfg_gps);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_PS_CFG,(uint8_t*)&temp_sns_cfg_ps);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_EDGE_CFG,(uint8_t*)&temp_sns_cfg_edge);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_OBC_CFG,(uint8_t*)&temp_sns_cfg_obc);

    /***** GEN2 *****/
   //    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_EDGE1_GEN2_CFG,(uint8_t*)&temp_sns_cfg_edge1_gen2);
   //    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_EDGE2_GEN2_CFG,(uint8_t*)&temp_sns_cfg_edge2_gen2);
   //    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_PS_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ps_gen2);
   //    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_NIC1_CFG,(uint8_t*)&temp_sns_cfg_nic1);
   //    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_SSD1_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ssd1);
   //    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_SSD2_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ssd2);
   //    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_SSD3_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ssd3);
   //    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_SSD4_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ssd4);

    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_DT_DS620_PS_CFG,(uint8_t*)&dgtl_thrmst_cfg_ps);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_DT_DS620_EDGE_CFG,(uint8_t*)&dgtl_thrmst_cfg_edge);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_DT_DS620_SPE01_CFG,(uint8_t*)&dgtl_thrmst_cfg_spe01);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_DT_DS620_SPE02_CFG,(uint8_t*)&dgtl_thrmst_cfg_spe02);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_DT_DS620_SPW01_CFG,(uint8_t*)&dgtl_thrmst_cfg_spw01);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_DT_DS620_SPW02_CFG,(uint8_t*)&dgtl_thrmst_cfg_spw02);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_DT_DS620_SPB01_CFG,(uint8_t*)&dgtl_thrmst_cfg_spb01);

    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_POWER_SENSE_MONITOR_OBC_CFG,(uint8_t*)&pwr_sns_mtr_cfg_obc);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_POWER_SENSE_MONITOR_PS_CFG,(uint8_t*)&pwr_sns_mtr_cfg_ps);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_EDGE_CFG,(uint8_t*)&htswp_cntlr_cfg_edge);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_PS_1_CFG,(uint8_t*)&htswp_cntlr_cfg_ps_1);
    nvm_sts = nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_PS_2_CFG,(uint8_t*)&htswp_cntlr_cfg_ps_2);
    return nvm_sts;
}
#if defined(COREBOARD) || defined(LINUX_TEMP_PORT)

/**
 * @brief API to handle the sensor interrupt
 */
static void sensor_interrupt_hdlr(uint32_t ahw_id)
{
#ifndef LINUX_TEMP_PORT                
    uint32_t thrsld_sts;
    switch(ahw_id)
    {
        case IMU_BMX160_OBC_1:
        case IMU_BMX160_OBC_2:
        case DIGITAL_THERMOSTAT_DS620_EDGE:
        case DIGITAL_THERMOSTAT_DS620_PS:
        case HSC_ADM1176_EDGE:
        case HSC_ADM1176_PS_1:
        case HSC_ADM1176_PS_2:
            break;
        case TEMP_SENSOR_MCP9843_OBC:
            thrsld_sts = check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_OBC);
            if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
            {
                obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
                eps_ctrl_en_chnl(HW_PL_SERVER,OFF);
                eps_ctrl_en_chnl(HW_EDGE_BRD,OFF);
                eps_ctrl_en_chnl(HW_GPS,OFF);

                eps_ctrl_en_chnl(HW_EDGE1,OFF);
                eps_ctrl_en_chnl(HW_EDGE2,OFF);
                eps_ctrl_en_chnl(HW_PS_GEN2,OFF);
                eps_ctrl_en_chnl(HW_NIC1,OFF);
                eps_ctrl_en_chnl(HW_SSD1,OFF);
                eps_ctrl_en_chnl(HW_SSD2,OFF);
                eps_ctrl_en_chnl(HW_SSD3,OFF);
                eps_ctrl_en_chnl(HW_SSD4,OFF);
                os_timer_start(brd_restart_tmr_obc,BRD_RESTART_TMR_MS);
            }
            break;

        case TEMP_SENSOR_MCP9843_PS:
            thrsld_sts = check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_PS);
            if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
            {
                obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
                eps_ctrl_en_chnl(HW_PL_SERVER,OFF);
                os_timer_start(brd_restart_tmr_ps,BRD_RESTART_TMR_MS);
            }
            break;

        case TEMP_SENSOR_MCP9843_EDGE:
            thrsld_sts = check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_EDGE);
            if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
            {
                obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
                eps_ctrl_en_chnl(HW_EDGE_BRD,OFF);
                os_timer_start(brd_restart_tmr_edge,BRD_RESTART_TMR_MS);
            }
            break;

        case TEMP_SENSOR_MCP9843_GPS:
            thrsld_sts = check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_GPS);
            if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
            {
                os_delay(1);
                obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
                eps_ctrl_en_chnl(HW_GPS,OFF);
                os_timer_start(brd_restart_tmr_gps,BRD_RESTART_TMR_MS);
            }
            break;

#if 0
        /***** GEN2 ****/
        case TEMP_SENSOR_MCP9843_EDGE_1:
        	thrsld_sts = check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_EDGE_1);
        	if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
        	{
        		os_delay(1);
        		obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
        		eps_ctrl_en_chnl(HW_EDGE1,OFF);
        		os_timer_start(brd_restart_tmr_edge1,BRD_RESTART_TMR_MS);
        	}
        	break;

        case TEMP_SENSOR_MCP9843_EDGE_2:
        	thrsld_sts = check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_EDGE_2);
        	if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
        	{
        		os_delay(1);
        		obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
        		eps_ctrl_en_chnl(HW_EDGE2,OFF);
        		os_timer_start(brd_restart_tmr_edge2,BRD_RESTART_TMR_MS);
        	}
        	break;

        case TEMP_SENSOR_MCP9843_PS_GEN_2:
        	thrsld_sts = check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_PS_GEN_2);
        	if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
        	{
        		os_delay(1);
        		obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
        		eps_ctrl_en_chnl(HW_PS_GEN2,OFF);
        		os_timer_start(brd_restart_tmr_ps_gen2,BRD_RESTART_TMR_MS);
        	}
        	break;

        case TEMP_SENSOR_MCP9843_NIC_1:
        	thrsld_sts = check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_NIC_1);
        	if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
        	{
        		os_delay(1);
        		obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
        		eps_ctrl_en_chnl(HW_NIC1,OFF);
        		os_timer_start(brd_restart_tmr_nic1,BRD_RESTART_TMR_MS);
        	}
        	break;

        case TEMP_SENSOR_MCP9843_SSD_1:
        	thrsld_sts = check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_SSD_1);
        	if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
        	{
        		os_delay(1);
        		obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
        		eps_ctrl_en_chnl(HW_SSD1,OFF);
        		os_timer_start(brd_restart_tmr_ssd1,BRD_RESTART_TMR_MS);
        	}
        	break;

        case TEMP_SENSOR_MCP9843_SSD_2:
        	thrsld_sts = check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_SSD_2);
        	if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
        	{
        		os_delay(1);
        		obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
        		eps_ctrl_en_chnl(HW_SSD2,OFF);
        		os_timer_start(brd_restart_tmr_ssd2,BRD_RESTART_TMR_MS);
        	}
        	break;

        case TEMP_SENSOR_MCP9843_SSD_3:
        	thrsld_sts = check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_SSD_3);
        	if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
        	{
        		os_delay(1);
        		obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
        		eps_ctrl_en_chnl(HW_SSD3,OFF);
        		os_timer_start(brd_restart_tmr_ssd3,BRD_RESTART_TMR_MS);
        	}
        	break;

        case TEMP_SENSOR_MCP9843_SSD_4:
        	thrsld_sts = check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_SSD_4);
        	if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
        	{
        		os_delay(1);
        		obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
        		eps_ctrl_en_chnl(HW_SSD4,OFF);
        		os_timer_start(brd_restart_tmr_ssd4,BRD_RESTART_TMR_MS);
        	}
        	break;
#endif

        case PSM_INA230_OBC:
            thrsld_sts = check_pwr_sns_thrsld(PSM_INA230_OBC);
            if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
            {
            	os_delay(1);
                obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
                eps_ctrl_en_chnl(HW_GPS,OFF);
                eps_ctrl_en_chnl(HW_PL_SERVER,OFF);
            }
            break;

        case PSM_INA230_PS:
            thrsld_sts = check_pwr_sns_thrsld(PSM_INA230_PS);
            if(thrsld_sts<SNS_THRSLD_TYPE_MAX)
            {
            	os_delay(1);
                obc_prepare_ipc_msg((uint8_t*)&thrsld_sts,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
                eps_ctrl_en_chnl(HW_GPS,OFF);
                eps_ctrl_en_chnl(HW_PL_SERVER,OFF);
            }
            break;
        default:
            break;
    }
#endif
}
#endif

/**
 * @brief API to handle the sensor configuration event
 */
#if defined(COREBOARD) || defined(LINUX_TEMP_PORT)
static void sensor_cfg_hdlr(uint32_t ahw_id)
{
    switch(ahw_id)
    {
        case IMU_BMX160_OBC_1:
        case IMU_BMX160_OBC_2:
            break;
        case DIGITAL_THERMOSTAT_DS620_EDGE:
            {
                os_memcpy(&dgtl_thrmst_cfg_edge,sns_hdlr_ipc.pld.pld_ptr,sizeof(digital_thermostat_cfg));
                nvm_parameter_write(NVM_DATA,NVM_DT_DS620_EDGE_CFG,(uint8_t*)&dgtl_thrmst_cfg_edge);
                if(brd_act_sts[HW_EDGE_BRD]==SW_ACTIVE)
                {
                    dt_sns_deinit(ahw_id);
                    dt_sns_init(&hdt_edge,&dgtl_thrmst_cfg_edge);
                }
            }
            break;

        case DIGITAL_THERMOSTAT_DS620_PS:
            {
                os_memcpy(&dgtl_thrmst_cfg_ps,sns_hdlr_ipc.pld.pld_ptr,sizeof(digital_thermostat_cfg));
                nvm_parameter_write(NVM_DATA,NVM_DT_DS620_PS_CFG,(uint8_t*)&dgtl_thrmst_cfg_ps);
                if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
                {
                    dt_sns_deinit(ahw_id);
                    dt_sns_init(&hdt_ps,&dgtl_thrmst_cfg_ps);
                }
            }
            break;

        case HSC_ADM1176_EDGE:
            {
                os_memcpy(&htswp_cntlr_cfg_edge,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
                nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_EDGE_CFG,(uint8_t*)&htswp_cntlr_cfg_edge);
                if(brd_act_sts[HW_EDGE_BRD]==SW_ACTIVE)
                {
                    hsc_sns_deinit(ahw_id);
                    hsc_sns_init(&hsc_edge,&htswp_cntlr_cfg_edge);
                }
            }
            break;

        case HSC_ADM1176_PS_1:
            {
                os_memcpy(&htswp_cntlr_cfg_ps_1,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
                nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_PS_1_CFG,(uint8_t*)&htswp_cntlr_cfg_ps_1);
                if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
                {
                    hsc_sns_deinit(ahw_id);
                    hsc_sns_init(&hsc_ps_1,&htswp_cntlr_cfg_ps_1);
                }
            }
            break;

        case HSC_ADM1176_PS_2:
            {
                os_memcpy(&htswp_cntlr_cfg_ps_2,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
                nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_PS_2_CFG,(uint8_t*)&htswp_cntlr_cfg_ps_2);
                if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
                {
                    hsc_sns_deinit(ahw_id);
                    hsc_sns_init(&hsc_ps_2,&htswp_cntlr_cfg_ps_2);
                }
            }
            break;
       /***** GEN2 *****/
        case HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY:
        {
            os_memcpy(&htswp_cntlr_ps_brd_supply,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
            nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_PS_BRD_SUP_CFG,(uint8_t*)&htswp_cntlr_ps_brd_supply);
            if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
            {
                hsc_sns_deinit(ahw_id);
                hsc_sns_init(&hsc_ps_brd_supply,&htswp_cntlr_ps_brd_supply);
            }
        }
        break;

        case HSC_ADM1176_PS_1_IN_SUPPLY:
        {
            os_memcpy(&htswp_cntlr_ps1_supply,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
            nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_PS1_SUP_CFG,(uint8_t*)&htswp_cntlr_ps1_supply);
            if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
            {
                hsc_sns_deinit(ahw_id);
                hsc_sns_init(&hsc_ps1_supply,&htswp_cntlr_ps1_supply);
            }
        }
        break;

        case HSC_ADM1176_PS_2_IN_SUPPLY:
        {
            os_memcpy(&htswp_cntlr_ps2_supply,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
            nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_PS2_SUP_CFG,(uint8_t*)&htswp_cntlr_ps2_supply);
            if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
            {
                hsc_sns_deinit(ahw_id);
                hsc_sns_init(&hsc_ps2_supply,&htswp_cntlr_ps2_supply);
            }
        }
        break;

        case HSC_ADM1176_EDGE_1_IN_SUPPLY:
        {
            os_memcpy(&htswp_cntlr_edge1_supply,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
            nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_EDGE1_SUP_CFG,(uint8_t*)&htswp_cntlr_edge1_supply);
            if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
            {
                hsc_sns_deinit(ahw_id);
                hsc_sns_init(&hsc_edge1_supply,&htswp_cntlr_edge1_supply);
            }
        }
        break;

        case HSC_ADM1176_EDGE_1_HEAT_COIL:
        {
            os_memcpy(&htswp_cntlr_edge1_heat_coil,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
            nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_EDGE1_HEAT_COIL_CFG,(uint8_t*)&htswp_cntlr_edge1_heat_coil);
            if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
            {
                hsc_sns_deinit(ahw_id);
                hsc_sns_init(&hsc_edge1_heat_coil,&htswp_cntlr_edge1_heat_coil);
            }
        }
        break;

        case HSC_ADM1176_EDGE_2_IN_SUPPLY:
        {
            os_memcpy(&htswp_cntlr_edge2_supply,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
            nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_EDGE2_SUP_CFG,(uint8_t*)&htswp_cntlr_edge2_supply);
            if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
            {
                hsc_sns_deinit(ahw_id);
                hsc_sns_init(&hsc_edge2_supply,&htswp_cntlr_edge2_supply);
            }
        }
        break;

        case HSC_ADM1176_EDGE_2_HEAT_COIL:
        {
            os_memcpy(&htswp_cntlr_edge2_heat_coil,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
            nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_EDGE2_HEAT_COIL_CFG,(uint8_t*)&htswp_cntlr_edge2_heat_coil);
            if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
            {
                hsc_sns_deinit(ahw_id);
                hsc_sns_init(&hsc_edge1_heat_coil,&htswp_cntlr_edge2_heat_coil);
            }
        }
        break;

        case HSC_ADM1176_IO_BRD_IN_SUPPLY:
        {
            os_memcpy(&htswp_cntlr_io_brd_supply,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
            nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_IO_BRD_SUP_CFG,(uint8_t*)&htswp_cntlr_io_brd_supply);
            if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
            {
                hsc_sns_deinit(ahw_id);
                hsc_sns_init(&hsc_io_brd_supply,&htswp_cntlr_io_brd_supply);
            }
        }
        break;

        case HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1:
        {
            os_memcpy(&htswp_cntlr_io_brd_top1,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
            nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_IO_BRD_TOP1_CFG,(uint8_t*)&htswp_cntlr_io_brd_top1);
            if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
            {
                hsc_sns_deinit(ahw_id);
                hsc_sns_init(&hsc_io_brd_top1,&htswp_cntlr_io_brd_top1);
            }
        }
        break;

        case HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2:
        {
            os_memcpy(&htswp_cntlr_io_brd_top2,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
            nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_IO_BRD_TOP2_CFG,(uint8_t*)&htswp_cntlr_io_brd_top2);
            if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
            {
                hsc_sns_deinit(ahw_id);
                hsc_sns_init(&hsc_io_brd_top2,&htswp_cntlr_io_brd_top2);
            }
        }
        break;

        case HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1:
        {
            os_memcpy(&htswp_cntlr_io_brd_bot1,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
            nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_IO_BRD_BOT1_CFG,(uint8_t*)&htswp_cntlr_io_brd_bot1);
            if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
            {
                hsc_sns_deinit(ahw_id);
                hsc_sns_init(&hsc_io_brd_bot1,&htswp_cntlr_io_brd_bot1);
            }
        }
        break;

        case HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2:
        {
            os_memcpy(&htswp_cntlr_io_brd_bot2,sns_hdlr_ipc.pld.pld_ptr,sizeof(hotswap_cntlr_cfg));
            nvm_parameter_write(NVM_DATA,NVM_HSC_ADM1176_IO_BRD_BOT2_CFG,(uint8_t*)&htswp_cntlr_io_brd_bot2);
            if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
            {
                hsc_sns_deinit(ahw_id);
                hsc_sns_init(&hsc_io_brd_bot2,&htswp_cntlr_io_brd_bot2);
            }
        }
        break;

            case DIGITAL_THERMOSTAT_DS620_SPE02:
            {
                os_memcpy(&dgtl_thrmst_cfg_spe02,sns_hdlr_ipc.pld.pld_ptr,sizeof(digital_thermostat_cfg));
                nvm_parameter_write(NVM_DATA,NVM_DT_DS620_SPE02_CFG,(uint8_t*)&dgtl_thrmst_cfg_spe02);
                dt_sns_deinit(ahw_id);
                dt_sns_init(&ahw_ts_spe02,&dgtl_thrmst_cfg_spe02);
            }
            break;
        	case DIGITAL_THERMOSTAT_DS620_SPW01:
            {
                os_memcpy(&dgtl_thrmst_cfg_spw01,sns_hdlr_ipc.pld.pld_ptr,sizeof(digital_thermostat_cfg));
                nvm_parameter_write(NVM_DATA,NVM_DT_DS620_SPW01_CFG,(uint8_t*)&dgtl_thrmst_cfg_spw01);
                dt_sns_deinit(ahw_id);
                dt_sns_init(&ahw_ts_spw01,&dgtl_thrmst_cfg_spw01);
            }
            break;
        	case DIGITAL_THERMOSTAT_DS620_SPE01:
            {
                os_memcpy(&dgtl_thrmst_cfg_spe01,sns_hdlr_ipc.pld.pld_ptr,sizeof(digital_thermostat_cfg));
                nvm_parameter_write(NVM_DATA,NVM_DT_DS620_SPE01_CFG,(uint8_t*)&dgtl_thrmst_cfg_spe01);
                dt_sns_deinit(ahw_id);
                dt_sns_init(&ahw_ts_spe01,&dgtl_thrmst_cfg_spe01);
            }
            break;
        	case DIGITAL_THERMOSTAT_DS620_SPW02:
            {
                os_memcpy(&dgtl_thrmst_cfg_spw02,sns_hdlr_ipc.pld.pld_ptr,sizeof(digital_thermostat_cfg));
                nvm_parameter_write(NVM_DATA,NVM_DT_DS620_SPW02_CFG,(uint8_t*)&dgtl_thrmst_cfg_spw02);
                dt_sns_deinit(ahw_id);
                dt_sns_init(&ahw_ts_spw02,&dgtl_thrmst_cfg_spw02);
            }
            break;
        	case DIGITAL_THERMOSTAT_DS620_SPB01:
            {
                os_memcpy(&dgtl_thrmst_cfg_spb01,sns_hdlr_ipc.pld.pld_ptr,sizeof(digital_thermostat_cfg));
                nvm_parameter_write(NVM_DATA,NVM_DT_DS620_SPB01_CFG,(uint8_t*)&dgtl_thrmst_cfg_spb01);
                dt_sns_deinit(ahw_id);
                dt_sns_init(&ahw_ts_spb01,&dgtl_thrmst_cfg_spb01);
            }
            break;
        case TEMP_SENSOR_MCP9843_OBC:
            {
                os_memcpy(&temp_sns_cfg_obc,sns_hdlr_ipc.pld.pld_ptr,sizeof(temp_sens_cfg));
                nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_OBC_CFG,(uint8_t*)&temp_sns_cfg_obc);
                temp_sns_deinit(ahw_id);
                temp_sns_init(&ahw_ts_obc,&temp_sns_cfg_obc);
            }
            break;

        case TEMP_SENSOR_MCP9843_PS:
            {
                os_memcpy(&temp_sns_cfg_ps,sns_hdlr_ipc.pld.pld_ptr,sizeof(temp_sens_cfg));
                nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_PS_CFG,(uint8_t*)&temp_sns_cfg_ps);
                if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
                {
                    temp_sns_deinit(ahw_id);
                    temp_sns_init(&ahw_ts_ps,&temp_sns_cfg_ps);
                }
            }
            break;

        case TEMP_SENSOR_MCP9843_EDGE:
            {
                os_memcpy(&temp_sns_cfg_edge,sns_hdlr_ipc.pld.pld_ptr,sizeof(temp_sens_cfg));
                nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_EDGE_CFG,(uint8_t*)&temp_sns_cfg_edge);
                if(brd_act_sts[HW_EDGE_BRD]==SW_ACTIVE)
                {
                    temp_sns_deinit(ahw_id);
                    temp_sns_init(&ahw_ts_edge,&temp_sns_cfg_edge);
                }
            }
            break;

        case TEMP_SENSOR_MCP9843_GPS:
            {
                os_memcpy(&temp_sns_cfg_gps,sns_hdlr_ipc.pld.pld_ptr,sizeof(temp_sens_cfg));
                nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_GPS_CFG,(uint8_t*)&temp_sns_cfg_gps);
                if(brd_act_sts[HW_GPS]==SW_ACTIVE)
                {
                    temp_sns_deinit(ahw_id);
                    temp_sns_init(&ahw_ts_gps,&temp_sns_cfg_gps);
                }
            }
            break;

            /*****  GEN 2  *****/
        case TEMP_SENSOR_MCP9843_EDGE_1:
        {
        	os_memcpy(&temp_sns_cfg_edge1_gen2,sns_hdlr_ipc.pld.pld_ptr,sizeof(temp_sens_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_EDGE1_GEN2_CFG,(uint8_t*)&temp_sns_cfg_edge1_gen2);
        	if(brd_act_sts[HW_GPS]==SW_ACTIVE)
        	{
        		temp_sns_deinit(ahw_id);
        		temp_sns_init(&ahw_ts_edge1_gen2,&temp_sns_cfg_edge1_gen2);
        	}
        }
        break;
        case TEMP_SENSOR_MCP9843_EDGE_2:
        {
        	os_memcpy(&temp_sns_cfg_edge2_gen2,sns_hdlr_ipc.pld.pld_ptr,sizeof(temp_sens_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_EDGE2_GEN2_CFG,(uint8_t*)&temp_sns_cfg_edge2_gen2);
        	if(brd_act_sts[HW_GPS]==SW_ACTIVE)
        	{
        		temp_sns_deinit(ahw_id);
        		temp_sns_init(&ahw_ts_edge2_gen2,&temp_sns_cfg_edge2_gen2);
        	}
        }
        break;
        case TEMP_SENSOR_MCP9843_PS_GEN_2:
        {
        	os_memcpy(&temp_sns_cfg_ps_gen2,sns_hdlr_ipc.pld.pld_ptr,sizeof(temp_sens_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_PS_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ps_gen2);
        	if(brd_act_sts[HW_GPS]==SW_ACTIVE)
        	{
        		temp_sns_deinit(ahw_id);
        		temp_sns_init(&ahw_ts_ps_gen2,&temp_sns_cfg_ps_gen2);
        	}
        }
        break;
        case TEMP_SENSOR_MCP9843_NIC_1:
        {
        	os_memcpy(&temp_sns_cfg_nic1,sns_hdlr_ipc.pld.pld_ptr,sizeof(temp_sens_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_NIC1_CFG,(uint8_t*)&temp_sns_cfg_nic1);
        	if(brd_act_sts[HW_GPS]==SW_ACTIVE)
        	{
        		temp_sns_deinit(ahw_id);
        		temp_sns_init(&ahw_ts_nic1,&temp_sns_cfg_nic1);
        	}
        }
        break;
        case TEMP_SENSOR_MCP9843_SSD_1:
        {
        	os_memcpy(&temp_sns_cfg_ssd1,sns_hdlr_ipc.pld.pld_ptr,sizeof(temp_sens_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_SSD1_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ssd1);
        	if(brd_act_sts[HW_GPS]==SW_ACTIVE)
        	{
        		temp_sns_deinit(ahw_id);
        		temp_sns_init(&ahw_ts_ssd1,&temp_sns_cfg_ssd1);
        	}
        }
        break;
        case TEMP_SENSOR_MCP9843_SSD_2:
        {
        	os_memcpy(&temp_sns_cfg_ssd2,sns_hdlr_ipc.pld.pld_ptr,sizeof(temp_sens_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_SSD2_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ssd2);
        	if(brd_act_sts[HW_GPS]==SW_ACTIVE)
        	{
        		temp_sns_deinit(ahw_id);
        		temp_sns_init(&ahw_ts_ssd2,&temp_sns_cfg_ssd2);
        	}
        }
        break;
        case TEMP_SENSOR_MCP9843_SSD_3:
        {
        	os_memcpy(&temp_sns_cfg_ssd3,sns_hdlr_ipc.pld.pld_ptr,sizeof(temp_sens_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_SSD3_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ssd3);
        	if(brd_act_sts[HW_GPS]==SW_ACTIVE)
        	{
        		temp_sns_deinit(ahw_id);
        		temp_sns_init(&ahw_ts_ssd3,&temp_sns_cfg_ssd3);
        	}
        }
        break;
        case TEMP_SENSOR_MCP9843_SSD_4:
        {
        	os_memcpy(&temp_sns_cfg_ssd4,sns_hdlr_ipc.pld.pld_ptr,sizeof(temp_sens_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_TEMP_SENSOR_MCP9843_SSD4_GEN2_CFG,(uint8_t*)&temp_sns_cfg_ssd4);
        	if(brd_act_sts[HW_GPS]==SW_ACTIVE)
        	{
        		temp_sns_deinit(ahw_id);
        		temp_sns_init(&ahw_ts_ssd4,&temp_sns_cfg_ssd4);
        	}
        }
        break;

        case PSM_INA230_OBC:
            {
                os_memcpy(&pwr_sns_mtr_cfg_obc,sns_hdlr_ipc.pld.pld_ptr,sizeof(power_sense_mntr_cfg));
                nvm_parameter_write(NVM_DATA,NVM_POWER_SENSE_MONITOR_OBC_CFG,(uint8_t*)&pwr_sns_mtr_cfg_obc);
                psm_sns_deinit(ahw_id);
                psm_sns_init(&ahw_hpsm_obc,&pwr_sns_mtr_cfg_obc);
            }
            break;

        case PSM_INA230_PS:
            {
                os_memcpy(&pwr_sns_mtr_cfg_ps,sns_hdlr_ipc.pld.pld_ptr,sizeof(power_sense_mntr_cfg));
                nvm_parameter_write(NVM_DATA,NVM_POWER_SENSE_MONITOR_PS_CFG,(uint8_t*)&pwr_sns_mtr_cfg_ps);
                if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
                {
                    psm_sns_deinit(ahw_id);
                    psm_sns_init(&ahw_hpsm_ps,&pwr_sns_mtr_cfg_ps);
                }
            }

            /***** GEN2 PSM *****/

        case PSM_INA230_PS_GEN_2:
        {
        	os_memcpy(&pwr_sns_mtr_cfg_ps_gen2,sns_hdlr_ipc.pld.pld_ptr,sizeof(power_sense_mntr_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_POWER_SENSE_MONITOR_PS_GEN2_CFG,(uint8_t*)&pwr_sns_mtr_cfg_ps_gen2);
        	if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
        	{
        		psm_sns_deinit(ahw_id);
        		psm_sns_init(&ahw_hpsm_ps_gen2,&pwr_sns_mtr_cfg_ps_gen2);
        	}
        }

        case PSM_INA230_CORE_BRD_A:
        {
        	os_memcpy(&pwr_sns_mtr_cfg_core_brd_a,sns_hdlr_ipc.pld.pld_ptr,sizeof(power_sense_mntr_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_POWER_SENSE_MONITOR_CORE_BRD_A_CFG,(uint8_t*)&pwr_sns_mtr_cfg_core_brd_a);
        	if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
        	{
        		psm_sns_deinit(ahw_id);
        		psm_sns_init(&ahw_hpsm_core_brd_a,&pwr_sns_mtr_cfg_core_brd_a);
        	}
        }

        case PSM_INA230_CORE_BRD_B:
        {
        	os_memcpy(&pwr_sns_mtr_cfg_core_brd_b,sns_hdlr_ipc.pld.pld_ptr,sizeof(power_sense_mntr_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_POWER_SENSE_MONITOR_CORE_BRD_B_CFG,(uint8_t*)&pwr_sns_mtr_cfg_core_brd_b);
        	if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
        	{
        		psm_sns_deinit(ahw_id);
        		psm_sns_init(&ahw_hpsm_ps,&pwr_sns_mtr_cfg_core_brd_b);
        	}
        }
        case PSM_INA230_PS_1:
        {
        	os_memcpy(&pwr_sns_mtr_cfg_ps1,sns_hdlr_ipc.pld.pld_ptr,sizeof(power_sense_mntr_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_POWER_SENSE_MONITOR_PS_1_CFG,(uint8_t*)&pwr_sns_mtr_cfg_ps1);
        	if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
        	{
        		psm_sns_deinit(ahw_id);
        		psm_sns_init(&ahw_hpsm_ps,&pwr_sns_mtr_cfg_ps1);
        	}
        }
        case PSM_INA230_PS_2:
        {
        	os_memcpy(&pwr_sns_mtr_cfg_ps2,sns_hdlr_ipc.pld.pld_ptr,sizeof(power_sense_mntr_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_POWER_SENSE_MONITOR_PS_2_CFG,(uint8_t*)&pwr_sns_mtr_cfg_ps2);
        	if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
        	{
        		psm_sns_deinit(ahw_id);
        		psm_sns_init(&ahw_hpsm_ps,&pwr_sns_mtr_cfg_ps2);
        	}
        }
        case PSM_INA230_EDGE_1:
        {
        	os_memcpy(&pwr_sns_mtr_cfg_edge1,sns_hdlr_ipc.pld.pld_ptr,sizeof(power_sense_mntr_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_POWER_SENSE_MONITOR_EDGE_1_CFG,(uint8_t*)&pwr_sns_mtr_cfg_edge1);
        	if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
        	{
        		psm_sns_deinit(ahw_id);
        		psm_sns_init(&ahw_hpsm_ps,&pwr_sns_mtr_cfg_edge1);
        	}
        }
        case PSM_INA230_EDGE_2_IN_SUPPLY:
        {
        	os_memcpy(&pwr_sns_mtr_cfg_edge2_supply,sns_hdlr_ipc.pld.pld_ptr,sizeof(power_sense_mntr_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_POWER_SENSE_MONITOR_EDGE_2_SUP_CFG,(uint8_t*)&pwr_sns_mtr_cfg_edge2_supply);
        	if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
        	{
        		psm_sns_deinit(ahw_id);
        		psm_sns_init(&ahw_hpsm_ps,&pwr_sns_mtr_cfg_edge2_supply);
        	}
        }
        case PSM_INA230_IO_BRD_IN_SUPPLY:
        {
        	os_memcpy(&pwr_sns_mtr_cfg_io_supply,sns_hdlr_ipc.pld.pld_ptr,sizeof(power_sense_mntr_cfg));
        	nvm_parameter_write(NVM_DATA,NVM_POWER_SENSE_MONITOR_IO_BRD_SUP_CFG,(uint8_t*)&pwr_sns_mtr_cfg_io_supply);
        	if(brd_act_sts[HW_PL_SERVER]==SW_ACTIVE)
        	{
        		psm_sns_deinit(ahw_id);
        		psm_sns_init(&ahw_hpsm_ps,&pwr_sns_mtr_cfg_io_supply);
        	}
        }

            break;

        default:
            break;
    }
}
#endif

/**
 * @brief API to handle the sensor polling timer expiry
 */
#if defined(COREBOARD) || defined(LINUX_TEMP_PORT)
static void sensor_tmr_expry_hdlr(uint32_t ahw_id, uint8_t buff_idx)
{
    uint64_t tp_epoch_time;
    double tp_temperature;
    switch(ahw_id)
    {
        case IMU_BMX160_OBC_1:
        case IMU_BMX160_OBC_2:
            break;
        case DIGITAL_THERMOSTAT_DS620_EDGE:
            dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_EDGE);
            dt_edge_data_buffer[buff_idx].temperature=tp_temperature;
            get_rtc_tm(&tp_epoch_time);
            dt_edge_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time; 
#if 0
            if(edge_ssd_heat_sts == 1)
            {
            	tp_temperature=sns_data_average(DIGITAL_THERMOSTAT_DS620_EDGE,3);
                if( tp_temperature > dgtl_thrmst_cfg_edge.high_temp_thrsld)
                {
                	heat_coil_enable_control(2,0);
                }
//                else if(tp_temperature < dgtl_thrmst_cfg_edge.low_temp_thrsld)
//                {
//                	heat_coil_enable_control(2,1);
//                }
            }
#endif      
                /** Buffer it to FW */
                dt_data_s *dt_edge_q_data_buffer = os_malloc(sizeof(dt_data_s));
                if(dt_edge_q_data_buffer)
                {
                    dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_EDGE);
                    dt_edge_q_data_buffer->temperature=tp_temperature;
                    get_rtc_tm(&tp_epoch_time);
                    dt_edge_q_data_buffer->dt_epoch_time=tp_epoch_time; 
                    tc_buff_fw_enqueue_req((uint8*)dt_edge_q_data_buffer, DT_EDGE_DATA_QUEUE_ID);

                }
                else
                {
                    // malloc failed
                }
            break;
        case DIGITAL_THERMOSTAT_DS620_PS:
            {
                dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_PS);
                dt_ps_data_buffer[buff_idx].temperature=tp_temperature;
                get_rtc_tm(&tp_epoch_time);
                dt_ps_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;
#if 0
            if(ps_ssd_heat_sts == 1)
            {
            	tp_temperature=sns_data_average(DIGITAL_THERMOSTAT_DS620_PS,3);
            	if(tp_temperature> dgtl_thrmst_cfg_ps.high_temp_thrsld)
            	{
            		heat_coil_enable_control(1,0);
            	}
//            	else if(tp_temperature < dgtl_thrmst_cfg_ps.low_temp_thrsld)
//            	{
//            		heat_coil_enable_control(1,1);
//            	}
            }
#endif      
                /** Buffer it to FW */
                dt_data_s *dt_ps_q_data_buffer = os_malloc(sizeof(dt_data_s));
                if(dt_ps_q_data_buffer)
                {
                    dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_PS);
                    dt_ps_q_data_buffer->temperature=tp_temperature;
                    get_rtc_tm(&tp_epoch_time);
                    dt_ps_q_data_buffer->dt_epoch_time=tp_epoch_time;
                    tc_buff_fw_enqueue_req((uint8*)dt_ps_q_data_buffer, DT_PS_DATA_QUEUE_ID);
                }
                else
                {
                    //malloc error
                }
            }         
            break;
        case HSC_ADM1176_EDGE:
            {
                hsc_get_func(&hsc_edge_data_buffer[buff_idx].hsc_data,HSC_ADM1176_EDGE);
                get_rtc_tm(&tp_epoch_time);
                hsc_edge_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;
#if 0
            if(edge_ssd_heat_sts == 1)
            {
            	if(sns_data_average(HSC_ADM1176_EDGE,3) > htswp_cntlr_cfg_edge.current_thrsld)
            	{
            		heat_coil_enable_control(2,0);
            	}
            }
#endif                
                /** Buffer it to FW */
                hsc_data_s *hsc_edge_q_data_buffer = os_malloc(sizeof(hsc_data_s));
                if(hsc_edge_q_data_buffer)
                {
                    hsc_get_func(&hsc_edge_q_data_buffer->hsc_data,HSC_ADM1176_EDGE);
                    get_rtc_tm(&tp_epoch_time);
                    hsc_edge_q_data_buffer->adm_epoch_time=tp_epoch_time;
                    tc_buff_fw_enqueue_req((uint8*)hsc_edge_q_data_buffer, HSC_EDGE_DATA_QUEUE_ID);
                }
                else
                {
                    //malloc
                }
            }

            break;
        case HSC_ADM1176_PS_1:
            {
                hsc_get_func(&hsc_ps_1_data_buffer[buff_idx].hsc_data,HSC_ADM1176_PS_1);
                get_rtc_tm(&tp_epoch_time);
                hsc_ps_1_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;
                
                /** Buffer it to FW */
                hsc_data_s *hsc_ps1_q_data_buffer = os_malloc(sizeof(hsc_data_s));
                if(hsc_ps1_q_data_buffer)
                {
                    hsc_get_func(&hsc_ps_1_data_buffer->hsc_data,HSC_ADM1176_PS_1);
                    get_rtc_tm(&tp_epoch_time);
                    hsc_ps_1_data_buffer->adm_epoch_time=tp_epoch_time;
                    tc_buff_fw_enqueue_req((uint8*)hsc_ps1_q_data_buffer, HSC_PS1_DATA_QUEUE_ID);
                }
                else
                {
                    //malloc error
                }
            }
            break;
        case HSC_ADM1176_PS_2:
            {
                hsc_get_func(&hsc_ps_2_data_buffer[buff_idx].hsc_data,HSC_ADM1176_PS_2);
                get_rtc_tm(&tp_epoch_time);
                hsc_ps_2_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;
#if 0
            if(ps_ssd_heat_sts == 1)
            {
            	if(sns_data_average(HSC_ADM1176_PS_2,3) > htswp_cntlr_cfg_ps_2.current_thrsld)
            	{
            		heat_coil_enable_control(1,0);
            	}
            }
#endif       
                /** Buffer it to FW */
                hsc_data_s *hsc_ps2_q_data_buffer = os_malloc(sizeof(hsc_data_s));
                if(hsc_ps2_q_data_buffer)
                {
                    hsc_get_func(&hsc_ps2_q_data_buffer->hsc_data,HSC_ADM1176_PS_2);
                    get_rtc_tm(&tp_epoch_time);
                    hsc_ps2_q_data_buffer->adm_epoch_time=tp_epoch_time;
                    tc_buff_fw_enqueue_req((uint8*)hsc_ps2_q_data_buffer, HSC_PS2_DATA_QUEUE_ID);
                }
                else
                {
                    //malloc error
                }
            }         
            break;

       /***** ***********************************GEN2 HSC ************************************** *****/
        case HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY:
        {
            hsc_get_func(&hsc_ps_brd_supply_data_buffer[buff_idx].hsc_data,HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY);
            get_rtc_tm(&tp_epoch_time);
            hsc_ps_brd_supply_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;

            /** Buffer it to FW */
            hsc_data_s *hsc_ps_brd_supply_q_data_buffer = os_malloc(sizeof(hsc_data_s));
            if(hsc_ps_brd_supply_q_data_buffer)
            {
                hsc_get_func(&hsc_ps_brd_supply_data_buffer->hsc_data,HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY);
                get_rtc_tm(&tp_epoch_time);
                hsc_ps_brd_supply_data_buffer->adm_epoch_time=tp_epoch_time;
                tc_buff_fw_enqueue_req((uint8*)hsc_ps_brd_supply_q_data_buffer, HSC_PS_BRD_SUPPLY_DATA_QUEUE_ID);
            }
            else
            {
                //malloc error
            }
        }
        break;

        case HSC_ADM1176_PS_1_IN_SUPPLY:
        {
            hsc_get_func(&hsc_ps1_supply_data_buffer[buff_idx].hsc_data,HSC_ADM1176_PS_1_IN_SUPPLY);
            get_rtc_tm(&tp_epoch_time);
            hsc_ps1_supply_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;

            /** Buffer it to FW */
            hsc_data_s *hsc_ps1_supply_q_data_buffer = os_malloc(sizeof(hsc_data_s));
            if(hsc_ps1_supply_q_data_buffer)
            {
                hsc_get_func(&hsc_ps1_supply_data_buffer->hsc_data,HSC_ADM1176_PS_1_IN_SUPPLY);
                get_rtc_tm(&tp_epoch_time);
                hsc_ps1_supply_data_buffer->adm_epoch_time=tp_epoch_time;
                tc_buff_fw_enqueue_req((uint8*)hsc_ps1_supply_q_data_buffer, HSC_PS1_SUPPLY_DATA_QUEUE_ID);
            }
            else
            {
                //malloc error
            }
        }
        break;

        case HSC_ADM1176_PS_2_IN_SUPPLY:
        {
            hsc_get_func(&hsc_ps2_supply_data_buffer[buff_idx].hsc_data,HSC_ADM1176_PS_2_IN_SUPPLY);
            get_rtc_tm(&tp_epoch_time);
            hsc_ps2_supply_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;

            /** Buffer it to FW */
            hsc_data_s *hsc_ps2_supply_q_data_buffer = os_malloc(sizeof(hsc_data_s));
            if(hsc_ps2_supply_q_data_buffer)
            {
                hsc_get_func(&hsc_ps2_supply_data_buffer->hsc_data,HSC_ADM1176_PS_2_IN_SUPPLY);
                get_rtc_tm(&tp_epoch_time);
                hsc_ps2_supply_data_buffer->adm_epoch_time=tp_epoch_time;
                tc_buff_fw_enqueue_req((uint8*)hsc_ps2_supply_q_data_buffer, HSC_PS2_SUPPLY_DATA_QUEUE_ID);
            }
            else
            {
                //malloc error
            }
        }
        break;

        case HSC_ADM1176_EDGE_1_IN_SUPPLY:
        {
            hsc_get_func(&hsc_edge1_supply_data_buffer[buff_idx].hsc_data,HSC_ADM1176_EDGE_1_IN_SUPPLY);
            get_rtc_tm(&tp_epoch_time);
            hsc_edge1_supply_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;

            /** Buffer it to FW */
            hsc_data_s *hsc_edge1_supply_q_data_buffer = os_malloc(sizeof(hsc_data_s));
            if(hsc_edge1_supply_q_data_buffer)
            {
                hsc_get_func(&hsc_edge1_supply_data_buffer->hsc_data,HSC_ADM1176_EDGE_1_IN_SUPPLY);
                get_rtc_tm(&tp_epoch_time);
                hsc_edge1_supply_data_buffer->adm_epoch_time=tp_epoch_time;
                tc_buff_fw_enqueue_req((uint8*)hsc_edge1_supply_q_data_buffer, HSC_EDGE1_SUPPLY_DATA_QUEUE_ID);
            }
            else
            {
                //malloc error
            }
        }
        break;

        case HSC_ADM1176_EDGE_1_HEAT_COIL:
        {
            hsc_get_func(&hsc_edge1_heat_coil_data_buffer[buff_idx].hsc_data,HSC_ADM1176_EDGE_1_HEAT_COIL);
            get_rtc_tm(&tp_epoch_time);
            hsc_edge1_heat_coil_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;

            /** Buffer it to FW */
            hsc_data_s *hsc_edge1_heat_coil_q_data_buffer = os_malloc(sizeof(hsc_data_s));
            if(hsc_edge1_heat_coil_q_data_buffer)
            {
                hsc_get_func(&hsc_edge1_heat_coil_data_buffer->hsc_data,HSC_ADM1176_EDGE_1_HEAT_COIL);
                get_rtc_tm(&tp_epoch_time);
                hsc_edge1_heat_coil_data_buffer->adm_epoch_time=tp_epoch_time;
                tc_buff_fw_enqueue_req((uint8*)hsc_edge1_heat_coil_q_data_buffer, HSC_EDGE1_HEAT_COIL_DATA_QUEUE_ID);
            }
            else
            {
                //malloc error
            }
        }
        break;

        case HSC_ADM1176_EDGE_2_IN_SUPPLY:
        {
            hsc_get_func(&hsc_edge2_supply_data_buffer[buff_idx].hsc_data,HSC_ADM1176_EDGE_2_IN_SUPPLY);
            get_rtc_tm(&tp_epoch_time);
            hsc_edge2_supply_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;

            /** Buffer it to FW */
            hsc_data_s *hsc_edge2_supply_q_data_buffer = os_malloc(sizeof(hsc_data_s));
            if(hsc_edge2_supply_q_data_buffer)
            {
                hsc_get_func(&hsc_edge2_supply_data_buffer->hsc_data,HSC_ADM1176_EDGE_2_IN_SUPPLY);
                get_rtc_tm(&tp_epoch_time);
                hsc_edge2_supply_data_buffer->adm_epoch_time=tp_epoch_time;
                tc_buff_fw_enqueue_req((uint8*)hsc_edge2_supply_q_data_buffer, HSC_EDGE2_SUPPLY_DATA_QUEUE_ID);
            }
            else
            {
                //malloc error
            }
        }
        break;

        case HSC_ADM1176_EDGE_2_HEAT_COIL:
        {
            hsc_get_func(&hsc_edge2_heat_coil_data_buffer[buff_idx].hsc_data,HSC_ADM1176_EDGE_2_HEAT_COIL);
            get_rtc_tm(&tp_epoch_time);
            hsc_edge2_heat_coil_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;

            /** Buffer it to FW */
            hsc_data_s *hsc_edge2_heat_coil_q_data_buffer = os_malloc(sizeof(hsc_data_s));
            if(hsc_edge2_heat_coil_q_data_buffer)
            {
                hsc_get_func(&hsc_edge2_heat_coil_data_buffer->hsc_data,HSC_ADM1176_EDGE_2_HEAT_COIL);
                get_rtc_tm(&tp_epoch_time);
                hsc_edge2_heat_coil_data_buffer->adm_epoch_time=tp_epoch_time;
                tc_buff_fw_enqueue_req((uint8*)hsc_edge2_heat_coil_data_buffer, HSC_EDGE2_HEAT_COIL_DATA_QUEUE_ID);
            }
            else
            {
                //malloc error
            }
        }
        break;

        case HSC_ADM1176_IO_BRD_IN_SUPPLY:
        {
            hsc_get_func(&hsc_io_brd_supply_data_buffer[buff_idx].hsc_data,HSC_ADM1176_IO_BRD_IN_SUPPLY);
            get_rtc_tm(&tp_epoch_time);
            hsc_io_brd_supply_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;

            /** Buffer it to FW */
            hsc_data_s *hsc_io_brd_supply_q_data_buffer = os_malloc(sizeof(hsc_data_s));
            if(hsc_io_brd_supply_q_data_buffer)
            {
                hsc_get_func(&hsc_io_brd_supply_data_buffer->hsc_data,HSC_ADM1176_IO_BRD_IN_SUPPLY);
                get_rtc_tm(&tp_epoch_time);
                hsc_io_brd_supply_data_buffer->adm_epoch_time=tp_epoch_time;
                tc_buff_fw_enqueue_req((uint8*)hsc_io_brd_supply_q_data_buffer, HSC_IO_SUPPLY_DATA_QUEUE_ID);
            }
            else
            {
                //malloc error
            }
        }
        break;

        case HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1:
        {
            hsc_get_func(&hsc_io_brd_top1_data_buffer[buff_idx].hsc_data,HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1);
            get_rtc_tm(&tp_epoch_time);
            hsc_io_brd_top1_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;

            /** Buffer it to FW */
            hsc_data_s *hsc_io_brd_top1_q_data_buffer = os_malloc(sizeof(hsc_data_s));
            if(hsc_io_brd_top1_q_data_buffer)
            {
                hsc_get_func(&hsc_io_brd_top1_data_buffer->hsc_data,HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1);
                get_rtc_tm(&tp_epoch_time);
                hsc_io_brd_top1_data_buffer->adm_epoch_time=tp_epoch_time;
                tc_buff_fw_enqueue_req((uint8*)hsc_io_brd_top1_q_data_buffer, HSC_IO_BRD_TOP1_DATA_QUEUE_ID);
            }
            else
            {
                //malloc error
            }
        }
        break;

        case HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2:
        {
            hsc_get_func(&hsc_io_brd_top2_data_buffer[buff_idx].hsc_data,HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2);
            get_rtc_tm(&tp_epoch_time);
            hsc_io_brd_top2_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;

            /** Buffer it to FW */
            hsc_data_s *hsc_io_brd_top2_q_data_buffer = os_malloc(sizeof(hsc_data_s));
            if(hsc_io_brd_top2_q_data_buffer)
            {
                hsc_get_func(&hsc_io_brd_top2_data_buffer->hsc_data,HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2);
                get_rtc_tm(&tp_epoch_time);
                hsc_io_brd_top2_data_buffer->adm_epoch_time=tp_epoch_time;
                tc_buff_fw_enqueue_req((uint8*)hsc_io_brd_top2_q_data_buffer, HSC_IO_BRD_TOP2_DATA_QUEUE_ID);
            }
            else
            {
                //malloc error
            }
        }
        break;

        case HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1:
        {
            hsc_get_func(&hsc_io_brd_bot1_data_buffer[buff_idx].hsc_data,HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1);
            get_rtc_tm(&tp_epoch_time);
            hsc_io_brd_bot1_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;

            /** Buffer it to FW */
            hsc_data_s *hsc_io_brd_bot1_q_data_buffer = os_malloc(sizeof(hsc_data_s));
            if(hsc_io_brd_bot1_q_data_buffer)
            {
                hsc_get_func(&hsc_io_brd_bot1_data_buffer->hsc_data,HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1);
                get_rtc_tm(&tp_epoch_time);
                hsc_io_brd_bot1_data_buffer->adm_epoch_time=tp_epoch_time;
                tc_buff_fw_enqueue_req((uint8*)hsc_io_brd_bot1_q_data_buffer, HSC_IO_BRD_BOT1_DATA_QUEUE_ID);
            }
            else
            {
                //malloc error
            }
        }
        break;

        case HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2:
        {
            hsc_get_func(&hsc_io_brd_bot2_data_buffer[buff_idx].hsc_data,HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2);
            get_rtc_tm(&tp_epoch_time);
            hsc_io_brd_bot2_data_buffer[buff_idx].adm_epoch_time=tp_epoch_time;

            /** Buffer it to FW */
            hsc_data_s *hsc_io_brd_bot2_q_data_buffer = os_malloc(sizeof(hsc_data_s));
            if(hsc_io_brd_bot2_q_data_buffer)
            {
                hsc_get_func(&hsc_io_brd_bot2_data_buffer->hsc_data,HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2);
                get_rtc_tm(&tp_epoch_time);
                hsc_io_brd_bot2_data_buffer->adm_epoch_time=tp_epoch_time;
                tc_buff_fw_enqueue_req((uint8*)hsc_io_brd_bot2_q_data_buffer, HSC_IO_BRD_BOT2_DATA_QUEUE_ID);
            }
            else
            {
                //malloc error
            }
        }
        break;
       /*****/

        case TEMP_SENSOR_MCP9843_OBC:
            {
                temp_get_func(&temp_obc_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_OBC);
                get_rtc_tm(&tp_epoch_time);
                temp_obc_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_obc_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_obc_data_buffer)
                {
                    temp_get_func(&temp_q_obc_data_buffer->temperature,TEMP_SENSOR_MCP9843_OBC);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_obc_data_buffer->temp_epoch_time =tp_epoch_time;
                    tc_buff_fw_enqueue_req((uint8*)temp_q_obc_data_buffer, TEMP_OBC_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;
        case TEMP_SENSOR_MCP9843_PS:
            {
                temp_get_func(&temp_ps_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_PS);
                get_rtc_tm(&tp_epoch_time);
                temp_ps_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_ps_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_ps_data_buffer)
                {
                    temp_get_func(&temp_q_ps_data_buffer->temperature,TEMP_SENSOR_MCP9843_PS);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_ps_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_ps_data_buffer, TEMP_PS_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;
        case TEMP_SENSOR_MCP9843_EDGE:
            {
                temp_get_func(&temp_edge_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_EDGE);
                get_rtc_tm(&tp_epoch_time);
                temp_edge_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_es_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_es_data_buffer)
                {
                    temp_get_func(&temp_q_es_data_buffer->temperature,TEMP_SENSOR_MCP9843_EDGE);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_es_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_es_data_buffer, TEMP_ES_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;
        case TEMP_SENSOR_MCP9843_GPS:
            {
                temp_get_func(&temp_gps_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_GPS);
                get_rtc_tm(&tp_epoch_time);
                temp_gps_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_gps_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_gps_data_buffer)
                {
                    temp_get_func(&temp_q_gps_data_buffer->temperature,TEMP_SENSOR_MCP9843_GPS);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_gps_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_gps_data_buffer, TEMP_GPS_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;

            /********** GEN 2 ***********/
        case TEMP_SENSOR_MCP9843_EDGE_1:
            {
                temp_get_func(&temp_edge1_gen2_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_EDGE_1);
                get_rtc_tm(&tp_epoch_time);
                temp_edge1_gen2_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_edge1_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_edge1_data_buffer)
                {
                    temp_get_func(&temp_q_edge1_data_buffer->temperature,TEMP_SENSOR_MCP9843_EDGE_1);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_edge1_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_edge1_data_buffer, TEMP_EDGE1_GEN2_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;

        case TEMP_SENSOR_MCP9843_EDGE_2:
            {
                temp_get_func(&temp_edge2_gen2_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_EDGE_2);
                get_rtc_tm(&tp_epoch_time);
                temp_edge2_gen2_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_edge2_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_edge2_data_buffer)
                {
                    temp_get_func(&temp_q_edge2_data_buffer->temperature,TEMP_SENSOR_MCP9843_EDGE_2);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_edge2_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_edge2_data_buffer, TEMP_EDGE2_GEN2_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;

        case TEMP_SENSOR_MCP9843_PS_GEN_2:
            {
                temp_get_func(&temp_ps_gen2_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_PS_GEN_2);
                get_rtc_tm(&tp_epoch_time);
                temp_ps_gen2_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_ps_gen2_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_ps_gen2_data_buffer)
                {
                    temp_get_func(&temp_ps_gen2_data_buffer->temperature,TEMP_SENSOR_MCP9843_PS_GEN_2);
                    get_rtc_tm(&tp_epoch_time);
                    temp_ps_gen2_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_ps_gen2_data_buffer, TEMP_PS_GEN2_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;

        case TEMP_SENSOR_MCP9843_NIC_1:
            {
                temp_get_func(&temp_nic1_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_NIC_1);
                get_rtc_tm(&tp_epoch_time);
                temp_nic1_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_nic1_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_nic1_data_buffer)
                {
                    temp_get_func(&temp_q_nic1_data_buffer->temperature,TEMP_SENSOR_MCP9843_NIC_1);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_nic1_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_nic1_data_buffer, TEMP_NIC1_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;

        case TEMP_SENSOR_MCP9843_SSD_1:
            {
                temp_get_func(&temp_ssd1_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_SSD_1);
                get_rtc_tm(&tp_epoch_time);
                temp_ssd1_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_ssd1_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_ssd1_data_buffer)
                {
                    temp_get_func(&temp_q_ssd1_data_buffer->temperature,TEMP_SENSOR_MCP9843_SSD_1);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_ssd1_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_ssd1_data_buffer, TEMP_SSD1_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;

        case TEMP_SENSOR_MCP9843_SSD_2:
            {
                temp_get_func(&temp_ssd2_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_SSD_2);
                get_rtc_tm(&tp_epoch_time);
                temp_ssd2_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_ssd2_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_ssd2_data_buffer)
                {
                    temp_get_func(&temp_q_ssd2_data_buffer->temperature,TEMP_SENSOR_MCP9843_SSD_2);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_ssd2_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_ssd2_data_buffer, TEMP_SSD2_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;

        case TEMP_SENSOR_MCP9843_SSD_3:
            {
                temp_get_func(&temp_ssd3_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_SSD_3);
                get_rtc_tm(&tp_epoch_time);
                temp_ssd3_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_ssd3_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_ssd3_data_buffer)
                {
                    temp_get_func(&temp_q_ssd3_data_buffer->temperature,TEMP_SENSOR_MCP9843_SSD_3);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_ssd3_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_ssd3_data_buffer, TEMP_SSD3_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;

        case TEMP_SENSOR_MCP9843_SSD_4:
            {
                temp_get_func(&temp_ssd4_data_buffer[buff_idx].temperature,TEMP_SENSOR_MCP9843_SSD_4);
                get_rtc_tm(&tp_epoch_time);
                temp_ssd4_data_buffer[buff_idx].temp_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_ssd4_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_ssd4_data_buffer)
                {
                    temp_get_func(&temp_q_ssd4_data_buffer->temperature,TEMP_SENSOR_MCP9843_SSD_4);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_ssd4_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_ssd4_data_buffer, TEMP_SSD4_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;


        case DIGITAL_THERMOSTAT_DS620_SPE01:
            {

                dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_SPE01);
                temp_spe01_data_buffer[buff_idx].temperature=tp_temperature;
                get_rtc_tm(&tp_epoch_time);
                temp_spe01_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;
       
                /** Buffer it to FW */
                temp_data_s *temp_q_spe01_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_spe01_data_buffer)
                {
                    temp_get_func(&temp_q_spe01_data_buffer->temperature,DIGITAL_THERMOSTAT_DS620_SPE01);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_spe01_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_spe01_data_buffer, DT_SPE01_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;
        case DIGITAL_THERMOSTAT_DS620_SPE02:
            {
                dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_SPE02);
                temp_spe02_data_buffer[buff_idx].temperature=tp_temperature;
                get_rtc_tm(&tp_epoch_time);
                temp_spe02_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_spe02_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_spe02_data_buffer)
                {
                    temp_get_func(&temp_q_spe02_data_buffer->temperature,DIGITAL_THERMOSTAT_DS620_SPE02);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_spe02_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_spe02_data_buffer, DT_SPE02_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;
        case DIGITAL_THERMOSTAT_DS620_SPB01:
            {
                dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_SPB01);
                temp_spb01_data_buffer[buff_idx].temperature=tp_temperature;
                get_rtc_tm(&tp_epoch_time);
                temp_spb01_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_spb01_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_spb01_data_buffer)
                {
                    temp_get_func(&temp_q_spb01_data_buffer->temperature,DIGITAL_THERMOSTAT_DS620_SPB01);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_spb01_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_spb01_data_buffer, DT_SPB01_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;
        case DIGITAL_THERMOSTAT_DS620_SPW01:
            {
                dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_SPW01);
                temp_spw01_data_buffer[buff_idx].temperature=tp_temperature;
                get_rtc_tm(&tp_epoch_time);
                temp_spw01_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_spw01_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_spw01_data_buffer)
                {
                    temp_get_func(&temp_q_spw01_data_buffer->temperature,DIGITAL_THERMOSTAT_DS620_SPW01);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_spw01_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_spw01_data_buffer, DT_SPW01_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;
        case DIGITAL_THERMOSTAT_DS620_SPW02:
            {
                dt_get_func(&tp_temperature,DIGITAL_THERMOSTAT_DS620_SPW02);
                temp_spw02_data_buffer[buff_idx].temperature=tp_temperature;
                get_rtc_tm(&tp_epoch_time);
                temp_spw02_data_buffer[buff_idx].dt_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                temp_data_s *temp_q_spw02_data_buffer = os_malloc(sizeof(temp_data_s));
                if(temp_q_spw02_data_buffer)
                {
                    temp_get_func(&temp_q_spw02_data_buffer->temperature,DIGITAL_THERMOSTAT_DS620_SPW02);
                    get_rtc_tm(&tp_epoch_time);
                    temp_q_spw02_data_buffer->temp_epoch_time =tp_epoch_time;

                    tc_buff_fw_enqueue_req((uint8*)temp_q_spw02_data_buffer, DT_SPW02_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;
        case PSM_INA230_OBC:
            {
                psm_get_func(&psm_obc_data_buffer[buff_idx].pwr,PSM_INA230_OBC);
                get_rtc_tm(&tp_epoch_time);
                psm_obc_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                psm_data_s *psm_q_obc_data_buffer = os_malloc(sizeof(psm_data_s));
                if(psm_q_obc_data_buffer)
                {
                    psm_get_func(&psm_q_obc_data_buffer->pwr,PSM_INA230_OBC);
                    get_rtc_tm(&tp_epoch_time);
                    psm_q_obc_data_buffer->psm_epoch_time=tp_epoch_time;
                    tc_buff_fw_enqueue_req((uint8*)psm_q_obc_data_buffer, PSM_OBC_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;

        case PSM_INA230_PS:
            {
                psm_get_func(&psm_ps_data_buffer[buff_idx].pwr,PSM_INA230_PS);
                get_rtc_tm(&tp_epoch_time);
                psm_ps_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;

                /** Buffer it to FW */
                psm_data_s *psm_q_ps_data_buffer = os_malloc(sizeof(psm_data_s));
                if(psm_q_ps_data_buffer)
                {
                    psm_get_func(&psm_q_ps_data_buffer->pwr,PSM_INA230_PS);
                    get_rtc_tm(&tp_epoch_time);
                    psm_q_ps_data_buffer->psm_epoch_time=tp_epoch_time;
                    tc_buff_fw_enqueue_req((uint8*)psm_q_ps_data_buffer, PSM_PS_DATA_QUEUE_ID);
                }
                else
                {
                    // malloc failed
                }
            }
            break;
          /***** GEN2 PSM *****/
        case PSM_INA230_PS_GEN_2:
                    {
                        psm_get_func(&psm_ps_gen2_data_buffer[buff_idx].pwr,PSM_INA230_PS_GEN_2);
                        get_rtc_tm(&tp_epoch_time);
                        psm_ps_gen2_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;

                        /** Buffer it to FW */
                        psm_data_s *psm_q_ps_gen2_data_buffer = os_malloc(sizeof(psm_data_s));
                        if(psm_q_ps_gen2_data_buffer)
                        {
                            psm_get_func(&psm_q_ps_gen2_data_buffer->pwr,PSM_INA230_PS_GEN_2);
                            get_rtc_tm(&tp_epoch_time);
                            psm_q_ps_gen2_data_buffer->psm_epoch_time=tp_epoch_time;
                            tc_buff_fw_enqueue_req((uint8*)psm_q_ps_gen2_data_buffer, PSM_PS_GEN2_DATA_QUEUE_ID);
                        }
                        else
                        {
                            // malloc failed
                        }
                    }
                    break;
        case PSM_INA230_CORE_BRD_A:
                    {
                        psm_get_func(&psm_core_brd_a_data_buffer[buff_idx].pwr,PSM_INA230_CORE_BRD_A);
                        get_rtc_tm(&tp_epoch_time);
                        psm_core_brd_a_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;

                        /** Buffer it to FW */
                        psm_data_s *psm_q_core_brd_a_data_buffer = os_malloc(sizeof(psm_data_s));
                        if(psm_q_core_brd_a_data_buffer)
                        {
                            psm_get_func(&psm_q_core_brd_a_data_buffer->pwr,PSM_INA230_CORE_BRD_A);
                            get_rtc_tm(&tp_epoch_time);
                            psm_q_core_brd_a_data_buffer->psm_epoch_time=tp_epoch_time;
                            tc_buff_fw_enqueue_req((uint8*)psm_q_core_brd_a_data_buffer, PSM_CORE_BRD_A_DATA_QUEUE_ID);
                        }
                        else
                        {
                            // malloc failed
                        }
                    }
                    break;
        case PSM_INA230_CORE_BRD_B:
                    {
                        psm_get_func(&psm_core_brd_b_data_buffer[buff_idx].pwr,PSM_INA230_CORE_BRD_B);
                        get_rtc_tm(&tp_epoch_time);
                        psm_core_brd_b_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;

                        /** Buffer it to FW */
                        psm_data_s *psm_q_core_brd_b_data_buffer = os_malloc(sizeof(psm_data_s));
                        if(psm_q_core_brd_b_data_buffer)
                        {
                            psm_get_func(&psm_q_core_brd_b_data_buffer->pwr,PSM_INA230_CORE_BRD_B);
                            get_rtc_tm(&tp_epoch_time);
                            psm_q_core_brd_b_data_buffer->psm_epoch_time=tp_epoch_time;
                            tc_buff_fw_enqueue_req((uint8*)psm_q_core_brd_b_data_buffer, PSM_CORE_BRD_B_DATA_QUEUE_ID);
                        }
                        else
                        {
                            // malloc failed
                        }
                    }
                    break;
        case PSM_INA230_PS_1:
                    {
                        psm_get_func(&psm_ps1_data_buffer[buff_idx].pwr,PSM_INA230_PS_1);
                        get_rtc_tm(&tp_epoch_time);
                        psm_ps1_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;

                        /** Buffer it to FW */
                        psm_data_s *psm_q_ps1_data_buffer = os_malloc(sizeof(psm_data_s));
                        if(psm_q_ps1_data_buffer)
                        {
                            psm_get_func(&psm_q_ps1_data_buffer->pwr,PSM_INA230_PS_1);
                            get_rtc_tm(&tp_epoch_time);
                            psm_q_ps1_data_buffer->psm_epoch_time=tp_epoch_time;
                            tc_buff_fw_enqueue_req((uint8*)psm_q_ps1_data_buffer, PSM_PS1_DATA_QUEUE_ID);
                        }
                        else
                        {
                            // malloc failed
                        }
                    }
                    break;
        case PSM_INA230_PS_2:
                    {
                        psm_get_func(&psm_ps2_data_buffer[buff_idx].pwr,PSM_INA230_PS_2);
                        get_rtc_tm(&tp_epoch_time);
                        psm_ps2_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;

                        /** Buffer it to FW */
                        psm_data_s *psm_q_ps2_data_buffer = os_malloc(sizeof(psm_data_s));
                        if(psm_q_ps2_data_buffer)
                        {
                            psm_get_func(&psm_q_ps2_data_buffer->pwr,PSM_INA230_PS_2);
                            get_rtc_tm(&tp_epoch_time);
                            psm_q_ps2_data_buffer->psm_epoch_time=tp_epoch_time;
                            tc_buff_fw_enqueue_req((uint8*)psm_q_ps2_data_buffer, PSM_PS2_DATA_QUEUE_ID);
                        }
                        else
                        {
                            // malloc failed
                        }
                    }
                    break;
        case PSM_INA230_EDGE_1:
                    {
                        psm_get_func(&psm_edge1_data_buffer[buff_idx].pwr,PSM_INA230_EDGE_1);
                        get_rtc_tm(&tp_epoch_time);
                        psm_edge1_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;

                        /** Buffer it to FW */
                        psm_data_s *psm_q_edge1_data_buffer = os_malloc(sizeof(psm_data_s));
                        if(psm_q_edge1_data_buffer)
                        {
                            psm_get_func(&psm_q_edge1_data_buffer->pwr,PSM_INA230_EDGE_1);
                            get_rtc_tm(&tp_epoch_time);
                            psm_q_edge1_data_buffer->psm_epoch_time=tp_epoch_time;
                            tc_buff_fw_enqueue_req((uint8*)psm_q_edge1_data_buffer, PSM_EDGE1_DATA_QUEUE_ID);
                        }
                        else
                        {
                            // malloc failed
                        }
                    }
                    break;
        case PSM_INA230_EDGE_2_IN_SUPPLY:
                    {
                        psm_get_func(&psm_edge2_supply_data_buffer[buff_idx].pwr,PSM_INA230_EDGE_2_IN_SUPPLY);
                        get_rtc_tm(&tp_epoch_time);
                        psm_edge2_supply_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;

                        /** Buffer it to FW */
                        psm_data_s *psm_q_edge2_supply_data_buffer = os_malloc(sizeof(psm_data_s));
                        if(psm_q_edge2_supply_data_buffer)
                        {
                            psm_get_func(&psm_q_edge2_supply_data_buffer->pwr,PSM_INA230_EDGE_2_IN_SUPPLY);
                            get_rtc_tm(&tp_epoch_time);
                            psm_q_edge2_supply_data_buffer->psm_epoch_time=tp_epoch_time;
                            tc_buff_fw_enqueue_req((uint8*)psm_q_edge2_supply_data_buffer, PSM_EDGE1_SUPPLY_DATA_QUEUE_ID);
                        }
                        else
                        {
                            // malloc failed
                        }
                    }
                    break;
        case PSM_INA230_IO_BRD_IN_SUPPLY:
                    {
                        psm_get_func(&psm_io_supply_data_buffer[buff_idx].pwr,PSM_INA230_IO_BRD_IN_SUPPLY);
                        get_rtc_tm(&tp_epoch_time);
                        psm_io_supply_data_buffer[buff_idx].psm_epoch_time=tp_epoch_time;

                        /** Buffer it to FW */
                        psm_data_s *psm_q_io_supply_data_buffer = os_malloc(sizeof(psm_data_s));
                        if(psm_q_io_supply_data_buffer)
                        {
                            psm_get_func(&psm_q_io_supply_data_buffer->pwr,PSM_INA230_IO_BRD_IN_SUPPLY);
                            get_rtc_tm(&tp_epoch_time);
                            psm_q_io_supply_data_buffer->psm_epoch_time=tp_epoch_time;
                            tc_buff_fw_enqueue_req((uint8*)psm_q_io_supply_data_buffer, PSM_IO_SUPPLY_DATA_QUEUE_ID);
                        }
                        else
                        {
                            // malloc failed
                        }
                    }
                    break;

        default:
            break;
    }
}

/**
 * @brief API to check the temperature sensor threshold
 */
static uint8_t check_temp_sns_thrsld(uint32_t ahw_id)
{
    float temperature=0;
    float temperature_temp=0;
    int i;
    hal_ret_sts sts;
    uint8_t ret=SNS_THRSLD_TYPE_MAX;
    for(i=0;i<5;i++)
    {
        sts= ahw_al_temp_sensor_gettemperature(ahw_id,&temperature);
        temperature_temp+=temperature;
    }
    if(sts==HAL_SCS)
    {
        temperature=(temperature_temp/5.0);
        switch(ahw_id)
        {
            case TEMP_SENSOR_MCP9843_OBC:
                if(temperature>=temp_sns_cfg_obc.high_temp_thrsld)
                {
                    ret = OBC_TEMP_SNS_HIGH_THRSLD;
                }
                else if(temperature<=temp_sns_cfg_obc.low_temp_thrsld)
                {
                    ret = OBC_TEMP_SNS_LOW_THRSLD;
                }
                break;
            case TEMP_SENSOR_MCP9843_PS:
                if(temperature>=temp_sns_cfg_ps.high_temp_thrsld)
                {
                    ret = PS_TEMP_SNS_HIGH_THRSLD;
                }
                else if(temperature<=temp_sns_cfg_ps.low_temp_thrsld)
                {
                    ret = PS_TEMP_SNS_LOW_THRSLD;
                }
                break;

                /*******  GEN 2 *******/
            case TEMP_SENSOR_MCP9843_EDGE_1:
            	if(temperature>=temp_sns_cfg_edge1_gen2.high_temp_thrsld)
            	{
            		ret = EDGE1_GEN2_TEMP_SNS_HIGH_THRSLD;
            	}
            	else if(temperature<=temp_sns_cfg_edge1_gen2.low_temp_thrsld)
            	{
            		ret = EDGE1_GEN2_TEMP_SNS_LOW_THRSLD;
            	}
            	break;
            case TEMP_SENSOR_MCP9843_EDGE_2:
            	if(temperature>=temp_sns_cfg_edge2_gen2.high_temp_thrsld)
            	{
            		ret = EDGE2_GEN2_TEMP_SNS_HIGH_THRSLD;
            	}
            	else if(temperature<=temp_sns_cfg_edge2_gen2.low_temp_thrsld)
            	{
            		ret = EDGE2_GEN2_TEMP_SNS_LOW_THRSLD;
            	}
            	break;
            case TEMP_SENSOR_MCP9843_PS_GEN_2:
            	if(temperature>=temp_sns_cfg_ps_gen2.high_temp_thrsld)
            	{
            		ret = PS_GEN2_TEMP_SNS_HIGH_THRSLD;
            	}
            	else if(temperature<=temp_sns_cfg_ps_gen2.low_temp_thrsld)
            	{
            		ret = PS_GEN2_TEMP_SNS_LOW_THRSLD;
            	}
            	break;
            case TEMP_SENSOR_MCP9843_NIC_1:
            	if(temperature>=temp_sns_cfg_nic1.high_temp_thrsld)
            	{
            		ret = NIC1_TEMP_SNS_HIGH_THRSLD;
            	}
            	else if(temperature<=temp_sns_cfg_nic1.low_temp_thrsld)
            	{
            		ret = NIC1_TEMP_SNS_LOW_THRSLD;
            	}
            	break;
            case TEMP_SENSOR_MCP9843_SSD_1:
            	if(temperature>=temp_sns_cfg_ssd1.high_temp_thrsld)
            	{
            		ret = SSD1_TEMP_SNS_HIGH_THRSLD;
            	}
            	else if(temperature<=temp_sns_cfg_ssd1.low_temp_thrsld)
            	{
            		ret = SSD1_TEMP_SNS_LOW_THRSLD;
            	}
            	break;
            case TEMP_SENSOR_MCP9843_SSD_2:
            	if(temperature>=temp_sns_cfg_ssd2.high_temp_thrsld)
            	{
            		ret = SSD2_TEMP_SNS_HIGH_THRSLD;
            	}
            	else if(temperature<=temp_sns_cfg_ssd2.low_temp_thrsld)
            	{
            		ret = SSD2_TEMP_SNS_LOW_THRSLD;
            	}
            	break;
            case TEMP_SENSOR_MCP9843_SSD_3:
            	if(temperature>=temp_sns_cfg_ssd3.high_temp_thrsld)
            	{
            		ret = SSD3_TEMP_SNS_HIGH_THRSLD;
            	}
            	else if(temperature<=temp_sns_cfg_ssd3.low_temp_thrsld)
            	{
            		ret = SSD3_TEMP_SNS_LOW_THRSLD;
            	}
            	break;
            case TEMP_SENSOR_MCP9843_SSD_4:
            	if(temperature>=temp_sns_cfg_ssd4.high_temp_thrsld)
            	{
            		ret = SSD4_TEMP_SNS_HIGH_THRSLD;
            	}
            	else if(temperature<=temp_sns_cfg_ssd4.low_temp_thrsld)
            	{
            		ret = SSD4_TEMP_SNS_LOW_THRSLD;
            	}
            	break;


            case TEMP_SENSOR_MCP9843_GPS:
                if(temperature>=temp_sns_cfg_gps.high_temp_thrsld)
                {
                    ret = GPS_TEMP_SNS_HIGH_THRSLD;
                }
                else if(temperature<=temp_sns_cfg_gps.low_temp_thrsld)
                {
                    ret = GPS_TEMP_SNS_LOW_THRSLD;
                }
                break;
            case TEMP_SENSOR_MCP9843_EDGE:
                if(temperature>=temp_sns_cfg_edge.high_temp_thrsld)
                {
                    ret = EDGE_TEMP_SNS_HIGH_THRSLD;
                }
                else if(temperature<=temp_sns_cfg_edge.low_temp_thrsld)
                {
                    ret = EDGE_TEMP_SNS_LOW_THRSLD;
                }
                break;
            default:
                break;
        }
    }
    else
    {
        ret = SNS_THRSLD_TYPE_MAX;
    }
    return ret;
}

#ifndef LINUX_TEMP_PORT

/**
 * @brief API to check the power sense monitor threshold
 */
static uint8_t check_pwr_sns_thrsld(uint32_t ahw_id)
{
    float current=0,thrsld_temp;
    int i;
    uint8_t ret;
    for(i=0;i<5;i++)
    {
        current = ahw_al_psm_get_current(ahw_id);
        thrsld_temp+=current;
    }
    current=(thrsld_temp/5.0);
    switch(ahw_id)
    {
        case PSM_INA230_OBC:
            if(current>=pwr_sns_mtr_cfg_obc.current_thrsld)
            {
                ret = OBC_PWR_SNS_HIGH_THRSLD;
            }
            break;
        case PSM_INA230_PS:
            if(current>=pwr_sns_mtr_cfg_ps.current_thrsld)
            {
                ret = PS_PWR_SNS_HIGH_THRSLD;
            }
            break;
        default:
            break;
    }
    return ret;
}

#endif 

#endif

#ifndef LINUX_TEMP_PORT 
/**
 * @brief API to create board restart timers
 */
static void brd_restart_tmr_create()
{
    os_timer_create(&brd_restart_tmr_obc,"obc_brd_restart_tmr",ONESHOT,(ral_timer_cbfunc_t)sensor_timer_cb,&brd_restart_tmr_obc);
    os_timer_create(&brd_restart_tmr_ps,"ps_brd_restart_tmr",ONESHOT,(ral_timer_cbfunc_t)sensor_timer_cb,&brd_restart_tmr_ps);
    os_timer_create(&brd_restart_tmr_edge,"edge_brd_restart_tmr",ONESHOT,(ral_timer_cbfunc_t)sensor_timer_cb,&brd_restart_tmr_edge);
    os_timer_create(&brd_restart_tmr_gps,"gps_brd_restart_tmr",ONESHOT,(ral_timer_cbfunc_t)sensor_timer_cb,&brd_restart_tmr_gps);
}
#endif 
/**
 * @brief API to handle board restart timer expiry
 */
#if defined(COREBOARD) || defined(LINUX_TEMP_PORT)
static void brd_restart_hdlr(uint8_t brd_id)
{
    uint32_t thrsld_status=OBC_TEMP_SNS_HIGH_THRSLD;
    switch(brd_id)
    {
        case HW_EDGE_BRD:
            eps_ctrl_en_chnl(HW_EDGE_BRD,ON);
            if(check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_EDGE)==OBC_TEMP_SNS_HIGH_THRSLD)
            {
                obc_prepare_ipc_msg((uint8_t*)&thrsld_status,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
                eps_ctrl_en_chnl(HW_EDGE_BRD,OFF);
            }
            break;
        case HW_PL_SERVER:
            eps_ctrl_en_chnl(HW_PL_SERVER,ON);
            if(check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_EDGE)==OBC_TEMP_SNS_HIGH_THRSLD)
            {
                obc_prepare_ipc_msg((uint8_t*)&thrsld_status,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
                eps_ctrl_en_chnl(HW_PL_SERVER,OFF);
            }
            break;
        case HW_GPS:
            eps_ctrl_en_chnl(HW_GPS,ON);
            if(check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_EDGE)==OBC_TEMP_SNS_HIGH_THRSLD)
            {
                obc_prepare_ipc_msg((uint8_t*)&thrsld_status,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
                eps_ctrl_en_chnl(HW_GPS,OFF);
            }
            break;
        case MAX_SAT_DEV_CNT:
            eps_ctrl_en_chnl(HW_PL_SERVER,ON);
            eps_ctrl_en_chnl(HW_EDGE_BRD,ON);
            eps_ctrl_en_chnl(HW_GPS,ON);
            if(check_temp_sns_thrsld(TEMP_SENSOR_MCP9843_OBC)==OBC_TEMP_SNS_HIGH_THRSLD)
            {
                obc_prepare_ipc_msg((uint8_t*)&thrsld_status,4,TM_SNS_THRSLD_STS,TM_SRC_OBC);
                eps_ctrl_en_chnl(HW_PL_SERVER,OFF);
                eps_ctrl_en_chnl(HW_EDGE_BRD,OFF);
                eps_ctrl_en_chnl(HW_GPS,OFF);
            }
            break;
    }
}

static uint8_t send_sns_health_mntr_data()
{
	s_sensor_beacon_info* sns_hlth_mtrcs;
	uint8_t buff_idx;
	uint8_t sts = 1;
	os_itc_msg_handle_t sns_hlth_mtrcs_ipc;

	sns_hlth_mtrcs = os_malloc(sizeof(s_sensor_beacon_info));
	buff_idx=buff_entries_trace[TEMP_SENSOR_MCP9843_OBC];
	sns_hlth_mtrcs->temp_obc = temp_obc_data_buffer[buff_idx].temperature;
	buff_idx=buff_entries_trace[TEMP_SENSOR_MCP9843_PS];
	sns_hlth_mtrcs->temp_ps = temp_ps_data_buffer[buff_idx].temperature;
	buff_idx=buff_entries_trace[TEMP_SENSOR_MCP9843_EDGE];
	sns_hlth_mtrcs->temp_es = temp_edge_data_buffer[buff_idx].temperature;
	buff_idx=buff_entries_trace[TEMP_SENSOR_MCP9843_GPS];
	sns_hlth_mtrcs->temp_gps = temp_gps_data_buffer[buff_idx].temperature;

	/*****  GEN2  *****/
	buff_idx=buff_entries_trace[TEMP_SENSOR_MCP9843_EDGE_1];
	sns_hlth_mtrcs->temp_edge1 = temp_edge1_gen2_data_buffer[buff_idx].temperature;
	buff_idx=buff_entries_trace[TEMP_SENSOR_MCP9843_EDGE_2];
	sns_hlth_mtrcs->temp_edge2 = temp_edge2_gen2_data_buffer[buff_idx].temperature;
	buff_idx=buff_entries_trace[TEMP_SENSOR_MCP9843_PS_GEN_2];
	sns_hlth_mtrcs->temp_ps_gen2 = temp_ps_gen2_data_buffer[buff_idx].temperature;
	buff_idx=buff_entries_trace[TEMP_SENSOR_MCP9843_NIC_1];
	sns_hlth_mtrcs->temp_nic1 = temp_nic1_data_buffer[buff_idx].temperature;
	buff_idx=buff_entries_trace[TEMP_SENSOR_MCP9843_SSD_1];
	sns_hlth_mtrcs->temp_ssd1 = temp_ssd1_data_buffer[buff_idx].temperature;
	buff_idx=buff_entries_trace[TEMP_SENSOR_MCP9843_SSD_2];
	sns_hlth_mtrcs->temp_ssd2 = temp_ssd2_data_buffer[buff_idx].temperature;
	buff_idx=buff_entries_trace[TEMP_SENSOR_MCP9843_SSD_3];
	sns_hlth_mtrcs->temp_ssd3 = temp_ssd3_data_buffer[buff_idx].temperature;
	buff_idx=buff_entries_trace[TEMP_SENSOR_MCP9843_SSD_4];
	sns_hlth_mtrcs->temp_ssd4 = temp_ssd4_data_buffer[buff_idx].temperature;


	buff_idx=buff_entries_trace[PSM_INA230_OBC];
	sns_hlth_mtrcs->obc_power = ((psm_obc_data_buffer[buff_idx].pwr.power)/1000) * 10 ;

	buff_idx=buff_entries_trace[PSM_INA230_PS];
	sns_hlth_mtrcs->ps_power = ((psm_ps_data_buffer[buff_idx].pwr.power)/1000);

	sns_hlth_mtrcs_ipc.Msg_len = sizeof(s_sensor_beacon_info);
	sns_hlth_mtrcs_ipc.Msg_id = SEN_SDR_APP_MH_RSP;
	sns_hlth_mtrcs_ipc.pld.pld_ptr=sns_hlth_mtrcs;
	sns_hlth_mtrcs_ipc.src_entity = OBC_SENSOR_HDLR;

	if(os_itc_msg_send(&sns_hlth_mtrcs_ipc, SDR_APP,1000)== os_success)
	{
		sts = 0;
	}
	return sts;
}

#endif

#if 0
static float sns_data_average(uint8_t ahw_id, uint8_t avg_count)
{
	float avg = 0;
	uint8_t buff_idx;
	if(ahw_id<MAX_AH_INST_ID && avg_count!=0)
	{
		buff_idx=buff_entries_trace[ahw_id];

	switch(ahw_id)
	{
	case DIGITAL_THERMOSTAT_DS620_EDGE:
		for(int i=0; i<avg_count;i++)
		{
			(buff_idx==0)?buff_idx=(SENSOR_MAX_BUFF_SIZE-1):buff_idx--;
			avg += dt_edge_data_buffer[buff_idx].temperature;
		}
		break;
	case DIGITAL_THERMOSTAT_DS620_PS:
		for(int i=0; i<avg_count;i++)
		{
			(buff_idx==0)?buff_idx=(SENSOR_MAX_BUFF_SIZE-1):buff_idx--;
			avg += dt_ps_data_buffer[buff_idx].temperature;
		}
		break;
    case HSC_ADM1176_PS_2:
		for(int i=0; i<avg_count;i++)
		{
			(buff_idx==0)?buff_idx=(SENSOR_MAX_BUFF_SIZE-1):buff_idx--;
			avg += hsc_ps_2_data_buffer[buff_idx].hsc_data.current;
		}
        break;
    case HSC_ADM1176_EDGE:
		for(int i=0; i<avg_count;i++)
		{
			(buff_idx==0)?buff_idx=(SENSOR_MAX_BUFF_SIZE-1):buff_idx--;
			avg += hsc_edge_data_buffer[buff_idx].hsc_data.current;
		}
        break;
	}
	avg=avg/avg_count;
	}
	return avg;
}
#endif
void temp_sns_reconfig(uint32_t ahw_id)
{

	temp_sns_deinit(ahw_id);

	switch(ahw_id)
	{

	   case TEMP_SENSOR_MCP9843_OBC:
		   temp_sns_init(&ahw_ts_obc,&temp_sns_cfg_obc);
		   break;
	   case TEMP_SENSOR_MCP9843_PS:
		   temp_sns_init(&ahw_ts_ps,&temp_sns_cfg_ps);
		   break;
	   case TEMP_SENSOR_MCP9843_EDGE:
		   temp_sns_init(&ahw_ts_edge,&temp_sns_cfg_edge);
		   break;
	   case TEMP_SENSOR_MCP9843_GPS:
		   temp_sns_init(&ahw_ts_gps,&temp_sns_cfg_gps);
		   break;
		   /********* GEN2 *********/
	   case TEMP_SENSOR_MCP9843_EDGE_1:
		   temp_sns_init(&ahw_ts_edge1_gen2,&temp_sns_cfg_edge1_gen2);
		   break;
	   case TEMP_SENSOR_MCP9843_EDGE_2:
		   temp_sns_init(&ahw_ts_edge2_gen2,&temp_sns_cfg_edge2_gen2);
		   break;
	   case TEMP_SENSOR_MCP9843_PS_GEN_2:
		   temp_sns_init(&ahw_ts_ps_gen2,&temp_sns_cfg_ps_gen2);
		   break;
	   case TEMP_SENSOR_MCP9843_NIC_1:
		   temp_sns_init(&ahw_ts_nic1,&temp_sns_cfg_nic1);
		   break;
	   case TEMP_SENSOR_MCP9843_SSD_1:
		   temp_sns_init(&ahw_ts_ssd1,&temp_sns_cfg_ssd1);
		   break;
	   case TEMP_SENSOR_MCP9843_SSD_2:
		   temp_sns_init(&ahw_ts_ssd2,&temp_sns_cfg_ssd2);
		   break;
	   case TEMP_SENSOR_MCP9843_SSD_3:
		   temp_sns_init(&ahw_ts_ssd3,&temp_sns_cfg_ssd3);
		   break;
	   case TEMP_SENSOR_MCP9843_SSD_4:
		   temp_sns_init(&ahw_ts_ssd4,&temp_sns_cfg_ssd4);
		   break;
	}

}


void psm_sns_reconfig(uint32 ahw_id)
{

	psm_sns_deinit(ahw_id);

	switch(ahw_id)
	{

      case PSM_INA230_OBC:
    	   psm_sns_init(&ahw_hpsm_obc,&pwr_sns_mtr_cfg_obc);
		   break;
      case PSM_INA230_PS:
           psm_sns_init(&ahw_hpsm_ps,&pwr_sns_mtr_cfg_ps);
           break;

	}

}

void dt_sns_reconfig(uint32 ahw_id)
{

    dt_sns_deinit(ahw_id);

    switch(ahw_id)
    {

    case DIGITAL_THERMOSTAT_DS620_PS:
    	dt_sns_init(&hdt_ps,&dgtl_thrmst_cfg_ps);
    	break;
    case DIGITAL_THERMOSTAT_DS620_EDGE:
    	dt_sns_init(&hdt_edge,&dgtl_thrmst_cfg_edge);
    	break;
    case DIGITAL_THERMOSTAT_DS620_SPE01:
    	dt_sns_init(&ahw_ts_spe01,&dgtl_thrmst_cfg_spe01);
    	break;
    case DIGITAL_THERMOSTAT_DS620_SPE02:
    	dt_sns_init(&ahw_ts_spe02,&dgtl_thrmst_cfg_spe02);
    	break;
    case DIGITAL_THERMOSTAT_DS620_SPW01:
    	dt_sns_init(&ahw_ts_spw01,&dgtl_thrmst_cfg_spw01);
    	break;
    case DIGITAL_THERMOSTAT_DS620_SPW02:
    	dt_sns_init(&ahw_ts_spw02,&dgtl_thrmst_cfg_spw02);
    	break;
    case DIGITAL_THERMOSTAT_DS620_SPB01:
    	dt_sns_init(&ahw_ts_spb01,&dgtl_thrmst_cfg_spb01);
    	break;
    }
}


void hsc_sns_reconfig(uint32_t ahw_id)
{
	hsc_sns_deinit(ahw_id);

	switch(ahw_id)
	{

	case HSC_ADM1176_EDGE:
         hsc_sns_init(&hsc_edge,&htswp_cntlr_cfg_edge);
         break;
	case HSC_ADM1176_PS_2:
         hsc_sns_init(&hsc_ps_2,&htswp_cntlr_cfg_ps_2);
         break;
	case HSC_ADM1176_PS_1:
		 hsc_sns_init(&hsc_ps_1,&htswp_cntlr_cfg_ps_1);
		 break;

	}
}
void tc_buff_fw_req_queue(uint32 instance_size, uint32 num_of_instance, uint8 queue_id)
{
    os_itc_msg_handle_t sns_req_ipc;
    s_tc_tm_buffer_req *buff_req = os_malloc(sizeof(s_tc_tm_buffer_req));
    if(buff_req)
    {
        os_memset(buff_req, 0, sizeof(s_tc_tm_buffer_req));
        buff_req->queue_id = queue_id;
        buff_req->instance_size = instance_size;
        buff_req->num_instance = num_of_instance;
        buff_req->wrap_dsb = 0;
        buff_req->priority = 0;
        buff_req->strg_flag = 0;
        buff_req->thresh = 0;
        sns_req_ipc.pld.pld_ptr = (void*)buff_req; 
        sns_req_ipc.src_entity = OBC_SENSOR_HDLR;
        sns_req_ipc.Msg_id = OBC_TC_TM_BUFFER_REQ;
        os_itc_msg_send(&sns_req_ipc, HM_MANAGER_IPC_RECEIVE, os_send_itc_wait);
    }
}

void tc_buff_fw_enqueue_req(uint8* data, uint8 queue_id)
{
    os_itc_msg_handle_t sns_req_ipc;
    sns_req_ipc.pld.pld_data = queue_id; 
    sns_req_ipc.pld.pld_ptr = data; 
    sns_req_ipc.src_entity = OBC_SENSOR_HDLR;
    sns_req_ipc.Msg_id = OBC_TC_TM_ENQUEUE_REQ;
    os_itc_msg_send(&sns_req_ipc, HM_MANAGER_IPC_RECEIVE, os_send_itc_wait);
}


uint8_t get_temperature_sensor_cfg(uint16_t ahw_id, temp_sens_cfg* config)
{
	uint8_t ret = 0;
	if(config != NULL)
	{
		switch(ahw_id)
		{
		case TEMP_SENSOR_MCP9843_OBC:
			os_memcpy(config,&temp_sns_cfg_obc,sizeof(temp_sens_cfg));
			break;
		case TEMP_SENSOR_MCP9843_PS:
			os_memcpy(config,&temp_sns_cfg_ps,sizeof(temp_sens_cfg));
			break;
		case TEMP_SENSOR_MCP9843_EDGE:
			os_memcpy(config,&temp_sns_cfg_edge,sizeof(temp_sens_cfg));
			break;
		case TEMP_SENSOR_MCP9843_GPS:
			os_memcpy(config,&temp_sns_cfg_gps,sizeof(temp_sens_cfg));
			break;

		case TEMP_SENSOR_MCP9843_EDGE_1:
			os_memcpy(config,&temp_sns_cfg_edge1_gen2,sizeof(temp_sens_cfg));
			break;
		case TEMP_SENSOR_MCP9843_EDGE_2:
			os_memcpy(config,&temp_sns_cfg_edge2_gen2,sizeof(temp_sens_cfg));
			break;
		case TEMP_SENSOR_MCP9843_PS_GEN_2:
			os_memcpy(config,&temp_sns_cfg_ps_gen2,sizeof(temp_sens_cfg));
			break;
		case TEMP_SENSOR_MCP9843_NIC_1:
			os_memcpy(config,&temp_sns_cfg_nic1,sizeof(temp_sens_cfg));
			break;
		case TEMP_SENSOR_MCP9843_SSD_1:
			os_memcpy(config,&temp_sns_cfg_ssd1,sizeof(temp_sens_cfg));
			break;
		case TEMP_SENSOR_MCP9843_SSD_2:
			os_memcpy(config,&temp_sns_cfg_ssd2,sizeof(temp_sens_cfg));
			break;
		case TEMP_SENSOR_MCP9843_SSD_3:
			os_memcpy(config,&temp_sns_cfg_ssd3,sizeof(temp_sens_cfg));
			break;
		case TEMP_SENSOR_MCP9843_SSD_4:
			os_memcpy(config,&temp_sns_cfg_ssd4,sizeof(temp_sens_cfg));
			break;

		default:
			ret =1;
			break;
		}
	}
	else
	{
		ret =1;
	}
	return ret;
}

uint8_t get_power_monitor_sensor_cfg(uint16_t ahw_id, power_sense_mntr_cfg* config)
{
	uint8_t ret = 0;
	if(config != NULL)
	{
		switch(ahw_id)
		{
		case PSM_INA230_OBC:
			os_memcpy(config,&pwr_sns_mtr_cfg_obc,sizeof(power_sense_mntr_cfg));
			break;
		case PSM_INA230_PS:
			os_memcpy(config,&pwr_sns_mtr_cfg_ps,sizeof(power_sense_mntr_cfg));
			break;
		case PSM_INA230_PS_GEN_2:
			os_memcpy(config,&pwr_sns_mtr_cfg_ps_gen2,sizeof(power_sense_mntr_cfg));
			break;
		case PSM_INA230_CORE_BRD_A:
			os_memcpy(config,&pwr_sns_mtr_cfg_core_brd_a,sizeof(power_sense_mntr_cfg));
			break;
		case PSM_INA230_CORE_BRD_B:
			os_memcpy(config,&pwr_sns_mtr_cfg_core_brd_b,sizeof(power_sense_mntr_cfg));
			break;
		case PSM_INA230_PS_1:
			os_memcpy(config,&pwr_sns_mtr_cfg_ps1,sizeof(power_sense_mntr_cfg));
			break;
		case PSM_INA230_PS_2:
			os_memcpy(config,&pwr_sns_mtr_cfg_ps2,sizeof(power_sense_mntr_cfg));
			break;
		case PSM_INA230_EDGE_1:
			os_memcpy(config,&pwr_sns_mtr_cfg_edge1,sizeof(power_sense_mntr_cfg));
			break;
		case PSM_INA230_EDGE_2_IN_SUPPLY:
			os_memcpy(config,&pwr_sns_mtr_cfg_edge2_supply,sizeof(power_sense_mntr_cfg));
			break;
		case PSM_INA230_IO_BRD_IN_SUPPLY:
			os_memcpy(config,&pwr_sns_mtr_cfg_io_supply,sizeof(power_sense_mntr_cfg));
			break;

		default:
			ret =1;
			break;
		}
	}
	else
	{
          ret =1;
	}
	return ret;
}


uint8_t get_hotswap_cntlr_sensor_cfg(uint16_t ahw_id, hotswap_cntlr_cfg* config)
{
	uint8_t ret = 0;
	if(config != NULL)
	{
		switch(ahw_id)
		{
		case HSC_ADM1176_EDGE:
			os_memcpy(config,&htswp_cntlr_cfg_edge,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_PS_1:
			os_memcpy(config,&htswp_cntlr_cfg_ps_1,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_PS_2:
			os_memcpy(config,&htswp_cntlr_cfg_ps_2,sizeof(hotswap_cntlr_cfg));
			break;

		case HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY:
			os_memcpy(config,&htswp_cntlr_ps_brd_supply,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_PS_1_IN_SUPPLY:
			os_memcpy(config,&htswp_cntlr_ps1_supply,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_PS_2_IN_SUPPLY:
			os_memcpy(config,&htswp_cntlr_ps2_supply,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_EDGE_1_IN_SUPPLY:
			os_memcpy(config,&htswp_cntlr_edge1_supply,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_EDGE_1_HEAT_COIL:
			os_memcpy(config,&htswp_cntlr_edge1_heat_coil,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_EDGE_2_IN_SUPPLY:
			os_memcpy(config,&htswp_cntlr_edge2_supply,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_EDGE_2_HEAT_COIL:
			os_memcpy(config,&htswp_cntlr_edge2_heat_coil,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_IO_BRD_IN_SUPPLY:
			os_memcpy(config,&htswp_cntlr_io_brd_supply,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1:
			os_memcpy(config,&htswp_cntlr_io_brd_top1,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2:
			os_memcpy(config,&htswp_cntlr_io_brd_top2,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1:
			os_memcpy(config,&htswp_cntlr_io_brd_bot1,sizeof(hotswap_cntlr_cfg));
			break;
		case HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2:
			os_memcpy(config,&htswp_cntlr_io_brd_bot2,sizeof(hotswap_cntlr_cfg));
			break;

		default:
			ret =1;
			break;
		}
	}
	else
	{
          ret =1;
	}
	return ret;
}

uint8_t get_dgtl_thermst_sensor_cfg(uint16_t ahw_id, digital_thermostat_cfg* config)
{
	uint8_t ret = 0;
	if(config != NULL)
	{
		switch(ahw_id)
		{
		case PSM_INA230_OBC:
			os_memcpy(config,&dgtl_thrmst_cfg_edge,sizeof(digital_thermostat_cfg));
			break;
		case PSM_INA230_PS:
			os_memcpy(config,&dgtl_thrmst_cfg_ps,sizeof(digital_thermostat_cfg));
			break;
		default:
			ret =1;
			break;
		}
	}
	else
	{
          ret =1;
	}
	return ret;
}


#if 0

	   case PSM_INA230_OBC:
	   case	IMU_BMX160_OBC_1:
	   case	IMU_BMX160_OBC_2:
	   case THRUSTER_MORPHEUS_OBC: // need to check
	   case VOLTAGE_SEQUENCER_UCD9801_OBC:// need to check
	    break;
	   case PSM_INA230_PS:
	   case DIGITAL_THERMOSTAT_DS620_PS:
	   case HSC_ADM1176_PS_1:
	   case HSC_ADM1176_PS_2:
	   case DATA_LOGGER_ADS7828_PS: // need to check
		break;
	   case TEMP_SENSOR_MCP9843_EDGE:
	   case	DIGITAL_THERMOSTAT_DS620_EDGE:
	   case	HSC_ADM1176_EDGE:
		   temp_sns_init(&ahw_ts_edge,&temp_sns_cfg_edge);
		break;
	   case TEMP_SENSOR_MCP9843_GPS:
	}
}
#endif
