/***********************************************************************************************************
 * Copyright (c)  2021 - 2022, Unicmicro Co.,Ltd .
 * All rights reserved.
 * Filename    : gpio.h
 * Description : gpio driver header file
 * Author(s)   : yanhaihua
 * version     : V1.0
 * Modify date : 2021-09-23
 ***********************************************************************************************************/
#ifndef __GPIO_H__
#define __GPIO_H__

#include "config.h"

#ifdef UM3213xA_USING_GPIO

typedef enum
{
	PA0 											= 0,
	PA1 											= 1,
	PA2 											= 2,
	PA3 											= 3,
	PA4 											= 4,
	PA5 											= 5,
	PA6 											= 6,
	
	PB0 											= 8,
	PB1 											= 9,
	PB2 											= 10,
	PB3 											= 11,
	PB4 											= 12,
	PB5 											= 13,
	PB6 											= 14,
	PB7 											= 15,
	
	PC1 											= 17,
	PC2 											= 18,
	PC3 											= 19,
	PC4 											= 20,
	PC5 											= 21,
	PC6 											= 22,

	PD0 											= 24,
	PD1 											= 25,
	PD2 											= 26,
	PD3 											= 27,
	PD4 											= 28,
	PD5 											= 29,
	PD6 											= 30,
	PD7 											= 31,
	
	PE0 											= 32,
	PE1 											= 33,
	PE2 											= 34,
	PE3 											= 35,
	PE4 											= 36,
	PE5 											= 37,
}em_gpio_pin_t;

typedef enum
{
	GPIO_DIR_INPUT 									= 0,													/* 方向为输入 */
	GPIO_DIR_OUTPUT 								= 1,													/* 方向为输出 */
}em_gpio_dir_t;

typedef enum
{
	GPIO_IS_EDGE 									= 0,													/* 边沿检测 */
	GPIO_IS_LEVEL 									= 1,													/* 电平检测 */
}em_gpio_is_t;

typedef enum
{
	GPIO_IBE_SINGLE 								= 0,													/* 单边沿触发 */
	GPIO_IBE_DOUBLE 								= 1,													/* 双边沿触发 */
}em_gpio_ibe_t;

typedef enum
{
	GPIO_IEV_FALLING_EDGE_LOW_LEVEL					= 0,													/* 0:下降沿 /低电平触发； */
	GPIO_IEV_RISING_EDGE_HIGH_LEVEL					= 1,													/* 1:上升沿 /高电平触发。 */
}em_gpio_iev_t;


void gpio_init(em_gpio_pin_t pin);																			/* 初始化 */

void gpio_set_dir(em_gpio_pin_t pin,em_gpio_dir_t dir);														/* 设置IO方向 */

void gpio_set_bit(em_gpio_pin_t pin);																		/* 输出1 */

void gpio_clr_bit(em_gpio_pin_t pin);																		/* 输出0 */

uint8_t gpio_get_bit(em_gpio_pin_t pin);																	/* 读IO */

void gpio_irq_init(em_gpio_pin_t pin,em_enable_t enable,void(*pfunc)());									/* 中断初始化 */

void gpio_set_is(em_gpio_pin_t pin,em_gpio_is_t is);														/* 中断触发模式 */

void gpio_set_ibe(em_gpio_pin_t pin,em_gpio_ibe_t ibe);														/* 中断边沿触发设置 */

void gpio_set_iev(em_gpio_pin_t pin,em_gpio_iev_t iev);														/* 中断高低电平触发设置 */

void gpio_set_pu(em_gpio_pin_t pin, em_enable_t enable);													/* 使能上拉 */

void gpio_set_pd(em_gpio_pin_t pin, em_enable_t enable);													/* 使能下拉 */

void gpio_set_od(em_gpio_pin_t pin, em_enable_t enable);													/* 使能开漏 */

void gpio_set_ie(em_gpio_pin_t pin, em_enable_t enable);													/* 使能输入 */

void gpio_set_sel(em_gpio_pin_t pin,uint8_t sel);															/* 设置复用 */

#endif

#endif
