Bladeren bron

Improve USB Media Host conditions (#20176)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Victor Oliveira 3 jaren geleden
bovenliggende
commit
f1cdd02d4c
No account linked to committer's email address

+ 4
- 0
Marlin/src/HAL/LPC1768/inc/Conditionals_adv.h Bestand weergeven

@@ -20,3 +20,7 @@
20 20
  *
21 21
  */
22 22
 #pragma once
23
+
24
+#if DISABLED(NO_SD_HOST_DRIVE)
25
+  #define HAS_SD_HOST_DRIVE 1
26
+#endif

+ 2
- 2
Marlin/src/HAL/LPC1768/main.cpp Bestand weergeven

@@ -122,7 +122,7 @@ void HAL_init() {
122 122
   delay(1000);                              // Give OS time to notice
123 123
   USB_Connect(TRUE);
124 124
 
125
-  #if DISABLED(NO_SD_HOST_DRIVE)
125
+  #if HAS_SD_HOST_DRIVE
126 126
     MSC_SD_Init(0);                         // Enable USB SD card access
127 127
   #endif
128 128
 
@@ -140,7 +140,7 @@ void HAL_init() {
140 140
 
141 141
 // HAL idle task
142 142
 void HAL_idletask() {
143
-  #if HAS_SHARED_MEDIA
143
+  #if HAS_SD_HOST_DRIVE
144 144
     // If Marlin is using the SD card we need to lock it to prevent access from
145 145
     // a PC via USB.
146 146
     // Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but

+ 1
- 1
Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp Bestand weergeven

@@ -31,7 +31,7 @@
31 31
   #error "ERROR - Only STM32F103xE, STM32F103xG, STM32F4xx or STM32F7xx CPUs supported"
32 32
 #endif
33 33
 
34
-#ifdef USBD_USE_CDC_COMPOSITE
34
+#if HAS_SD_HOST_DRIVE
35 35
 
36 36
   // use USB drivers
37 37
 

+ 4
- 0
Marlin/src/HAL/STM32/inc/Conditionals_adv.h Bestand weergeven

@@ -20,3 +20,7 @@
20 20
  *
21 21
  */
22 22
 #pragma once
23
+
24
+#if defined(USBD_USE_CDC_COMPOSITE) && DISABLED(NO_SD_HOST_DRIVE)
25
+  #define HAS_SD_HOST_DRIVE 1
26
+#endif

+ 11
- 13
Marlin/src/HAL/STM32F1/HAL.cpp Bestand weergeven

@@ -82,7 +82,7 @@
82 82
 // Public Variables
83 83
 // ------------------------
84 84
 
85
-#if (defined(SERIAL_USB) && !defined(USE_USB_COMPOSITE))
85
+#if defined(SERIAL_USB) && !HAS_SD_HOST_DRIVE
86 86
   USBSerial SerialUSB;
87 87
 #endif
88 88
 
@@ -251,7 +251,7 @@ void HAL_init() {
251 251
   #if PIN_EXISTS(LED)
252 252
     OUT_WRITE(LED_PIN, LOW);
253 253
   #endif
254
-  #ifdef USE_USB_COMPOSITE
254
+  #if HAS_SD_HOST_DRIVE
255 255
     MSC_SD_init();
256 256
   #endif
257 257
   #if PIN_EXISTS(USB_CONNECT)
@@ -263,17 +263,15 @@ void HAL_init() {
263 263
 
264 264
 // HAL idle task
265 265
 void HAL_idletask() {
266
-  #ifdef USE_USB_COMPOSITE
267
-    #if HAS_SHARED_MEDIA
268
-      // If Marlin is using the SD card we need to lock it to prevent access from
269
-      // a PC via USB.
270
-      // Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
271
-      // this will not reliably detect delete operations. To be safe we will lock
272
-      // the disk if Marlin has it mounted. Unfortunately there is currently no way
273
-      // to unmount the disk from the LCD menu.
274
-      // if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
275
-      /* copy from lpc1768 framework, should be fixed later for process HAS_SHARED_MEDIA*/
276
-    #endif
266
+  #if HAS_SD_HOST_DRIVE
267
+    // If Marlin is using the SD card we need to lock it to prevent access from
268
+    // a PC via USB.
269
+    // Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
270
+    // this will not reliably detect delete operations. To be safe we will lock
271
+    // the disk if Marlin has it mounted. Unfortunately there is currently no way
272
+    // to unmount the disk from the LCD menu.
273
+    // if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
274
+    /* copy from lpc1768 framework, should be fixed later for process HAS_SD_HOST_DRIVE*/
277 275
     // process USB mass storage device class loop
278 276
     MarlinMSC.loop();
279 277
   #endif

+ 2
- 2
Marlin/src/HAL/STM32F1/HAL.h Bestand weergeven

@@ -42,7 +42,7 @@
42 42
 
43 43
 #include "../../inc/MarlinConfigPre.h"
44 44
 
45
-#ifdef USE_USB_COMPOSITE
45
+#if HAS_SD_HOST_DRIVE
46 46
   #include "msc_sd.h"
47 47
 #endif
48 48
 
@@ -61,7 +61,7 @@
61 61
 #endif
62 62
 
63 63
 #ifdef SERIAL_USB
64
-  #ifndef USE_USB_COMPOSITE
64
+  #if !HAS_SD_HOST_DRIVE
65 65
     #define UsbSerial Serial
66 66
   #else
67 67
     #define UsbSerial MarlinCompositeSerial

+ 0
- 5
Marlin/src/HAL/STM32F1/inc/Conditionals_LCD.h Bestand weergeven

@@ -20,8 +20,3 @@
20 20
  *
21 21
  */
22 22
 #pragma once
23
-
24
-#if ENABLED(USE_USB_COMPOSITE)
25
-  //#warning "SD_CHECK_AND_RETRY isn't needed with USE_USB_COMPOSITE."
26
-  #undef SD_CHECK_AND_RETRY
27
-#endif

+ 8
- 0
Marlin/src/HAL/STM32F1/inc/Conditionals_adv.h Bestand weergeven

@@ -20,3 +20,11 @@
20 20
  *
21 21
  */
22 22
 #pragma once
23
+
24
+#ifdef USE_USB_COMPOSITE
25
+  //#warning "SD_CHECK_AND_RETRY isn't needed with USE_USB_COMPOSITE."
26
+  #undef SD_CHECK_AND_RETRY
27
+  #if DISABLED(NO_SD_HOST_DRIVE)
28
+    #define HAS_SD_HOST_DRIVE 1
29
+  #endif
30
+#endif

+ 2
- 2
Marlin/src/HAL/STM32F1/msc_sd.cpp Bestand weergeven

@@ -13,7 +13,7 @@
13 13
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
14 14
  *
15 15
  */
16
-#if defined(__STM32F1__) && defined(USE_USB_COMPOSITE)
16
+#if defined(__STM32F1__) && HAS_SD_HOST_DRIVE
17 17
 
18 18
 #include "msc_sd.h"
19 19
 #include "SPI.h"
@@ -77,4 +77,4 @@ void MSC_SD_init() {
77 77
   #endif
78 78
 }
79 79
 
80
-#endif // __STM32F1__ && USE_USB_COMPOSITE
80
+#endif // __STM32F1__ && HAS_SD_HOST_DRIVE

+ 5
- 4
Marlin/src/HAL/STM32F1/onboard_sd.cpp Bestand weergeven

@@ -21,10 +21,11 @@
21 21
 #include "SPI.h"
22 22
 #include "fastio.h"
23 23
 
24
-#if HAS_SHARED_MEDIA
25
-  #ifndef ONBOARD_SPI_DEVICE
26
-    #define ONBOARD_SPI_DEVICE SPI_DEVICE
27
-  #endif
24
+#ifndef ONBOARD_SPI_DEVICE
25
+  #define ONBOARD_SPI_DEVICE SPI_DEVICE
26
+#endif
27
+
28
+#if HAS_SD_HOST_DRIVE
28 29
   #define ONBOARD_SD_SPI SPI
29 30
 #else
30 31
   SPIClass OnboardSPI(ONBOARD_SPI_DEVICE);

+ 1
- 3
Marlin/src/inc/Conditionals_post.h Bestand weergeven

@@ -360,14 +360,13 @@
360 360
  */
361 361
 #if ENABLED(SDSUPPORT)
362 362
 
363
-  #if SD_CONNECTION_IS(ONBOARD) && DISABLED(NO_SD_HOST_DRIVE) && !defined(ARDUINO_GRAND_CENTRAL_M4)
363
+  #if HAS_SD_HOST_DRIVE && SD_CONNECTION_IS(ONBOARD)
364 364
     //
365 365
     // The external SD card is not used. Hardware SPI is used to access the card.
366 366
     // When sharing the SD card with a PC we want the menu options to
367 367
     // mount/unmount the card and refresh it. So we disable card detect.
368 368
     //
369 369
     #undef SD_DETECT_PIN
370
-    #define HAS_SHARED_MEDIA 1
371 370
   #endif
372 371
 
373 372
   #if PIN_EXISTS(SD_DETECT)
@@ -381,7 +380,6 @@
381 380
       #define SD_DETECT_STATE LOW
382 381
     #endif
383 382
   #endif
384
-
385 383
 #endif
386 384
 
387 385
 #if ANY(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT) || !PIN_EXISTS(SD_DETECT)

Laden…
Annuleren
Opslaan