#ifndef _OBC_TC_TM_SAMPLE_H_
#define _OBC_TC_TM_SAMPLE_H_

#include "exo_types.h"
#include "exo_osal_mem_management.h"
#include "exo_osal_common.h"
#include "tc_common.h"
#include "tm_common.h"
#include "tc_tm_lib_common.h"
#include "eps.h"
#include "exo_types.h"
#include "exo_osal_mem_cpy.h"
#include "thruster_tc_tm.h"

/**
 *  @brief  TCTM Encoder Decoder API Execution status macros
 */
#define TCTM_OK                   (0)      ///< Success return value
#define TCTM_NULL_PTR             (-1)     ///< Null pointer return value
#define OBC_ENBL_DBG_PRNT         (1)      ///< Macro for enabling debug prints


//#define TM_SRC_OBC                  0x81           ///< TM Source ID configuration value for OBC
//#define TM_SRC_PS                   0x86           ///< TM Source ID configuration value for PS
#define TM_SRC_PS                   TM_SRC_PLD_SRVR///< TM Source ID configuration value for PS

#if defined(JANUS1)
#define PLD_HW_ID_TRANS         (0x4001)
#define PLD_HW_ID_AICraft       (0x4002)
#define PLD_HW_ID_ZES           (0x4003)
#define PLD_HW_ID_SAYAR         (0x4004)
#define PLD_HW_ID_NETRA         (0x4005)
#else
/** J2 specific payloads */
#define PLD_HW_ID_TRANS         (0x4001)
#define PLD_HW_ID_SCANWAY       (0x4002)
#define PLD_HW_ID_NETRA         (0x4003)
#endif

#define SNS_CALIB_DATA_CNT  7


typedef enum _obc_ps_trig_resp_check
{
    OBC_PS_IPCC_TRIG_STS_NTF,
    OBC_PS_IPCC_RESP_RCV_NTF

}obc_ps_trig_resp_check;


typedef struct
{
   uint64_t total_mem;
   uint64_t used_mem;
   uint64_t available_mem;

}__attribute__((__packed__)) iram_heap_status ;

typedef struct
{
    uint64_t iram_heap_mem_total;
    uint64_t iram_heap_mem_used;
    uint64_t eram_heap_mem_total;
    uint64_t eram_heap_mem_used;
    uint64_t eflash_qspi_mem_total;
    uint64_t eflash_qspi_mem_used;
    uint64_t eflash_fmc_mem_total;
    uint64_t eflash_fmc_mem_used;
    uint64_t eram_mem_total;
    uint64_t eram_mem_used;


}__attribute__((__packed__)) sys_mem_status ;

typedef enum
{
	MEM_TYPE_IRAM = 0,
	MEM_TYPE_SDRAM,
	MEM_TYPE_IFLASH,
	MEM_TYPE_QSPI,
	MEM_TYPE_NOR_FLASH

}mem_type;

typedef struct
{
    uint8_t mode;
    ptr_typ address;
    uint16_t len;
    uint8_t mem_type;
}__attribute__ ((__packed__))nvm_param;

typedef struct
{
    uint32_t tm_rsp_id;
	uint16_t  rx_data_len;
	uint16_t  tx_data_len;
    uint8_t* rx_data;
	uint8_t* tx_data;
}obc_pck_data;

typedef struct
{
    uint32_t io_fault;
	uint32_t ahw_fault;
	uint32_t sys_fault;
    uint32_t ser_fault;

}err_hdle_fault_sts;

typedef struct
{
    uint32_t instance_id;
    uint32_t polling_tmr_prdcty;
    float high_temp_thrsld;
    float low_temp_thrsld;
    uint8_t adc_resolution;
    uint8_t thrmst_enable;
    uint8_t thrmst_pin_polarity;
    uint8_t conversion_type;

}__attribute__ ((__packed__))digital_thermostat_cfg;

typedef struct
{
    uint32_t instance_id;
    uint32_t polling_tmr_prdcty;
    float high_temp_thrsld;
    float low_temp_thrsld;
    uint8_t adc_resolution;
    uint8_t intr_mask;
    uint8_t intr_pin_polarity;
    uint8_t conversion_type;

}__attribute__((packed, aligned(4)))temp_sens_cfg;

typedef struct
{
    uint32_t instance_id;
    uint8_t intr_mask;
    uint8_t intr_pin_polarity;

}__attribute__((packed, aligned(4)))gpio_exp_cfg;

typedef struct
{
    uint32_t instance_id;
    uint32_t polling_tmr_prdcty;
    float voltage_thrsld;
    float current_thrsld;
    uint8_t intr_msk;
    uint8_t intr_pin_polarity;
    uint8_t hotswap_sts;
    uint8_t conversion_type;

}__attribute__((packed, aligned(4)))hotswap_cntlr_cfg;

typedef struct
{
    uint32_t instance_id;
    uint32_t polling_tmr_prdcty;
    float vbus_thrsld;
    uint32_t power_thrsld;
    float current_thrsld;
    uint8_t intr_type;
    uint8_t intr_pin_polarity;
    uint8_t conversion_type;

}__attribute__((packed, aligned(4)))power_sense_mntr_cfg;

typedef struct
{
    uint32_t instance_id;
    uint32_t polling_tmr_prdcty;
    uint8_t  intr_mask;

}__attribute__((packed, aligned(4)))voltage_seq_mntr_cfg;

typedef struct
{
	uint64_t 		mem_address;		///> data download from memory address
	uint32_t 		mem_size;			///> size to be downloaded
	uint16_t 		ftm_ftds_cfg;
	uint16_t 		ftm_mtu_cfg;
	uint8_t 		ftm_seq_detct_cfg;
	uint8_t 	    mem_type;

}obc_mem_dwldr_request_form_def;

