diff loadtools/romload.c @ 49:54392d1ea474

loadtools: first beginnings for the baud rate switching logic
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 23 Jun 2013 02:53:16 +0000
parents 24b88c119465
children f1df95eed62c
line wrap: on
line diff
--- a/loadtools/romload.c	Sun Jun 23 01:13:03 2013 +0000
+++ b/loadtools/romload.c	Sun Jun 23 02:53:16 2013 +0000
@@ -13,14 +13,17 @@
 #include <strings.h>
 #include <termios.h>
 #include <unistd.h>
+#include "baudrate.h"
 #include "srecreader.h"
 
 extern int errno;
 
 extern char *target_ttydev;
 extern int target_fd;
+extern struct baudrate baud_rate_table[];
 
 struct srecreader iramimage;
+struct baudrate *romload_baud_rate = baud_rate_table;	/* 1st entry default */
 
 static int beacon_interval = 13;	/* in milliseconds */
 
@@ -153,6 +156,7 @@
 
 	usleep(SERIAL_FLUSH_DELAY * 1000);
 	tcflush(target_fd, TCIFLUSH);
+	param_cmd[2] = romload_baud_rate->bootrom_code;
 	write(target_fd, param_cmd, sizeof param_cmd);
 	resp = expect_response(INTERMEDIATE_TIMEOUT);
 	if (resp != 'p') {
@@ -168,8 +172,9 @@
 				resp);
 		exit(1);
 	}
-	printf("<p command successful, switching to 115200 baud\n");
-	switch_baud_rate(B115200);
+	printf("<p command successful, switching to %s baud\n",
+		romload_baud_rate->name);
+	switch_baud_rate(romload_baud_rate);
 	usleep(SERIAL_FLUSH_DELAY * 1000);
 	tcflush(target_fd, TCIFLUSH);