/**
  ******************************************************************************
  * @file    eport_hal.h
  * @author  Product application department
  * @version V1.0
  * @date    2020.03.23
  * @brief   Header file of EPORT HAL module.
  * 
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __EPORT_HAL_H
#define __EPORT_HAL_H

#ifdef __cplusplus
extern "C"
{
#endif

/* Includes ------------------------------------------------------------------*/
#include "type.h"
#include "hal_def.h"
#include "eport_drv.h"
#include "ioctrl_hal.h"


/**@defgroup HAL HAL driver
  *
  *@{
  */

/** @defgroup HAL_EPORT EPORT
  *
  *@{
  */

/*** 宏定义 *******************************************************************/
/** @defgroup EPORT_Exported_Macros Exported Macros
  *
  * @{
  */            

#define _EPORT_PIN0_OUTPUT_SET(eportx)   _eport_epddr_pin0_output_set(eportx)
#define _EPORT_PIN1_OUTPUT_SET(eportx)   _eport_epddr_pin1_output_set(eportx)
#define _EPORT_PIN2_OUTPUT_SET(eportx)   _eport_epddr_pin2_output_set(eportx)
#define _EPORT_PIN4_OUTPUT_SET(eportx)   _eport_epddr_pin3_output_set(eportx)
#define _EPORT_PIN5_OUTPUT_SET(eportx)   _eport_epddr_pin4_output_set(eportx)
#define _EPORT_PIN6_OUTPUT_SET(eportx)   _eport_epddr_pin5_output_set(eportx)
#define _EPORT_PIN7_OUTPUT_SET(eportx)   _eport_epddr_pin6_output_set(eportx)
#define _EPORT_PIN8_OUTPUT_SET(eportx)   _eport_epddr_pin7_output_set(eportx)

#define _EPORT_PIN0_INPUT_SET(eportx)    _eport_epddr_pin0_input_set(eportx)
#define _EPORT_PIN1_INPUT_SET(eportx)    _eport_epddr_pin1_input_set(eportx)
#define _EPORT_PIN2_INPUT_SET(eportx)    _eport_epddr_pin2_input_set(eportx)
#define _EPORT_PIN4_INPUT_SET(eportx)    _eport_epddr_pin3_input_set(eportx)
#define _EPORT_PIN5_INPUT_SET(eportx)    _eport_epddr_pin4_input_set(eportx)
#define _EPORT_PIN6_INPUT_SET(eportx)    _eport_epddr_pin5_input_set(eportx)
#define _EPORT_PIN7_INPUT_SET(eportx)    _eport_epddr_pin6_input_set(eportx)
#define _EPORT_PIN8_INPUT_SET(eportx)    _eport_epddr_pin7_input_set(eportx)

#define _EPORT_PIN0_LEVEL_GET(eportx)    _eport_eppdr_pin0_data_get(eportx)
#define _EPORT_PIN1_LEVEL_GET(eportx)    _eport_eppdr_pin1_data_get(eportx)
#define _EPORT_PIN2_LEVEL_GET(eportx)    _eport_eppdr_pin2_data_get(eportx)
#define _EPORT_PIN3_LEVEL_GET(eportx)    _eport_eppdr_pin3_data_get(eportx)
#define _EPORT_PIN4_LEVEL_GET(eportx)    _eport_eppdr_pin4_data_get(eportx)
#define _EPORT_PIN5_LEVEL_GET(eportx)    _eport_eppdr_pin5_data_get(eportx)
#define _EPORT_PIN6_LEVEL_GET(eportx)    _eport_eppdr_pin6_data_get(eportx)
#define _EPORT_PIN7_LEVEL_GET(eportx)    _eport_eppdr_pin7_data_get(eportx)

#define _EPORT_PIN0_LEVEL_SET(eportx)    _eport_epdr_pin0_load_set(eportx)
#define _EPORT_PIN1_LEVEL_SET(eportx)    _eport_epdr_pin1_load_set(eportx)
#define _EPORT_PIN2_LEVEL_SET(eportx)    _eport_epdr_pin2_load_set(eportx)
#define _EPORT_PIN3_LEVEL_SET(eportx)    _eport_epdr_pin3_load_set(eportx)
#define _EPORT_PIN4_LEVEL_SET(eportx)    _eport_epdr_pin4_load_set(eportx)
#define _EPORT_PIN5_LEVEL_SET(eportx)    _eport_epdr_pin5_load_set(eportx)
#define _EPORT_PIN6_LEVEL_SET(eportx)    _eport_epdr_pin6_load_set(eportx)
#define _EPORT_PIN7_LEVEL_SET(eportx)    _eport_epdr_pin7_load_set(eportx)

