mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 22:05:17 +03:00
support for already initialized mcu
This commit is contained in:
parent
bb5bffc555
commit
77f00b0c6b
1 changed files with 22 additions and 11 deletions
33
js/stm32.js
33
js/stm32.js
|
@ -337,20 +337,31 @@ STM32_protocol.prototype.upload_procedure = function(step) {
|
||||||
switch (step) {
|
switch (step) {
|
||||||
case 1:
|
case 1:
|
||||||
// initialize serial interface on the MCU side, auto baud rate settings
|
// initialize serial interface on the MCU side, auto baud rate settings
|
||||||
// we could probably use interval timer here to try 2-3 times and then fail afterwards
|
var send_counter = 0;
|
||||||
self.send([0x7F], 1, function(reply) {
|
GUI.interval_add('stm32_initialize_mcu', function() { // 200 ms interval (just in case mcu was already initialized), we need to break the 2 bytes command requirement
|
||||||
if (reply[0] == self.status.ACK || reply[0] == self.status.NACK) {
|
self.send([0x7F], 1, function(reply) {
|
||||||
console.log('STM32 - Serial interface initialized on the MCU side');
|
if (reply[0] == self.status.ACK || reply[0] == self.status.NACK) {
|
||||||
|
GUI.interval_remove('stm32_initialize_mcu');
|
||||||
|
console.log('STM32 - Serial interface initialized on the MCU side');
|
||||||
|
|
||||||
|
// proceed to next step
|
||||||
|
self.upload_procedure(2);
|
||||||
|
} else {
|
||||||
|
console.log(reply);
|
||||||
|
|
||||||
|
GUI.interval_remove('stm32_initialize_mcu');
|
||||||
|
STM32.GUI_status('STM32 Communication with bootloader <span style="color: red">failed</span>');
|
||||||
|
|
||||||
// proceed to next step
|
// disconnect
|
||||||
self.upload_procedure(2);
|
self.upload_procedure(99);
|
||||||
} else {
|
}
|
||||||
STM32.GUI_status('STM32 Communication with bootloader <span style="color: red">failed</span>');
|
});
|
||||||
|
|
||||||
// disconnect
|
if (send_counter++ > 3) {
|
||||||
self.upload_procedure(99);
|
// stop retrying, its too late to get any response from MCU
|
||||||
|
GUI.interval_remove('stm32_initialize_mcu');
|
||||||
}
|
}
|
||||||
});
|
}, 200);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// get version of the bootloader and supported commands
|
// get version of the bootloader and supported commands
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue