/**
 * @file adcs_va.h
 *
 * @brief This file contains data types and function prototypes
 * for vendor abstracted adcs functionalities
 *
 * @copyright Copyright 2023 Antaris, Inc.
 */

#ifndef ADCS_VA_H_
#define ADCS_VA_H_

#include "exo_types.h"
#include "stdint.h"

#ifdef __cplusplus
extern "C" {
#endif

#define ADCS_TCTM_SOF1      (0x1f)  ///< ADCS start of frame 1
#define ADCS_TCTM_SOF2      (0x7f)  ///< ADCS start of frame 2
#define ADCS_TCTM_EOF1      (0x1f)  ///< ADCS end of frame 1
#define ADCS_TCTM_EOF2      (0xff)  ///< ADCS end of frame 2
#define ADCS_TC_TM_ID_IDX   (0x02)  ///< ADCS TCTM ID index
/// Adcs events
typedef enum {
    RESET_DONE = 1,       ///< Reset done successfully
    RESET_FAIL = 2,       ///< Reset failure
    BOOT_INIT_DONE,       ///< Boot done successfully
    BOOT_INIT_FAIL,       ///< Boot failure
    CONFIG_UPDT_DONE,     ///< Config update success
    CONFIG_UPDT_FAIL,     ///< Config update failure
    SENSOR_INIT_DONE,     ///< Sensor init success
    SENSOR_INIT_FAIL,     ///< Sensor init failure
    ACTUATOR_INIT_DONE,   ///< Actuator init success
    ACTUATOR_INIT_FAIL,   ///< Actuator init failure
    DETUMBLE_DONE,        ///< Detumble success
    DETUMBLE_FAIL,        ///< Detumble failure
    COARSE_MOMENTUM_DONE, ///< Coarse momentum success
    COARSE_MOMENTUM_FAIL, ///< Coarse momentum failure
    FINE_MOMENTUM_DONE,   ///< Fine momentum success
    COARSE_TRANSITION,    ///< Fine momentum transition to coarse momentum
    FINE_MOMENTUM_FAIL,   ///< Fine momentum failure
    CONTROL_DONE,         ///< Target pointing control success
    CONTROL_FAIL,         ///< Target pointing control failure
    ADCS_BYPASS_DONE,     ///< Bypass mode command success
    ADCS_BYPASS_FAIL,     ///< Bypass mode command failure
    ADCS_SHUTDOWN_DONE,   ///< Shutdown success
    ADCS_SHUTDOWN_FAIL,   ///< Shutdown failure
    ADCS_TEST_DONE,       ///< Test command success
    ADCS_TEST_FAIL        ///< Test command failure
}e_adcs_event;

/// Adcs operation status
typedef enum {
    OPERATION_SUCCESS = 0,  ///< ADCS operation success
    OPERATION_FAILURE = -1, ///< ADCS operation failure
    TC_TM_ERROR = -2,       ///< TC TM error
    IO_INTERFACE_ERR = -3,  ///< Interface error
    ID_NOT_SUPPORT = -4,    ///< Id not support
    INVLD_PWR_STATE = -5,   ///< ADCS HW in invalid power state
    ADCS_SEM_TAKE_FAIL = -6 ///< ADCS Semapore take failure
}e_adcs_status;

/// ADCS Firmware available status
typedef enum {
    ADCS_FW_NOT_AVAILABLE,  ///< Firmware Not available
    ADCS_FW_AVAILABLE,      ///< Firmware available
    ADCS_FW_UPLOAD_SUCCESS, ///< Firmware Upload success
    ADCS_FW_UPLOAD_FAILURE, ///< Firmware upload failure
    ADCS_BCKUP_FW_UPLD_SCS  ///< Backup Firmware upload success
}e_adcs_fw_avl_sts;

/// Adcs firmware operation status
typedef enum {
    FW_UPLOAD_SUCCESS = 0,      ///< Firmware Upload Success
    FW_UPLOAD_FAILURE = -1,     ///< Firmware Upload Failure
    FW_NOT_AVAILABLE = -2,      ///< Firmware Not Available
    FW_SDRAM_CRC_ERR = -3,      ///< Firmware SDRAM CRC Error
    FW_FMC_NOR_CRC_ERR = -3,    ///< Firmware FMC NOR CRC Error
    FW_ADCS_CRC_ERR = -4,       ///< Firmware ADCS CRC Error
    FW_ADCS_BCK_FW_UPLD_SCS = -5///< Backup firmware updated Success
}e_adcs_fw_upload_status;

/// Adcs sensors
typedef enum {
    ADCS_MAG = 0,            ///< Magnetometer
    ADCS_RED_MAG = 1,        ///< Redundant Magnetometer
    ADCS_MEMS_RATE,          ///< MEMS Rate sensor
    ADCS_COARSE_SUN,         ///< Coarse sun sensor
    ADCS_FINE_SUN,           ///< Fine sun sensor
    ADCS_NADIR_SENS,         ///< Nadir pointing sensor
    ADCS_GPS,                ///< GPS sensor
    ADCS_STAR_SENS           ///< Star tracking sensor
}e_adcs_sensor_type;

/// Adcs sensors
typedef enum {
    TCMD_OK = 0,            ///< Telecommand sent successfully
    TLM_OK = 0              ///< Telemetry request submitted successfully
}e_tctm_status;

/// Adcs actuators
typedef enum {
    ADCS_MAG_TORQUER = 0,   ///< Magnetorquer
    ADCS_WHEEL = 1,         ///< Reaction Wheel
    ADCS_THRUSTER           ///< Thruster
}e_adcs_actuator_type;
/// Adcs reaction wheel types
typedef enum {
    R_WHEEL_X = 0, ///< X axis reaction wheel
    R_WHEEL_Y = 1, ///< Y axis reaction wheel
    R_WHEEL_Z = 2  ///< Z axis reaction wheel
}e_rwheel_axis;
/// Adcs reaction wheel Instance Id 
typedef enum {
    R_WHEEL_1 = 1, ///< Reaction wheel 1
    R_WHEEL_2 = 2, ///< Reaction wheel 2
    R_WHEEL_3 = 3, ///< Reaction wheel 3
    R_WHEEL_4 = 4  ///< Reaction wheel 4
}e_rwheel_id;
/// TC TM ID
typedef enum
{
    TC_SET_ADCS_RESET = 1,          ///< Reset command
    TC_SET_ADCS_UTC,                ///< UTC Set command
    TC_SET_ADCS_CLEAR_ERROR,        ///< Clear Error
    TC_SET_ADCS_SAVE_ORBIT,         ///< Save orbit parameters
    TC_SET_ADCS_TLE,                ///< TLE Set command
    TC_SET_ADCS_MOI,                ///< Set moment of intertia
    TC_SET_ADCS_PWR,                ///< Set Power configuration
    TC_SET_ADCS_MAGMTR_MODE_OPER,   ///< Set magnetometer operation mode
    TC_SET_ADCS_GYRO_CFG,           ///< Set gyro configuration
    TC_SET_ADCS_CSS_CFG,            ///< Set coarse sun sensor configuration
    TC_SET_ADCS_STAR_TRAC_CFG,      ///< Set star tracker configuration
    TC_SET_ADCS_MAGMTR_CFG,         ///< Set Magnetometer configuration
    TC_SET_ADCS_REDUN_MAGMTR_CFG,   ///< Set Redudent magnetometer
                                    ///< configuration
    TC_SET_ADCS_MAG_BOOM,           ///< Set Magnetometer boom
    TC_SET_ADCS_MGNTRQR_OUT,        ///< Set Magnetorquer output
    TC_SET_ADCS_RW_SPEED,           ///< Set Reaction wheel speed
    TC_SET_ADCS_MGNTRQR_CFG,        ///< Set Magnetorquer configuration
    TC_SET_ADCS_RW_CFG,             ///< Set Reaction wheel configuration
    TC_SET_ADCS_CTRL_MODE,          ///< Set Control mode configuration
    TC_SET_ADCS_DETUMBLE_CTRL,      ///< Set Detumble control parameters
    TC_SET_ADCS_Y_RW_CTRL,          ///< Set Y axis Reaction wheel control
                                    ///< parameter
    TC_SET_ADCS_Z_RW_CTRL,          ///< Set Z axis Reaction wheel control
                                    ///< parameter
    TC_SET_ADCS_RW_CTRL,            ///< Set Reaction wheel control
    TC_SET_ADCS_TRCK_CTRL_GAIN,     ///< Set tracking control gain
    TC_SET_ADCS_ATTITUDE_ANGL,      ///< Set attitude angle parameters
    TC_SET_ADCS_TRCK_TARGET,        ///< Set target tracking parameters
    TC_SET_ADCS_INRTL_REF,          ///< Set inertial reference
    TC_SET_ADCS_EST_MODE,           ///< Set estimation mode
    TC_SET_ADCS_EST_PARAM,          ///< Set estimation parameters
    TC_SET_ADCS_SENSORS_CFG,        ///< Set Sensor configuration
    TC_SET_ADCS_ACTUATORS_CFG,      ///< Set Acruator configuration
    TC_SET_ADCS_FSS_CFG,            ///< Set Fine sun sensor configuration
    TC_SET_ADCS_NADIR_CFG,          ///< Set Nadir configuration
    TC_SET_ADCS_THRUSTER_CMD,       ///< Set thruster command configuration
    TC_SET_ADCS_BOOT_INDEX,            ///< Set Boot Index
    TC_SET_ADCS_RUN_SEL_PROG,          ///< Run selected program
    TC_SET_ADCS_READ_PROG_INFO,        ///< Read Program crc, length
    TC_SET_ADCS_COPY_PROG_TO_INT_FLASH,///< copy program to internal flash
    TC_SET_ADCS_RESET_LOG_PTR,         ///< Reset Log Pointer
    TC_SET_ADCS_ADVANCE_LOG_PTR,       ///< Advance Log Pointer
    TC_SET_ADCS_RESET_BOOT_REG,        ///< Reset Boot Registers
    TC_SET_ADCS_FORMAT_SD_CARD,        ///< Format sd card
    TC_SET_ADCS_ERASE_FILE,            ///< Erase File
    TC_SET_ADCS_LOAD_FILE_DWNLD_BLK,   ///< Load File Download Block
    TC_SET_ADCS_ADVANCE_FILE_LIST,///< Advance File List Read Pointer
    TC_SET_ADCS_INIT_FILE_UPLD,   ///< Initiate File Upload
    TC_SET_ADCS_FILE_UPLD_PKT,    ///< File upload packet
    TC_SET_ADCS_FLZE_UPLD_BLK,    ///< Finalize upload block
    TC_SET_ADCS_RESET_UPLD_BLK,   ///< Reset upload block
    TC_SET_ADCS_RST_FILE_LIST_PTR,///< Reset File List Read Pointer
    TC_SET_ADCS_INIT_DWNLD_BURST, ///< Initiate Download Burst
    TC_SET_ADCS_RUN_MODE,         ///< ADCS Run mode
    TC_SET_ADCS_ASGP4_RUN,        ///< ASGP4 Run Mode
    TC_SET_ADCS_ASGP4_TRIG,       ///< ASGP4 Trigger
    TC_SET_ADCS_CONV_JPG,         ///< Convert to JPG file
    TC_SET_ADCS_SAVE_IMG,         ///< save image
    TC_SET_ADCS_SAVE_CFG,         ///< Save configurations
    TC_SET_ADCS_CACHE_CMD,        ///< Set Cache command
    TC_SET_ADCS_SRAM_SCRUB,       ///< Set ADCS sram scrub settings
    TC_SET_ADCS_UTC_FLASH,        ///< Unix Time Save to Flash
    TC_SET_ADCS_ASGP4_PARAM,      ///< Set asgp4 parameter
    TC_SET_ADCS_USER_CTRLR_EST,   ///< User-coded Controller and
                                  ///< Estimator Parameters
    TC_SET_ADCS_SD_LOG1_CFG_CFG,  ///< Set SD Log1 configuration
    TC_SET_ADCS_SD_LOG2_CFG_CFG,  ///< Set SD Log2 configuration
    TC_SET_ADCS_UART_LOG_CFG,     ///< Set UART log configuration
    TC_SET_ADCS_HOLE_MAP1,        ///< set holemap1
    TC_SET_ADCS_HOLE_MAP2,        ///< set holemap2
    TC_SET_ADCS_HOLE_MAP3,        ///< set holemap3
    TC_SET_ADCS_HOLE_MAP4,        ///< set holemap4
    TC_SET_ADCS_HOLE_MAP5,        ///< set holemap5
    TC_SET_ADCS_HOLE_MAP6,        ///< set holemap6
    TC_SET_ADCS_HOLE_MAP7,        ///< set holemap7
    TC_SET_ADCS_HOLE_MAP8,        ///< set holemap8
    TC_SET_ADCS_TRIG_LOOP,        ///< ADCS Trigger loop
    TC_SET_ADCS_TRIG_SIMU_SNS,    ///< Trigger ADCS Loop with
                                  ///< Simulated Sensor Data
    TC_SET_ADCS_HM_PERIODICITY = 124, ///< Set HM buffer periodicity
    ADCS_INTERFACE_CFG = 125,     ///< Communication Interface Configuration
    TC_SET_ADCS_STATE_CFG = 126,  ///< FSM State Configuration
    ADCS_OEM_CMD = 127,           ///< ADCS Other Equipment command

    TM_GET_ADCS_ID = 128,          ///< Get Identification
    TM_GET_ADCS_STATE,             ///< Get ADCS state
    TM_GET_ADCS_TLE,               ///< Get TLE
    TM_GET_ADCS_MOI,               ///< Get moment of inetria
    TM_GET_ADCS_PWR,               ///< Get power configuration
    TM_GET_ADCS_MAG_FIELD_VEC,     ///< Get magnetic field vector
    TM_GET_ADCS_CSS_VEC,           ///< Get CSS vector
    TM_GET_ADCS_FSS_VEC,           ///< Get FSS vector
    TM_GET_ADCS_NADIR_VEC,         ///< Get nadir vector
    TM_GET_ADCS_SENSOR_RATE,       ///< Get sensor rate
    TM_GET_ADCS_STAR_TRKR_BVEC,    ///< Get star tracker body vector
    TM_GET_ADCS_STAR_TRKR_OVEC,    ///< Get star trackere orbit vector
    TM_GET_ADCS_RAW_NADIR_SEN,     ///< Get raw nadir sensor meaurement
    TM_GET_ADCS_RAW_FSS_SEN,       ///< Get raw fine sun sensor measurement
    TM_GET_ADCS_RAW_MAGMTR,        ///< Get raw magnetometer measurement
    TM_GET_ADCS_RAW_GPS_STS,       ///< Get raw GPS staus
    TM_GET_ADCS_RAW_GPS_TIME,      ///< Get raw GPS time
    TM_GET_ADCS_RAW_GPS_X,         ///< Get raw GPS X axis
    TM_GET_ADCS_RAW_GPS_Y,         ///< Get raw GPS Y axis
    TM_GET_ADCS_RAW_GPS_Z,         ///< Get raw GPS Z axis
    TM_GET_ADCS_STAR_MAG,          ///< Get star magnitude
    TM_GET_ADCS_STAR_PERFORM,      ///< Get star performance
    TM_GET_ADCS_STAR_TIMING,       ///< Get star timing
    TM_GET_ADCS_RAW_SENS,          ///< Get raw sensor measurement
    TM_GET_ADCS_RAW_GPS,           ///< Get raw GPS measurement
    TM_GET_ADCS_RAW_STAR_TRAC,     ///< Get raw star tracker measurement
    TM_GET_ADCS_STAR_RDATA,        ///< Get raw star tracker data
    TM_GET_ADCS_RAW_SEC_MAGMTR,    ///< Get raw secondary magnetometer
                                   ///< measurement
    TM_GET_ADCS_RAW_SENS_RATE,     ///< Get raw sensor rates
    TM_GET_ADCS_STAR_EST_RATE,     ///< Get star tracker estimation rate
    TM_GET_ADCS_SENS_CUR,          ///< Get sensor current
    TM_GET_ADCS_CON_CUR,           ///< Get adcs consumed current measurement
    TM_GET_ADCS_RW_CUR,            ///< Get reaction wheel current
    TM_GET_ADCS_TEMP,              ///< Get adcs temperature
    TM_GET_ADCS_SENS_RATE_TEMP,    ///< Get rate sensor temperature
    TM_GET_ADCS_POW_TEMP,          ///< Get power and temperature measurement
    TM_GET_ADCS_GYRO_CFG,          ///< Get gyro configuration
    TM_GET_ADCS_STAR_TRAC_CFG,     ///< Get star tracker configuration
    TM_GET_ADCS_MAGMTR_CFG,        ///< Get magnetometer configuration
    TM_GET_ADCS_CSS_CFG,           ///< Get coarse sun sensor configuration
    TM_GET_ADCS_FSS_CFG,           ///< Get fine sun sensor configuration
    TM_GET_ADCS_NADIR_CFG,         ///< Get nadir configuration
    TM_GET_ADCS_RED_MAGMTR_CFG,    ///< Get redudent magnetometer
                                ///< configuration
    TM_GET_ADCS_MGNTRQR_CFG,       ///< Get magnetorquer configuration
    TM_GET_ADCS_RW_CFG,            ///< Get reaction wheel configuration
    TM_GET_ADCS_DETUMBLE_CTRL,     ///< Get detumble parameters
    TM_GET_ADCS_Y_RW_CTRL,         ///< Get Y reaction wheel control
    TM_GET_ADCS_RW_CTRL,           ///< Get reaction wheel control
    TM_GET_ADCS_TRCK_CTRL_GAIN,    ///< Get tracking control gain
    TM_GET_ADCS_ATTITUDE_ANGL,     ///< Get attitude angle
    TM_GET_ADCS_TRCK_TARGET,       ///< Get target tracking parameters
    TM_GET_ADCS_INRTL_REF,         ///< Get inertial reference
    TM_GET_ADCS_EST_PARAM,         ///< Get estimation paremeters
    TM_GET_ADCS_POS_ECI,           ///< Get sattelite position ECI
    TM_GET_ADCS_VEL,               ///< Get sattelite velocity
    TM_GET_ADCS_POS_LLH,           ///< Get sattelte position LLH
    TM_GET_ADCS_EST_RATE,          ///< Get estimation rates
    TM_GET_ADCS_EST_QUTRN,         ///< Get estimated quaternion
    TM_GET_ADCS_ECEF_POS,          ///< Get ECEF sattelite position
    TM_GET_ADCS_MODL_MAG,          ///< Get moduled magnetic field vector
    TM_GET_ADCS_MODL_SUN,          ///< Get moduled sun vector
    TM_GET_ADCS_EST_GYRO,          ///< Get estimated gyro measurement
    TM_GET_ADCS_EST_INNOVN,        ///< Get estimation innovation
    TM_GET_ADCS_QUTR_ERROR,        ///< Get quaternion error vector
    TM_GET_ADCS_QUTR_COVR,         ///< Get quaternion covariance
    TM_GET_ADCS_ANGL_COVR,         ///< Get angular rate covariance
    TM_GET_ADCS_CTRL_MODE,         ///< Get Control mode configuration
    TM_GET_ADCS_RW_SPEED,           ///< Get commanded Reaction wheel speed
    TM_GET_ADCS_RW_SPEED_MEASURE,   ///< Get measured Reactin wheel speed
    TM_GET_ADCS_BOOT_RUNG_PRGRM_STS,///< Get Boot and running program status
    TM_GET_ADCS_BOOT_INDX_STS,      ///< Get Boot index and status
    TM_GET_ADCS_LST_LGGD_EVNT,      ///< Get Last logged event
    TM_GET_ADCS_SRAM_LATCHUP_CNTR,  ///< Get SRAM latchup counters
    TM_GET_ADCS_EDAC_ERR_CNTR,      ///< Get EDAC error counter
    TM_GET_ADCS_COMM_STS,           ///< Get Communication Status
    TM_GET_ADCS_FRMT_PRGRS,         ///< Get format progress
    TM_GET_ADCS_TC_ACK,             ///< Get telecommand acknowledgment
    TM_GET_ADCS_FILE_DWNLD_CNTNT,   ///< Get File download buffer content
    TM_GET_ADCS_DWNLD_BLCK_RDY,     ///< Get Download block ready
    TM_GET_ADCS_FILE_INFO,          ///< Get file information
    TM_GET_ADCS_INITLZE_UPLD_CMPLT, ///< Get Initalize upload complete
    TM_GET_ADCS_UPLD_BLCK_CMPLT,    ///< Get upload block complete
    TM_GET_ADCS_BLCK_CRC,           ///< Get block chechsum
    TM_GET_ADCS_BTLR_STATE,         ///< Get bootloader state
    TM_GET_ADCS_PRGRM_INFO,         ///< Get program information
    TM_GET_ADCS_CPY_INTRNL_FLSH_PRGRS, ///< Get copy to internal flash progress
    TM_GET_ADCS_JPG_CNVRSN_PRGRS,   ///< Get JPG conversion progress
    TM_GET_ADCS_EXECN_TIME,         ///< Get Execution Time
    TM_GET_ADCS_EXECN_STATE,        ///< Get Execution state
    TM_GET_ADCS_IMG_CPTR_SAVE_OPR_STS, ///< Get Image Capture status
    TM_GET_ADCS_MGNTRQR_CMD,           ///< Get Magnetorquer command
    TM_GET_ADCS_ACTUATOR_CMD,          ///< Get Actuator command
    TM_GET_ADCS_EST_DATA,              ///< Get Estimation data
    TM_GET_STAR_EST_QUTRN,             ///< Get Star tracker Estimated
                                       ///< Attitude Quaternion
    TM_GET_FINE_EST_RATE,              ///< Get Fine Estimated Angular Rates
    TM_GET_ADCS_MEASUREMENT,           ///< Get ADCS Measurement
    TM_GET_ADCS_CACHE_CMD,         ///< Get Cache commands
    TM_GET_ADCS_SRAM_SCRUB,        ///< Get sram scrub settings
    TM_GET_ADCS_UTC_FLASH,         ///< Get Flash UTC
    TM_GET_ADCS_ASGP4_PARAM,       ///< Get asgp4 parameters
    TM_GET_ADCS_USER_CTRLR_EST, ///< Get user controller estimation settings
    TM_GET_ADCS_SDLOG1_CFG,         ///< Get sdlog1 configuration
    TM_GET_ADCS_SDLOG2_CFG,         ///< Get sdlog2 configuration
    TM_GET_ADCS_UART_LOG_CFG,       ///< Get uart log configuration
    TM_GET_ADCS_HOLE_MAP1,          ///< Get holemap1
    TM_GET_ADCS_HOLE_MAP2,          ///< Get holemap2
    TM_GET_ADCS_HOLE_MAP3,          ///< Get holemap3
    TM_GET_ADCS_HOLE_MAP4,          ///< Get holemap4
    TM_GET_ADCS_HOLE_MAP5,          ///< Get holemap5
    TM_GET_ADCS_HOLE_MAP6,         ///< Get holemap6
    TM_GET_ADCS_HOLE_MAP7,         ///< Get holemap7
    TM_GET_ADCS_HOLE_MAP8,         ///< Get holemap8
    TM_GET_ADCS_CRNT_UTC,          ///< Get current UTC time
    TM_GET_ADCS_EST_ATTITUDE_ANGL,    ///< Get estimated attitude angles
    TM_GET_ADCS_MISC_CUR,          ///< Get ADCS misc current measurements
    TM_GET_ADCS_ASGP4_TLE,         ///< Get asgp4 telemetry
    TM_GET_ADCS_STAR_PERFORM2,      ///< Get star performance 2
    TM_GET_ADCS_EST_MODE,            ///< Get Estimation Mode
    TM_GET_ADCS_SENSORS_CFG,        ///< Get Generic Sensor Configuration
    TM_GET_ADCS_ACTUATORS_CFG,      ///< Get Generic Actuator Configuration
    TM_GET_ADCS_RAW_CSS,            ///< Get Raw CSS measurement
    TM_GET_ADCS_FW_UPD_STS = 252,   ///< Get ADCS FW update status
    TM_GET_ADCS_STATE_CFG = 253,  ///< FSM State Configuration
    TM_GET_ADCS_HEALTH_METRICS = 254,  ///< Get ADCS Health Metrics
    OBC_SET_ADCS_FDWNLD_PARAM = 255 ///< Configure Custom File Download params
}e_adcs_tc_tm_id;

///Adcs set and get enumeration
typedef enum
{
    SET_DATA = 0, ///< Set Operation
    GET_DATA = 1  ///< Get Operation
}e_adcs_set_get_opr;


/// Attitude parameters
typedef struct
{
    uint8 status;   ///< status
    float latRef;   ///< latitude
    float longRef;  ///< longitude
    float altRef;   ///< Altitude
}s_attitude_param;

/**
 * @brief Abstracted API to set sensor parameters
 *
 *
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_set_sensor_params(void);

/**
 * @brief Abstracted API to set detumbling parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_set_detumble_params(void);

/**
 * @brief Abstracted API to set coarse momentum parameters
 * 
 * @return status of operation
 * @retval COARSE_MOMENTUM_DONE-->Success
 *         COARSE_MOMENTUM_FAIL-->Fail
 */
e_adcs_event adcs_set_coarse_momentum_params(void);

/**
 * @brief Abstracted API to set fine momentum parameters
 * 
 * @return status of operation
 * @retval FINE_MOMENTUM_DONE-->Success
 *         FINE_MOMENTUM_FAIL-->Fail
 */
e_adcs_event adcs_set_fine_momentum_params(void);

/**
 * @brief Abstracted API to set actuator parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_set_acutuator_params(void);

/**
 * @brief Abstracted API to set configuration parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_set_cfg_params(void);

/**
 * @brief Abstracted API to get sensor parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_get_sensor_params(void);

/**
 * @brief Abstracted API to get detumble parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_get_detumble_params(void);

/**
 * @brief Abstracted API to get coarse momentum parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_get_coarse_momentum_params(void);

/**
 * @brief Abstracted API to get fine momentum parameters
 * 
 * @return status of operation
 * @retval Always zero 
 */
e_adcs_event adcs_get_fine_momentum_params(void);

/**
 * @brief Abstracted API to get actuator parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_get_acutuator_params(void);

/**
 * @brief Abstracted API to get configuration parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_get_cfg_params(void);

/**
 * @brief Abstracted API to set spg4 parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_set_spg4_orbit_params(void);

/**
 * @brief Abstracted API to get spg4 parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_get_spg4_orbit_params(void);

/**
 * @brief Abstracted API to set control mode parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_set_ctrl_mode(void);

/**
 * @brief Abstracted API to get control mode parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_get_ctrl_mode(void);

/**
 * @brief Abstracted API to set non-volatile memory parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_set_nvm(void);

/**
 * @brief Abstracted API to get non-volatile memory parameters
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_get_nvm(void);

/**
 * @brief Abstracted API to set logging configuration
 * 
 * @return status of operation
 * @retval CONFIG_UPDT_DONE-->Success
 *         CONFIG_UPDT_FAIL-->Fail
 */
e_adcs_event adcs_cfg_log(void);

/**
 * @brief Abstracted API to command adcs boot
 * 
 * @return status of operation
 * @retval BOOT_INIT_DONE-->Success
 *         BOOT_INIT_FAIL-->Fail
 */
e_adcs_event adcs_boot(void);

/**
 * @brief Abstracted API to command adcs reset
 * 
 * @return status of operation
 * @retval RESET_DONE-->Success
 *         RESET_FAIL-->Fail
 */
e_adcs_event adcs_reset(void);

/**
 * @brief Abstracted API to command magnetometer deployment
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_deploy_magntmtr(void);

/**
 * @brief Abstracted API to command solar panel deployment
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_deploy_solar(void);

/**
 * @brief Abstracted API to initiliaze adcs sensors
 * 
 * @return status of operation
 * @retval SENSOR_INIT_DONE-->Success
 *         SENSOR_INIT_FAIL-->Fail
 */
e_adcs_event adcs_sensor_init(void);

/**
 * @brief Abstracted API to reset adcs sensors
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_sensor_reset(void);

/**
 * @brief Abstracted API to trigger adcs sensor calibration
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_sensor_calib_trgr(void);

/**
 * @brief Abstracted API to initiliaze adcs actuators
 * 
 * @return status of operation
 * @retval ACTUATOR_INIT_DONE-->Success
 *         ACTUATOR_INIT_FAIL-->Fail
 */
e_adcs_event adcs_actuator_init(void);

/**
 * @brief Abstracted API to start coarse momentum
 * 
 * @return status of operation
 * @retval COARSE_MOMENTUM_DONE-->Success
 *         COARSE_MOMENTUM_FAIL-->Fail
 */
e_adcs_event adcs_coarse_momentum(void);

/**
 * @brief Abstracted API to start fine momentum
 * 
 * @return status of operation
 * @retval FINE_MOMENTUM_DONE-->Success
 *         FINE_MOMENTUM_FAIL-->Fail
 */
e_adcs_event adcs_fine_momentum(void);

/**
 * @brief Abstracted API to reset adcs actuators
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_actuator_reset(void);

/**
 * @brief Abstracted API to trigger adcs actuator calibration
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_actuator_calib_trgr(void);

/**
 * @brief Abstracted API to read adcs sensor measurements
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_sensor_read_meas(void);

/**
 * @brief Abstracted API to read adcs actuator measurements
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_actuator_read_meas(void);

/**
 * @brief Abstracted API to trigger adcs sensor tests
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_sensor_test(void);

/**
 * @brief Abstracted API to trigger adcs actuator tests
 *
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_actuator_test(void);

/**
 * @brief Abstracted API to initialize firmware update
 *
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_frmwr_updt_init(void);

/**
 * @brief Abstracted API to initialize firmware download
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_frmwr_dwnld_file(void);

/**
 * @brief Abstracted API to perform firmware readback
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_frmwr_read_back(void);

/**
 * @brief Abstracted API to perform firmware checksum test
 * 
 * @return status of operation
 * @retval Always zero
 */
e_adcs_event adcs_frmwr_checksum_test(void);

/**
 * @brief Abstracted API to change attitude
 * 
 * @param[in] param : Attitude parameter in pointer
 * 
 * @return status of operation
 * @retval CONTROL_DONE-->Success
 *         CONTROL_FAIL-->Fail
 */
e_adcs_event adcs_change_attitude(s_attitude_param *param);

/**
 * @brief Abstracted API to command adcs detumble
 * 
 * @return status of operation
 * @retval DETUMBLE_DONE-->Success
 *         DETUMBLE_FAIL-->Fail
 */
e_adcs_event adcs_detumble(void);

/**
 * @brief Abstracted API to perform bypass mode operations
 * 
 * @param[in] tx_data: Pointer to input data to be forwarded adcs
 * @param[in] tx_size: size of input data
 * @param[out] rx_data: Pointer to data received from adcs
 * @param[out] rx_size: size of data received from adcs
 * 
 * @return status of operation
 * @retval ADCS_BYPASS_DONE -->Success
 *         ADCS_BYPASS_FAIL -->Fail
 */
e_adcs_event adcs_bypass_mode(uint8 *tx_data, uint8 *rx_data, uint16 tx_size,\
        uint16* rx_size);

/**
 * @brief Abstracted API to perform shutdown operations
 * @return status of operation
 * @retval ADCS_SHUTDOWNE_DONE-->Success
 *         ADCS_SHUTDOWN_FAIL-->Fail
 */
e_adcs_event adcs_shutdown_rqst(void);

/**
 * @brief Abstracted API to perform testing operations
 * @param[in] void : Array of the sequence in hexadecimal.
 * @return status of operation
 * @retval  ADCS_TEST_DONE -> Success
 *          ADCS_TEST_FAIL -> Fail
 */
e_adcs_event adcs_test_mode(void);

/**
 * @brief Abstracted API to perform execute fallback
 */
void adcs_exec_flbk(void);

/**
 * @brief Abstracted API to perform execute sequence
 *
 * @param[in] seq : Array of the sequence in hexadecimal.
 * @param[in] size : length of the sequence.
 */
void adcs_exec_seq(uint8* seq, uint16 size);

/**
 * @brief Abstracted API to initialize the adcs sequence.
 */
void adcs_init_seq();



/**
 * @brief API to handles ADCS telecommand's and telemetry's
 *
 * @param[in] id : TCTM id
 * @param[in] tx_data : Pointer to transmit data
 * @param[out] rx_data : Pointer to receive data
 * @param[out] rx_size : Pointer to receive size
 * @return status of operation
 * @retval 0 -->Success
 *         others -->Fail
 */
int8 adcs_unified_tctm_hdlr(uint8_t id, uint8_t *tx_data, uint8_t *rx_data,\
        uint16_t *rx_size);

/**
 * @brief API to handles ADCS telecommand & telemetry
 *
 * @param[in] tx_data : Pointer to transmit data
 * @param[in] tx_size : size of Transmit data
 * @param[out] rx_data : Pointer to receive data
 * @param[out] rx_size : Pointer to receive size
 *
 * @return status of operation
 * @retval ADCS_SHUTDOWNE_DONE-->Success
 *         ADCS_SHUTDOWN_FAIL-->Fail
 */
int8 adcs_tc_tm_hdlr(uint8_t* tx_data, uint8_t tx_size,\
        uint8_t *rx_data, uint16_t *rx_size);


/**
 * @brief This API Copy the health metrics data from global buffer to rx_data
 *
 * @param[in] hm_id         : Health Metric Id
 * @param[in] hm_buf_cnt    : Health Metric buffer count need to copy.
 * @param[out] rx_data      : Pointer to receive data
 *
 * @return status of operation
 * @retval OPERATION_SUCCESS -->Success
 *         Other values -->Fail
 */
int8 adcs_get_health_metrics(uint8 hm_id, uint8 hm_buf_cnt, uint8* rx_data);

/**
 * @brief This API Update the health metrics in global buffer
 *
 * @return No Return
 */
void adcs_health_info_event();

/**
 * @brief This API Returns the heath metrics structure length for
 * heath metrics id
 *
 * @param[in] hm_id            : Health Metric Id
 * @return Return value of Telemetry length
 * @retval 0 -> Error
 *          Other values -> Success
 */
uint8 adcs_get_hm_tlm_len(uint8 hm_id);

/**
 * @brief This API Initialize Health metrics global buffer values to Zero
 *
 * @return No Return
 */
void adcs_hm_buffer_init();

/*
 * @Brief This API Self recover ADCS interface errors by switching interfaces
 * and power reset ADCS
 *
 * @return No Return
 */
void adcs_intrface_error_recvry(void);

/*
 * @Brief This API recovers temperature error by power off ADCS and
 * turn on after given period of time to verify temperature reduced
 * to normal range
 *
 * @return No Return
 */
void adcs_temperature_error_rcvry(void);

/**
 * ADCS FSM State Configuration
 *
 */
e_adcs_status adcs_fsm_state_cfg(uint8_t* tx_data, uint8_t* rx_data);

/**
 * @brief This api handle ADCS Health metrices queue create
 *
 * @param[in] instance_size : Health metrices telemetry strcuture size
 * @param[in] num_of_instance : Number maximum telemetry size.
 * @param[in] queue_id : Health metrices Telemetry queue id.
 *
 * @return No Return
 */
void adcs_hm_req_queue(uint32_t instance_size, uint32_t num_of_instance, \
        uint8_t queue_id);

/**
 * @brief This api enqueue ADCS health metrices data.
 *
 * @param[in] data : Pointer to Health metrices telemetry data
 * @param[in] data_len : Size of telemetry data.
 * @param[in] queue_id : Health metrices Telemetry queue id.
 *
 * @return No Return
 */
void adcs_hm_enqueue_req(uint8_t* data, uint16_t data_len, uint8_t queue_id);

/**
 * @brief Function to synchronize the ADCS Unix time
 *
 * @param[in] adcs_ctx : pointer to ADCS context
 * @param[in] data : pointer to received payload data
 *
 * @return void
 */
void adcs_sync_time(uint8_t* data);

#ifdef __cplusplus
}
#endif
#endif /* ADCS_VA_H_ */
