now that's a proper cleanup

10.3.x-maintenance
cTn 2014-06-10 00:19:42 +02:00
parent c0387850aa
commit 99c5906a4b
1 changed files with 11 additions and 37 deletions

View File

@ -368,39 +368,12 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
self.verify_hex.push([]); self.verify_hex.push([]);
} }
function load_read_address() { // start
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) { self.clearStatus(function() {
var delay = data[1] | (data[2] << 8) | (data[3] << 16); self.loadAddress(address, function() {
self.clearStatus(read);
setTimeout(function() {
if (data[4] != self.state.dfuUPLOAD_IDLE) {
self.loadAddress(address, function() {
clear_status();
});
} else {
clear_status(function() {
load_read_address();
});
}
}, delay);
}); });
} });
function clear_status(callback) {
self.controlTransfer('out', self.request.CLRSTATUS, 0, 0, 0, 0, function() {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
if (data[4] == self.state.dfuIDLE) {
if (callback) {
callback();
} else {
read();
}
} else {
clear_status();
}
});
});
}
function read() { function read() {
if (bytes_verified < self.hex.data[reading_block].bytes) { if (bytes_verified < self.hex.data[reading_block].bytes) {
@ -428,9 +401,13 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
address = self.hex.data[reading_block].address; address = self.hex.data[reading_block].address;
bytes_verified = 0; bytes_verified = 0;
//wBlockNum = 2; wBlockNum = 2;
load_read_address(); self.clearStatus(function() {
self.loadAddress(address, function() {
self.clearStatus(read);
});
});
} else { } else {
// all blocks read, verify // all blocks read, verify
@ -463,9 +440,6 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
} }
} }
} }
// start
load_read_address();
break; break;
case 6: case 6:
// jump to application code // jump to application code