/*
 * @file adm1176_interface.c
 *
 * @brief This file contains function definition to read and
 * store the data from hotswap controller
 *
 * @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.
 */

#include "adm1176_interface.h"

extern ahw_al_hsc_hdl hsc_edge;
extern ahw_al_hsc_hdl hsc_ps_1;
extern ahw_al_hsc_hdl hsc_ps_2;

os_timer_handle_ptr hsc_polling_tmr;
extern os_queue_handle_ptr sensor_polling_q;

/**
 * @brief Application API to get the voltage with the given instance id
 */
void hsc_get_func(adm_get_info_s *adm_param,uint8_t adm_inst_id)
{
	switch(adm_inst_id)
	{
	case HSC_ADM1176_EDGE:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_EDGE,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_EDGE,&adm_param->current);
	}
	break;

	case HSC_ADM1176_PS_1:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_PS_1,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_PS_1,&adm_param->current);
	}
	break;

	case HSC_ADM1176_PS_2:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_PS_2,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_PS_2,&adm_param->current);
	}
	break;

    /***** GEN2 HSC *****/
	case HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY,&adm_param->current);
	}
	break;

	case HSC_ADM1176_PS_1_IN_SUPPLY:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_PS_1_IN_SUPPLY,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_PS_1_IN_SUPPLY,&adm_param->current);
	}
	break;

	case HSC_ADM1176_PS_2_IN_SUPPLY:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_PS_2_IN_SUPPLY,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_PS_2_IN_SUPPLY,&adm_param->current);
	}
	break;

	case HSC_ADM1176_EDGE_1_IN_SUPPLY:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_EDGE_1_IN_SUPPLY,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_EDGE_1_IN_SUPPLY,&adm_param->current);
	}
	break;

	case HSC_ADM1176_EDGE_1_HEAT_COIL:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_EDGE_1_HEAT_COIL,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_EDGE_1_HEAT_COIL,&adm_param->current);
	}
	break;

	case HSC_ADM1176_EDGE_2_IN_SUPPLY:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_EDGE_2_IN_SUPPLY,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_EDGE_2_IN_SUPPLY,&adm_param->current);
	}
	break;

	case HSC_ADM1176_EDGE_2_HEAT_COIL:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_EDGE_2_HEAT_COIL,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_EDGE_2_HEAT_COIL,&adm_param->current);
	}
	break;

	case HSC_ADM1176_IO_BRD_IN_SUPPLY:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_IO_BRD_IN_SUPPLY,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_IO_BRD_IN_SUPPLY,&adm_param->current);
	}
	break;

	case HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1,&adm_param->current);
	}
	break;

	case HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2,&adm_param->current);
	}
	break;

	case HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1,&adm_param->current);
	}
	break;

	case HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2:
	{
		ahw_al_hsc_read_voltage(HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2,&adm_param->voltage);
		ahw_al_hsc_read_current(HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2,&adm_param->current);
	}
	break;

	default:
		DEBUG_CPRINT(("Invalid ID"));
		break;
	}
}

