#ifndef _91x_GPIO_H
#define _91x_GPIO_H

/* Includes ------------------------------------------------------------------*/
#include "91x_map.h"

/* GPIO Init structure definition */
typedef struct
{
  u8 GPIO_Pin;
  u8 GPIO_Direction;
  u8 GPIO_Type;
  u8 GPIO_IPConnected;
  u16 GPIO_Alternate;
}GPIO_InitTypeDef;

/* Bit_SET and Bit_RESET enumeration */
typedef enum
{ Bit_RESET = 0,
  Bit_SET
}BitAction;


/* Exported constants --------------------------------------------------------*/
#define GPIO_Pin_None 0x00
#define GPIO_Pin_0    0x01
#define GPIO_Pin_1    0x02
#define GPIO_Pin_2    0x04
#define GPIO_Pin_3    0x08
#define GPIO_Pin_4    0x10
#define GPIO_Pin_5    0x20
#define GPIO_Pin_6    0x40
#define GPIO_Pin_7    0x80
#define GPIO_Pin_All  0xFF

#define GPIO_PinInput  0x00
#define GPIO_PinOutput 0x01

#define GPIO_Type_PushPull      0x00
#define GPIO_Type_OpenCollector 0x01

#define GPIO_IPConnected_Disable 0x00
#define GPIO_IPConnected_Enable  0x01

#define GPIO_InputAlt1  0x00
#define GPIO_OutputAlt1 0x01
#define GPIO_OutputAlt2 0x02
#define GPIO_OutputAlt3 0x03

#define GPIO_ANAChannel0   0x01
#define GPIO_ANAChannel1   0x02
#define GPIO_ANAChannel2   0x04
#define GPIO_ANAChannel3   0x08
#define GPIO_ANAChannel4   0x10
#define GPIO_ANAChannel5   0x20
#define GPIO_ANAChannel6   0x40
#define GPIO_ANAChannel7   0x80
#define GPIO_ANAChannelALL 0xFF

void GPIO_DeInit(GPIO_TypeDef* GPIOx);
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);
void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);
u8 GPIO_ReadBit(GPIO_TypeDef* GPIOx, u8 GPIO_Pin);
u8 GPIO_Read(GPIO_TypeDef* GPIOx);
void GPIO_WriteBit(GPIO_TypeDef* GPIOx, u8 GPIO_Pin, BitAction BitVal);
void GPIO_Write(GPIO_TypeDef* GPIOx, u8 PortVal);
void GPIO_EMIConfig(FunctionalState NewState);
void GPIO_ANAPinConfig(u8 GPIO_ANAChannel, FunctionalState NewState);
u8 GPIO_GetGPIONumber(GPIO_TypeDef* GPIOx);


#endif /* _91x_GPIO_H */