typedef struct
{
    uint8_t calib_data_cnt;
    uint32_t instance_id;
    uint8_t mjr_vrsn;
    uint8_t mnr_vrsn;
    uint16_t ptch_vrsn;
    uint8_t brd_err_cde;
    uint8_t brd_err_count;
    uint8_t rst_sts;
    uint32_t strt_tm;
    uint32_t master_tm;
    uint32_t bkpln_master_tm;			/*!< master time of backplane			*/
    uint8_t rst_backplane;		    	/*!< backplane reset			    	*/
    uint16_t pwr;		    		/*!< power		    			*/
    uint16_t unreg_vol;			    	/*!< unregulated voltage			*/
    uint32_t unit_master_tm;			/*!< master time of unit			*/
    uint8_t mode;		    		/*!< mode		    			*/
    uint16_t dev_on_sts;		    	/*!< device on status				*/
    uint8_t rst_sts_unit;		    	/*!< reset status of unit		    	*/
    int8_t temp;		    		/*!< temperature	    			*/
    uint16_t prplt;		    		/*!< propellant		    			*/
    uint16_t force;		    		/*!< force		    			*/
    uint16_t azmth; 				/*!< azimuthal angle		    		*/
    uint8_t polar;		    		/*!< polar angle		    		*/
    uint16_t unregu_vol;		    	/*!< unregulated voltage		    	*/
    uint32_t calib_data[SNS_CALIB_DATA_CNT]; 			/*!< calibration value		    		*/
    uint8_t heat_err;		    		/*!< heater error		    		*/
    uint8_t heat_duty;		    		/*!< heater duty cycle			    	*/
    int8_t heat_temp;		    		/*!< heater temperature			    	*/
    int8_t heat_targ_temp;		    	/*!< heater target temperature			*/
    uint16_t emit_vol;			    	/*!< emitter voltage			    	*/
    uint16_t emit_cur;			    	/*!< emitter current			    	*/
    uint16_t emit_ip_cur;	    		/*!< emitter current			    	*/
    uint16_t ext1_vol;		    		/*!< extractor1 voltage			    	*/
    uint16_t ext1_cur;		    		/*!< extractor1 current			    	*/
    uint16_t ext1_ip_cur;	    		/*!< extractor1 input current			*/
    uint16_t ext2_vol;		    		/*!< extractor2 voltage			    	*/
    uint16_t ext2_cur;		    		/*!< extractor2 current		    		*/
    uint16_t ext2_ip_cur;	    		/*!< extractor2 input current			*/
    uint16_t ext3_vol;		    		/*!< extractor3 voltage			    	*/
    uint16_t ext3_cur;		    		/*!< extractor3 voltage			    	*/
    uint16_t ext3_ip_cur;	    		/*!< extractor3 voltage			    	*/
    uint16_t ext4_vol;		    		/*!< extractor4 voltage			    	*/
    uint16_t ext4_cur;		    		/*!< extractor4 voltage			    	*/
    uint16_t ext4_ip_cur;	    		/*!< extractor4 voltage			    	*/
    uint16_t ext5_vol;		    		/*!< extractor5 voltage			    	*/
    uint16_t ext5_cur;		    		/*!< extractor5 voltage			    	*/
    uint16_t ext5_ip_cur;	    		/*!< extractor5 voltage				*/
    uint16_t ext6_vol;		    		/*!< extractor6 voltage				*/
    uint16_t ext6_cur;		    		/*!< extractor6 voltage	    			*/
    uint16_t ext6_ip_cur;   			/*!< extractor6 voltage	    			*/
    uint16_t ext7_vol;	    			/*!< extractor7 voltage	    			*/
    uint16_t ext7_cur;	    			/*!< extractor7 voltage	    			*/
    uint16_t ext7_ip_cur;   			/*!< extractor7 voltage				*/
    uint16_t neut1_vol;	    			/*!< neutralizer1 voltage	    		*/
    uint16_t neut1_cur;	    			/*!< neutralizer1 current		    	*/
    uint16_t neut1_ip_cur;  			/*!< neutralizer1 input current			*/
    uint16_t neut1_ret_cur; 			/*!< neutralizer1 return current		*/
    uint16_t neut2_vol;	    			/*!< neutralizer2 voltage	    		*/
    uint16_t neut2_cur;	    			/*!< neutralizer2 current		    	*/
    uint16_t neut2_ip_cur;	    		/*!< neutralizer2 input current			*/
    uint16_t neut2_ret_cur;	    		/*!< neutralizer2 return current		*/
    uint16_t tot_force;				/*!< total force	    		*/
    uint16_t tot_azmth;				/*!< total azimuthal angle		*/
    uint8_t tot_polar;				/*!< total polar angle		    	*/
    uint16_t tot_pwr_cnsp;		/*!< total power consumption		*/
    uint16_t force_unit1;			/*!< force of unit1     	    	*/
    uint8_t azmth_unit1;			/*!< azimuthal angle of unit1	        */
    uint16_t polar_unit1;			/*!< polar angle of unit1	    	*/
    uint16_t pwr_unit1;				/*!< power of unit1	    		*/
    uint8_t mode_unit1;				/*!< mode of unit1	    		*/
    uint16_t force_unit2;			/*!< force of unit2	    		*/
    uint8_t polar_unit2;			/*!< polar angle of unit2   		*/
    uint16_t azmth_unit2;			/*!< azimuthal angle of unit2		*/
    uint16_t pwr_unit2;				/*!< power of unit2		    	*/
    uint8_t mode_unit2;				/*!< mode of unit2  			*/

}__attribute__ ((__packed__))thruster_info;

typedef struct
{
    uint32_t instance_id;
    uint8_t unit_num;
    uint8_t mode;
    float force;

}__attribute__((packed, aligned(4)))thruster_param;

typedef struct
{
    uint32_t instance_id;
    uint8_t chnl_num;
    uint8_t pwr_dwn_optn;
    uint16_t data;

}__attribute__ ((__packed__))data_acq_dvc_info;

