Skip to content

Commit 5aa4a73

Browse files
committed
Correct tinyusb attach/detach usage
1 parent a741846 commit 5aa4a73

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/Wippersnapper.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,13 +2500,10 @@ void Wippersnapper::runNetFSM() {
25002500
*/
25012501
/**************************************************************************/
25022502
void Wippersnapper::haltError(String error, ws_led_status_t ledStatusColor) {
2503-
#ifdef USE_TINYUSB
2504-
if (!TinyUSBDevice.mounted()) {
2505-
TinyUSBDevice.attach(); // calling when already attached breaks SAMD
2506-
}
2507-
#endif
25082503
for (int i=0;;i++) {
2509-
WS_DEBUG_PRINT("ERROR [WDT RESET]: ");
2504+
WS_DEBUG_PRINT("ERROR [WDT RESET IN ");
2505+
WS_DEBUG_PRINT(25 - i);
2506+
WS_DEBUG_PRINTLN("]: ");
25102507
WS_DEBUG_PRINTLN(error);
25112508
// let the WDT fail out and reset!
25122509
statusLEDSolid(ledStatusColor);

src/provisioning/tinyusb/Wippersnapper_FS.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Wippersnapper_FS::Wippersnapper_FS() {
106106
// If a filesystem does not already exist - attempt to initialize a new
107107
// filesystem
108108
if (!initFilesystem() && !initFilesystem(true)) {
109+
TinyUSBDevice.attach();
109110
setStatusLEDColor(RED);
110111
fsHalt("ERROR Initializing Filesystem");
111112
}
@@ -222,8 +223,8 @@ void Wippersnapper_FS::initUSBMSC() {
222223
if (TinyUSBDevice.mounted()) {
223224
TinyUSBDevice.detach();
224225
delay(10);
226+
TinyUSBDevice.attach();
225227
}
226-
TinyUSBDevice.attach();
227228
delay(500);
228229
}
229230

@@ -490,8 +491,6 @@ void Wippersnapper_FS::writeToBootOut(PGM_P str) {
490491
*/
491492
/**************************************************************************/
492493
void Wippersnapper_FS::fsHalt(String msg) {
493-
TinyUSBDevice.attach();
494-
delay(500);
495494
statusLEDSolid(WS_LED_STATUS_FS_WRITE);
496495
while (1) {
497496
WS_DEBUG_PRINTLN("Fatal Error: Halted execution!");

0 commit comments

Comments
 (0)