/**
  * @}
  */

/*** 结构体、枚举变量定义 *****************************************************/
/** @defgroup EPORT_Exported_Types Exported Types
  *
  * @{
  */
  
/**
* @brief EPORT pin脚定义
* @note enum类型
*/
typedef enum
{
    /*EPORT*/
    EPORT_PIN0 = _bit(0),
    EPORT_PIN1 = _bit(1),
    EPORT_PIN2 = _bit(2),
    EPORT_PIN3 = _bit(3),
    EPORT_PIN4 = _bit(4),
    EPORT_PIN5 = _bit(5),
    EPORT_PIN6 = _bit(6),
    EPORT_PIN7 = _bit(7),

    /*EPORT1*/
    EPORT_PIN8 = _bit(0),
    EPORT_PIN9 = _bit(1),
    EPORT_PIN10 = _bit(2),
    EPORT_PIN11 = _bit(3),
    EPORT_PIN12 = _bit(4),
    EPORT_PIN13 = _bit(5),
    EPORT_PIN14 = _bit(6),
    EPORT_PIN15 = _bit(7),
    
    /*EPORT2*/
    EPORT_PIN16 = _bit(0),
    EPORT_PIN17 = _bit(1),
    EPORT_PIN18 = _bit(2),
    EPORT_PIN19 = _bit(3),
    EPORT_PIN20 = _bit(4),
    EPORT_PIN21 = _bit(5),
    EPORT_PIN22 = _bit(6),
    EPORT_PIN23 = _bit(7),
    
    /*EPORT3*/
    EPORT_PIN24 = _bit(0),
    EPORT_PIN25 = _bit(1),
    EPORT_PIN26 = _bit(2),
    EPORT_PIN27 = _bit(3),
    EPORT_PIN28 = _bit(4),
    EPORT_PIN29 = _bit(5),
    EPORT_PIN30 = _bit(6),
    EPORT_PIN31 = _bit(7),
    
    /*EPORT4*/
    EPORT_PIN32 = _bit(0),
    EPORT_PIN33 = _bit(1),
    EPORT_PIN34 = _bit(2),
    EPORT_PIN35 = _bit(3),
    EPORT_PIN36 = _bit(4),
    EPORT_PIN37 = _bit(5),
    EPORT_PIN38 = _bit(6),
    EPORT_PIN39 = _bit(7),
		
		/*EPORT5*/
    EPORT_PIN40 = _bit(0),
    EPORT_PIN41 = _bit(1),
    EPORT_PIN42 = _bit(2),
    EPORT_PIN43 = _bit(3),
    EPORT_PIN44 = _bit(4),
    EPORT_PIN45 = _bit(5),
    EPORT_PIN46 = _bit(6),
    EPORT_PIN47 = _bit(7),
		
		/*EPORT6*/
    EPORT_PIN48 = _bit(0),
    EPORT_PIN49 = _bit(1),
    EPORT_PIN50 = _bit(2),
    EPORT_PIN51 = _bit(3),
    EPORT_PIN52 = _bit(4),
    EPORT_PIN53 = _bit(5),
    EPORT_PIN54 = _bit(6),
    EPORT_PIN55 = _bit(7),
		
		/*EPORT7*/
    EPORT_PIN56 = _bit(0),
    EPORT_PIN57 = _bit(1),
    EPORT_PIN58 = _bit(2),
    EPORT_PIN59 = _bit(3),
    EPORT_PIN60 = _bit(4),
    EPORT_PIN61 = _bit(5),
    EPORT_PIN62 = _bit(6),
    EPORT_PIN63 = _bit(7),
		
		/*EPORT8*/
    EPORT_PIN64 = _bit(0),
    EPORT_PIN65 = _bit(1),
    EPORT_PIN66 = _bit(2),
    EPORT_PIN67 = _bit(3),
    EPORT_PIN68 = _bit(4),
    EPORT_PIN69 = _bit(5),
    EPORT_PIN70 = _bit(6),
    EPORT_PIN71 = _bit(7),
		
		/*EPORT9*/
    EPORT_PIN72 = _bit(0),
    EPORT_PIN73 = _bit(1),
    EPORT_PIN74 = _bit(2),
    EPORT_PIN75 = _bit(3),
    EPORT_PIN76 = _bit(4),
    EPORT_PIN77 = _bit(5),
    EPORT_PIN78 = _bit(6),
    EPORT_PIN79 = _bit(7),
		
		/*EPORT10*/
    EPORT_PIN80 = _bit(0),
    EPORT_PIN81 = _bit(1),
    EPORT_PIN82 = _bit(2),
    EPORT_PIN83 = _bit(3),
    EPORT_PIN84 = _bit(4),
    EPORT_PIN85 = _bit(5),
    EPORT_PIN86 = _bit(6),
    EPORT_PIN87 = _bit(7),
		
		/*EPORT11*/
    EPORT_PIN88 = _bit(0),
    EPORT_PIN89 = _bit(1),
    EPORT_PIN90 = _bit(2),
    EPORT_PIN91 = _bit(3),
    EPORT_PIN92 = _bit(4),
    EPORT_PIN93 = _bit(5),
    EPORT_PIN94 = _bit(6),
    EPORT_PIN95 = _bit(7),
		
		/*EPORT12*/
    EPORT_PIN96 = _bit(0),
    EPORT_PIN97 = _bit(1),
    EPORT_PIN98 = _bit(2),
    EPORT_PIN99 = _bit(3),
    EPORT_PIN100 = _bit(4),
    EPORT_PIN101 = _bit(5),
    EPORT_PIN102 = _bit(6),
    EPORT_PIN103 = _bit(7),
		
		/*EPORT13*/
    EPORT_PIN104 = _bit(0),
    EPORT_PIN105 = _bit(1),
    EPORT_PIN106 = _bit(2),
    EPORT_PIN107 = _bit(3),
    EPORT_PIN108 = _bit(4),
    EPORT_PIN109 = _bit(5),
    EPORT_PIN110 = _bit(6),
    EPORT_PIN111 = _bit(7),
		
		/*EPORT14*/
    EPORT_PIN112 = _bit(0),
    EPORT_PIN113 = _bit(1),
    EPORT_PIN114 = _bit(2),
    EPORT_PIN115 = _bit(3),
    EPORT_PIN116 = _bit(4),
    EPORT_PIN117 = _bit(5),
    EPORT_PIN118 = _bit(6),
    EPORT_PIN119 = _bit(7),
		
		/*EPORT15*/
    EPORT_PIN120 = _bit(0),
    EPORT_PIN121 = _bit(1),
    EPORT_PIN122 = _bit(2),
    EPORT_PIN123 = _bit(3),
    EPORT_PIN124 = _bit(4),
    EPORT_PIN125 = _bit(5),
    EPORT_PIN126 = _bit(6),
    EPORT_PIN127 = _bit(7),
		
		/*EPORT16*/
    EPORT_PIN128 = _bit(0),
    EPORT_PIN129 = _bit(1),
    EPORT_PIN130 = _bit(2),
    EPORT_PIN131 = _bit(3),
    EPORT_PIN132 = _bit(4),
    EPORT_PIN133 = _bit(5),
    EPORT_PIN134 = _bit(6),
    EPORT_PIN135 = _bit(7),

}EPORT_PinxTypeDef;

