/*
 * @file es_brd.h
 */

#ifndef ES_BRD_H
#define ES_BRD_H

#include "mcp23008_gpio_expander.h"

#define ES_BRD_1_OFF   1
#define ES_BRD_2_OFF   2
/*
 * Defining U16 gpio expander pin name
 */
#define E1_EN_5V_EDGE                  MCP23008_GPIO_O
#define E1_EDGE_TEM_SEN_INT            MCP23008_GPIO_1
#define E1_EN_1P8V_EDGE                MCP23008_GPIO_2
#define E1_EN_3P3V_EDGE                MCP23008_GPIO_3
#define E1_PGOOD_1P8V_EDGE             MCP23008_GPIO_4
#define E1_PGOOD_3P3V_EDGE             MCP23008_GPIO_5
#define MUX_SSD_EN1                    MCP23008_GPIO_6
#define MUX_SSD_EN2                    MCP23008_GPIO_7

/*
 * Defining U37 gpio expander pin name
 */
#define CLK_EN_A_B                     MCP23008_GPIO_O
#define SSD_RST_CON_ENB                MCP23008_GPIO_1
#define SSD_WAKE_CON_ENB               MCP23008_GPIO_2
#define E1_FORCE_RECOVERY_LT           MCP23008_GPIO_3
#define E2_FORCE_RECOVERY_LT           MCP23008_GPIO_4
#define E2_EDGE_TEM_SEN_INT            MCP23008_GPIO_5
#define CONN2_PCIE0_CLKREQ             MCP23008_GPIO_6
#define CONN1_PCIE0_CLKREQ             MCP23008_GPIO_7

/*
 * Defining U38 gpio expander pin name
 */
#define E2_EN_5V_EDGE                  MCP23008_GPIO_O
#define E2_EN_1P8V_EDGE                MCP23008_GPIO_2
#define E2_EN_3P3V_EDGE_EN             MCP23008_GPIO_3
#define E2_PGOOD_1P8V_EDGE             MCP23008_GPIO_4
#define E2_PGOOD_3P3V_EDGE             MCP23008_GPIO_5
#define USB_PD1_PD2                    MCP23008_GPIO_6
#define USB_SEL1_SEL2                  MCP23008_GPIO_7

/*** U40 ***/
#define SSD_RST_ENB                    MCP23008_GPIO_O
#define SSD_WAKE_ENB                   MCP23008_GPIO_1
#define EI_SEL1_SEL2                   MCP23008_GPIO_2
#define E2_SEL1_SEL2                   MCP23008_GPIO_3
#define SSD0_SEL1_SEL2                 MCP23008_GPIO_4
#define SSD1_SEL1_SEL2                 MCP23008_GPIO_5
#define E1_E2_PD                       MCP23008_GPIO_6
#define SSD0_SSD1_PD                   MCP23008_GPIO_7

typedef enum
{
    EDGE_1_SSD_1 = 1,                 /*!< edge board A ssd 1 */
    EDGE_1_SSD_2,                     /*!< edge board A ssd 2 */
    EDGE_2_SSD_1,                     /*!< edge board B ssd 1 */
    EDGE_2_SSD_2,                     /*!< edge board B ssd 2 */
}edge2_board_ssd_id;

typedef struct
{
    float temp_1;                     /*!< U13 Temp variable */
    float temp_2;                     /*!< U34 Temp variable */
}temp_struct;

/**
 * @Edge Board - 1 Booting function sequence.
 */
uint8_t es_brd_test1 ();

/**
 * @Edge Board - 2 Booting function sequence.
 */
uint8_t es_brd_test2 ();

/**
 * @Edge Board - 1 SSD => 0,1 Deducting sequence.
 * @param[in]edge_brd_ssd_id         : handle edge-1 ssd id.
 *
 */
uint8_t edge1_ssd_test (uint8_t edge_brd_ssd_id);

/**
 * @Edge Board - 2 SSD => 0,1 Deducting sequence.
 * @param[in]edge_brd_ssd_id         : handle edge-2 ssd id.
 */
uint8_t edge2_ssd_test (uint8_t edge_brd_ssd_id);

/**
 * @Get edge board temperature.
 * @param[out] temperature       : edge board get temperature
 */
uint8_t edge_brd_get_tempreature(temp_struct *temperature);

/**
 * @Edge Board power off function.
 * @param[in]ahw_id         : edge 1 or 2 power sequence id.
 */
uint8_t edge_brd_pwr_off(uint8_t* ahw_id);


#endif
