gpio: add L508_X6 gpio test
Change-Id: I279bd363763536442ccec8940541310e10f41733
diff --git a/mbtk/mbtk_lib/src/mbtk_gpio.c b/mbtk/mbtk_lib/src/mbtk_gpio.c
index a389252..9e562a9 100755
--- a/mbtk/mbtk_lib/src/mbtk_gpio.c
+++ b/mbtk/mbtk_lib/src/mbtk_gpio.c
@@ -36,6 +36,120 @@
static int gpio_debug = 0;
+#if defined(MBTK_PROJECT_L508_X6)
+struct gpio_register_function gpio_func_register[128] = {
+ {GPIO_FUNC_GPIO_00, 0},
+ {GPIO_FUNC_GPIO_01, 0},
+ {GPIO_FUNC_GPIO_02, 0},
+ {GPIO_FUNC_GPIO_03, 0},
+ {GPIO_FUNC_GPIO_04, 0},
+ {GPIO_FUNC_GPIO_05, 0},
+ {GPIO_FUNC_GPIO_06, 0},
+ {GPIO_FUNC_GPIO_07, 0},
+ {GPIO_FUNC_GPIO_08, 0},
+ {GPIO_FUNC_GPIO_09, 0},
+ {GPIO_FUNC_GPIO_10, 0},
+ {GPIO_FUNC_GPIO_11, 0},
+ {GPIO_FUNC_GPIO_12, 0},
+ {GPIO_FUNC_GPIO_13, 0},
+ {GPIO_FUNC_GPIO_14, 0},
+ {GPIO_FUNC_GPIO_15, 0},
+ {GPIO_FUNC_GPIO_16, 0},
+ {GPIO_FUNC_GPIO_17, 0},
+ {GPIO_FUNC_GPIO_18, 0},
+ {GPIO_FUNC_GPIO_19, 0},
+ {GPIO_FUNC_GPIO_20, 0},
+ {GPIO_FUNC_GPIO_21, 0},
+ {GPIO_FUNC_GPIO_22, 0},
+ {GPIO_FUNC_GPIO_23, 0},
+ {GPIO_FUNC_GPIO_24, 0},
+ {GPIO_FUNC_GPIO_25, 0},
+ {GPIO_FUNC_GPIO_26, 0},
+ {GPIO_FUNC_GPIO_27, 0},
+ {GPIO_FUNC_GPIO_28, 0},
+ {GPIO_FUNC_GPIO_29, 0},
+ {GPIO_FUNC_GPIO_30, 0},
+ {GPIO_FUNC_GPIO_31, 0},
+ {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 1}, //GPIO_71
+ {GPIO_FUNC_QSPI_DAT2, 1}, //GPIO_72
+ {GPIO_FUNC_QSPI_DAT1, 1}, //GPIO_73
+ {GPIO_FUNC_QSPI_DAT0, 1}, //GPIO_74
+ {GPIO_FUNC_QSPI_CLK, 1}, //GPIO_75
+ {GPIO_FUNC_QSPI_CS1, 1}, //GPIO_76
+ {GPIO_FUNC_GPIO_77, 0},
+ {GPIO_FUNC_GPIO_78, 0},
+ {GPIO_FUNC_GPIO_79, 0},
+ {GPIO_FUNC_GPIO_80, 0},
+ {GPIO_FUNC_USIM_UCLK, 1},//GPIO_81
+ {GPIO_FUNC_USIM_UIO, 1},//GPIO_82
+ {GPIO_FUNC_USIM_URSTn, 1},//GPIO_83
+
+ {GPIO_FUNC_MMC1_DAT3,5}, //GPIO_84
+ {GPIO_FUNC_MMC1_DAT2,5}, //GPIO_85
+ {GPIO_FUNC_MMC1_DAT1,5}, //GPIO_86
+ {GPIO_FUNC_MMC1_DAT0,5}, //GPIO_87
+ {GPIO_FUNC_MMC1_CMD,5}, //GPIO_88
+ {GPIO_FUNC_MMC1_CLK,5}, //GPIO_89
+ {GPIO_FUNC_MMC1_CD,1}, //GPIO_90
+ {0,0},
+ {0,0},{0,0},{0,0},{0,0},
+ {0,0},{0,0},{0,0},
+ {GPIO_FUNC_USB_ID, 1},//GPIO_99
+ {0,0},{0,0},{0,0},{0,0},
+ {0,0},{0,0},{0,0},{0,0},
+ {0,0},{0,0},{0,0},{0,0},
+ {0,0},{0,0},{0,0},{0,0},
+ {0,0},
+ {GPIO_FUNC_PRI_TDI, 1}, //GPIO_117
+ {GPIO_FUNC_PRI_TMS, 1}, //GPIO_118
+ {GPIO_FUNC_PRI_TCK, 1}, //GPIO_119
+ {GPIO_FUNC_PRI_TDO, 1}, //GPIO_120
+ {GPIO_FUNC_QSPI_VMODE_GPIO, 1}, //GPIO_121
+ {GPIO_FUNC_VBUS_DRV, 1}, //GPIO_122
+ {GPIO_FUNC_CLK_REQ, 1}, //GPIO_123
+ {0,0},
+ {GPIO_FUNC_VCXO_REQ, 1}, //GPIO_125
+ {0,0}, //GPIO_126
+ {GPIO_FUNC_VCXO_OUT, 1}, //GPIO_127
+ {0,0},
+};
+
+#else
struct gpio_register_function gpio_func_register[128] = {
{GPIO_FUNC_GPIO_00, 0},
{GPIO_FUNC_GPIO_01, 0},
@@ -137,6 +251,7 @@
{0,0},
};
+#endif
static int mbtk_gpio_adc(channel)
{
@@ -931,8 +1046,6 @@
}
#elif defined(MBTK_PROJECT_L508_X6)
-
-
int gpio_register_test_out_0(int port, int value)
{
int ret;
@@ -948,7 +1061,7 @@
}
gpio_register_set_direction(port, 1); //设方向为输出
ret = gpio_register_get_value(port);
- //printf("gpio default value is : %d.\n", ret);
+ printf("gpio default value is : %d.\n", ret);
//[High]
@@ -956,7 +1069,7 @@
gpio_register_set_value(port, 1);
usleep(50);
valueh = gpio_register_get_value(port);
- //printf("set high? %d\n",valueh);
+ printf("set high? %d\n",valueh);
if(1 == valueh){
break;
}
@@ -969,7 +1082,7 @@
break;
}
}
- //printf("******gpio should is high: %d.******\n", ret);
+ printf("******gpio should is high: %d.******\n", ret);
if(1 != ret){
ret=-1;
goto exit;
@@ -983,7 +1096,7 @@
gpio_register_set_value(port, 0); //输出低
usleep(50);
valuel = gpio_register_get_value(port);
- //printf("set low? %d\n",valuel);
+ printf("set low? %d\n",valuel);
if(0 == valuel){
break;
}
@@ -996,7 +1109,7 @@
break;
}
}
- //printf("******gpio should is low: %d.******\n", ret);
+ printf("******gpio should is low: %d.******\n", ret);
if(0 != ret){
ret=-1;
goto exit;
@@ -1031,7 +1144,7 @@
gpio_register_set_value(port, 1);
usleep(50);
valueh = gpio_register_get_value(port);
- //printf("set high? %d\n",valueh);
+ printf("set high? %d\n",valueh);
if(1 == valueh){
break;
}
@@ -1048,7 +1161,7 @@
ret=-1;
goto exit;
}
- //printf("******gpio should is high: %d.******\n", ret);
+ printf("******gpio should is high: %d.******\n", ret);
//[Low]
@@ -1057,7 +1170,7 @@
gpio_register_set_value(port, 0); //输出低
usleep(50);
valuel = gpio_register_get_value(port);
- //printf("set low? %d\n",valuel);
+ printf("set low? %d\n",valuel);
if(0 == valuel){
break;
}
@@ -1070,17 +1183,100 @@
break;
}
}
- //printf("******gpio should is low: %d.******\n", ret);
+ printf("******gpio should is low: %d.******\n", ret);
if(0 != ret){
ret=-1;
goto exit;
}
exit:
- //gpio_register_set_direction(port, 0); //设方向为输入
+ gpio_register_set_value(port, 0);
+ gpio_register_set_direction(port, 0); //设方向为输入
return ret;
}
+
+int gpio_register_test_out_2(int port_in, int port_out, int value)
+{
+ int ret_in;
+ int ret_out;
+ int i;
+ int valueh = 0;
+ int valuel = 1;
+
+ printf("Gpio port [%d] test start!\n", port_out);
+ ret_in = gpio_register_set_func_0(port_in); //设功能为GPIO
+ ret_out = gpio_register_set_func_0(port_out);
+ if((ret_in+ret_out)){
+ printf("gpio_port can't support!\n");
+ return -1;
+ }
+ gpio_register_set_direction(port_out, 1); //设方向为输出
+ gpio_register_set_direction(port_in, 0); //设方向为输入
+ ret_in = gpio_register_get_value(port_in);
+ printf("gpio default value is : %d.\n", ret_in);
+
+
+ //[High]
+ for(i = 0; i <= 10; i++){
+ gpio_register_set_value(port_out, 1);
+ usleep(50);
+ valueh = gpio_register_get_value(port_out);
+ printf("set high? %d\n",valueh);
+ if(1 == valueh){
+ break;
+ }
+ }
+
+
+ for(i = 0; i <= 35; i++){
+ ret_in = gpio_register_get_value(port_in);
+ usleep(3000);
+ if(1 == ret_in){
+ break;
+ }
+ }
+ if(1 != ret_in){
+ ret_in=-1;
+ printf("get high failed! \n");
+ goto exit;
+ }
+ printf("******gpio should is high: %d.******\n", ret_in);
+
+
+ //[Low]
+ usleep(200);
+ for(i = 0; i <= 10; i++){
+ gpio_register_set_value(port_out, 0); //输出低
+ usleep(50);
+ valuel = gpio_register_get_value(port_out);
+ printf("set low? %d\n",valuel);
+ if(0 == valuel){
+ break;
+ }
+ }
+
+ for(i = 0; i <= 35; i++){
+ ret_in = gpio_register_get_value(port_in);
+ usleep(3000);
+ if(0 == ret_in){
+ break;
+ }
+ }
+ printf("******gpio should is low: %d.******\n", ret_in);
+ if(0 != ret_in){
+ ret_in=-1;
+ printf("get low failed! \n");
+ goto exit;
+ }
+
+exit:
+ gpio_register_set_value(port_out, 0);
+ gpio_register_set_direction(port_out, 0); //设方向为输入
+ return ret_in;
+}
+
+
void gpio_test_init_test_gpio_mode(void )
{
@@ -1090,7 +1286,7 @@
56, 58, 55, 57, 48, 59, 123, 122, 20, 53,
19, 49, 50, 32 ,31, 6, 11, 10,
88, 87, 86, 85, 84, 89,
- 90, 43, 46, 127
+ 90, 46, 127, 117, 119,
};
int test_gpio_0[] = {
@@ -1103,8 +1299,10 @@
total_0 = (sizeof(test_gpio_0)/sizeof(int));
total_1 = (sizeof(test_gpio_1)/sizeof(int));
- system("i2cset -y -f 2 0x32 0x0d 0x00");
- usleep(10000);
+ //system("at at+gpsinit=0");
+ system("i2cset -y -f 2 0x32 0x0d 0x00");
+ system("i2cset -y -f 2 0x31 0x18 0x8f");
+ usleep(10000);
//printf("[init]gpio_test_init_test_gpio_mode FINISH\n");
/* [1 all gpio set to low] */
@@ -1136,25 +1334,25 @@
}
}
if(0 != (ret_0 + ret_1)){
+
printf("Fail, please retest");
return -1;
}
-
+ gpio_register_set_value(119, 1);
+ gpio_register_set_value(117, 1);
}
int mbtk_at_gpio(void* arg)
{
- //123,122,7,8,27,28,26,25,15,1,3,0 error
- printf("Start test gpio V0.3\n");
-
+
+ printf("Start test gpio V1.0\n");
int test_gpio_1[] = {
40, 33, 34, 39, 99,
56, 58, 55, 57, 48, 59, 20, 53,
19, 49, 50, 32 ,31, 6, 11, 10,7,
- /* 88, 87, 86, 85, 84, 89, SD卡*/
- 90, 43, 46, 127
- /* 123, 122 这两没接*/
+ 90, 46, 127,
+ 88, 87, 86, 85, 84, 89,
};
int test_gpio_0[] = {
@@ -1162,20 +1360,23 @@
54, 125, 18, 13, 14, 17, 16, 5, 4, 2, 12,0,
27, 28, 26, 25, 15, 1, 3,
37, 38,8
- /* 44, 45, 47 UART_GPS*/
+ };
+ int test_gpio_2[] = { //GPS组
+ 43,47,
+ //45,44
};
- int i, j, ret_0, ret_1, total_1, total_0, n = 0;
+ int i, j, ret_0, ret_1, ret_2, total_1, total_0, total_2, n = 0;
int *fail_io = (int *)arg;
total_0 = (sizeof(test_gpio_0)/sizeof(int));
total_1 = (sizeof(test_gpio_1)/sizeof(int));
+ total_2 = (sizeof(test_gpio_2)/sizeof(int));
/* [1 all gpio Init] */
gpio_test_init_test_gpio_mode();
/* [2 GPIOTEST] */
-
//Test 0
for(i = 0; i < total_0; i++){
ret_0 = gpio_register_test_out_0(test_gpio_0[i], 0);
@@ -1184,7 +1385,7 @@
fail_io[n] = test_gpio_0[i];
n++;
}else{
- //printf("############gpio [%d] test success############\n", test_gpio_0[i]);
+ printf("############gpio [%d] test success############\n", test_gpio_0[i]);
}
}
@@ -1196,17 +1397,28 @@
fail_io[n] = test_gpio_1[i];
n++;
}else{
- //printf("############gpio [%d] test success############\n", test_gpio_1[i]);
+ printf("############gpio [%d] test success############\n", test_gpio_1[i]);
}
}
+
+ //Test 2
+ for(i = 0; i < total_2; i=i+2){
+ ret_2 = gpio_register_test_out_2(test_gpio_2[i], test_gpio_2[i+1], 0);
+ if(-1 == ret_2){
+ printf("!!!!!!!!!!!!gpio [%d] test failed!!!!!!!!!!!!\n", test_gpio_2[i+1]);
+ fail_io[n] = test_gpio_2[i];
+ n++;
+ }else{
+ printf("############gpio [%d] test success############\n", test_gpio_2[i+1]);
+ }
+ }
+
mbtk_adc_close();
return n;
}
-
#else
-
int mbtk_at_gpio(void* arg)
{
return -1;