/*
 * @file exo_hal_io_al_common.h
 *
 * @brief This file contains function mapping for IO-AL
 *
 * @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.
 */

#ifndef _HAL_IO_AL_COMMON_H_
#define _HAL_IO_AL_COMMON_H_

#include "exo_types.h"



/**
 * @brief This is AHW lookup table function
 */
void ahw_io_lookup_table_updt(void);

/**
 * @brief IO interface type enumeration
 */
typedef enum
{
    UART,				///< UART interface
    I2C,				///< I2C interface
    SPI,				///< SPI interface
    CAN,				///< CAN interface
    USB,				///< USB interface
    QSPI,				///< OSPI interface
    FMC_NOR,			///< FMC_NOR interface
    FMC_SDRAM,			///< FMC-SDRAM interface
    ETHERNET,			///< ETHERNET interface
    MAX_INTF_TYPE
}io_intf_type;

/**
 * @brief IO instance ID enumeration
 */
typedef enum _io_inst_id
{
    INVLD_IO_INST_ID,		///< invalid IO interface

    IOAL_INST_I2C1,
    IOAL_INST_I2C2,
    IOAL_INST_I2C3,
    IOAL_INST_I2C4,
    IOAL_INST_SPI1,
    IOAL_INST_SPI2,
    IOAL_INST_UART1,
    IOAL_INST_UART2,
    IOAL_INST_UART3,
    IOAL_INST_UART4,
    IOAL_INST_UART5,
    IOAL_INST_UART6,
    IOAL_INST_USB1,
    IOAL_INST_CAN1,
    IOAL_INST_CAN2,
    IOAL_INST_CAN3,
    IOAL_INST_ETHERNET1,
    IOAL_INST_RTC1,
    IOAL_INST_QSPI1,
    IOAL_INST_FMC_NOR1,
    IOAL_INST_GPIO,
    IOAL_INST_CRC,
    IOAL_INST_ADC1,
    MAX_IO_INST_ID
}io_inst_id;

/**
 * @brief AHW instance ID enumeration
 */
