void ts_test(void) { unsigned char c = 0; int lcd_x = 10, lcd_y = 10; printf("press q to exit\n\r"); while (1) { while (!has_get_xy) { getc_nowait(&c); if (c == 'q' || c == 'Q') { return ; } } hide_cross(lcd_x, lcd_y); has_get_xy = 0; lcd_x = (470 - 10)*(x - x_min) / (x_max - x_min) + 10; lcd_y = (262 - 10)*(y - y_min) / (y_max - y_min) + 10; if (lcd_x < 0 || lcd_x > 470 || lcd_y < 0 || lcd_y > 271) { printf("ts error!\n\r"); } else { show_cross(lcd_x, lcd_y); } } }
int main(int argc, char **argv) { char ch; cprintf("Main started\nVersion: "); cprintf(MAIN_VERSION); cprintf("\n"); for (ch = 0; ch < 26; ch++) { osram_write(osram_init[ch]); }; rs485Init(); steppersInit(); cmdlineInit(); cmdlineAddCommand("help", do_help); cmdlineAddCommand("?", do_help); cmdlineAddCommand("dump", do_dump); cmdlineAddCommand("ls", do_ls); cmdlineAddCommand("dir", do_ls); cmdlineAddCommand("mv", do_rename); cmdlineAddCommand("rename", do_rename); cmdlineAddCommand("rm", do_rm); cmdlineAddCommand("delete", do_rm); cmdlineAddCommand("spi_speed", do_spi_speed); cmdlineAddCommand("osram", do_osram); cmdlineAddCommand("flash", do_flash); cmdlineAddCommand("readmem", do_readmem); cmdlineAddCommand("rd", do_rd); cmdlineAddCommand("wr", do_wr); cmdlineAddCommand("rd32", do_rd32); cmdlineAddCommand("wr32", do_wr32); cmdlineAddCommand("step", do_step); cmdlineAddCommand("build", do_build); cmdlineAddCommand("sendcmd", do_sendcmd); cmdlineAddCommand("reset", (void *)0xE000); cmdlinePrintPrompt(); while (1) { if (getc_nowait(&ch)) { cmdlineInputFunc(ch); }; cmdlineMainLoop(); rs485MainLoop(); steppersMainLoop(); }; cprintf("\ndone\n"); return 0; }
void update_program(void) { unsigned char *buf = (unsigned char *)0x52000000; unsigned long len = 0; int have_begin = 0; int nodata_time = 0; char c; /* 读串口获得数据 */ printf("\n\ruse gtkterm to send file\n\r", len); while (1) { if (getc_nowait(&buf[len]) == 0) { have_begin = 1; nodata_time = 0; len++; } else { if (have_begin) { nodata_time++; } } if (nodata_time == 1000) { break; } } printf("have get %d bytes data\n\r", len); printf("Press Y to program the flash: \n\r"); c = getc(); if (c == 'y' || c == 'Y') { /* 烧写到nand flash block 0 */ nand_erase_block(0); nand_write(0, buf, len); printf("update program successful\n\r"); } else { printf("Cancel program!\n\r"); } }
void run_program(void) { unsigned char *buf = (unsigned char *)0x52000000; unsigned long len = 0; int have_begin = 0; int nodata_time = 0; void (*theProgram)(void); /* 读串口获得数据 */ printf("\n\ruse gtkterm to send file\n\r", len); while (1) { if (getc_nowait(&buf[len]) == 0) { have_begin = 1; nodata_time = 0; len++; } else { if (have_begin) { nodata_time++; } } if (nodata_time == 1000) { break; } } printf("have get %d bytes data\n\r", len); printf("jump to 0x52000000 to run it\n\r"); theProgram = (void (*)(void))0x52000000; theProgram(); }
void update_program(void) { unsigned char *buf = (unsigned char *)0x52000000; unsigned long len = 0; int have_begin = 0; int nodata_time = 0; unsigned long erase_addr; char c; int i; /* 读串口获得数据 */ printf("\n\ruse V2.2.exe/gtkterm to send file\n\r", len); while (1) { if (getc_nowait(&buf[len]) == 0) { have_begin = 1; nodata_time = 0; len++; } else { if (have_begin) { nodata_time++; } } if (nodata_time == 1000) { break; } } printf("have get %d bytes data\n\r", len); printf("the first 16 bytes data: \n\r"); for (i = 0; i < 16; i++) { printf("%02x ", buf[i]); } printf("\n\r"); printf("Press Y to program the flash: \n\r"); c = getc(); if (c == 'y' || c == 'Y') { /* 烧写到nand flash block 0 */ for (erase_addr = 0; erase_addr < ((len + 0x1FFFF) & ~0x1FFFF); erase_addr += 0x20000) { nand_erase_block(erase_addr); } nand_write(0, buf, len); printf("update program successful\n\r"); } else { printf("Cancel program!\n\r"); } }