Skip to content

Commit 5dcae22

Browse files
committed
Fix wrong behaviour on Windows10 1903
1 parent b575efa commit 5dcae22

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

firmwares/MuxTO/MuxTO.ino

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,30 @@ void loop() {
118118
}
119119
}
120120

121-
if ((Serial.baud() != baudrate || serialNeedReconfiguration) && (millis() - updi_mode_end > 200)) {
122-
baudrate = Serial.baud();
123-
Serial1.begin(baudrate, serial_mode);
124-
serialNeedReconfiguration = false;
125-
if (baudrate == 1200 && Serial.dtr() == 1) {
126-
updi_mode = true;
127-
updi_mode_start = millis();
121+
if (baudrate == 1200 && Serial.dtr() == 0 && (millis() - updi_mode_end > 200)) {
122+
// don't reenter here if you just finished flashing
123+
updi_mode = true;
124+
updi_mode_start = millis();
125+
updi_mode_end = 0;
126+
}
127+
128+
if (Serial.baud() != baudrate || serialNeedReconfiguration) {
129+
if (Serial.dtr() == 1) {
130+
baudrate = Serial.baud();
131+
Serial1.end();
132+
Serial1.begin(baudrate, serial_mode);
133+
serialNeedReconfiguration = false;
128134
}
129135
}
136+
return;
130137
}
131138

132139
if (updi_mode == true) {
133140

134141
// updi_mode cannot last more than 1 minute; in that case, break forcibly
135-
if (millis() - updi_mode_start > 60000) {
142+
if ((updi_mode_end != 0 && (millis() - updi_mode_end) > 500) || ((millis() - updi_mode_start) > 60000)) {
136143
updi_mode = false;
144+
baudrate = -1;
137145
return;
138146
}
139147

@@ -161,10 +169,9 @@ void loop() {
161169
case JTAG2::CMND_SIGN_OFF:
162170
// Restore default baud rate before exiting
163171
JTAG2::PARAM_BAUD_RATE_VAL = JTAG2::baud_19200;
164-
updi_mode = false;
165-
updi_mode_end = millis();
166172
case JTAG2::CMND_LEAVE_PROGMODE:
167173
JTAG2::leave_progmode();
174+
updi_mode_end = millis();
168175
break;
169176
case JTAG2::CMND_GET_SYNC:
170177
case JTAG2::CMND_GO:

firmwares/MuxTO/crc16.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "JICE_io.h"
1111

1212
namespace {
13-
uint16_t crc_table[256] =
13+
static const uint16_t crc_table[256] =
1414
{ 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
1515
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
1616
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,

0 commit comments

Comments
 (0)