/*
 * @file ina230_interface.c
 *
 * @brief This file contains function definition to read and
 * store the data from digital thermostat
 *
 * @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 "ina230_interface.h"

extern ahw_al_psm_hdle ahw_hpsm_ps;
extern ahw_al_psm_hdle ahw_hpsm_obc;

os_timer_handle_ptr psm_polling_tmr;
extern os_queue_handle_ptr sensor_polling_q;

/**
 * @brief Application API to get the power sense monitor data with the given instance id
 */
void psm_get_func(psm_get_info_s *psm_param,uint8_t psm_inst_id)
{
	if(psm_inst_id == PSM_INA230_OBC)
	{
		psm_param->vbus_voltage = ahw_al_psm_get_vbus(psm_inst_id);
		psm_param->vshunt_voltage = ahw_al_psm_get_vshunt(psm_inst_id);
		psm_param->power  = ahw_al_psm_get_power(psm_inst_id);
		psm_param->current  = ahw_al_psm_get_current(psm_inst_id);
	}
	else if(psm_inst_id == PSM_INA230_PS)
	{
		psm_param->vbus_voltage = ahw_al_psm_get_vbus(psm_inst_id);
		psm_param->vshunt_voltage = ahw_al_psm_get_vshunt(psm_inst_id);
		psm_param->power  = ahw_al_psm_get_power(psm_inst_id);
		psm_param->current  = ahw_al_psm_get_current(psm_inst_id);
	}

	else if(psm_inst_id == PSM_INA230_PS_GEN_2)
	{
		psm_param->vbus_voltage = ahw_al_psm_get_vbus(psm_inst_id);
		psm_param->vshunt_voltage = ahw_al_psm_get_vshunt(psm_inst_id);
		psm_param->power  = ahw_al_psm_get_power(psm_inst_id);
		psm_param->current  = ahw_al_psm_get_current(psm_inst_id);
	}
	else if(psm_inst_id == PSM_INA230_CORE_BRD_A)
	{
		psm_param->vbus_voltage = ahw_al_psm_get_vbus(psm_inst_id);
		psm_param->vshunt_voltage = ahw_al_psm_get_vshunt(psm_inst_id);
		psm_param->power  = ahw_al_psm_get_power(psm_inst_id);
		psm_param->current  = ahw_al_psm_get_current(psm_inst_id);
	}
	else if(psm_inst_id == PSM_INA230_CORE_BRD_B)
	{
		psm_param->vbus_voltage = ahw_al_psm_get_vbus(psm_inst_id);
		psm_param->vshunt_voltage = ahw_al_psm_get_vshunt(psm_inst_id);
		psm_param->power  = ahw_al_psm_get_power(psm_inst_id);
		psm_param->current  = ahw_al_psm_get_current(psm_inst_id);
	}
	else if(psm_inst_id == PSM_INA230_PS_1)
	{
		psm_param->vbus_voltage = ahw_al_psm_get_vbus(psm_inst_id);
		psm_param->vshunt_voltage = ahw_al_psm_get_vshunt(psm_inst_id);
		psm_param->power  = ahw_al_psm_get_power(psm_inst_id);
		psm_param->current  = ahw_al_psm_get_current(psm_inst_id);
	}
	else if(psm_inst_id == PSM_INA230_PS_2)
	{
		psm_param->vbus_voltage = ahw_al_psm_get_vbus(psm_inst_id);
		psm_param->vshunt_voltage = ahw_al_psm_get_vshunt(psm_inst_id);
		psm_param->power  = ahw_al_psm_get_power(psm_inst_id);
		psm_param->current  = ahw_al_psm_get_current(psm_inst_id);
	}
	else if(psm_inst_id == PSM_INA230_EDGE_2_IN_SUPPLY)
	{
		psm_param->vbus_voltage = ahw_al_psm_get_vbus(psm_inst_id);
		psm_param->vshunt_voltage = ahw_al_psm_get_vshunt(psm_inst_id);
		psm_param->power  = ahw_al_psm_get_power(psm_inst_id);
		psm_param->current  = ahw_al_psm_get_current(psm_inst_id);
	}
	else if(psm_inst_id == PSM_INA230_IO_BRD_IN_SUPPLY)
	{
		psm_param->vbus_voltage = ahw_al_psm_get_vbus(psm_inst_id);
		psm_param->vshunt_voltage = ahw_al_psm_get_vshunt(psm_inst_id);
		psm_param->power  = ahw_al_psm_get_power(psm_inst_id);
		psm_param->current  = ahw_al_psm_get_current(psm_inst_id);
	}
	else if(psm_inst_id == PSM_INA230_EDGE_1)
	{
		psm_param->vbus_voltage = ahw_al_psm_get_vbus(psm_inst_id);
		psm_param->vshunt_voltage = ahw_al_psm_get_vshunt(psm_inst_id);
		psm_param->power  = ahw_al_psm_get_power(psm_inst_id);
		psm_param->current  = ahw_al_psm_get_current(psm_inst_id);
	}
	else
	{
		DEBUG_CPRINT(("Invalid Id"));
	}
}

