/*
 * @file sensors_action.c
 *
 * @brief This file contains function definition to
 * handle the sensor events
 *
 * @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 "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 "exo_gpio.h"



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


extern volatile uint8_t kernel_init_status;
static os_itc_msg_handle_t sns_int_ipc;

/**
 * @brief ON-board controller temperature sensor event handle callback function
 */
void obc_temp_sns_isr()
{
	if(kernel_init_status!=0)
	{
		sns_int_ipc.pld_info=SNS_INTERRUPT;
		sns_int_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_OBC;
		os_itc_msg_send(&sns_int_ipc,OBC_SENSOR_HDLR,0);
	}
}

/**
 * @brief ON-board controller power sense monitor event handle callback function
 */
void obc_pwr_sns_isr()
{
	if(kernel_init_status!=0)
	{
		sns_int_ipc.pld_info=SNS_INTERRUPT;
		sns_int_ipc.pld.pld_data= PSM_INA230_OBC;
		os_itc_msg_send(&sns_int_ipc,OBC_SENSOR_HDLR,0);
	}
}

/**
 * @brief Payload server power sense monitor event handle callback function
 */
void ps_pwr_sns_isr()
{
	if(kernel_init_status!=0)
	{
		sns_int_ipc.pld_info=SNS_INTERRUPT;
		sns_int_ipc.pld.pld_data=PSM_INA230_PS;
		os_itc_msg_send(&sns_int_ipc,OBC_SENSOR_HDLR,0);

	}
}

/**
 * @brief Payload server temperature sensor event handle callback function
 */
void ps_temp_sns_isr()
{
	if(kernel_init_status!=0)
	{
		sns_int_ipc.pld_info=SNS_INTERRUPT;
		sns_int_ipc.pld.pld_data=TEMP_SENSOR_MCP9843_PS;
		os_itc_msg_send(&sns_int_ipc,OBC_SENSOR_HDLR,0);
	}
}

/**
 * @brief GPS temperature sensor event handle callback function
 */
void gps_temp_sns_isr()
{
	if(kernel_init_status!=0)
	{
		sns_int_ipc.pld_info=SNS_INTERRUPT;
		sns_int_ipc.pld.pld_data= TEMP_SENSOR_MCP9843_GPS;
		os_itc_msg_send(&sns_int_ipc,OBC_SENSOR_HDLR,0);
	}
}

/**
 * @brief Edge temperature sensor event handle callback function
 */
void edge_temp_sns_isr()
{
	if(kernel_init_status!=0)
	{
		sns_int_ipc.pld_info=SNS_INTERRUPT;
		sns_int_ipc.pld.pld_data= TEMP_SENSOR_MCP9843_EDGE;
		os_itc_msg_send(&sns_int_ipc,OBC_SENSOR_HDLR,0);
	}
}