typedef struct
{
    uint32_t instance_id;
    uint32_t timer_idx;
    uint8_t event_ctrl;
    uint8_t chnl_num;
    uint8_t pwr_dwn_optn;

}__attribute__((packed, aligned(4)))data_acq_dvc_param;

typedef struct
{
    uint32_t instance_id;
    /*! X-axis sensor data */
    int16_t accel_x;
    /*! Y-axis sensor data */
    int16_t accel_y;
    /*! Z-axis sensor data */
    int16_t accel_z;
    /*! X-axis sensor data */
    int16_t gyro_x;
    /*! Y-axis sensor data */
    int16_t gyro_y;
    /*! Z-axis sensor data */
    int16_t gyro_z;
    /*! X-axis sensor data */
    int16_t mag_x;
    /*! Y-axis sensor data */
    int16_t mag_y;
    /*! Z-axis sensor data */
    int16_t mag_z;
    /*! rhall data */
    int16_t mag_rhall;
    /*! power mode */
    uint8_t power;
    /*! output data rate */
    uint8_t odr;
    /*! range */
    uint8_t range;
    /*! bandwidth */
    uint8_t bw;

}__attribute__ ((__packed__))imu_info;

typedef struct
{
    uint32_t instance_id;
    uint32_t timer_idx;
    uint8_t event_ctrl;
    /*! power mode */
    uint8_t power;
    /*! output data rate */
    uint8_t odr;
    /*! range */
    uint8_t range;
    /*! bandwidth */
    uint8_t bw;

}__attribute__((packed, aligned(4)))imu_param;

/*********************************************************************************/
/***************** TeleCommand Payload Structure Definitions *********************/
/*********************************************************************************/

/*!
 *  @brief This structure holds the Target Pointing request parameter information
 */
typedef struct _tctm_trgt_pt_req
{
    float lat;
    float longit;
    float alt;
    uint8 pld_hw_id;
    uint8 act_tmr_min;
    uint8 act_tmr_sec;
    uint16 act_tmr_ms;
}tctm_trgt_pt_req_s;

typedef struct tc_defferd_strg_t
{
    uint32 wrt_offset;
    uint16 data_len;
    uint8* defferd_data_ptr;
}s_tc_defferd_strg;

typedef struct
{
	uint8_t down_via_tm_or_ftm : 4;
	uint8_t seq_loss_enable : 1;
	uint8_t reserved : 3;
	uint16_t down_blocks;
	uint16_t down_mtu;
	uint16_t sat_ftds;
}__attribute__((__packed__))log_data_s;

/*********************************************************************************/
/******************* TeleMetry Payload Structure Definitions *********************/
/*********************************************************************************/

/*!
 *  @brief This structure holds the location information
 */
typedef struct _tctm_gnss_loc_info
{
    uint8 status;
    float lat;
    float longit;
    float alt;
}__attribute__((__packed__))tctm_gnss_loc_info_s;

/**
 *  *   @brief UART Init Structure definition
 *   **/
typedef struct
{
    uint32_t baudrate;
    uint32_t wordlength;
    uint32_t stopbits;
    uint32_t parity;
    uint32_t mode;
    uint32_t hw_flow_ctl;
    uint32_t over_sampling;
    uint32_t onebit_sampling;
}__attribute__((__packed__))tctm_uart_init_s;


/**
 * *  @brief USB Instance Initialization Structure definition
 * */
typedef struct
{
    uint32_t dev_endpoints;
    uint32_t host_channels;
    uint32_t speed;
    uint32_t dma_enable;
    uint32_t ep0_mps;
    uint32_t phy_itface;
    uint32_t sof_enable;
    uint32_t low_power_enable;
    uint32_t lpm_enable;
    uint32_t battery_charging_enable;
    uint32_t vbus_sensing_enable;
    uint32_t use_dedicated_ep1;
    uint32_t use_external_vbus;

}__attribute__((__packed__))tctm_usb_otg_cfg_s;


/**
 *  * @defgroup I2C_Configuration_Structure_definition I2C Configuration Structure definition
 *   * @brief  I2C Configuration Structure definition
 *    *
 *     **/
typedef struct
{
    uint32_t timing;
    uint32_t own_address1;
    uint32_t addressing_mode;
    uint32_t dual_address_mode;
    uint32_t own_address2;
    uint32_t own_address2_masks;
    uint32_t generalcall_mode;
    uint32_t no_stretch_mode;
}__attribute__((__packed__))tctm_i2c_init_s;
/**
 *  *  @brief  CAN init structure definition
 *   **/
typedef struct
{
    uint32_t prescaler;
    uint32_t mode;
    uint32_t syncjumpwidth;
    uint32_t time_seg1;
    uint32_t time_seg2;
    uint8_t  time_triggered_mode;
    uint8_t  autobus_off;
    uint8_t  autowake_up;
    uint8_t  auto_retransmission;
    uint8_t  receive_fifo_locked;
    uint8_t  transmit_fifo_priority;

}__attribute__((__packed__))tctm_can_init_s;

/*
 * @brief  ETH Init Structure definition
 */
typedef struct
{
    uint32_t  auto_negotiation;
    uint32_t  speed;
    uint32_t  duplex_mode;
    uint16_t  phy_address;
    uint8_t   *mac_addr;
    uint32_t  rx_mode;
    uint32_t  checksum_mode;
    uint32_t  media_interface;

}__attribute__((__packed__))tctm_ethernet_init_s;


/**
 *  *   @brief  SPI Configuration Structure definition
 *   **/
typedef struct
{
    uint32_t mode;
    uint32_t direction;
    uint32_t datasize;
    uint32_t clk_polarity;
    uint32_t clk_phase;
    uint32_t nss;
    uint32_t baudrate_prescaler;
    uint32_t firstbit;
    uint32_t timode;
    uint32_t crc_calculation;
    uint32_t crc_polynomial;
    uint32_t crc_length;
    uint32_t nssp_mode;
}__attribute__((__packed__))tctm_spi_init_s;

