Bladeren bron

Reset the device after writing to Flash

Reset the device, so it will possibly start executing the programmed code.
Mateusz Bugdalski 13 jaren geleden
bovenliggende
commit
d19d40eb30
2 gewijzigde bestanden met toevoegingen van 5 en 2 verwijderingen
  1. 2 1
      lpc.c
  2. 3 1
      sprog.c

+ 2 - 1
lpc.c

@@ -61,7 +61,7 @@ struct lpc_device *lpc_setup(struct serial_device *port) {
   dev = malloc(sizeof(struct lpc_device));
   dev->port = port;
   dev->part = NULL;
-  dev->reply_time = 500;
+  dev->reply_time = 5000;
   lpc_reset(dev, 1);
   return dev;
 }
@@ -345,6 +345,7 @@ void lpc_reset(struct lpc_device *dev, int isp) {
 }
 
 void lpc_close(struct lpc_device *dev) {
+  lpc_reset(dev, 0);
   serial_close(dev->port);
   free(dev);
 }

+ 3 - 1
sprog.c

@@ -54,8 +54,10 @@ void sprog_process(const struct sprog_family *fam, void *arg, const struct sprog
   fam->init(arg);
   if(mode==1)
     fam->exec(arg, d);
-  else if(mode==2)
+  else if(mode==2) {
     fam->write(arg, d);
+    fam->close(d);
+  }
 }
 
 void sprog_load(struct sprog_data *d, const char *path) {