Skip to content

Commit c61cd8a

Browse files
committed
Trigger 1200bps reset only if serial is in connected state
This patch MUST be retested on every OS
1 parent a6a95e1 commit c61cd8a

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

cores/arduino/CDC.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
#ifdef SERIAL_CDC
99
#include "USBSerial.h"
1010

11-
static void usbPortChanged(int baud, int bits, int parity, int stop) {
12-
if (baud == 1200) {
13-
_ontouch1200bps_();
14-
}
15-
}
16-
1711
namespace arduino {
1812

1913
namespace internal {
2014
extern USBSerial _serial;
2115
}
2216

17+
static void usbPortChanged(int baud, int bits, int parity, int stop) {
18+
if (baud == 1200 && internal::_serial.connected()) {
19+
_ontouch1200bps_();
20+
}
21+
}
22+
2323
class CDC : public HardwareSerial {
2424
public:
2525
CDC() {}

variants/ARDUINO_NANO33BLE/pins_arduino.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ static const uint8_t SCK = PIN_SPI_SCK;
132132

133133
#define digitalPinToPort(P) (digitalPinToPinName(P)/32)
134134

135-
static inline void _ontouch1200bps_() {
136-
__disable_irq();
137-
NRF_POWER->GPREGRET = DFU_MAGIC_SERIAL_ONLY_RESET;
138-
NVIC_SystemReset();
139-
}
135+
void _ontouch1200bps_();
140136

141137
#endif //__PINS_ARDUINO__

variants/ARDUINO_NANO33BLE/variant.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,11 @@ void initVariant() {
7979
#ifdef SERIAL_CDC
8080
#include "CDC.h"
8181
CDC SerialUSB;
82+
83+
void _ontouch1200bps_() {
84+
__disable_irq();
85+
NRF_POWER->GPREGRET = DFU_MAGIC_SERIAL_ONLY_RESET;
86+
NVIC_SystemReset();
87+
}
88+
8289
#endif

0 commit comments

Comments
 (0)