Add basic change for v1453

Change-Id: I9497a61bbc3717f66413794a4e7dee0347c0bc33
diff --git a/mbtk/include/ql_v2/ql_gpio.h b/mbtk/include/ql_v2/ql_gpio.h
new file mode 100755
index 0000000..144d363
--- /dev/null
+++ b/mbtk/include/ql_v2/ql_gpio.h
@@ -0,0 +1,445 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of Quectel Co., Ltd. 2019
+*
+*****************************************************************************/
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ *   ql_gpio.h 
+ *
+ * Project:
+ * --------
+ *   OpenLinux
+ *
+ * Description:
+ * ------------
+ *   GPIO API defines.
+ *
+ *
+ *============================================================================
+ *             HISTORY
+ *----------------------------------------------------------------------------
+ * WHO            WHEN                WHAT
+ *----------------------------------------------------------------------------
+ * Larry.Zhang   24/09/2021		  Create.
+ ****************************************************************************/
+
+#ifndef __QL_GPIO_H__
+#define __QL_GPIO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* GPIO MAP */
+typedef enum{
+	PINNAME_BEGIN = -1,
+
+	/* GPIO1 ~ GPIO8 */
+	PINNAME_GPIO_117 = 117,    /* GPIO1 */
+	PINNAME_GPIO_118 = 118,    /* GPIO2 */
+	PINNAME_GPIO_120 = 120,    /* GPIO3 */
+	PINNAME_GPIO_122 = 122,    /* GPIO4 */
+	PINNAME_GPIO_38  = 38,     /* GPIO5 */
+	PINNAME_GPIO_39  = 39,     /* GPIO6 */
+	PINNAME_GPIO_37  = 37,     /* GPIO7 */
+	PINNAME_GPIO_40  = 40,     /* GPIO8 */
+
+	/* The follow pins are not use as GPIO by defaut, please contract Quectel for support */
+
+	/* WLAN */
+	PINNAME_GPIO_58  = 58,     /* SDIO1_CMD */
+	PINNAME_GPIO_59  = 59,     /* SDIO1_CLK */
+	PINNAME_GPIO_57  = 57,     /* SDIO1_DATA0 */
+	PINNAME_GPIO_56  = 56,     /* SDIO1_DATA1 */
+	PINNAME_GPIO_55  = 55,     /* SDIO1_DATA2 */
+	PINNAME_GPIO_48  = 48,     /* SDIO1_DATA3 */
+	PINNAME_GPIO_19  = 19,     /* WLAN_EN */
+	PINNAME_GPIO_43  = 43,     /* WLAN_SLP_CLK */
+	PINNAME_GPIO_123 = 123,    /* WLAN_PWR_EN */
+	PINNAME_GPIO_11  = 11,     /* BT_EN */
+	PINNAME_GPIO_127 = 127,    /* WLAN_WAKE */
+	PINNAME_GPIO_125 = 125,    /* RESERVED */
+
+	/* I2C */
+	PINNAME_GPIO_50  = 50,     /* I2C1_SDA */
+	PINNAME_GPIO_49  = 49,     /* I2C1_SCL */
+	PINNAME_GPIO_42  = 42,     /* I2C2_SDA */
+	PINNAME_GPIO_41  = 41,     /* I2C2_SCL */
+
+	/* UART */
+	PINNAME_GPIO_32  = 32,     /* MAIN_CTS */
+	PINNAME_GPIO_31  = 31,     /* MAIN_RTS */
+	PINNAME_GPIO_51  = 51,     /* MAIN_RXD */
+	PINNAME_GPIO_52  = 52,     /* MAIN_TXD */
+	PINNAME_GPIO_54  = 54,     /* BT_TXD */
+	PINNAME_GPIO_47  = 47,     /* BT_CTS */
+	PINNAME_GPIO_53  = 53,     /* BT_RXD */
+	PINNAME_GPIO_46  = 46,     /* BT_RTS */
+	PINNAME_GPIO_45  = 45,     /* GNSS_TXD */
+	PINNAME_GPIO_44  = 44,     /* GNSS_RXD */
+
+	/* SPI */
+	PINNAME_GPIO_23  = 23,     /* SPI1_DOUT */
+	PINNAME_GPIO_24  = 24,     /* SPI1_DIN */
+	PINNAME_GPIO_22  = 22,     /* SPI1_CS */
+	PINNAME_GPIO_21  = 21,     /* SPI1_CLK */
+	PINNAME_GPIO_34  = 34,     /* SPI2_CS */
+	PINNAME_GPIO_35  = 35,     /* SPI2_DIN */
+	PINNAME_GPIO_36  = 36,     /* SPI2_DOUT */
+	PINNAME_GPIO_33  = 33,     /* SPI2_CLK */
+
+	PINNAME_END = 127
+}ENUM_PINNAME;
+
+
+/****************************************************************************
+ * Error Code Definition
+ ***************************************************************************/
+enum {
+        RES_OK = 0,
+        RES_BAD_PARAMETER  = -1,     ///< Parameter is invalid.
+        RES_IO_NOT_SUPPORT = -2,
+        RES_IO_ERROR = -3,
+        RES_NOT_IMPLEMENTED = -4
+};
+
+typedef enum{
+    PINDIRECTION_IN  = 0,	/** GPIO input direction */
+    PINDIRECTION_OUT = 1	/** GPIO output direction */
+}ENUM_PIN_DIRECTION;
+
+typedef enum{
+    PINLEVEL_LOW  = 0,		/** GPIO low level */
+    PINLEVEL_HIGH = 1		/** GPIO high level */
+}ENUM_PIN_LEVEL;
+
+typedef enum{
+    PINPULLSEL_DISABLE  = 0,		 /** Disable pull selection */
+    PINPULLSEL_PULLDOWN = 1, 	 	/**pull down */
+    PINPULLSEL_PULLUP   = 2  		/**pull up */
+}ENUM_PIN_PULLSEL;
+
+/****************************************************************************
+ * GPIO Config Items
+ ***************************************************************************/
+typedef struct{
+    ENUM_PINNAME            pin_name;	  /** GPIO pin_name arrey*/
+    ENUM_PIN_DIRECTION      pin_direction;  /** GPIO pinDirection arrey*/
+    ENUM_PIN_LEVEL          pin_level;	  /** GPIO pinLevel arrey*/
+    ENUM_PIN_PULLSEL        pin_pullSel;	  /** GPIO pinPullSel arrey*/
+}st_gpio_config;
+
+//------------------------------------------------------------------------------
+/**
+ * The type of GPIO Edge Sensivity.
+ */
+//------------------------------------------------------------------------------
+typedef enum {
+    EINT_SENSE_NONE,       // pin is input, but no an interrupt pin.
+    EINT_SENSE_RISING,
+    EINT_SENSE_FALLING,
+    EINT_SENSE_BOTH
+}ENUM_EINT_TYPE;
+
+/*****************************************************************
+* Function:     ql_gpio_init 
+* 
+* Description:
+*               This function enables the GPIO function of the specified pin,
+*               and initialize the configurations, including direction,
+*               level and pull selection.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of ENUM_PINNAME.
+*               dir:
+*                   The initial direction of GPIO, one value of ENUM_PIN_DIRECTION.
+*               level:
+*                   The initial level of GPIO, one value of ENUM_PIN_LEVEL. 
+*               pullSel:
+*                   Pull selection, one value of ENUM_PIN_PULLSEL.
+* Return:        
+*               RES_OK, this function succeeds.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid. 
+*               RES_IO_ERR, the function failed
+*               other place. For example this GPIO has been using as EINT.
+*****************************************************************/
+int ql_gpio_init(ENUM_PINNAME       pin_name, 
+                 ENUM_PIN_DIRECTION  dir, 
+                 ENUM_PIN_LEVEL      level, 
+                 ENUM_PIN_PULLSEL    pull_sel
+                 );
+
+/*****************************************************************
+* Function:     ql_gpio_base_init 
+* 
+* Description:
+*               This function enables the GPIO function of the specified pin.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of ENUM_PINNAME.
+*            
+* Return:        
+*               RES_OK, this function succeeds.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid. 
+*               RES_IO_ERR, the function failed
+*****************************************************************/
+int ql_gpio_base_init(ENUM_PINNAME pin_name );
+
+/*****************************************************************
+* Function:     ql_gpio_set_level 
+* 
+* Description:
+*               This function sets the level of the specified GPIO.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of ENUM_PINNAME.
+*               level:
+*                   The initial level of GPIO, one value of ENUM_PIN_LEVEL. 
+* Return:        
+*               RES_OK, this function succeeds.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid. 
+*               RES_IO_ERR, the function failed
+*               other place. For example this GPIO has been using as EINT.
+*****************************************************************/
+int ql_gpio_set_level(ENUM_PINNAME pin_name, ENUM_PIN_LEVEL level);
+
+/*****************************************************************
+* Function:     ql_gpio_get_level 
+* 
+* Description:
+*               This function gets the level of the specified GPIO.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of ENUM_PINNAME.
+* Return:        
+*               The level value of the specified GPIO, which is 
+*               nonnegative integer.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid.
+*****************************************************************/
+int ql_gpio_get_level(ENUM_PINNAME pin_name);
+
+/*****************************************************************
+* Function:     ql_gpio_set_direction 
+* 
+* Description:
+*               This function sets the direction of the specified GPIO.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of ENUM_PINNAME.
+*               dir:
+*                   The initial direction of GPIO, one value of ENUM_PIN_DIRECTION.
+* Return:        
+*               RES_OK, this function succeeds.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid. 
+*               RES_IO_ERR, the function failed
+*               other place. For example this GPIO has been using as EINT.
+*****************************************************************/
+int ql_gpio_set_direction(ENUM_PINNAME pin_name, ENUM_PIN_DIRECTION dir);
+
+/*****************************************************************
+* Function:     ql_gpio_get_direction 
+* 
+* Description:
+*               This function gets the direction of the specified GPIO.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of ENUM_PINNAME.
+* Return:        
+*               0  INPUT
+*               1  OUTPUT
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid. 
+*               other place. For example this GPIO has been using as EINT.
+*****************************************************************/
+int ql_gpio_get_direction(ENUM_PINNAME pin_name);
+
+
+/*****************************************************************
+* Function:     ql_gpio_set_pull_selection 
+* 
+* Description:
+*               This function sets the pull selection of the specified GPIO.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of ENUM_PINNAME.
+*               ENUM_PIN_PULLSEL:
+*                   Pull selection, one value of ENUM_PIN_PULLSEL.
+* Return:        
+*               RES_OK, this function succeeds.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid. 
+*               RES_IO_ERR, the function failed
+*               other place. For example this GPIO has been using as EINT.
+*****************************************************************/
+int ql_gpio_set_pull_selection(ENUM_PINNAME pin_name, ENUM_PIN_PULLSEL pull_sel);
+
+/*****************************************************************
+* Function:     ql_gpio_get_pull_selection 
+* 
+* Description:
+*               This function gets the pull selection of the specified GPIO.
+*
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of ENUM_PINNAME.
+* Return:        
+*               0   no pull
+*               1   pull down
+*               3   pull up
+*****************************************************************/
+int ql_gpio_get_pull_selection(ENUM_PINNAME pin_name);
+
+/*****************************************************************
+* Function:     ql_gpio_uninit 
+* 
+* Description:
+*               This function releases the specified GPIO that was 
+*               initialized by calling ql_gpio_init() previously.
+*               After releasing, the GPIO can be used for other purpose.
+* Parameters:
+*               pin_name:
+*                   Pin name, one value of ENUM_PINNAME.
+* Return:        
+*               RES_OK, this function succeeds.
+*               RES_IO_NOT_SUPPORT, the input GPIO is invalid. 
+*               RES_IO_ERR, the function failed
+*               other place. For example this GPIO has been using as EINT.
+*****************************************************************/
+int ql_gpio_uninit(ENUM_PINNAME pin_name);
+
+//------------------------------------------------------------------------------
+/*
+* Description:
+*     Definition for EINT callback function.
+* 
+* Parameters:
+*     pin_name:
+*         EINT pin name, one value of ENUM_PINNAME.
+*
+*     level:
+*         The EINT level value, one value of ENUM_PIN_LEVEL. 
+*         0 or 1
+*/
+//------------------------------------------------------------------------------
+typedef void (*ql_eint_callback)(ENUM_PINNAME eint_pin_name, int level);
+
+//------------------------------------------------------------------------------
+/*
+* Function:     ql_eint_enable 
+* 
+* Description:
+*               Set the interrupt sense mode, and enable interrupt. 
+*
+* Parameters:
+*               eint_pin_name:
+*                   EINT pin name, one value of ENUM_PINNAME that has 
+*                   the interrupt function.
+*
+*               eint_type:
+*                   Interrupt type, level-triggered or edge-triggered.
+*                   Now, only edge-triggered interrupt is supported.
+*
+*               eint_callback:
+*                   call back function
+*
+* Return:        
+*               RES_OK, this function succeeds.
+*               else failed to execute the function. 
+*/
+//------------------------------------------------------------------------------
+int ql_eint_enable(ENUM_PINNAME eint_pin_name, ENUM_EINT_TYPE eint_type, ql_eint_callback eint_callback);
+
+
+//------------------------------------------------------------------------------
+/*
+* Function:     ql_eint_disable 
+* 
+* Description:
+*               Disable the interrupt sense. 
+*
+* Parameters:
+*               eint_pin_name:
+*                   EINT pin name, one value of ENUM_PINNAME that has 
+*                   the interrupt function.
+*
+* Return:        
+*               RES_OK, this function succeeds.
+*               else failed to execute the function. 
+*/
+//------------------------------------------------------------------------------
+int ql_eint_disable(ENUM_PINNAME eint_pin_name);
+
+
+/*-----------------------------------------------------------------------------------------------*/
+/**
+Function:     ql_set_gpio_function 
+* 
+* Description:
+*             set pin function. 
+*
+* Parameters:
+*            pin_name:
+*            EINT pin name, one value of ENUM_PINNAME.
+*		 func:
+*		 pin function,value range from 0 to 7
+*
+* Return:        
+*               RES_OK, this function succeeds.
+*               else failed to execute the function. 
+*/
+/*-----------------------------------------------------------------------------------------------*/
+int ql_set_gpio_function(ENUM_PINNAME pin_name,unsigned int func);
+
+
+/*-----------------------------------------------------------------------------------------------*/
+/*Function:     ql_get_gpio_function 
+* 
+* Description:
+*               get pin function. 
+*
+* Parameters:
+*               pin_name:
+*               EINT pin name, one value of ENUM_PINNAME.
+*
+* Return:        
+*               return 0-7, this function succeeds.
+*               else failed to execute the function. 
+*/
+/*-----------------------------------------------------------------------------------------------*/
+int ql_get_gpio_function(ENUM_PINNAME pin_name);
+
+/*-----------------------------------------------------------------------------------------------*/
+/*Function:     ql_check_pin_function_status 
+* 
+* Description:
+*               Check whether the pin is gpio function. 
+*
+* Parameters:
+*               pin_name:
+*               EINT pin name, one value of ENUM_PINNAME.
+*
+* Return:        
+*               return 1, this pin is gpio function.
+*               return 0, this pin is not gpio function. 
+*		     else failed to execute the function.
+*/
+/*-----------------------------------------------------------------------------------------------*/
+int ql_check_pin_function_status(ENUM_PINNAME  pin_name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  // __QL_GPIO_H__