typedef struct
{
    uint8_t dev_id;
    uint8_t temp;
}ps_get_temp_s;

typedef struct
{
    uint8_t dev_id;
    uint32_t uptime;
    uint32_t epoch_time;
}ps_get_time_s;

typedef struct
{
    uint8_t dev_id;
    char processor_name[50];
    uint8_t chip_id;
    uint32_t clock_speed;
    uint8_t cores;
    uint32_t cache_size;
}__attribute__((__packed__))ps_get_chip_info_s;

typedef struct
{
    uint8_t dev_id;
    uint64_t tot_mem;
    uint64_t available_mem;
    uint64_t free_mem;
}ps_get_ext_mem_s;

typedef struct
{
    uint8_t dev_id;
    uint32_t clock_speed;
    uint8_t cores;
    uint32_t cache_size;
}ps_get_feature_s;

typedef struct
{
    uint8_t adc_id;
    uint8_t adc_chnl_id;
    float* adc_vltge;
}__attribute__((__packed__))adc_board_read;


typedef struct
{
    uint8_t ps_id;
    uint8_t ps_ssd_id;
}__attribute__((__packed__))ps_brd_ssd_id;

#if 0
typedef struct _tctm_set_conv_board_par
{
    uint8_t mppt_conv1_enb;
    uint8_t mppt_conv2_enb;
    uint8_t mppt_conv3_enb;
    uint8_t mppt_conv4_enb;
    uint8_t op_conv1_enb;
    uint8_t op_conv2_enb;
    uint8_t op_conv3_enb;
    uint8_t op_conv4_enb;
    float conv1_op_vol_val;
    float conv2_op_vol_val;
    float conv3_op_vol_val;
    float conv4_op_vol_val;

}__attribute__((__packed__))tctm_set_conv_board_par_s;

typedef struct _tctm_get_conv_board_par
{
    uint8_t mppt_conv1_enb;
    uint8_t mppt_conv2_enb;
    uint8_t mppt_conv3_enb;
    uint8_t mppt_conv4_enb;
    uint8_t op_conv1_enb;
    uint8_t op_conv2_enb;
    uint8_t op_conv3_enb;
    uint8_t op_conv4_enb;
    float conv1_op_vol_val;
    float conv2_op_vol_val;
    float conv3_op_vol_val;
    float conv4_op_vol_val;
    float pv1_vol;
    float pv2_vol;
    float pv3_vol;
    float pv4_vol;
    float pv1_cur;
    float pv2_cur;
    float pv3_cur;
    float pv4_cur;

}__attribute__((__packed__))tctm_get_conv_board_par_s;

typedef struct _tctm_set_batt_board_par
{
    float bat_cur_pos;
    float bat_cur_neg;
    uint8_t batt1_temp_low_lmt_val;
    uint8_t batt1_temp_upp_lmt_val;
    uint8_t batt2_temp_low_lmt_val;
    uint8_t batt2_temp_upp_lmt_val;
    uint8_t batt3_temp_low_lmt_val;
    uint8_t batt3_temp_upp_lmt_val;
    uint8_t batt4_temp_low_lmt_val;
    uint8_t batt4_temp_upp_lmt_val;
    uint8_t batt5_temp_low_lmt_val;
    uint8_t batt5_temp_upp_lmt_val;
    uint8_t batt6_temp_low_lmt_val;
    uint8_t batt6_temp_upp_lmt_val;
    uint8_t batt7_temp_low_lmt_val;
    uint8_t batt7_temp_upp_lmt_val;
    uint8_t batt8_temp_low_lmt_val;
    uint8_t batt8_temp_upp_lmt_val;

}__attribute__((__packed__))tctm_set_batt_board_par_s;

typedef struct _tctm_get_batt_board_par
{
    float bat_cur_pos;
    float bat_cur_neg;
    uint8_t batt1_temp_low_lmt_val;
    uint8_t batt1_temp_upp_lmt_val;
    uint8_t batt2_temp_low_lmt_val;
    uint8_t batt2_temp_upp_lmt_val;
    uint8_t batt3_temp_low_lmt_val;
    uint8_t batt3_temp_upp_lmt_val;
    uint8_t batt4_temp_low_lmt_val;
    uint8_t batt4_temp_upp_lmt_val;
    uint8_t batt5_temp_low_lmt_val;
    uint8_t batt5_temp_upp_lmt_val;
    uint8_t batt6_temp_low_lmt_val;
    uint8_t batt6_temp_upp_lmt_val;
    uint8_t batt7_temp_low_lmt_val;
    uint8_t batt7_temp_upp_lmt_val;
    uint8_t batt8_temp_low_lmt_val;
    uint8_t batt8_temp_upp_lmt_val;
    float tot_batt_vol;
    float batt1_vol;
    float batt2_vol;
    float batt3_vol;
    float batt_cur;
    uint8_t batt1_temp;
    uint8_t batt2_temp;
    uint8_t batt3_temp;
    uint8_t batt4_temp;
    uint8_t batt5_temp;
    uint8_t batt6_temp;
    uint8_t batt7_temp;
    uint8_t batt8_temp;

}__attribute__((__packed__))tctm_get_batt_board_par_s;

typedef struct _tctm_out_chnl_enb
{
    uint8_t ch1_enb;
    uint8_t ch2_enb;
    uint8_t ch3_enb;
    uint8_t ch4_enb;
    uint8_t ch5_enb;
    uint8_t ch6_enb;
    uint8_t ch7_enb;
    uint8_t ch8_enb;
    uint8_t ch9_enb;
    uint8_t ch10_enb;
    uint8_t ch11_enb;
    uint8_t ch12_enb;

}__attribute__((__packed__))tctm_out_chnl_enb_s;

