@@ -60,6 +60,7 @@ FatVolume wipperFatFs_v2; ///< File system object from Adafruit SDFat library
60
60
Adafruit_USBD_MSC usb_msc_v2; /* !< USB mass storage object */
61
61
Adafruit_USBD_CDC usb_cdc; /* !< USB CDC object */
62
62
static bool _fs_changed = false ;
63
+ static bool _did_init_msc = false ;
63
64
64
65
/* *************************************************************************/
65
66
/* !
@@ -105,6 +106,7 @@ FRESULT format_fs_fat12(void) {
105
106
/* *************************************************************************/
106
107
Wippersnapper_FS::Wippersnapper_FS () {
107
108
_fs_changed = false ;
109
+ _did_init_msc = false ;
108
110
109
111
usb_cdc.begin (115200 );
110
112
// Re-enumerate to allow cdc class begin() to take effect
@@ -121,7 +123,7 @@ Wippersnapper_FS::Wippersnapper_FS() {
121
123
}
122
124
123
125
// If we are not formatted, attempt to format the filesystem as fat12
124
- if (! wipperFatFs_v2.begin (&flash_v2)) {
126
+ if (!wipperFatFs_v2.begin (&flash_v2)) {
125
127
FRESULT rc = format_fs_fat12 ();
126
128
if (rc != FR_OK) {
127
129
setStatusLEDColor (RED);
@@ -141,10 +143,10 @@ Wippersnapper_FS::Wippersnapper_FS() {
141
143
HaltFilesystem (" FATAL ERROR: Could not write filesystem contents!" );
142
144
}
143
145
144
- // Initialize USB-MSC
145
- #ifndef BUILD_OFFLINE_ONLY
146
+ // Initialize USB-MSC
147
+ #ifndef BUILD_OFFLINE_ONLY
146
148
InitUsbMsc ();
147
- #endif
149
+ #endif
148
150
149
151
// If we wrote a fresh secrets.json file, halt until user edits the file and
150
152
// RESETs the device Signal to user that action must be taken (edit
@@ -300,6 +302,7 @@ void Wippersnapper_FS::InitUsbMsc() {
300
302
delay (10 );
301
303
TinyUSBDevice.attach ();
302
304
}
305
+ _did_init_msc = true ;
303
306
}
304
307
305
308
/* *************************************************************************/
@@ -679,6 +682,9 @@ void Wippersnapper_FS::WriteFileBoot(PGM_P str) {
679
682
*/
680
683
/* *************************************************************************/
681
684
void Wippersnapper_FS::HaltFilesystem (String msg) {
685
+ if (!_did_init_msc) {
686
+ InitUsbMsc ();
687
+ }
682
688
TinyUSBDevice.attach ();
683
689
delay (500 );
684
690
statusLEDSolid (WS_LED_STATUS_FS_WRITE);
@@ -699,6 +705,9 @@ void Wippersnapper_FS::HaltFilesystem(String msg) {
699
705
/* *************************************************************************/
700
706
void Wippersnapper_FS::HaltFilesystem (String msg,
701
707
ws_led_status_t ledStatusColor) {
708
+ if (!_did_init_msc) {
709
+ InitUsbMsc ();
710
+ }
702
711
TinyUSBDevice.attach ();
703
712
delay (500 );
704
713
statusLEDSolid (ledStatusColor);
0 commit comments