summaryrefslogtreecommitdiffstats
path: root/firmware/x300/lib/chinch.c
diff options
context:
space:
mode:
authorBen Hilburn <ben.hilburn@ettus.com>2014-02-14 12:05:07 -0800
committerBen Hilburn <ben.hilburn@ettus.com>2014-02-14 12:05:07 -0800
commitff1546f8137f7f92bb250f685561b0c34cc0e053 (patch)
tree7fa6fd05c8828df256a1b20e2935bd3ba9899e2c /firmware/x300/lib/chinch.c
parent4f691d88123784c2b405816925f1a1aef69d18c1 (diff)
downloaduhd-ff1546f8137f7f92bb250f685561b0c34cc0e053.tar.gz
uhd-ff1546f8137f7f92bb250f685561b0c34cc0e053.tar.bz2
uhd-ff1546f8137f7f92bb250f685561b0c34cc0e053.zip
Pushing the bulk of UHD-3.7.0 code.
Diffstat (limited to 'firmware/x300/lib/chinch.c')
-rw-r--r--firmware/x300/lib/chinch.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/firmware/x300/lib/chinch.c b/firmware/x300/lib/chinch.c
index 054845754..e33378851 100644
--- a/firmware/x300/lib/chinch.c
+++ b/firmware/x300/lib/chinch.c
@@ -210,15 +210,18 @@ bool chinch_flash_write_buf(uint32_t offset, uint16_t* buf, uint32_t size)
STATUS_CHAIN(chinch_poke16(base_addr + (i * 2), buf[i]), status);
}
- //Commit write and poll until data is written
+ //Commit write
STATUS_CHAIN(chinch_poke16(CHINCH_FLASH_WINDOW_BASE, 0x0029), status);
- if (status) {
- uint16_t read_data;
- while (true) {
- STATUS_MERGE(chinch_flash_read(base_addr, &read_data), status); //Wait for write to finish
- if ((read_data == buf[0]) || !status) break;
- }
- }
+
+ //Poll for completion
+ //Bit 7 of the data at the final address is the status bit.
+ //It is set to the inverse of bit 7 of the final data to be
+ //written until the final write is completed.
+ uint32_t read_data;
+ do {
+ STATUS_MERGE(chinch_peek16(base_addr + ((size - 1) * 2), &read_data), status);
+ } while (status && (((uint16_t)read_data ^ buf[size - 1]) & (1 << 7)));
+
return status;
}