static void * case_thread(DirectThread *thread, void *arg) { int ret; case_t *caseP = arg; bool passflg = false; FILE *fp = NULL; char command[100]; struct stat st; bool iio_enable; iio_enable = is_iio_enable(); printf("iio_enable = %d\n", iio_enable); if(caseP->type == 0) { switch(caseP->index) { //mem case mem: sprintf(command, "memtester %s 1 2 > /memerr.log 1> /dev/null", caseP->nod_path); // printf("command = %s\n", command); ret = system(command); // printf("mem ret = %d\n", ret); if(!ret && stat("/memerr.log", &st) >= 0) //获取文件信息 { if(st.st_size == 0) { passflg = true; } } break; case ddrsize: passflg = test_ddrsize(caseP); break; //flash case flash:; passflg = test_flash(caseP); break; //wifi case wifi: passflg = test_wifi(caseP); break; case bt: passflg = test_bt(caseP); break; //gsensor case gsensor: if(!iio_enable) passflg = test_gsensor(caseP); else passflg = test_iio(caseP, info); break; case gyro: if(!iio_enable) passflg = false; else passflg = test_iio(caseP, info + 1); break; case comp: if(!iio_enable) passflg = false; else passflg = test_iio(caseP, info + 2); break; case lightsensor: passflg = test_lightsensor(caseP); break; //camera // case camera: // passflg = wait_dev_plugin(caseP->nod_path); // break; //rtc case rtc: passflg = test_rtc(caseP); break; case gps: passflg = test_gps(caseP); break; case uart: passflg = test_uart(caseP); break; case ethernet: passflg = test_ethernet(caseP); break; } } else if(caseP->type == 1) { switch(caseP->index) { //sdcard case 0: passflg = test_mmc(caseP); break; //usb case 1: passflg = test_usb(caseP); break; case 2: passflg = test_pc(caseP); break; //hdmi case 3: wait_nod_state(caseP, &hdmi_flg); //test_hdmi(caseP, &hdmi_flg); break; //headphone case 4: wait_nod_state(caseP, &headphone_flg); break; //key case 5: passflg = test_key(caseP); break; //onoff case 6: passflg = test_key_onff(caseP); break; //charege case 7: passflg = test_charge(caseP); break; //mtv case 8: passflg = test_mtv(caseP); break; } } draw_result(caseP, passflg); }
int main(void) { LPC_GPIO2->FIODIR = BV(4) | BV(5); LPC_GPIO1->FIODIR = BV(23) | BV(SNES_CIC_PAIR_BIT); BITBAND(SNES_CIC_PAIR_REG->FIOSET, SNES_CIC_PAIR_BIT) = 1; LPC_GPIO0->FIODIR = BV(16); /* connect UART3 on P0[25:26] + SSP0 on P0[15:18] + MAT3.0 on P0[10] */ LPC_PINCON->PINSEL1 = BV(18) | BV(19) | BV(20) | BV(21) /* UART3 */ | BV(3) | BV(5); /* SSP0 (FPGA) except SS */ LPC_PINCON->PINSEL0 = BV(31); /* SSP0 */ /* | BV(13) | BV(15) | BV(17) | BV(19) SSP1 (SD) */ /* pull-down CIC data lines */ LPC_PINCON->PINMODE0 = BV(0) | BV(1) | BV(2) | BV(3); clock_disconnect(); snes_init(); snes_reset(1); power_init(); timer_init(); uart_init(); fpga_spi_init(); spi_preinit(); led_init(); /* do this last because the peripheral init()s change PCLK dividers */ clock_init(); LPC_PINCON->PINSEL0 |= BV(20) | BV(21); /* MAT3.0 (FPGA clock) */ led_pwm(); sdn_init(); printf("\n\nsd2snes mk.2\n============\nfw ver.: " VER "\ncpu clock: %d Hz\n", CONFIG_CPU_FREQUENCY); printf("PCONP=%lx\n", LPC_SC->PCONP); file_init(); cic_init(0); /* setup timer (fpga clk) */ LPC_TIM3->CTCR=0; LPC_TIM3->EMR=EMC0TOGGLE; LPC_TIM3->MCR=MR0R; LPC_TIM3->MR0=1; LPC_TIM3->TCR=1; fpga_init(); char *testnames[11] = { "SD ", "USB ", "RTC ", "CIC ", "FPGA ", "RAM ", "CLK ", "DAC ", "SNES IRQ", "SNES RAM", "SNES PA "}; char *teststate_names [3] = { "no run", "\x1b[32;1mPassed\x1b[m", "\x1b[31;1mFAILED\x1b[m" }; int testresults[11] = { NO_RUN, NO_RUN, NO_RUN, NO_RUN, NO_RUN, NO_RUN, NO_RUN, NO_RUN, NO_RUN, NO_RUN, NO_RUN }; testresults[TEST_SD] = test_sd(); //testresults[TEST_USB] = test_usb(); testresults[TEST_RTC] = test_rtc(); delay_ms(209); testresults[TEST_CIC] = test_cic(); testresults[TEST_FPGA] = test_fpga(); testresults[TEST_RAM] = test_mem(); printf("Loading SNES test ROM\n=====================\n"); load_rom((uint8_t*)"/sd2snes/test.bin", 0, LOADROM_WITH_RESET); printf("\n\n\n"); delay_ms(1000); testresults[TEST_CLK] = test_clk(); fpga_set_bram_addr(0x1fff); fpga_write_bram_data(0x01); // tell SNES test program to continue uint8_t snestest_irq_state, snestest_pa_state, snestest_mem_state, snestest_mem_bank; uint8_t snestest_irq_done = 0, snestest_pa_done = 0, snestest_mem_done = 0; uint8_t last_irq_state = 0x77, last_pa_state = 0x77, last_mem_state = 0x77, last_mem_bank = 0x77; uint32_t failed_addr = 0; while(!(snestest_irq_done & snestest_pa_done & snestest_mem_done)) { fpga_set_bram_addr(0); snestest_irq_state = fpga_read_bram_data(); snestest_mem_state = fpga_read_bram_data(); snestest_pa_state = fpga_read_bram_data(); snestest_mem_bank = fpga_read_bram_data(); if(snestest_irq_state != last_irq_state || snestest_mem_state != last_mem_state || snestest_pa_state != last_pa_state || snestest_mem_bank != last_mem_bank) { printf("SNES test status: IRQ: %02x PA: %02x MEM: %02x/%02x\r", snestest_irq_state, snestest_pa_state, snestest_mem_state, snestest_mem_bank); } last_irq_state = snestest_irq_state; last_mem_state = snestest_mem_state; last_pa_state = snestest_pa_state; last_mem_bank = snestest_mem_bank; if(snestest_pa_state != 0x00) snestest_pa_done = 1; if(snestest_irq_state != 0x00) snestest_irq_done = 1; if(snestest_mem_state == 0xff || snestest_mem_state == 0x5a) snestest_mem_done = 1; cli_entrycheck(); } printf("\n"); if(snestest_pa_state == 0xff) testresults[TEST_SNES_PA] = FAILED; else testresults[TEST_SNES_PA] = PASSED; if(snestest_irq_state == 0xff) testresults[TEST_SNES_IRQ] = FAILED; else testresults[TEST_SNES_IRQ] = PASSED; if(snestest_mem_state == 0xff) { testresults[TEST_SNES_RAM] = FAILED; fpga_set_bram_addr(4); failed_addr = fpga_read_bram_data(); failed_addr |= fpga_read_bram_data() << 8; failed_addr |= fpga_read_bram_data() << 16; printf("SNES MEM test FAILED (failed address: %06lx)\n", failed_addr); } else testresults[TEST_SNES_RAM] = PASSED; printf("\n\nTEST SUMMARY\n============\n\n"); printf("Test Result\n----------------\n"); int testcount; for(testcount=0; testcount < 11; testcount++) { printf("%s %s\n", testnames[testcount], teststate_names[testresults[testcount]]); } cli_loop(); while(1); }