void K9S1208_Menu(void) { int i; U16 id; printf("\n[K9S1208 NAND Flash JTAG Programmer]\n"); K9S1208_JtagInit(); NF_Init(); id=NF_CheckId(); if(id!=0xec76) { printf("ERROR: K9S1208 is not detected. Detected ID=0x%x.\n",id); return; } else { printf("K9S1208 is detected. ID=0x%x\n",id); } while(1) { i=0; while(1) { //display menu printf("%2d:%s",i,function[i][1]); i++; if((int)(function[i][0])==0) { printf("\n"); break; } if((i%4)==0) printf("\n"); } printf("Select the function to test :"); scanf("%d",&i); if( i>=0 && (i<((sizeof(function)/8)-2)) ) ( (void (*)(void)) (function[i][0]) )(); else break; //Exit menu } }
void K9S1208_PrintBlock(void)// Printf one page { int i; U16 id; U32 block,page; U8 buffer[512+16]; printf("\n[SMC(K9S1208) NAND Flash block read]\n"); NF_Init(); id=NF_CheckId(); printf("ID=%x(0xec76)\n",id); if(id!=0xec76) return; printf("Input target block number:"); scanf("%d",&block); printf("Input target page number:"); scanf("%d",&page); NF_ReadPage(block,page,buffer,buffer+512); printf("block=%d,page=%d:",block,page); for(i=0;i<512;i++) { if(i%16==0) printf("\n%3xh:",i); printf("%02x ",buffer[i]); } printf("\nS.A.:",i); for(i=512;i<512+16;i++) { printf("%02x ",buffer[i]); } printf("\n"); }
int main_client(int argc, char *const *argv) { int ch; struct ntp_peer *np; struct ntp_peerset *npl; struct todolist *tdl; struct combine_delta *cd; int fd; int npeer = 0; setbuf(stdout, NULL); setbuf(stderr, NULL); tdl = TODO_NewList(); Time_Unix(tdl); PLL_Init(); npl = NTP_PeerSet_New(NULL); Param_Register(client_param_table); NF_Init(); while ((ch = getopt(argc, argv, "p:t:")) != -1) { switch(ch) { case 'p': Param_Tweak(NULL, optarg); break; case 't': ArgTracefile(optarg); break; default: Fail(NULL, 0, "Usage %s [-p param] [-t tracefile] servers...", argv[0]); break; } } argc -= optind; argv += optind; for (ch = 0; ch < argc; ch++) npeer += NTP_PeerSet_Add(NULL, npl, argv[ch]); if (npeer == 0) Fail(NULL, 0, "No NTP peers found"); Put(NULL, OCX_TRACE, "# NTIMED Format client 1.0\n"); Put(NULL, OCX_TRACE, "# Found %d peers\n", npeer); Param_Report(NULL, OCX_TRACE); #ifndef NOIPV6 /* Attempt IPv6, fall back to IPv4 */ fd = UdpTimedSocket(NULL, AF_INET6); if (fd < 0) fd = UdpTimedSocket(NULL, AF_INET); #else fd = UdpTimedSocket(NULL, AF_INET); #endif if (fd < 0) Fail(NULL, errno, "Could not open UDP socket"); cd = CD_New(); NTP_PeerSet_Foreach(np, npl) { NF_New(np); np->combiner = CD_AddSource(cd, np->hostname, np->ip); }