[L509][change GPIOTEST in factory][report failed pin]
Change-Id: I188ef8163bf977be1d4847070d4e8260c716984b
diff --git a/mbtk/libmbtk_factory/mbtk_gpio.c b/mbtk/libmbtk_factory/mbtk_gpio.c
index e4baaef..cfcd1fb 100755
--- a/mbtk/libmbtk_factory/mbtk_gpio.c
+++ b/mbtk/libmbtk_factory/mbtk_gpio.c
@@ -824,36 +824,39 @@
#elif defined(MBTK_PROJECT_L509)
-mbtk_gpio_test_pin_paired test_pin_array[] ={ //是GPIO_array
+#define DEBUG_GPIO_TEST 0
+mbtk_gpio_paired_info_struct test_pin_array[] ={ //是GPIO_array
+//output_pin, output_gpio,input_gpio,input_pin,test_result
//120 5 33 这几个输入脚没法正常设置为输入
- //{52,51,0}, //拉不低 没有这一组
- //{54,53,0},
- {16,17,0},
- {117,120,0},
- //{118,19,0}, //usim
- {123,126,0},
- {43,23,0},
- {28,27,0},
- {26,25,0},
- {34,33,0},
- {36,35,0},
- {49,50,0},
- {32,31,0},
- {7,2,0},
- {6,1,0},
- {15,3,0},
- {0,18,0},
- {4,5,0},
- {13,14,0},
- {48,55,0},
- {56,57,0},
- {59,58,0},
- {21,99,0},
- //{20,22,0}, //拉不低
- //{12,122,0}, //拉不低 122好像不该用
+ //{?,52,51,?,0}, //拉不低 没有这一组
+ //{?,54,53,?,0},
+ //Opin,Ogpio,Igpio,Ipin,res
+ {122, 16, 17, 121, 0}, //output_pin, output_gpio,input_gpio,input_pin,test_result
+ {1, 117, 120, 2, 0},
+ //{?,118,19,13,?,0}, //usim
+ {5, 123, 126, 6, 0},
+ {23, 43, 23, 62, 0},
+ {24, 28, 27, 25, 0},
+ {26, 26, 25, 27, 0},
+ {37, 34, 33, 40, 0},
+ {38, 36, 35, 39, 0},
+ {41, 49, 50, 42, 0},
+ {64, 32, 31, 65, 0},
+ {78, 7, 2, 73, 0},
+ {77, 6, 1, 76, 0},
+ {81, 15, 3, 75, 0},
+ {74, 0, 18, 120,0},
+ {79, 4, 5, 82, 0},
+ {80, 13, 14, 84, 0},
+ {129, 48, 55, 130,0},
+ {131, 56, 57, 132,0},
+ {133, 59, 58, 134,0},
+ {135, 21, 99, 139,0},
+ //{?,20,22,?,0}, //拉不低
+ //{?,12,122,?,0}, //拉不低 122好像不该用
};
//测低
-uint16 mbtk_gpio_test_all_low(mbtk_gpio_test_pin_paired *pin_array, uint16 MAX_pin_num)
+uint16 mbtk_gpio_test_all_low(mbtk_gpio_paired_info_struct *pin_array, uint16 MAX_pin_num)
{
uint16 index =0;
uint16 OUT_pin, Read_pin;
@@ -862,12 +865,12 @@
uint16 fail_num=0;
int res;
- printf("[test_low_begin]\n");
+ printf("[GPIOTEST][run test all pin low]\n");
for(index = 0; index < MAX_pin_num; index++){
- OUT_pin = pin_array[index].output_pin;
- Read_pin = pin_array[index].input_pin;
+ OUT_pin = pin_array[index].output_gpio;
+ Read_pin = pin_array[index].input_gpio;
//输出低
gpio_register_set_direction(OUT_pin,1);
@@ -878,17 +881,19 @@
}
for(index = 0; index < MAX_pin_num; index++){
- OUT_pin = pin_array[index].output_pin;
- Read_pin = pin_array[index].input_pin;
+ OUT_pin = pin_array[index].output_gpio;
+ Read_pin = pin_array[index].input_gpio;
read_low_value = gpio_register_get_value(Read_pin);
//结果检测
if(read_low_value != 0){
- printf("[!Low Failed!]: GPIO%d \n", Read_pin);
+ printf("[GPIOTEST][!Low Failed!]: GPIO%d PIN%d\n", Read_pin,pin_array[index].input_pin);
pin_array[index].mbtk_gpio_test_result = 1;
fail_num ++;
}
else{
- printf("[-Low Success-]: GPIO%d \n", Read_pin);
+#if DEBUG_GPIO_TEST
+ printf("[GPIOTEST][-Low Success-]: GPIO%d \n", Read_pin);
+#endif
}
}
return fail_num;
@@ -898,7 +903,7 @@
//测高
-uint16 mbtk_gpio_test_pin_high(mbtk_gpio_test_pin_paired *pin_array,uint16 MAX_pin_num)
+uint16 mbtk_gpio_test_pin_high(mbtk_gpio_paired_info_struct *pin_array,uint16 MAX_pin_num)
{
uint16 index =0;
uint16 OUT_pin, Read_pin;
@@ -907,12 +912,12 @@
uint16 fail_num=0;
int i = 0;
- printf("[test_high_begin]\n");
+ printf("[GPIOTEST][run test pin high]\n");
for(index = 0;index<MAX_pin_num;index++)
{
- OUT_pin = pin_array[index].output_pin;
- Read_pin = pin_array[index].input_pin;
+ OUT_pin = pin_array[index].output_gpio;
+ Read_pin = pin_array[index].input_gpio;
//设高
gpio_register_set_direction(OUT_pin,1);
@@ -920,8 +925,9 @@
gpio_register_set_value(OUT_pin, 1);
usleep(20000);
read_high_value = gpio_register_get_value(Read_pin);
- printf("[test_high]: Gpio%d: get value =%d \n", Read_pin, read_high_value);
-
+#if DEBUG_GPIO_TEST
+ printf("[GPIOTEST][test_high]: PIN%d: get value =%d \n", pin_array[index].input_pin, read_high_value);
+#endif
//设高后重新设低
usleep(20000);
@@ -936,32 +942,35 @@
}
usleep(20000);
}
-
- printf("[test_low]: Gpio%d: get value =%d \n", Read_pin, read_low_value);
-
+#if DEBUG_GPIO_TEST
+ printf("[GPIOTEST][test_low]: PIN%d: get value =%d \n", pin_array[index].input_pin, read_low_value);
+#endif
if(read_high_value != 1||read_low_value !=0)
{
- printf("[!High Failed!]: Gpio%d\n",Read_pin);
+ printf("[GPIOTEST][!High Failed!]: Gpio%d PIN%d\n",Read_pin,pin_array[index].input_pin);
pin_array[index].mbtk_gpio_test_result = 2;
fail_num ++;
}
else{
- printf("[-High Success-]: Gpio%d \n", Read_pin);
+#if DEBUG_GPIO_TEST
+ printf("[GPIOTEST][-High Success-]: Gpio%d \n", Read_pin);
+#endif
}
}
return fail_num;
}
-void gpio_test_init_test_gpio_mode(mbtk_gpio_test_pin_paired pin_array[],int MAX_pin_num)
+void gpio_test_init_test_gpio_mode(mbtk_gpio_paired_info_struct pin_array[],int MAX_pin_num)
{
int index =0;
int OUT_pin, Read_pin;
- printf("[init] L509 GPIOTEST v1 \n");
+ printf("[GPIOTEST] L509 GPIOTEST v2 --init\n");
+
for(index = 0;index<MAX_pin_num;index++)
{
- OUT_pin = pin_array[index].output_pin;
- Read_pin = pin_array[index].input_pin;
+ OUT_pin = pin_array[index].output_gpio;
+ Read_pin = pin_array[index].input_gpio;
pin_array[index].mbtk_gpio_test_result = 0; //init as passed
gpio_register_set_func_0(OUT_pin);
gpio_register_set_func_0(Read_pin);
@@ -976,84 +985,83 @@
system("echo in > /sys/class/gpio/gpio120/direction");
system("echo in > /sys/class/gpio/gpio5/direction");
system("echo in > /sys/class/gpio/gpio33/direction");
- printf("[3init]gpio_test_init_test_gpio_mode FINISH\n");
+#if DEBUG_GPIO_TEST
+ printf("[GPIOTEST]gpio_test_init_test_gpio_mode FINISH\n");
+#endif
}
int mbtk_at_gpio(void* arg)
{
- int i, num;
- int *fail_io = (int *)arg;
- /*OPEN SWITCH */
- uint16 test_fail_count = 0;
- uint16 test_MAX_pin_num = 0;
- char buf[STR_MAX_LEN];
- uint16 str_len=0;
- uint16 temp_len =0;
- uint16 Out_pin;
- uint16 in_pin;
- uint16 fail_print_num = 0;
+ int i, num;
+ int *fail_io = (int *)arg;
+ /*OPEN SWITCH */
+ uint16 test_fail_count = 0;
+ uint16 test_MAX_pin_num = 0;
+ char buf[STR_MAX_LEN];
+ uint16 str_len=0;
+ uint16 temp_len =0;
+ uint16 Out_pin;
+ uint16 in_pin;
+ uint16 fail_print_num = 0;
- gpio_register_set_func_0(125);
- gpio_register_set_direction(125, 1);
- gpio_register_set_value(125, 1); //开关使能脚
-#if 0
- /* [2]设置高低电压范围 */
- if(th->threshold_high == 0 && th->threshold_low == 0 &&th->threshold_high_low_diff== 0)
- { //use default threshold
- th->threshold_high = MBTK_GPIOTEST_THRESHOLD_DEFAULT_HIGH;
- th->threshold_low = MBTK_GPIOTEST_THRESHOLD_DEFAULT_LOW;
- th->threshold_high_low_diff = MBTK_GPIOTEST_THRESHOLD_DEFAULT_DIFF;
- }
- RTI_LOG("GPIOTEST: threshold -- %d -- %d -- %d",th->threshold_low,th->threshold_high_low_diff,th->threshold_high);
-#endif
+ gpio_register_set_func_0(125);
+ gpio_register_set_direction(125, 1);
+ gpio_register_set_value(125, 1); //开关使能脚
+
/* [3]初始化待测GPIO */
- test_MAX_pin_num = sizeof(test_pin_array)/sizeof(test_pin_array[0]);
- gpio_test_init_test_gpio_mode(test_pin_array,test_MAX_pin_num);
+ test_MAX_pin_num = sizeof(test_pin_array)/sizeof(test_pin_array[0]);
+
+ gpio_test_init_test_gpio_mode(test_pin_array,test_MAX_pin_num);
/* [4]测试过程 */
- test_fail_count = mbtk_gpio_test_all_low(test_pin_array,test_MAX_pin_num);
- printf("[set_low]set ALL GPIO low, fail_num=%d\n",test_fail_count);
- if(!test_fail_count) //set all pin low passed
- {
- printf("[set all pin low passed]\n");
- test_fail_count = mbtk_gpio_test_pin_high(&test_pin_array,test_MAX_pin_num);
- }
+ test_fail_count = mbtk_gpio_test_all_low(test_pin_array,test_MAX_pin_num);
- //memset(buf,0,STR_MAX_LEN);
+ if(!test_fail_count) //set all pin low passed
+ {
+ printf("[GPIOTEST]set all pin low: passed\n");
+ test_fail_count = mbtk_gpio_test_pin_high(&test_pin_array,test_MAX_pin_num);
+ }
+ else
+ {
+ printf("[GPIOTEST]set all pin low: failed num=%d!!!\n",test_fail_count);
+ }
+
+ //memset(buf,0,STR_MAX_LEN);
+
/* [5]测试结果检测 */
- if(test_fail_count )
- {
- //printf( "GPIOTEST Fail %02d PINs:\n", test_fail_count*2);
- sprintf(buf, "GPIOTEST Fail %02d PINs:", test_fail_count*2);
- temp_len = strlen(buf);
+ if(test_fail_count )
+ {
+ //printf( "GPIOTEST Fail %02d PINs:\n", test_fail_count*2);
+ sprintf(buf, "GPIOTEST Fail %02d PINs:", test_fail_count*2);
+ temp_len = strlen(buf);
- num = 0;
- for(i = 0; i< test_MAX_pin_num; i++)
- {
+ num = 0;
+ for(i = 0; i< test_MAX_pin_num; i++)
+ {
- if(test_pin_array[i].mbtk_gpio_test_result)
- {
+ if(test_pin_array[i].mbtk_gpio_test_result)
+ {
- Out_pin = test_pin_array[i].output_pin;
- in_pin = test_pin_array[i].input_pin;
- fail_io[num++] = Out_pin;
- fail_io[num++] = in_pin;
+ Out_pin = test_pin_array[i].output_pin;
+ in_pin = test_pin_array[i].input_pin;
+ fail_io[num++] = Out_pin;
+ fail_io[num++] = in_pin;
- }
- }
- }
+ }
+ }
+ }
- else
- {
+ else
+ {
printf(buf,"ALL GPIO TEST PASS\r\n");
- }
- //temp_len = strlen(buf);
+ }
+ //temp_len = strlen(buf);
return test_fail_count * 2;
}
diff --git a/mbtk/libmbtk_factory/mbtk_gpio_def.h b/mbtk/libmbtk_factory/mbtk_gpio_def.h
index d6d9b51..e9ba6a5 100755
--- a/mbtk/libmbtk_factory/mbtk_gpio_def.h
+++ b/mbtk/libmbtk_factory/mbtk_gpio_def.h
@@ -154,5 +154,14 @@
}mbtk_gpio_test_pin_paired;
+typedef struct
+{
+ uint16 output_pin;
+ uint16 output_gpio;
+ uint16 input_gpio;
+ uint16 input_pin;
+ uint8 mbtk_gpio_test_result; // 0 is pass, 1 is low failed, 2 is high failed
+}mbtk_gpio_paired_info_struct;
+
#endif /*__GPIO_DEFINE_H__*/