From 26c62ab4317a17e0df6133b77b23f3115ed60ce5 Mon Sep 17 00:00:00 2001 From: brentru Date: Thu, 21 Nov 2024 16:24:46 -0500 Subject: [PATCH] putback main way to attach msc --- src/Wippersnapper_demo.ino | 1 + src/provisioning/tinyusb/Wippersnapper_FS_V2.cpp | 13 ++++++------- src/provisioning/tinyusb/Wippersnapper_FS_V2.h | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Wippersnapper_demo.ino b/src/Wippersnapper_demo.ino index fc0c684e..a4c20ebc 100644 --- a/src/Wippersnapper_demo.ino +++ b/src/Wippersnapper_demo.ino @@ -31,6 +31,7 @@ void setup() { Serial.begin(115200); while (!Serial) delay(10); + Serial.println("Adafruit Wippersnapper API Manager Demo"); Serial.print("Running Wippersnapper API Version: "); Serial.println(manager.getAPIVersion()); diff --git a/src/provisioning/tinyusb/Wippersnapper_FS_V2.cpp b/src/provisioning/tinyusb/Wippersnapper_FS_V2.cpp index fc883c40..f39d3ddd 100644 --- a/src/provisioning/tinyusb/Wippersnapper_FS_V2.cpp +++ b/src/provisioning/tinyusb/Wippersnapper_FS_V2.cpp @@ -129,6 +129,9 @@ Wippersnapper_FS_V2::Wippersnapper_FS_V2() { fsHalt("FATAL ERROR: Could not write filesystem contents!"); } + // Initialize USB-MSC + initUSBMSC(); + // If we wrote a fresh secrets.json file, halt until user edits the file and // RESETs the device Signal to user that action must be taken (edit // secrets.json) @@ -146,8 +149,6 @@ Wippersnapper_FS_V2::Wippersnapper_FS_V2() { "values\n. Using a text editor, edit it to reflect your Adafruit IO " "and WiFi credentials. Then, reset the board."); } - delay(500); - initUSBMSC(); // re-init USB MSC to show new file to user for editing } /************************************************************/ @@ -243,11 +244,9 @@ void Wippersnapper_FS_V2::initUSBMSC() { // If already enumerated, additional class driverr begin() e.g msc, hid, midi // won't take effect until re-enumeration - if (TinyUSBDevice.mounted()) { - TinyUSBDevice.detach(); - delay(10); - TinyUSBDevice.attach(); - } + // Attach MSC and wait for enumeration + TinyUSBDevice.attach(); + delay(500); } /**************************************************************************/ diff --git a/src/provisioning/tinyusb/Wippersnapper_FS_V2.h b/src/provisioning/tinyusb/Wippersnapper_FS_V2.h index fb7b5fa4..9f65096f 100644 --- a/src/provisioning/tinyusb/Wippersnapper_FS_V2.h +++ b/src/provisioning/tinyusb/Wippersnapper_FS_V2.h @@ -23,7 +23,6 @@ #include "fatfs/diskio.h" #include "Wippersnapper_V2.h" -#define SD_FAT_TYPE 3 // TODO: Remove this and move to sdcard class instead? // forward decl. class Wippersnapper_V2;