typedef struct _tctm_out_chnl_cur_lmt
{
    float ch1_12v_cur_val;
    float ch2_12v_cur_val;
    float ch3_5v_cur_val;
    float ch4_12v_cur_val;
    float ch4_3v_cur_val;
    float ch5_5v_cur_val;
    float ch5_3v_cur_val;
    float ch5_batt_v_cur_val;
    float ch6_12v_cur_val;
    float ch6_3v_cur_val;
    float ch7_3v_cur_val;
    float ch8_5v_cur_val;
    float ch8_3v_cur_val;
    float ch9_5v_cur_val;
    float ch10_batt_v_cur_val;
    float ch11_batt_v_cur_val;
    float ch12_batt_v_cur_val;

}__attribute__((__packed__))tctm_out_chnl_cur_lmt_s;

typedef struct _tctm_out_chnl_par
{
    uint8_t ch1_enb;
    uint8_t ch2_enb;
    uint8_t ch3_enb;
    uint8_t ch4_enb;
    uint8_t ch5_enb;
    uint8_t ch6_enb;
    uint8_t ch7_enb;
    uint8_t ch8_enb;
    uint8_t ch9_enb;
    uint8_t ch10_enb;
    uint8_t ch11_enb;
    uint8_t ch12_enb;
    float ch1_12v_cur_val;
    float ch2_12v_cur_val;
    float ch3_5v_cur_val;
    float ch4_12v_cur_val;
    float ch4_3v_cur_val;
    float ch5_5v_cur_val;
    float ch5_3v_cur_val;
    float ch5_batt_v_cur_val;
    float ch6_12v_cur_val;
    float ch6_3v_cur_val;
    float ch7_3v_cur_val;
    float ch8_5v_cur_val;
    float ch8_3v_cur_val;
    float ch9_5v_cur_val;
    float ch10_batt_v_cur_val;
    float ch11_batt_v_cur_val;
    float ch12_batt_v_cur_val;

}__attribute__((__packed__))tctm_out_chnl_par_s;

typedef struct _tctm_eps_mode_par
{
    float nrml_mde_thrld_vol_val;
    float safe_mde_thrld_vol_val;
    float crtl_mde_thrld_vol_val;
    uint8_t full_mde_ch1_enb;
    uint8_t full_mde_ch2_enb;
    uint8_t full_mde_ch3_enb;
    uint8_t full_mde_ch4_enb;
    uint8_t full_mde_ch5_enb;
    uint8_t full_mde_ch6_enb;
    uint8_t full_mde_ch7_enb;
    uint8_t full_mde_ch8_enb;
    uint8_t full_mde_ch9_enb;
    uint8_t full_mde_ch10_enb;
    uint8_t full_mde_ch11_enb;
    uint8_t full_mde_ch12_enb;
    uint8_t nml_mde_ch1_enb;
    uint8_t nml_mde_ch2_enb;
    uint8_t nml_mde_ch3_enb;
    uint8_t nml_mde_ch4_enb;
    uint8_t nml_mde_ch5_enb;
    uint8_t nml_mde_ch6_enb;
    uint8_t nml_mde_ch7_enb;
    uint8_t nml_mde_ch8_enb;
    uint8_t nml_mde_ch9_enb;
    uint8_t nml_mde_ch10_enb;
    uint8_t nml_mde_ch11_enb;
    uint8_t nml_mde_ch12_enb;
    uint8_t safe_mde_ch1_enb;
    uint8_t safe_mde_ch2_enb;
    uint8_t safe_mde_ch3_enb;
    uint8_t safe_mde_ch4_enb;
    uint8_t safe_mde_ch5_enb;
    uint8_t safe_mde_ch6_enb;
    uint8_t safe_mde_ch7_enb;
    uint8_t safe_mde_ch8_enb;
    uint8_t safe_mde_ch9_enb;
    uint8_t safe_mde_ch10_enb;
    uint8_t safe_mde_ch11_enb;
    uint8_t safe_mde_ch12_enb;
    uint8_t crtl_mde_ch1_enb;
    uint8_t crtl_mde_ch2_enb;
    uint8_t crtl_mde_ch3_enb;
    uint8_t crtl_mde_ch4_enb;
    uint8_t crtl_mde_ch5_enb;
    uint8_t crtl_mde_ch6_enb;
    uint8_t crtl_mde_ch7_enb;
    uint8_t crtl_mde_ch8_enb;
    uint8_t crtl_mde_ch9_enb;
    uint8_t crtl_mde_ch10_enb;
    uint8_t crtl_mde_ch11_enb;
    uint8_t crtl_mde_ch12_enb;

}__attribute__((__packed__))tctm_eps_mode_par_s;

#endif

typedef struct _tctm_set_var_addr
{
    uint8_t slv_addr;
    uint8_t var_addr[4];
    uint8_t reserved[5];
}__attribute__((__packed__))tctm_eps_set_var_addr_s;


int8 obc_tc_ps_pwr_on_dec(const uint8 *data);
int8 obc_tc_pld_hw_pwr_on_dec(const uint8 *data);
int8 obc_tc_pld_vm_pwr_on_dec(const uint8 *data);
int8 obc_tc_sband_pwr_ctrl_dec(const uint8 *data);
int8 obc_tc_xband_pwr_ctrl_dec(const uint8 *data);
int8 obc_tc_adcs_pwr_ctrl_dec(const uint8 *data);
int8 obc_tc_thrust_pwr_ctrl_dec(const uint8 *data);
int8 obc_tc_edge_board_pwr_ctrl_dec(const uint8 *data);
int8 obc_tc_pld_hw_pwr_off_dec(const uint8 *data);
int8 obc_tc_pld_vm_pwr_off_dec(const uint8 *data);
int8 obc_tc_ps_pwr_off_dec(const uint8 *data);

int8 obc_tc_tty_start_dec(const uint8 *data);
int8 obc_tc_tty_end_dec(const uint8 *data);

