[RFC PATCH 06/10] Add function to read the rom from the OSTC3

Anton Lundin glance at acc.umu.se
Fri Nov 14 09:01:35 PST 2014


This is necessary to verify that the memory written got transfered
correctly.

This code is inspired by JeanDo ostc-companion.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 src/hw_ostc3.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/hw_ostc3.c b/src/hw_ostc3.c
index a4f2141..117a4bb 100644
--- a/src/hw_ostc3.c
+++ b/src/hw_ostc3.c
@@ -52,6 +52,7 @@
 #define RB_LOGBOOK_SIZE  256
 #define RB_LOGBOOK_COUNT 256
 
+#define READ_BLOCK 0x20
 #define ERASE_RANGE 0x42
 #define S_READY    0x4C
 #define READY      0x4D
@@ -821,3 +822,17 @@ hw_ostc3_device_erase_range (hw_ostc3_device_t *device, unsigned int addr, unsig
 
 	return rc;
 }
+
+static dc_status_t
+hw_ostc3_device_read_block (hw_ostc3_device_t *device, unsigned int addr, unsigned char block[], unsigned int block_size)
+{
+	unsigned char buffer[6];
+	uint24_be_array(addr, buffer);
+	uint24_be_array(block_size, buffer + 3);
+
+	// Make sure everything is in a sane state.
+	serial_sleep (device->port, 100);
+	serial_flush (device->port, SERIAL_QUEUE_BOTH);
+
+	return hw_ostc3_transfer (device, NULL, READ_BLOCK, buffer, sizeof(buffer), block, block_size);
+}
-- 
1.9.1



More information about the devel mailing list