[Feature][ZXW-149][GPIO]add GPIO demo

Only Configure:No
Affected branch:master
Affected module:gpio
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update:Yes

Change-Id: I377ea547eb414ec0c5116ca0f7dc5c7cb3c1c1e3
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gpio-demo/files/LICENSE b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gpio-demo/files/LICENSE
new file mode 100755
index 0000000..cb88533
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gpio-demo/files/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("Mobiletek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to Mobiletek Inc. and/or its licensors. Without
+the prior written permission of Mobiletek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of Mobiletek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+Mobiletek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("Mobiletek SOFTWARE")
+RECEIVED FROM Mobiletek AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. Mobiletek EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES Mobiletek PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE Mobiletek SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN Mobiletek
+SOFTWARE. Mobiletek SHALL ALSO NOT BE RESPONSIBLE FOR ANY Mobiletek SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND Mobiletek'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE Mobiletek SOFTWARE
+RELEASED HEREUNDER WILL BE, AT Mobiletek'S OPTION, TO REVISE OR REPLACE THE
+Mobiletek SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO Mobiletek FOR SUCH Mobiletek SOFTWARE AT ISSUE.
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gpio-demo/files/lynq-gpio-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gpio-demo/files/lynq-gpio-demo.cpp
new file mode 100755
index 0000000..51c0020
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gpio-demo/files/lynq-gpio-demo.cpp
@@ -0,0 +1,147 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <include/lynq-gpio.h>
+
+
+int main(int argc,char** argv)
+{
+    int ret;
+    int gpio;
+    int direction;
+    int value;
+    int pullsel;
+    if(argc < 2)
+    {
+        printf("wrong input format, please -h \n");
+        return -1;
+    }
+
+    if(strcmp(argv[1],"-h") == 0)
+    {
+        printf("        -h                                        --help\n");;
+        printf("        -ds  [gpio][direction]                    --lynq_gpio_direction_set\n");
+        printf("        -vs  [gpio][value]                        --lynq_gpio_value_set\n");
+        printf("        -ps  [gpio][pullsel]                      --lynq_gpio_pullsel_set\n");
+        printf("        -vg  [gpio]                               --lynq_gpio_value_get\n");
+        printf("        -pg  [gpio]                               --lynq_gpio_pullsel_get\n");
+        return 0;
+    }
+
+    gpio = atoi(argv[2]);
+    ret = lynq_gpio_init(gpio, 0, 0, 0);
+    if(ret != 0)
+    {
+        printf("lynq_gpio_init fail\n");
+    }
+    else
+    {
+        printf("lynq_gpio_init success\n");
+    }
+
+    if(strcmp(argv[1],"-ds") == 0)
+    {
+        if(argc < 3)
+        {
+            printf("wrong input format, please -h \n");
+            return -1;
+        }
+        direction = atoi(argv[3]);
+        ret = lynq_gpio_direction_set(gpio, direction);
+        if(ret != 0)
+        {
+            printf("lynq_gpio_direction_set fail\n");
+        }
+        else
+        {
+            printf("lynq_gpio_direction_set success\n");
+        }
+
+    }
+    else if(strcmp(argv[1],"-vs") == 0)
+    {
+        if(argc < 3)
+        {
+            printf("wrong input format, please -h \n");
+            return -1;
+        }
+        value = atoi(argv[3]);
+        ret = lynq_gpio_value_set(gpio, value);
+        if(ret < 0)
+        {
+            printf("lynq_gpio_value_set fail\n");
+        }
+        else
+        {
+            printf("lynq_gpio_value_set success\n");
+        }
+    }
+    else if (strcmp(argv[1],"-ps") == 0)
+    {
+        if(argc < 3)
+        {
+            printf("wrong input format, please -h \n");
+            return -1;
+        }
+        pullsel = atoi(argv[3]);
+        ret = lynq_gpio_pullsel_set(gpio, pullsel);
+        if(ret != 0)
+        {
+            printf("lynq_gpio_pullsel_set fail\n");
+            printf("ret=%d\n", ret);
+        }
+        else
+        {
+            printf("lynq_gpio_pullsel_set success\n");
+        }
+    }
+
+    else if (strcmp(argv[1],"-vg") == 0)
+    {
+        ret = lynq_gpio_value_get(gpio);
+        if(ret < 0)
+        {
+            printf("lynq_gpio_value_get fail\n");
+            printf("ret=%d\n", ret);
+        }
+        else
+        {
+            printf("lynq_gpio_value_get success\n");
+            printf("ret=%d\n", ret);
+        }
+    }
+    else if(strcmp(argv[1],"-pg") == 0)
+    {
+        ret = lynq_gpio_pullsel_get(gpio);
+        if(ret < 0)
+        {
+            printf("lynq_gpio_pullsel_get fail\n");
+            printf("ret=%d\n", ret);
+        }
+        else
+        {
+            printf("lynq_gpio_pullsel_get success\n");
+            printf("ret=%d\n", ret);
+        }
+    }
+    else
+    {
+        printf("wrong input format, please -h \n");
+        return -1;
+    }
+
+    ret = lynq_gpio_deinit(gpio);
+    if(ret != 0)
+    {
+        printf("lynq_gpio_deinit fail\n");
+        printf("ret=%d\n", ret);
+    }
+    else
+    {
+        printf("lynq_gpio_deinit success\n");
+    }
+
+    return 0;
+
+}
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gpio-demo/files/makefile b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gpio-demo/files/makefile
new file mode 100755
index 0000000..d135ce2
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gpio-demo/files/makefile
@@ -0,0 +1,53 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -std=gnu++14 \
+                -g -Os \
+                -flto \
+                -fpermissive \
+
+ifeq ($(strip $(TARGET_PLATFORM)), T106)
+LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0
+endif
+
+LOCAL_CFLAGS += -Werror=format-security
+
+$(warning ################# rock ROOT: $(ROOT),includedir:$(includedir),)
+
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH)/include/ \
+  -I$(ROOT)$(includedir)/ \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lstdc++ \
+    -lpthread \
+    -llynq-gpio \
+
+
+
+SOURCES = lynq-gpio-demo.cpp
+
+EXECUTABLE = lynq-gpio-demo
+
+OBJECTS=$(SOURCES:.cpp=.o)
+
+all: $(EXECUTABLE) 
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
+	$(RM) $(OBJECTS_TOOL) $(EXECUTABLE)
+
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gpio-demo/lynq-gpio-demo.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gpio-demo/lynq-gpio-demo.bb
new file mode 100644
index 0000000..0d8d91d
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gpio-demo/lynq-gpio-demo.bb
@@ -0,0 +1,31 @@
+#inherit externalsrc package
+#inherit externalsrc package systemd
+DESCRIPTION = "lynq-gpio-demo"
+LICENSE = "CLOSED"
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=b1e07e8d88e26263e71d3a9e2aa9a2ff"
+SRC_URI = "file://lynq-gpio-demo.cpp \
+           file://makefile \
+"
+DEPENDS += "liblynq-gpio"
+
+SRC-DIR = "${S}/../lynq-gpio-demo"
+FILES_${PN} += "${bindir}/"
+TARGET_CC_ARCH += "${LDFLAGS}"
+SYSTEMD_PACKAGES = "${PN}"
+S = "${WORKDIR}"
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+	if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+	else
+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+	fi
+}
+
+
+do_install() {
+
+	install -d ${D}${bindir}/
+	install -m 0755 ${S}/lynq-gpio-demo ${D}${bindir}/
+}