int8 obc_tc_spi_intf_param_dec(const uint8 *data);
int8 obc_tc_ethernet_intf_param_dec(const uint8 *data);
int8 obc_tc_can_intf_param_dec(const uint8 *data);
int8 obc_tc_i2c_intf_param_dec(const uint8 *data);
int8 obc_tc_usb_intf_param_dec(const uint8 *data);
int8 obc_tc_uart_intf_param_dec(const uint8 *data);
int8 obc_tc_spi_intf_set_dec(const uint8 *data);
int8 obc_tc_ethernet_intf_set_dec(const uint8 *data);
int8 obc_tc_can_intf_set_dec(const uint8 *data);
int8 obc_tc_i2c_intf_set_dec(const uint8 *data);
int8 obc_tc_usb_intf_set_dec(const uint8 *data);
int8 obc_tc_uart_intf_set_dec(const uint8 *data);

int8 obc_tm_obc_sw_rst_enc(uint8* data, uint32 tm_sw_rst_typ);
int8 obc_tm_ps_pwr_on_enc(uint8* data, uint32 ps_pwr_on_rsp_sts);
int8 obc_tm_pld_hw_pwr_on_enc(uint8* data, uint32 pld_hw_pwr_on_rsp_sts);
int8 obc_tm_pld_vm_pwr_on_enc(uint8* data, uint32 pld_vm_pwr_on_rsp_sts);
int8 obc_tm_pld_hw_pwr_off_enc(uint8* data, uint32 pld_hw_pwr_off_rsp_sts);
int8 obc_tm_pld_vm_pwr_off_enc(uint8* data, uint32 pld_vm_pwr_off_rsp_sts);
int8 obc_tm_ps_pwr_off_enc(uint8* data, uint32 ps_pwr_off_rsp_sts);

int8 obc_tm_tty_start_enc(uint8* data, uint32 tty_start_rsp_sts);
int8 obc_tm_tty_end_enc(uint8* data, uint32 tty_end_rsp_sts);
int8 obc_tm_tty_data_enc(uint8* data, uint8* tm_tty_data, uint32 data_size);
int8 obc_tc_tty_data_dec(uint8* data, uint8* tc_tty_data, uint32 data_size);
/*
 * @brief This API performs the following funtions
 * 1.Sends required TC data for encoding IPCC messages based on the CRRN ID
 * 2.It packs TM response to notify IPCC trigger status.
 */

int16 obc_ipcc_test_tc_dec(uint8 *data);
int8 obc_tc_eps_dec(uint8 *data);
int16 obc_tc_eps_btry_thrshld_dec(uint8 *data);
int16 obc_get_dev_temp_info_dec(uint8 *data);
int16 obc_get_dev_time_info_dec(uint8 *data);
int16 obc_get_dev_chip_info_dec(uint8 *data);
int16 obc_get_dev_ext_mem_dec(uint8 *data);

int8 obc_tc_set_min_reboot_dec(const uint8 *data);
int8 obc_sns_thread_send_ipc(uint8_t ah_type, void* src_ptr);
int8 obc_tc_temp_sns_param_dec(const uint8 *data);
int8 obc_tc_dig_therm_param_dec(const uint8 *data);
int8 obc_tc_imu_param_dec(const uint8 *data);
int8 obc_tc_thrstr_ctlr_param_dec(const uint8 *data);
int8 obc_tc_gpio_exp_param_dec(const uint8 *data);
int8 obc_tc_data_log_param_dec(const uint8 *data);
int8 obc_tc_pwr_mon_param_dec(const uint8 *data);
int8 obc_tc_vltg_ctlr_ctlr_param_dec(const uint8 *data);
int8 obc_tc_pwr_seq_mntr_param_dec(const uint8 *data);

int8 obc_tc_temp_sns_info_dec(const uint8 *data);
int8 obc_tc_dgtl_thrm_info_dec(const uint8 *data);
int8 obc_tc_thruster_ctlr_info_dec(const uint8 *data);
int8 obc_tc_imu_info_dec(const uint8 *data);
int8 obc_tc_gpio_exp_info_dec(const uint8 *data);
int8 obc_tc_data_log_info_dec(const uint8 *data);
int8 obc_tc_pwr_seq_mtr_info_dec(const uint8 *data);
int8 obc_tc_vltg_ctlr_info_dec(const uint8 *data);
int8 obc_tc_pwr_mon_info_dec(const uint8 *data);
int8 obc_tc_set_cur_time_dec(const uint8 *data);
int8 obc_tc_obc_soft_reset_dec(const uint8 *data);
int8 obc_tc_get_sns_data_dec(const uint8 *data);

int8 obc_tc_get_tmp_sns_data_dec(const uint8 *data);
int8 obc_tc_get_dt_sns_data_dec(const uint8 *data);
int8 obc_tc_get_pwr_mon_sns_data_dec(const uint8 *data);
int8 obc_tc_hsc_get_data_dec(const uint8 *data);
int8 obc_tc_pwr_seq_mon_dec(const uint8 *data);
int8 obc_tm_temp_sns_param_enc(uint8* data, uint32 temp_sen_set_parm_sts);
int8 obc_tm_set_min_reboot_enc(uint8* data, uint32 rbt_tm_sts);
int8 obc_tm_dgtl_thrmst_param_enc(uint8* data, uint32 dig_therm_set_parm_sts);
int8 obc_tm_imu_param_enc(uint8* data, uint32 imu_set_parm_sts);
int8 obc_tm_thrstr_cntlr_param_enc(uint8* data, uint32 thruster_ctrl_set_parm_sts);
int8 obc_tm_data_lgr_param_enc(uint8* data, uint32 data_log_set_parm_sts);
int8 obc_tm_gpio_exp_param_enc(uint8* data, uint32 gpio_exp_set_parm_sts);
int8 obc_tm_pwr_mon_param_enc(uint8* data, uint32 pwr_mon_set_param_sts);
int8 obc_tm_vlt_ctlr_param_enc(uint8* data, uint32 vlt_ctlr_set_param_sts);
int8 obc_tm_pwr_seq_mon_param_enc(uint8* data, uint32 pwr_seq_mon_set_param_sts);

