| 
					
				 | 
			
			
				@@ -60,22 +60,31 @@ void lpc_init(struct lpc_device *dev) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   char buf[4096]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   printf("?"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   fflush(stdout); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  fgets(buf, sizeof(buf), stdin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if(strcmp(buf, "Synchronized\r\n")==0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    sprog_error("Synchronization successful\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  printf("Synchronized\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  fflush(stdout); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  fgets(buf, sizeof(buf), stdin); /* deny echoed line */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  fgets(buf, sizeof(buf), stdin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if(strcmp(buf, "OK\r\n")!=0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    sprog_error("Expected OK, received '%s'\n", buf); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  sprog_error("Sending clock frequency\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  printf("12000\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  fflush(stdout); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  fgets(buf, sizeof(buf), stdin); /* deny echoed line */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  fgets(buf, sizeof(buf), stdin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if(strcmp(buf, "OK\r\n")!=0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    sprog_error("Expected OK, received '%s'\n", buf); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if(sprog_waitdata(500)==0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    printf("\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    fflush(stdout); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    fgets(buf, sizeof(buf), stdin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(strcmp(buf, "?\r\n")==0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      sprog_error("The device appears to be already synchronized\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      fgets(buf, sizeof(buf), stdin); /* deny invalid command reply */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    fgets(buf, sizeof(buf), stdin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(strcmp(buf, "Synchronized\r\n")==0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      sprog_error("Synchronization successful\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    printf("Synchronized\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    fflush(stdout); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    fgets(buf, sizeof(buf), stdin); /* deny echoed line */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    fgets(buf, sizeof(buf), stdin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(strcmp(buf, "OK\r\n")!=0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      sprog_error("Expected OK, received '%s'\n", buf); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sprog_error("Sending clock frequency\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    printf("12000\r\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    fflush(stdout); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    fgets(buf, sizeof(buf), stdin); /* deny echoed line */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    fgets(buf, sizeof(buf), stdin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(strcmp(buf, "OK\r\n")!=0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      sprog_error("Expected OK, received '%s'\n", buf); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   sprog_error("Reading part ID\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   if(lpc_read_partid(dev)==0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     sprog_error("Found device: %s, %dkB Flash, %dkB RAM\n", dev->part->name, dev->part->flash, dev->part->ram); 
			 |