From 6322e96268e1c41734e407bc1ab0ccbb0bb4b621 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Sun, 9 Nov 2014 19:42:41 +0100 Subject: [PATCH] Add function to read the rom from the OSTC3 This is necessary to verify that the memory written got transfered correctly. This code is inspired by JeanDo ostc-companion. Reviewed-by: Jef Driesen Signed-off-by: Anton Lundin --- src/hw_ostc3.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/hw_ostc3.c b/src/hw_ostc3.c index 919b41a..a3ce889 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 S_BLOCK_READ 0x20 #define S_ERASE 0x42 #define S_READY 0x4C #define READY 0x4D @@ -890,3 +891,13 @@ hw_ostc3_firmware_erase (hw_ostc3_device_t *device, unsigned int addr, unsigned return hw_ostc3_transfer (device, NULL, S_ERASE, buffer, sizeof (buffer), NULL, 0); } + +static dc_status_t +hw_ostc3_firmware_block_read (hw_ostc3_device_t *device, unsigned int addr, unsigned char block[], unsigned int block_size) +{ + unsigned char buffer[6]; + array_uint24_be_set (buffer, addr); + array_uint24_be_set (buffer + 3, block_size); + + return hw_ostc3_transfer (device, NULL, S_BLOCK_READ, buffer, sizeof (buffer), block, block_size); +}