int8 obc_tm_temp_sns_info_enc(uint8* data, temp_sens_cfg *sns_inf);
int8 obc_tm_dgtl_thrm_info_enc(uint8* data, digital_thermostat_cfg *sns_inf);
int8 obc_tm_thruster_ctlr_info_enc(uint8* data, thruster_info *sns_inf);
int8 obc_tm_imu_info_enc(uint8* data, imu_info *sns_inf);
int8 obc_tm_gpio_exp_info_enc(uint8* data, gpio_exp_cfg *sns_inf);
int8 obc_tm_data_log_info_enc(uint8* data, data_acq_dvc_info *sns_inf);
int8 obc_tm_pwr_seq_mtr_info_enc(uint8* data, voltage_seq_mntr_cfg *sns_inf);
int8 obc_tm_vltg_ctlr_info_enc(uint8* data, hotswap_cntlr_cfg *sns_inf);
int8 obc_tm_pwr_mon_info_enc(uint8* data, power_sense_mntr_cfg *sns_inf);
int8 obc_tm_get_sns_data_enc(uint8* data, void* src_buff, uint32_t len);

int8 obc_tm_spi_intf_rsp_enc(uint8* data, uint32 spi_intf_param_rsp_sts);
int8 obc_tm_ethernet_intf_rsp_enc(uint8* data, uint32 eth_intf_param_rsp_sts);
int8 obc_tm_can_intf_rsp_enc(uint8* data, uint32 can_intf_param_rsp_sts);
int8 obc_tm_i2c_intf_rsp_enc(uint8* data, uint32 i2c_intf_param_rsp_sts);
int8 obc_tm_usb_intf_rsp_enc(uint8* data, uint32 usb_intf_param_rsp_sts);
int8 obc_tm_uart_intf_rsp_enc(uint8* data, uint32 uart_intf_param_rsp_sts);
int8 obc_tm_spi_intf_param_enc(uint8* data, tctm_spi_init_s *spii);
int8 obc_tm_ethernet_intf_param_enc(uint8* data, tctm_ethernet_init_s *eth);
int8 obc_tm_can_intf_param_enc(uint8* data, tctm_can_init_s *cis);
int8 obc_tm_i2c_intf_param_enc(uint8* data, tctm_i2c_init_s *i2ci);
int8 obc_tm_usb_intf_param_enc(uint8* data, tctm_usb_otg_cfg_s *usbo);
int8 obc_tm_uart_intf_param_enc(uint8* data, tctm_uart_init_s *uarti);


void obc_tctm_validate_seq_num(uint16 actual_seq_no);
void sensor_info_init();
int8 obc_tc_eps_set_conv_brd_dec(const uint8 *data);
int8 obc_tc_eps_set_batt_brd_dec(const uint8 *data);
int8 obc_tc_eps_set_out_chnl_enb_dec(const uint8 *data);
int8 obc_tc_eps_out_chnl_cur_lmt_dec(const uint8 *data);
int8 obc_tc_eps_set_mode_dec(const uint8 *data);
int8 obc_tc_set_board_par(const uint8 *data);
int8 obc_tc_set_batt_board_par(const uint8 *data);
int8 obc_tc_out_chnl_enb(const uint8 *data);
int8 obc_tc_out_chnl_cur_lmt(const uint8 *data);
int8 obc_tc_set_eps_mode_cfg(const uint8 *data);
int8 obc_tc_gnss_loc_dec(const uint8 *data);
int8 obc_tc_ps_pwr_on_dec(const uint8 *data);
int8 obc_tc_schedule_deploy_dec(const uint8 *tc_data);
int8 tc_set_cur_time_dec(const uint8 *data);
#if 0
int8 obc_tc_eps_get_var_val(const uint8 *data);
#endif
int8 obc_tc_eps_set_expo_simu(const uint8* data);
int8 obc_tc_eps_set_ch_crnt_simu(const uint8* data);
int8 obc_tc_eps_set_btry_volt_simu(const uint8* data);
int8 obc_tc_eps_set_btry_temp_simu(const uint8* data);

int8 obc_tm_eps_set_conv_brd_enc(uint8* data, uint32 conv_board_par);
int8 obc_tm_eps_set_batt_brd_enc(uint8* data, uint32 batt_board_par);
int8 obc_tm_eps_set_out_chnl_enb(uint8* data, uint32 out_chnl_enb);
int8 obc_tm_eps_set_out_chnl_cur_lmt_enc(uint8* data, uint32 out_chnl_cur_lmt);
int8 obc_tm_eps_set_mode_cfg_enc(uint8* data, uint32 eps_mode_cfg);

//int8 obc_tm_eps_get_variable_data_enc(uint8* data, eps_set_var_addr_s *addr);
//int8 obc_tm_get_eps_var_info(uint8* data, eps_get_var_data_s *eps_var_info);


int8 obc_tc_flush_queue(uint8* data);

int8 obc_tc_schedule_lut_cfg_dec(const uint8 *tc_data, uint16 tc_data_len);
int8 obc_tc_schedule_lut_cfg_prsr(const uint8 *tc_data);

int8 obc_tm_schedule_deploy_rsp_enc(uint8* data, uint32 rsp_sts);

int8 tm_set_cur_time_enc(uint8* data,uint8_t *cur_time_rsp_sts);
int8 obc_tm_schedule_cfg_lut_rsp_enc(uint8* data, uint32 rsp_sts);

//void obc_pack_tm_data(void );
int obc_prepare_ipc_msg(uint8 *tm_data, uint16 tm_data_len, uint16 tm_id, uint16 src_id);
int8 obc_mem_debug_tm_send(void);
int8 obc_tm_ps_staged_tc_enc(uint8 *data,uint8_t rsp_sts);