typedef enum _ahw_inst_id
{
    INVLD_AH_INST_ID ,					///< invalid AH instance ID
    MCU_ID,
    IMU_BMX160_OBC_1,
    IMU_BMX160_OBC_2,
    IMU_BMX160_XXX,
    DIGITAL_THERMOSTAT_DS620_EDGE,
    DIGITAL_THERMOSTAT_DS620_PS,
    HSC_ADM1176_EDGE,
    HSC_ADM1176_PS_2,
    HSC_ADM1176_PS_1,
    TEMP_SENSOR_MCP9843_OBC,
    TEMP_SENSOR_MCP9843_PS,
    TEMP_SENSOR_MCP9843_EDGE,
    TEMP_SENSOR_MCP9843_GPS,
    DIGITAL_THERMOSTAT_DS620_SPE01,
    DIGITAL_THERMOSTAT_DS620_SPE02,
    DIGITAL_THERMOSTAT_DS620_SPW01,
    DIGITAL_THERMOSTAT_DS620_SPW02,
    DIGITAL_THERMOSTAT_DS620_SPB01,
    PSM_INA230_OBC,
    PSM_INA230_PS,
    GPIO_EXPANDER_PCAL6408A_PS,
    GPIO_EXPANDER_MCP23008_EDGE_1,
    GPIO_EXPANDER_MCP23008_EDGE_2,
    GPIO_EXPANDER_MCP23008_EDGE_3,
    GPIO_EXPANDER_MCP23008_EDGE_4,
    //GPIO_EXPANDER_MCP23008_IO_BRD_1,
    //GPIO_EXPANDER_MCP23008_IO_BRD_2,
    //GPIO_EXPANDER_MCP23008_IO_BRD_3,
//    GPIO_EXPANDER_MCP23008_SSD_BRD_1,
//    GPIO_EXPANDER_MCP23008_SSD_BRD_2,
//    GPIO_EXPANDER_MCP23008_PWR_BRD_1,
//    GPIO_EXPANDER_MCP23008_PWR_BRD_2,
//    GPIO_EXPANDER_MCP23008_BP_BRD,
//    GPIO_PCAL6408_PS,
    GPIO_EXPANDER_MCP23008_OBC_1,
    GPIO_EXPANDER_MCP23008_OBC_2,
    GPIO_EXPANDER_MCP23008_GPS,
    GPIO_EXPANDER_PCA9673,
    THRUSTER_MORPHEUS_OBC,
    VOLTAGE_SEQUENCER_UCD9801_OBC,
    DATA_LOGGER_ADS7828_PS,
    EXT_MEM_MX25L512_QSPI,
    EXT_MEM_MT25QL512_QSPI,
    EXT_MEM_S25HL512T_QSPI,
    EXT_MEM_MT28EW128_FMC,
    EXT_MEM_M24C16_EEPROM_1,
	EXT_MEM_M24C16_EEPROM_2,
    UART_EXPANDER_MAX14830_OBC,

        GPIO_EXPANDER_MCP23008_EDGE_1_GEN_2,
        TEMP_SENSOR_MCP9843_EDGE_1,
        GPIO_EXPANDER_MCP23008_EDGE_2_GEN_2,
        TEMP_SENSOR_MCP9843_EDGE_2,
        GPIO_EXPANDER_MCP23008_EDGE_3_GEN_2,
        GPIO_EXPANDER_MCP23008_EDGE_4_GEN_2,
        TEMP_SENSOR_MCP9843_PS_GEN_2,
        HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY,
        PSM_INA230_PS_GEN_2,
        GPIO_EXPANDER_PCAL6408A_PS_GEN2,
        GPIO_EXPANDER_MCP23008_NIC_1,
        GPIO_EXPANDER_MCP23008_NIC_2,
        GPIO_EXPANDER_MCP23008_NIC_3,
        TEMP_SENSOR_MCP9843_NIC_1,
        GPIO_EXPANDER_MCP23008_SSD_1,
        GPIO_EXPANDER_MCP23008_SSD_2,
        TEMP_SENSOR_MCP9843_SSD_1,
        TEMP_SENSOR_MCP9843_SSD_2,
        TEMP_SENSOR_MCP9843_SSD_3,
        TEMP_SENSOR_MCP9843_SSD_4,
        GPIO_EXPANDER_MCP23008_BACK_PLANE,
        PSM_INA230_CORE_BRD_A,
        GPIO_EXPANDER_MCP23008_POWER_BOARD_1,
        PSM_INA230_CORE_BRD_B,
        GPIO_EXPANDER_MCP23008_POWER_BOARD_2,
        HSC_ADM1176_PS_1_IN_SUPPLY,
        PSM_INA230_PS_1,
        ADC_AD7291_PS_1,
        HSC_ADM1176_PS_2_IN_SUPPLY,
        PSM_INA230_PS_2,
        ADC_AD7291_PS_2,
        HSC_ADM1176_EDGE_1_IN_SUPPLY,
        PSM_INA230_EDGE_1,
        HSC_ADM1176_EDGE_1_HEAT_COIL,
        HSC_ADM1176_EDGE_2_IN_SUPPLY,
        PSM_INA230_EDGE_2_IN_SUPPLY,
        HSC_ADM1176_EDGE_2_HEAT_COIL,
        HSC_ADM1176_IO_BRD_IN_SUPPLY,
        PSM_INA230_IO_BRD_IN_SUPPLY,
        HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1,
        HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2,
        ADC_AD7291_ORING_CIRCUIT,
        HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1,
        HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2,
		GPIO_EXPANDER_MCP23008_POWER_BOARD_3,
        MAX_AH_INST_ID

}ahw_inst_id_t;

/**
 * @brief AHW type enumeration
 */
typedef enum _ahw_type
{
    INVLD_AHW_TYPE,			///< invalid AHW type
    IMU,					///< IMU sensor
    TEMP_SENSOR,			///< Temperature sensor
    POWER_SENSE_MONITOR,	///< Power sensor monitor
    GPIO_EXPANDER,			///< GPIO expander
    STAR_CAMERA,			///< Star camera
    DIGI_THERM,				///< Digital thermostat
    HOT_SWP_CNTLR,		    ///< Hot swap controller
    THRUSTER_SENSOR,		///< Thruster sensor
    VOLTAGE_SEQ_MONITOR,	///< Voltage sequencer monitor
    DATA_ACQ_DVC,			///< Data logger
    GNSS,					///< GNSS
    EXT_FLASH_MEMORY,		///< External flash memories memories
    UART_EXPANDER,
    CURRENT_MONITER_SENSOR,
    POWER_SENSOR,
    MAX_AHW_TYPE
}ahw_type;

/**
 * @brief AHW IO map structure definition
 */
typedef struct _ahw_map
{
    io_inst_id io_instance_id;			/*!< IO instance ID structure variable      */
    ahw_inst_id_t ahw_id;				/*!< AHW ID structure variable				*/
    ahw_type ahw_type;					/*!< AHW type structure variable			*/
    uint8 ahw_model_id;					/*!< AHW model ID 							*/
    uint16 slv_addr;					/*!< slave address							*/
}ahw_io_map;

#endif /* _HAL_IO_AL_COMMON_H_ */