/**
* @brief EPORT初始化结构体定义
*
*/
typedef struct
{
    EPORT_TypeDef *Instance;                /**< 模块寄存器 */
    IOCTRL_GINTInitTypeDef ioctrl_init;     /**< 引脚属性 */
    GPIO_DirTypeDef dir;                    /**< 方向 */
    EPORT_OutputModeTypeDef output_mode;    /**< 输出方式 */
    EPORT_IntModeDef it_type;               /**< 触发方式 */
    FunctionalState it_status;              /**< 触发状态 */
    FunctionalState pull_up_status;         /**< 拉高状态 */
    uint8_t pins;                           /**< 引脚 */
}EPORT_InitTypeDef;



/**
  * @}
  */

/*** 全局变量声明 **************************************************************/
/** @defgroup EPORT_Exported_Variables Exported Variables
  *
  * @{
  */



/**
  * @}
  */

/*** 函数声明 ******************************************************************/
/** @defgroup EPORT_Exported_Functions Exported Functions
  * @{
  */
extern void HAL_EPORT_GintSwitch(EPORT_TypeDef *pEport, uint8_t Pins);
extern HAL_StatusTypeDef HAL_EPORT_Init(EPORT_InitTypeDef *pEportInit);
extern void HAL_EPORT_WritePinsLevel(EPORT_TypeDef * pEport, uint8_t Pins, BitActionTypeDef Level);
extern uint8_t HAL_EPORT_ReadPinsLevel(EPORT_TypeDef *pEport, uint8_t pins);
extern BitActionTypeDef HAL_EPORT_ReadPinLevel(EPORT_TypeDef *pEport, uint8_t pin);


/**
  * @}
  */

/**
  *@}
  */

/**
  *@}
  */

#ifdef __cplusplus
}
#endif

#endif /* __EPORT_HAL_H */