int16 obc_tc_eps_ch_pwr_dec(uint8 *data);
int8 obc_tc_set_eps_btry_chnl_map(uint8* data);
int8 obc_tc_get_eps_btry_chnl_map(uint8* data);
int8 obc_tc_eps_get_hw_sts_dec(uint8* data);

int8  obc_tm_ssd_select_enc(uint8* data,uint32* obc_ssd_slec_resp);
int8 obc_tc_ssd_select_dec(uint8 *data);
int8 obc_tm_ssd_heat_select_enc(uint8* data,uint32* obc_ssd_heat_slec_resp);
int8 obc_tc_ssd_heat_select_dec(uint8_t *data);
int8 obc_tc_get_ssd_heat_coil_selc(uint8 data);
int8 obc_tc_get_ssd_slot_selc(uint8 data);
int8 obc_tc_ps_staged_tc_trig(uint8 *data);
int8 obc_tc_deffered_strg(uint8 *data);
int16 obc_ex_mem_test_tc_dec(uint8 *data);
int8 obc_set_gs_contact(uint8 *data);
int8 obc_get_eps_buffer_dec(uint8* data);
int8 obc_eps_get_health_sts_dec(uint8* data);
int8 obc_eps_crc_sts(uint8* data);
int8 obc_tc_ps_brd_select(uint8 *tc_data);
int8 obc_tc_es_brd_select(const uint8 *data);
int8 obc_tc_adc_brd_select(const uint8 *data);
int8 obc_tc_io_brd_select(const uint8 *data);
int8 obc_tc_ps_ssd_select(const uint8 *data);
int8 obc_tc_es_ssd_select(const uint8 *data);
int8 obc_tc_auto_sensor_test(const uint8 *data);
int8 obc_tc_i2c_adxl345_test(const uint8 *data);
int8 obc_tc_uart_test(uint8_t* data);
int8 obc_tc_can_test(const uint8 *data);
int8 obc_tc_spi_adxl345_test();

#ifndef LINUX_TEMP_PORT
int8 obc_get_cpu_stats(uint8* data);
#endif

int8 obc_get_tctm_dbg_info();
int8 err_tc_decoder(uint16_t tc_id, uint8* data);
int8 obc_tc_set_ssd_heat_coil_periodicty_dec(uint8* tc_data);
int8 obc_tc_get_ssd_heat_coil_periodicity(uint8* data);


int8 obc_tc_log_buf_dwnld_read_set_config(uint16 tele_cmd_id, uint8 *data);
int8 obc_conops_sch_lut_ctrl(uint8 *data);
int8 obc_conops_sch_status_check(uint8 *data);

/*To set control flag for TM buffer*/
int8 obc_tc_set_ctrl_flag_tm_buffer();

/*To simmulate IPC from comms to TM manager to indicate Ground Pass*/
int8 obc_tc_set_comms_tm_dlreq();


/*To retrieve control flag value*/
uint8_t check_tm_buffer_cntrl_flag(void);



int8 obc_tm_mem_data_enc(uint8* data,nvm_param *rec_data);
int8 obc_mem_data_dec(uint8* data);
int8 obc_tc_eps_set_dev_tmr(uint8 *data);

void obc_pack_tm_data();
int16 obc_tc_btry_volt_dec(uint16 *data);
int16 obc_ex_mem_test_tc_dec(uint8 *data);

void set_authentication_sts(uint8_t auth_sts);
uint8_t get_authentication_sts();
uint8_t get_security_sts();
void set_security_sts(uint8_t sec_sts);
uint8_t get_radio_id();
void set_radio_id(uint8_t rm_id);

/*
 * @brief
 * This api will invoke file tranfser if input values are valid. else it will send below response code
 *
 *  1 -
 */
uint8_t obc_memory_downloader_start(obc_mem_dwldr_request_form_def *request_form);

/**
 * @brief Creates 2 threads to handle OBC TC and TM.
 *
 * @param[in] None
 *
 * @return Result of thread creation status
 * @retval ral_success -> Thread creation is success
 *         ral_error -> THread creation is failure
 */
os_status_t tc_tm_sample_obc_main(void);

/**
 * @brief This function set the timer periodicity of
 * GPS Sync time
 *
 * @param[in] data : pointer to input data
 *
 * @return status of operation
 * @retval TCTM_OK
 */
uint8 obc_tc_gps_set_time_sync_prdcty_dec(const uint8 *data);

/**
 * @brief This function get the timer periodicity of
 * GPS Sync time
 *
 * @param[in] data : pointer to input data
 *
 * @return status of operation
 * @retval TCTM_OK
 */
uint8 obc_tc_gps_get_time_sync_prdcty(const uint8 *data);

/**
 * @brief This function handle the sync GPS time
 *
 * @param[in] data : pointer to input data
 *
 * @return status of operation
 * @retval TCTM_OK
 */
uint8 obc_tc_gps_sync_time(const uint8 *data);

/**
 * @brief This function get the GPS time information
 *
 * @param[in] data : pointer to input data
 *
 * @return status of operation
 * @retval TCTM_OK
 */
uint8 obc_tc_get_gps_time(const uint8 *data);

/**
 * @brief This API store the Sent/Genrated TM information
 */
void store_snt_tm_info(uint32_t utc_time, uint16_t src_id, uint16_t tm_id);

/**
 * @brief This API store the received TC information
 */
void store_rcvd_tc_info(uint32_t utc_time, uint16_t dst_id, uint16_t tc_id);

/**
 * @brief This API used to get TCTM debug information
 */
void get_tc_tm_dbg_info(uint8_t *data);

/**
 * @brief Function to generate alert TM when memoery threshold exceed
 */
void gen_alert_tm_mem_exd_thrs();

#endif
