소스 검색

Update USB_FLASH_DRIVE_SUPPORT (#15021)

Marcio Teixeira 4 년 전
부모
커밋
da601d5114
100개의 변경된 파일12040개의 추가작업 그리고 494개의 파일을 삭제
  1. 18
    4
      Marlin/Configuration_adv.h
  2. 227
    63
      Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp
  3. 4
    20
      Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h
  4. 9
    11
      Marlin/src/sd/usb_flashdrive/lib-uhs2/README.txt
  5. 1
    1
      Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp
  6. 1
    2
      Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.h
  7. 0
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/UsbCore.h
  8. 0
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/address.h
  9. 0
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/confdescparser.h
  10. 0
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/hexdump.h
  11. 0
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/macros.h
  12. 2
    2
      Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp
  13. 0
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h
  14. 9
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/max3421e.h
  15. 1
    1
      Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp
  16. 0
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/message.h
  17. 1
    1
      Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.cpp
  18. 0
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.h
  19. 0
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/printhex.h
  20. 0
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/settings.h
  21. 0
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h
  22. 4
    4
      Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp
  23. 0
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.h
  24. 31
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/README.txt
  25. 249
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE.h
  26. 1210
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h
  27. 328
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_SCSI.h
  28. 33
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UNOFFICIAL_IDs.h
  29. 2995
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_USB_IDs.h
  30. 336
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UsbCore.h
  31. 248
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_address.h
  32. 70
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_hexdump.h
  33. 111
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host.h
  34. 1224
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h
  35. 393
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_macros.h
  36. 91
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_message.h
  37. 201
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printf_HELPER.h
  38. 96
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printhex.h
  39. 141
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_settings.h
  40. 222
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usb_ch9.h
  41. 452
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h
  42. 129
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_util_INLINE.h
  43. 226
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/UHS_max3421e.h
  44. 519
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD.h
  45. 1003
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h
  46. 153
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/macro_logic.h
  47. 246
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/dyn_SWI/SWI_INLINE.h
  48. 172
    0
      Marlin/src/sd/usb_flashdrive/lib-uhs3/dyn_SWI/dyn_SWI.h
  49. 0
    187
      Marlin/src/sd/usb_flashdrive/usb-2.0-host-library-changes.patch
  50. 18
    4
      config/default/Configuration_adv.h
  51. 18
    4
      config/examples/3DFabXYZ/Migbot/Configuration_adv.h
  52. 18
    4
      config/examples/ADIMLab/Granty v2/Configuration_adv.h
  53. 18
    4
      config/examples/AlephObjects/TAZ4/Configuration_adv.h
  54. 18
    4
      config/examples/Alfawise/U20/Configuration_adv.h
  55. 18
    4
      config/examples/AliExpress/UM2pExt/Configuration_adv.h
  56. 18
    4
      config/examples/Anet/A2/Configuration_adv.h
  57. 18
    4
      config/examples/Anet/A2plus/Configuration_adv.h
  58. 18
    4
      config/examples/Anet/A6/Configuration_adv.h
  59. 18
    4
      config/examples/Anet/A8/Configuration_adv.h
  60. 18
    4
      config/examples/Anet/A8plus/Configuration_adv.h
  61. 18
    4
      config/examples/Anet/E16/Configuration_adv.h
  62. 18
    4
      config/examples/AnyCubic/i3/Configuration_adv.h
  63. 18
    4
      config/examples/ArmEd/Configuration_adv.h
  64. 18
    4
      config/examples/BIBO/TouchX/cyclops/Configuration_adv.h
  65. 18
    4
      config/examples/BIBO/TouchX/default/Configuration_adv.h
  66. 18
    4
      config/examples/BQ/Hephestos/Configuration_adv.h
  67. 18
    4
      config/examples/BQ/Hephestos_2/Configuration_adv.h
  68. 18
    4
      config/examples/BQ/WITBOX/Configuration_adv.h
  69. 18
    4
      config/examples/Cartesio/Configuration_adv.h
  70. 18
    4
      config/examples/Creality/CR-10/Configuration_adv.h
  71. 18
    4
      config/examples/Creality/CR-10S/Configuration_adv.h
  72. 18
    4
      config/examples/Creality/CR-10_5S/Configuration_adv.h
  73. 18
    4
      config/examples/Creality/CR-10mini/Configuration_adv.h
  74. 18
    4
      config/examples/Creality/CR-20 Pro/Configuration_adv.h
  75. 18
    4
      config/examples/Creality/CR-20/Configuration_adv.h
  76. 18
    4
      config/examples/Creality/CR-8/Configuration_adv.h
  77. 18
    4
      config/examples/Creality/Ender-2/Configuration_adv.h
  78. 18
    4
      config/examples/Creality/Ender-3/Configuration_adv.h
  79. 18
    4
      config/examples/Creality/Ender-4/Configuration_adv.h
  80. 18
    4
      config/examples/Creality/Ender-5/Configuration_adv.h
  81. 18
    4
      config/examples/Dagoma/Disco Ultimate/Configuration_adv.h
  82. 18
    4
      config/examples/EVNOVO (Artillery)/Sidewinder X1/Configuration_adv.h
  83. 18
    4
      config/examples/Einstart-S/Configuration_adv.h
  84. 18
    4
      config/examples/FYSETC/AIO_II/Configuration_adv.h
  85. 18
    4
      config/examples/FYSETC/Cheetah 1.2/BLTouch/Configuration_adv.h
  86. 18
    4
      config/examples/FYSETC/Cheetah 1.2/base/Configuration_adv.h
  87. 18
    4
      config/examples/FYSETC/Cheetah/BLTouch/Configuration_adv.h
  88. 18
    4
      config/examples/FYSETC/Cheetah/base/Configuration_adv.h
  89. 2
    2
      config/examples/FYSETC/F6_13/Configuration_adv.h
  90. 18
    4
      config/examples/Felix/Configuration_adv.h
  91. 18
    4
      config/examples/FlashForge/CreatorPro/Configuration_adv.h
  92. 18
    4
      config/examples/FolgerTech/i3-2020/Configuration_adv.h
  93. 18
    4
      config/examples/Formbot/Raptor/Configuration_adv.h
  94. 18
    4
      config/examples/Formbot/T_Rex_2+/Configuration_adv.h
  95. 18
    4
      config/examples/Formbot/T_Rex_3/Configuration_adv.h
  96. 18
    4
      config/examples/Geeetech/A10/Configuration_adv.h
  97. 18
    4
      config/examples/Geeetech/A10M/Configuration_adv.h
  98. 18
    4
      config/examples/Geeetech/A20M/Configuration_adv.h
  99. 18
    4
      config/examples/Geeetech/MeCreator2/Configuration_adv.h
  100. 0
    0
      config/examples/Geeetech/Prusa i3 Pro C/Configuration_adv.h

+ 18
- 4
Marlin/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 227
- 63
Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp 파일 보기

@@ -22,12 +22,75 @@
22 22
 
23 23
 #include "../../inc/MarlinConfigPre.h"
24 24
 
25
+/**
26
+ * Adjust USB_DEBUG to select debugging verbosity.
27
+ *    0 - no debug messages
28
+ *    1 - basic insertion/removal messages
29
+ *    2 - show USB state transitions
30
+ *    3 - perform block range checking
31
+ *    4 - print each block access
32
+ */
33
+#define USB_DEBUG         1
34
+#define USB_STARTUP_DELAY 0
35
+
36
+// uncomment to get 'printf' console debugging. NOT FOR UNO!
37
+//#define HOST_DEBUG(...)     {char s[255]; sprintf(s,__VA_ARGS__); SERIAL_ECHOLNPAIR("UHS:",s);}
38
+//#define BS_HOST_DEBUG(...)  {char s[255]; sprintf(s,__VA_ARGS__); SERIAL_ECHOLNPAIR("UHS:",s);}
39
+//#define MAX_HOST_DEBUG(...) {char s[255]; sprintf(s,__VA_ARGS__); SERIAL_ECHOLNPAIR("UHS:",s);}
40
+
25 41
 #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
26 42
 
43
+#include "../../Marlin.h"
27 44
 #include "../../core/serial.h"
45
+#include "../../module/temperature.h"
46
+
47
+static_assert(USB_CS_PIN   != -1, "USB_CS_PIN must be defined");
48
+static_assert(USB_INTR_PIN != -1, "USB_INTR_PIN must be defined");
49
+
50
+#if ENABLED(USE_UHS3_USB)
51
+  #define NO_AUTO_SPEED
52
+  #define UHS_MAX3421E_SPD 8000000 >> SPI_SPEED
53
+  #define UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE 1
54
+  #define UHS_HOST_MAX_INTERFACE_DRIVERS 2
55
+  #define MASS_MAX_SUPPORTED_LUN 1
56
+  #define USB_HOST_SERIAL MYSERIAL0
57
+
58
+  // Workaround for certain issues with UHS3
59
+  #define SKIP_PAGE3F // Required for IOGEAR media adapter
60
+  #define USB_NO_TEST_UNIT_READY // Required for removable media adapter
61
+  #define USB_HOST_MANUAL_POLL // Optimization to shut off IRQ automatically
62
+
63
+  // Workarounds for keeping Marlin's watchdog timer from barking...
64
+  void marlin_yield() {
65
+    thermalManager.manage_heater();
66
+  }
67
+  #define SYSTEM_OR_SPECIAL_YIELD(...) marlin_yield();
68
+  #define delay(x) safe_delay(x)
69
+
70
+  #define LOAD_USB_HOST_SYSTEM
71
+  #define LOAD_USB_HOST_SHIELD
72
+  #define LOAD_UHS_BULK_STORAGE
73
+
74
+  #define MARLIN_UHS_WRITE_SS(v) WRITE(USB_CS_PIN, v)
75
+  #define MARLIN_UHS_READ_IRQ()  READ(USB_INTR_PIN)
76
+
77
+  #include "lib-uhs3/UHS_host/UHS_host.h"
78
+
79
+  MAX3421E_HOST usb(USB_CS_PIN, USB_INTR_PIN);
80
+  UHS_Bulk_Storage bulk(&usb);
81
+
82
+  #define UHS_START  (usb.Init() == 0)
83
+  #define UHS_STATE(state) UHS_USB_HOST_STATE_##state
84
+#else
85
+  #include "lib-uhs2/Usb.h"
86
+  #include "lib-uhs2/masstorage.h"
28 87
 
29
-#include "lib/Usb.h"
30
-#include "lib/masstorage.h"
88
+  USB usb;
89
+  BulkOnly bulk(&usb);
90
+
91
+  #define UHS_START usb.start()
92
+  #define UHS_STATE(state) USB_STATE_##state
93
+#endif
31 94
 
32 95
 #include "Sd2Card_FlashDrive.h"
33 96
 
@@ -35,10 +98,41 @@
35 98
   #include "../../lcd/ultralcd.h"
36 99
 #endif
37 100
 
38
-USB usb;
39
-BulkOnly bulk(&usb);
101
+static enum {
102
+  UNINITIALIZED,
103
+  DO_STARTUP,
104
+  WAIT_FOR_DEVICE,
105
+  WAIT_FOR_LUN,
106
+  MEDIA_READY,
107
+  MEDIA_ERROR
108
+} state;
109
+
110
+#if USB_DEBUG >= 3
111
+  uint32_t lun0_capacity;
112
+#endif
113
+
114
+bool Sd2Card::usbStartup() {
115
+  if (state <= DO_STARTUP) {
116
+    SERIAL_ECHOPGM("Starting USB host...");
117
+    if (!UHS_START) {
118
+      SERIAL_ECHOLNPGM(" failed.");
119
+      #if EITHER(ULTRA_LCD, EXTENSIBLE_UI)
120
+        LCD_MESSAGEPGM("USB start failed");
121
+      #endif
122
+      return false;
123
+    }
40 124
 
41
-Sd2Card::state_t Sd2Card::state;
125
+    // SPI quick test - check revision register
126
+    switch (usb.regRd(rREVISION)) {
127
+      case 0x01: SERIAL_ECHOLNPGM("rev.01 started"); break;
128
+      case 0x12: SERIAL_ECHOLNPGM("rev.02 started"); break;
129
+      case 0x13: SERIAL_ECHOLNPGM("rev.03 started"); break;
130
+      default:   SERIAL_ECHOLNPGM("started. rev unknown."); break;
131
+    }
132
+    state = WAIT_FOR_DEVICE;
133
+  }
134
+  return true;
135
+}
42 136
 
43 137
 // The USB library needs to be called periodically to detect USB thumbdrive
44 138
 // insertion and removals. Call this idle() function periodically to allow
@@ -46,75 +140,145 @@ Sd2Card::state_t Sd2Card::state;
46 140
 // of initializing the USB library for the first time.
47 141
 
48 142
 void Sd2Card::idle() {
49
-  static uint32_t next_retry;
50
-
51
-  switch (state) {
52
-    case USB_HOST_DELAY_INIT:
53
-      next_retry = millis() + 2000;
54
-      state = USB_HOST_WAITING;
55
-      break;
56
-    case USB_HOST_WAITING:
57
-      if (ELAPSED(millis(), next_retry)) {
58
-        next_retry = millis() + 2000;
59
-        state = USB_HOST_UNINITIALIZED;
60
-      }
61
-      break;
62
-    case USB_HOST_UNINITIALIZED:
63
-      SERIAL_ECHOPGM("Starting USB host...");
64
-      if (!usb.start()) {
65
-        SERIAL_ECHOPGM(" Failed. Retrying in 2s.");
66
-        #if HAS_DISPLAY
67
-          LCD_MESSAGEPGM("USB start failed");
68
-        #endif
69
-        state = USB_HOST_DELAY_INIT;
143
+  usb.Task();
144
+
145
+  const uint8_t task_state = usb.getUsbTaskState();
146
+
147
+  #if USB_DEBUG >= 2
148
+    if (state > DO_STARTUP) {
149
+      static uint8_t laststate = 232;
150
+      if (task_state != laststate) {
151
+        laststate = task_state;
152
+        #define UHS_USB_DEBUG(x) case UHS_STATE(x): SERIAL_ECHOLNPGM(#x); break
153
+        switch (task_state) {
154
+          UHS_USB_DEBUG(IDLE);
155
+          UHS_USB_DEBUG(RESET_DEVICE);
156
+          UHS_USB_DEBUG(RESET_NOT_COMPLETE);
157
+          UHS_USB_DEBUG(DEBOUNCE);
158
+          UHS_USB_DEBUG(DEBOUNCE_NOT_COMPLETE);
159
+          UHS_USB_DEBUG(WAIT_SOF);
160
+          UHS_USB_DEBUG(ERROR);
161
+          UHS_USB_DEBUG(CONFIGURING);
162
+          UHS_USB_DEBUG(CONFIGURING_DONE);
163
+          UHS_USB_DEBUG(RUNNING);
164
+          default:
165
+            SERIAL_ECHOLNPAIR("UHS_USB_HOST_STATE: ", task_state);
166
+            break;
167
+        }
70 168
       }
71
-      else
72
-        state = USB_HOST_INITIALIZED;
73
-      SERIAL_EOL();
74
-      break;
75
-    case USB_HOST_INITIALIZED:
76
-      const uint8_t lastUsbTaskState = usb.getUsbTaskState();
77
-      usb.Task();
78
-      const uint8_t newUsbTaskState  = usb.getUsbTaskState();
79
-
80
-      if (lastUsbTaskState == USB_STATE_RUNNING && newUsbTaskState != USB_STATE_RUNNING) {
81
-        // the user pulled the flash drive. Make sure the bulk storage driver releases the address
82
-        #ifdef USB_DEBUG
83
-          SERIAL_ECHOLNPGM("USB drive removed");
169
+    }
170
+  #endif
171
+
172
+  static millis_t next_state_ms = millis();
173
+
174
+  #define GOTO_STATE_AFTER_DELAY(STATE, DELAY) do{ state = STATE; next_state_ms  = millis() + DELAY; }while(0)
175
+
176
+  if (ELAPSED(millis(), next_state_ms)) {
177
+    GOTO_STATE_AFTER_DELAY(state, 250); // Default delay
178
+
179
+    switch (state) {
180
+
181
+      case UNINITIALIZED:
182
+        #ifndef MANUAL_USB_STARTUP
183
+          GOTO_STATE_AFTER_DELAY( DO_STARTUP, USB_STARTUP_DELAY );
84 184
         #endif
85
-        //bulk.Release();
86
-      }
87
-      if (lastUsbTaskState != USB_STATE_RUNNING && newUsbTaskState == USB_STATE_RUNNING) {
88
-        #ifdef USB_DEBUG
89
-          SERIAL_ECHOLNPGM("USB drive inserted");
185
+        break;
186
+
187
+      case DO_STARTUP: usbStartup(); break;
188
+
189
+      case WAIT_FOR_DEVICE:
190
+        if (task_state == UHS_STATE(RUNNING)) {
191
+          #if USB_DEBUG >= 1
192
+            SERIAL_ECHOLNPGM("USB device inserted");
193
+          #endif
194
+          GOTO_STATE_AFTER_DELAY( WAIT_FOR_LUN, 250 );
195
+        }
196
+        break;
197
+
198
+      case WAIT_FOR_LUN:
199
+        /* USB device is inserted, but if it is an SD card,
200
+         * adapter it may not have an SD card in it yet. */
201
+        if (bulk.LUNIsGood(0)) {
202
+          #if USB_DEBUG >= 1
203
+            SERIAL_ECHOLNPGM("LUN is good");
204
+          #endif
205
+          GOTO_STATE_AFTER_DELAY( MEDIA_READY, 100 );
206
+        }
207
+        else {
208
+          #ifdef USB_HOST_MANUAL_POLL
209
+            // Make sure we catch disconnect events
210
+            usb.busprobe();
211
+            usb.VBUS_changed();
212
+          #endif
213
+          #if USB_DEBUG >= 1
214
+            SERIAL_ECHOLNPGM("Waiting for media");
215
+          #endif
216
+          #if EITHER(ULTRA_LCD, EXTENSIBLE_UI)
217
+            LCD_MESSAGEPGM("Waiting for media");
218
+          #endif
219
+          GOTO_STATE_AFTER_DELAY(state, 2000);
220
+        }
221
+        break;
222
+
223
+      case MEDIA_READY: break;
224
+      case MEDIA_ERROR: break;
225
+    }
226
+
227
+    if (state > WAIT_FOR_DEVICE && task_state != UHS_STATE(RUNNING)) {
228
+      // Handle device removal events
229
+      #if USB_DEBUG >= 1
230
+        SERIAL_ECHOLNPGM("USB device removed");
231
+      #endif
232
+      #if EITHER(ULTRA_LCD, EXTENSIBLE_UI)
233
+        if (state != MEDIA_READY)
234
+          LCD_MESSAGEPGM("USB device removed");
235
+      #endif
236
+      GOTO_STATE_AFTER_DELAY( WAIT_FOR_DEVICE, 0 );
237
+    }
238
+
239
+    else if (state > WAIT_FOR_LUN && !bulk.LUNIsGood(0)) {
240
+      // Handle media removal events
241
+      #if USB_DEBUG >= 1
242
+        SERIAL_ECHOLNPGM("Media removed");
243
+      #endif
244
+      #if EITHER(ULTRA_LCD, EXTENSIBLE_UI)
245
+        LCD_MESSAGEPGM("Media removed");
246
+      #endif
247
+      GOTO_STATE_AFTER_DELAY( WAIT_FOR_DEVICE, 0 );
248
+    }
249
+
250
+    else if (task_state == UHS_STATE(ERROR)) {
251
+        #if EITHER(ULTRA_LCD, EXTENSIBLE_UI)
252
+          LCD_MESSAGEPGM("Media read error");
90 253
         #endif
91
-      }
92
-      break;
254
+        GOTO_STATE_AFTER_DELAY( MEDIA_ERROR, 0 );
255
+    }
93 256
   }
94 257
 }
95 258
 
96 259
 // Marlin calls this function to check whether an USB drive is inserted.
97 260
 // This is equivalent to polling the SD_DETECT when using SD cards.
98 261
 bool Sd2Card::isInserted() {
99
-  return usb.getUsbTaskState() == USB_STATE_RUNNING;
262
+  return state == MEDIA_READY;
100 263
 }
101 264
 
102
-// Marlin calls this to initialize an SD card once it is inserted.
103
-bool Sd2Card::init(const uint8_t sckRateID/*=0*/, const pin_t chipSelectPin/*=SD_CHIP_SELECT_PIN*/) {
104
-  if (!ready()) return false;
265
+bool Sd2Card::ready() {
266
+  return state > DO_STARTUP;
267
+}
105 268
 
106
-  if (!bulk.LUNIsGood(0)) {
107
-    SERIAL_ECHOLNPGM("LUN zero is not good");
108
-    return false;
109
-  }
269
+// Marlin calls this to initialize an SD card once it is inserted.
270
+bool Sd2Card::init(const uint8_t, const pin_t) {
271
+  if (!isInserted()) return false;
110 272
 
273
+  #if USB_DEBUG >= 1
111 274
   const uint32_t sectorSize = bulk.GetSectorSize(0);
112 275
   if (sectorSize != 512) {
113 276
     SERIAL_ECHOLNPAIR("Expecting sector size of 512. Got: ", sectorSize);
114 277
     return false;
115 278
   }
279
+  #endif
116 280
 
117
-  #ifdef USB_DEBUG
281
+  #if USB_DEBUG >= 3
118 282
     lun0_capacity = bulk.GetCapacity(0);
119 283
     SERIAL_ECHOLNPAIR("LUN Capacity (in blocks): ", lun0_capacity);
120 284
   #endif
@@ -123,8 +287,8 @@ bool Sd2Card::init(const uint8_t sckRateID/*=0*/, const pin_t chipSelectPin/*=SD
123 287
 
124 288
 // Returns the capacity of the card in blocks.
125 289
 uint32_t Sd2Card::cardSize() {
126
-  if (!ready()) return 0;
127
-  #ifndef USB_DEBUG
290
+  if (!isInserted()) return false;
291
+  #if USB_DEBUG < 3
128 292
     const uint32_t
129 293
   #endif
130 294
       lun0_capacity = bulk.GetCapacity(0);
@@ -132,13 +296,13 @@ uint32_t Sd2Card::cardSize() {
132 296
 }
133 297
 
134 298
 bool Sd2Card::readBlock(uint32_t block, uint8_t* dst) {
135
-  if (!ready()) return false;
136
-  #ifdef USB_DEBUG
299
+  if (!isInserted()) return false;
300
+  #if USB_DEBUG >= 3
137 301
     if (block >= lun0_capacity) {
138 302
       SERIAL_ECHOLNPAIR("Attempt to read past end of LUN: ", block);
139 303
       return false;
140 304
     }
141
-    #if USB_DEBUG > 1
305
+    #if USB_DEBUG >= 4
142 306
       SERIAL_ECHOLNPAIR("Read block ", block);
143 307
     #endif
144 308
   #endif
@@ -146,13 +310,13 @@ bool Sd2Card::readBlock(uint32_t block, uint8_t* dst) {
146 310
 }
147 311
 
148 312
 bool Sd2Card::writeBlock(uint32_t block, const uint8_t* src) {
149
-  if (!ready()) return false;
150
-  #ifdef USB_DEBUG
313
+  if (!isInserted()) return false;
314
+  #if USB_DEBUG >= 3
151 315
     if (block >= lun0_capacity) {
152 316
       SERIAL_ECHOLNPAIR("Attempt to write past end of LUN: ", block);
153 317
       return false;
154 318
     }
155
-    #if USB_DEBUG > 1
319
+    #if USB_DEBUG >= 4
156 320
       SERIAL_ECHOLNPAIR("Write block ", block);
157 321
     #endif
158 322
   #endif

+ 4
- 20
Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h 파일 보기

@@ -26,12 +26,6 @@
26 26
  * \brief Sd2Card class for V2 SD/SDHC cards
27 27
  */
28 28
 
29
-/* Uncomment USB_DEBUG to enable debugging.
30
- *    1 - basic debugging and bounds checking
31
- *    2 - print each block access
32
- */
33
-//#define USB_DEBUG 1
34
-
35 29
 #include "../SdFatConfig.h"
36 30
 #include "../SdInfo.h"
37 31
 
@@ -52,24 +46,13 @@
52 46
 
53 47
 class Sd2Card {
54 48
   private:
55
-
56
-    typedef enum : uint8_t {
57
-      USB_HOST_UNINITIALIZED,
58
-      USB_HOST_INITIALIZED,
59
-      USB_HOST_DELAY_INIT,
60
-      USB_HOST_WAITING
61
-    } state_t;
62
-
63
-    static state_t state;
64
-
65 49
     uint32_t pos;
66
-    #ifdef USB_DEBUG
67
-      uint32_t lun0_capacity;
68
-    #endif
69 50
 
70
-    static inline bool ready() { return state == USB_HOST_INITIALIZED; }
51
+    static void usbStateDebug();
71 52
 
72 53
   public:
54
+    static bool usbStartup();
55
+
73 56
     bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=SD_CHIP_SELECT_PIN);
74 57
 
75 58
     static void idle();
@@ -87,4 +70,5 @@ class Sd2Card {
87 70
 
88 71
     uint32_t cardSize();
89 72
     static bool isInserted();
73
+    static bool ready();
90 74
 };

Marlin/src/sd/usb_flashdrive/SOURCES.txt → Marlin/src/sd/usb_flashdrive/lib-uhs2/README.txt 파일 보기

@@ -1,15 +1,4 @@
1 1
 
2
-==== SUMMARY ====
3
-
4
-Source Path:                           Repository:                           License:
5
-------------                           -----------                           --------
6
-usb_flashdrive/lib                     github.com/felis/USB_Host_Shield_2.0  GPLv2 or later
7
-usb_flashdrive/lib/masstorage.cpp [1]  github.com/greiman/UsbFat             MIT
8
-usb_flashdrive/lib/settings.h [1]      github.com/greiman/UsbFat             MIT
9
-
10
-[1] Changes related to SKIP_WRITE_PROTECT and DELAY only
11
-
12
-
13 2
 ==== USB HOST SHIELD 2.0 LIBRARY ====
14 3
 
15 4
 The lib/ folder contains a subset of the files from the USB Host Shield 2.0
@@ -26,6 +15,15 @@ files needed for Marlin as "GPLv2 or later", as documented in this thread.
26 15
 Small modifications have been made to the source. Please search for
27 16
 USB_FLASH_DRIVE_SUPPORT or look at the patch file to see what was changed.
28 17
 
18
+==== LICENSE SUMMARY ====
19
+
20
+Source Path:                 Repository:                           License:
21
+------------                 -----------                           --------
22
+lib-uhs3/                    github.com/felis/USB_Host_Shield_2.0  GPLv2 or later
23
+lib-uhs3/lib/masstorage.cpp  github.com/greiman/UsbFat [1]         MIT
24
+lib-uhs3/lib/settings.h      github.com/greiman/UsbFat [1]         MIT
25
+
26
+[1] Changes related to SKIP_WRITE_PROTECT and DELAY only
29 27
 
30 28
 ==== PERFORMANCE ENHANCEMENTS FOR USB DRIVES ====
31 29
 

Marlin/src/sd/usb_flashdrive/lib/Usb.cpp → Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp 파일 보기

@@ -26,7 +26,7 @@
26 26
 
27 27
 #include "../../../inc/MarlinConfigPre.h"
28 28
 
29
-#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
29
+#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB)
30 30
 
31 31
 #include "Usb.h"
32 32
 

Marlin/src/sd/usb_flashdrive/lib/Usb.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.h 파일 보기

@@ -45,8 +45,7 @@
45 45
 #include "address.h"
46 46
 //#include "avrpins.h"
47 47
 #include "usb_ch9.h"
48
-//#include "usbhost.h"
49
-#include "../usb_host.h"
48
+#include "usbhost.h"
50 49
 #include "UsbCore.h"
51 50
 #include "parsetools.h"
52 51
 #include "confdescparser.h"

Marlin/src/sd/usb_flashdrive/lib/UsbCore.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/UsbCore.h 파일 보기


Marlin/src/sd/usb_flashdrive/lib/address.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/address.h 파일 보기


Marlin/src/sd/usb_flashdrive/lib/confdescparser.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/confdescparser.h 파일 보기


Marlin/src/sd/usb_flashdrive/lib/hexdump.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/hexdump.h 파일 보기


Marlin/src/sd/usb_flashdrive/lib/macros.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/macros.h 파일 보기


Marlin/src/sd/usb_flashdrive/lib/masstorage.cpp → Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp 파일 보기

@@ -25,7 +25,7 @@
25 25
 
26 26
 #include "../../../inc/MarlinConfigPre.h"
27 27
 
28
-#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
28
+#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB)
29 29
 
30 30
 #include "masstorage.h"
31 31
 
@@ -762,7 +762,7 @@ uint8_t BulkOnly::Page3F(uint8_t lun) {
762 762
                 buf[i] = 0x00;
763 763
         }
764 764
         WriteOk[lun] = true;
765
-        #if ENABLED(USB_FLASH_DRIVE_SUPPORT) && defined(SKIP_WRITE_PROTECT)
765
+        #ifdef SKIP_WRITE_PROTECT
766 766
           return 0;
767 767
         #endif
768 768
         uint8_t rc = ModeSense6(lun, 0, 0x3f, 0, 192, buf);

Marlin/src/sd/usb_flashdrive/lib/masstorage.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h 파일 보기


Marlin/src/sd/usb_flashdrive/lib/max3421e.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/max3421e.h 파일 보기

@@ -191,6 +191,15 @@
191 191
 #define bmSNDTOG1       0x80
192 192
 
193 193
 #define rHXFR       0xf0    //30<<3
194
+
195
+#undef tokSETUP
196
+#undef tokIN
197
+#undef tokOUT
198
+#undef tokINHS
199
+#undef tokOUTHS
200
+#undef tokISOIN
201
+#undef tokISOOUT
202
+
194 203
 /* Host transfer token values for writing the HXFR register (R30)   */
195 204
 /* OR this bit field with the endpoint number in bits 3:0               */
196 205
 #define tokSETUP  0x10  // HS=0, ISO=0, OUTNIN=0, SETUP=1

Marlin/src/sd/usb_flashdrive/lib/message.cpp → Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp 파일 보기

@@ -25,7 +25,7 @@
25 25
 
26 26
 #include "../../../inc/MarlinConfigPre.h"
27 27
 
28
-#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
28
+#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB)
29 29
 
30 30
 #include "Usb.h"
31 31
 

Marlin/src/sd/usb_flashdrive/lib/message.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/message.h 파일 보기


Marlin/src/sd/usb_flashdrive/lib/parsetools.cpp → Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.cpp 파일 보기

@@ -25,7 +25,7 @@
25 25
 
26 26
 #include "../../../inc/MarlinConfigPre.h"
27 27
 
28
-#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
28
+#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB)
29 29
 
30 30
 #include "Usb.h"
31 31
 

Marlin/src/sd/usb_flashdrive/lib/parsetools.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.h 파일 보기


Marlin/src/sd/usb_flashdrive/lib/printhex.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/printhex.h 파일 보기


Marlin/src/sd/usb_flashdrive/lib/settings.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/settings.h 파일 보기


Marlin/src/sd/usb_flashdrive/lib/usb_ch9.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h 파일 보기


Marlin/src/sd/usb_flashdrive/usb_host.cpp → Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp 파일 보기

@@ -23,12 +23,12 @@
23 23
  * lib/usbhost.c". This has been rewritten to use SPI routines from the
24 24
  * Marlin HAL */
25 25
 
26
-#include "../../inc/MarlinConfigPre.h"
26
+#include "../../../inc/MarlinConfigPre.h"
27 27
 
28
-#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
28
+#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB)
29 29
 
30
-#include "lib/Usb.h"
31
-#include "usb_host.h"
30
+#include "Usb.h"
31
+#include "usbhost.h"
32 32
 
33 33
 uint8_t MAX3421e::vbusState = 0;
34 34
 

Marlin/src/sd/usb_flashdrive/usb_host.h → Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.h 파일 보기


+ 31
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/README.txt 파일 보기

@@ -0,0 +1,31 @@
1
+==== USB HOST SHIELD 3.0 LIBRARY ====
2
+
3
+The lib-uhs3/ folder contains a subset of the files from the USB Host Shield
4
+3.0 library:
5
+
6
+  https://github.com/felis/UHS30
7
+
8
+
9
+==== LICENSE SUMMARY ====
10
+
11
+Source Path:              Repository:                    License:
12
+------------              -----------                    --------
13
+usb_flashdrive/lib        github.com/felis/UHS30         GPLv2 or later
14
+
15
+
16
+==== MARLIN INTEGRATION WORK ====
17
+
18
+All additional work done to integrate USB into Marlin was performed by
19
+AlephObjects, Inc. and is licensed under the GPLv3.
20
+
21
+This version of UHS3 has been modified for better compatibility with Marlin.
22
+The upstream version of UHS 3.0 runs a frame timer interrupt every 1 ms to
23
+handle device polling. This timer interrupt interferes with Marlin's stepper
24
+IRQ, so the flag USB_HOST_MANUAL_POLL has been added to move the polling to
25
+the idle task. Additional logic was added to disable and enable the frame
26
+IRQ.
27
+
28
+SKIP_PAGE3F and USB_NO_TEST_UNIT_READY were added to work around bugs with
29
+certain devices.
30
+
31
+-- marcio@alephobjects.com

+ 249
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE.h 파일 보기

@@ -0,0 +1,249 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+ Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+
27
+#if !defined(__UHS_BULK_STORAGE_H__)
28
+#define __UHS_BULK_STORAGE_H__
29
+
30
+
31
+////////////////////////////////////////////////////////////////////////////////
32
+// Define any of these options at the top of your sketch to override
33
+// the defaults contained herewith. Do NOT do modifications here.
34
+// Macro                                 | Settings and notes    | Default
35
+// -----------------------------------------+-----------------------+-----------
36
+//                                          | 1 to 8                |
37
+//                                          | Each LUN needs        |
38
+// MASS_MAX_SUPPORTED_LUN                   | ~13 bytes to be able  | 8
39
+//                                          | to track the state of |
40
+//                                          | each unit.            |
41
+// -----------------------------------------+-----------------------+-----------
42
+//                                          | Just define to use.   |
43
+// DEBUG_PRINTF_EXTRA_HUGE_UHS_BULK_STORAGE | works only if extra   |
44
+//                                          | huge debug is on too. |
45
+// -----------------------------------------^-----------------------^-----------
46
+
47
+#ifndef MASS_MAX_SUPPORTED_LUN
48
+#define MASS_MAX_SUPPORTED_LUN 8
49
+#endif
50
+
51
+#include "UHS_SCSI.h"
52
+
53
+#define                UHS_BULK_bmREQ_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
54
+#define                 UHS_BULK_bmREQ_IN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
55
+
56
+// Request Codes
57
+#define                 UHS_BULK_REQ_ADSC 0x00U
58
+#define                  UHS_BULK_REQ_GET 0xFCU
59
+#define                  UHS_BULK_REQ_PUT 0xFDU
60
+#define          UHS_BULK_REQ_GET_MAX_LUN 0xFEU
61
+#define                UHS_BULK_REQ_BOMSR 0xFFU // Mass Storage Reset
62
+
63
+#define            UHS_BULK_CBW_SIGNATURE 0x43425355LU
64
+#define            UHS_BULK_CSW_SIGNATURE 0x53425355LU
65
+
66
+#define              UHS_BULK_CMD_DIR_OUT 0x00U
67
+#define               UHS_BULK_CMD_DIR_IN 0x80U
68
+
69
+/* Bulk error codes */
70
+#define              UHS_BULK_ERR_SUCCESS UHS_HOST_ERROR_NONE
71
+#define          UHS_BULK_ERR_PHASE_ERROR 0x22U
72
+#define       UHS_BULK_ERR_UNIT_NOT_READY 0x23U
73
+#define            UHS_BULK_ERR_UNIT_BUSY 0x24U
74
+#define                UHS_BULK_ERR_STALL 0x25U
75
+#define    UHS_BULK_ERR_CMD_NOT_SUPPORTED 0x26U
76
+#define          UHS_BULK_ERR_INVALID_CSW 0x27U
77
+#define             UHS_BULK_ERR_NO_MEDIA 0x28U
78
+#define              UHS_BULK_ERR_BAD_LBA 0x29U
79
+#define        UHS_BULK_ERR_MEDIA_CHANGED 0x2AU
80
+#define  UHS_BULK_ERR_DEVICE_DISCONNECTED UHS_HOST_ERROR_UNPLUGGED
81
+#define    UHS_BULK_ERR_UNABLE_TO_RECOVER 0x32U // Reset recovery error
82
+#define          UHS_BULK_ERR_INVALID_LUN 0x33U
83
+#define          UHS_BULK_ERR_WRITE_STALL 0x34U
84
+#define            UHS_BULK_ERR_READ_NAKS 0x35U
85
+#define           UHS_BULK_ERR_WRITE_NAKS 0x36U
86
+#define      UHS_BULK_ERR_WRITE_PROTECTED 0x37U
87
+#define      UHS_BULK_ERR_NOT_IMPLEMENTED 0xFDU
88
+#define   UHS_BULK_ERR_GENERAL_SCSI_ERROR 0xF0U
89
+#define    UHS_BULK_ERR_GENERAL_USB_ERROR 0xFFU
90
+#define                 UHS_BULK_ERR_USER 0xA0U // For subclasses to define their own error codes
91
+
92
+#define                MASS_MAX_ENDPOINTS 3
93
+
94
+struct UHS_BULK_CommandBlockWrapperBase {
95
+        volatile uint32_t dCBWSignature;
96
+        volatile uint32_t dCBWTag;
97
+        volatile uint32_t dCBWDataTransferLength;
98
+        volatile uint8_t bmCBWFlags;
99
+public:
100
+
101
+        UHS_BULK_CommandBlockWrapperBase(void) {
102
+        }
103
+
104
+        UHS_BULK_CommandBlockWrapperBase(uint32_t tag, uint32_t xflen, uint8_t flgs) :
105
+        dCBWSignature(UHS_BULK_CBW_SIGNATURE), dCBWTag(tag), dCBWDataTransferLength(xflen), bmCBWFlags(flgs) {
106
+        }
107
+} __attribute__((packed));
108
+
109
+struct UHS_BULK_CommandBlockWrapper : public UHS_BULK_CommandBlockWrapperBase {
110
+
111
+        struct {
112
+                uint8_t bmCBWLUN : 4;
113
+                uint8_t bmReserved1 : 4;
114
+        };
115
+
116
+        struct {
117
+                uint8_t bmCBWCBLength : 4;
118
+                uint8_t bmReserved2 : 4;
119
+        };
120
+
121
+        uint8_t CBWCB[16];
122
+
123
+public:
124
+        // All zeroed.
125
+
126
+        UHS_BULK_CommandBlockWrapper() :
127
+        UHS_BULK_CommandBlockWrapperBase(0, 0, 0), bmReserved1(0), bmReserved2(0) {
128
+                for(int i = 0; i < 16; i++) CBWCB[i] = 0;
129
+        }
130
+
131
+        // Generic Wrap, CDB zeroed.
132
+
133
+        UHS_BULK_CommandBlockWrapper(uint32_t tag, uint32_t xflen, uint8_t flgs, uint8_t lu, uint8_t cmdlen, uint8_t cmd) :
134
+        UHS_BULK_CommandBlockWrapperBase(tag, xflen, flgs),
135
+        bmCBWLUN(lu), bmReserved1(0), bmCBWCBLength(cmdlen), bmReserved2(0) {
136
+                for(int i = 0; i < 16; i++) CBWCB[i] = 0;
137
+                SCSI_CDB_BASE_t *x = reinterpret_cast<SCSI_CDB_BASE_t *>(CBWCB);
138
+                x->LUN = cmd;
139
+        }
140
+
141
+        // Wrap for CDB of 6
142
+
143
+        UHS_BULK_CommandBlockWrapper(uint32_t tag, uint32_t xflen, SCSI_CDB6_t *cdb, uint8_t dir) :
144
+        UHS_BULK_CommandBlockWrapperBase(tag, xflen, dir),
145
+        bmCBWLUN(cdb->LUN), bmReserved1(0), bmCBWCBLength(6), bmReserved2(0) {
146
+                memcpy(&CBWCB, cdb, 6);
147
+        }
148
+        // Wrap for CDB of 10
149
+
150
+        UHS_BULK_CommandBlockWrapper(uint32_t tag, uint32_t xflen, SCSI_CDB10_t *cdb, uint8_t dir) :
151
+        UHS_BULK_CommandBlockWrapperBase(tag, xflen, dir),
152
+        bmCBWLUN(cdb->LUN), bmReserved1(0), bmCBWCBLength(10), bmReserved2(0) {
153
+                memcpy(&CBWCB, cdb, 10);
154
+        }
155
+} __attribute__((packed));
156
+
157
+struct UHS_BULK_CommandStatusWrapper {
158
+        uint32_t dCSWSignature;
159
+        uint32_t dCSWTag;
160
+        uint32_t dCSWDataResidue;
161
+        uint8_t bCSWStatus;
162
+} __attribute__((packed));
163
+
164
+class UHS_Bulk_Storage : public UHS_USBInterface {
165
+protected:
166
+        static const uint8_t epDataInIndex = 1; // DataIn endpoint index
167
+        static const uint8_t epDataOutIndex = 2; // DataOUT endpoint index
168
+        static const uint8_t epInterruptInIndex = 3; // InterruptIN  endpoint index
169
+
170
+        uint8_t bMaxLUN; // Max LUN
171
+        volatile uint32_t dCBWTag; // Tag
172
+        volatile uint8_t bTheLUN; // Active LUN
173
+        volatile uint32_t CurrentCapacity[MASS_MAX_SUPPORTED_LUN]; // Total sectors
174
+        volatile uint16_t CurrentSectorSize[MASS_MAX_SUPPORTED_LUN]; // Sector size, clipped to 16 bits
175
+        volatile bool LUNOk[MASS_MAX_SUPPORTED_LUN]; // use this to check for media changes.
176
+        volatile bool WriteOk[MASS_MAX_SUPPORTED_LUN];
177
+        void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr);
178
+
179
+public:
180
+        UHS_Bulk_Storage(UHS_USB_HOST_BASE *p);
181
+
182
+        volatile UHS_EpInfo epInfo[MASS_MAX_ENDPOINTS];
183
+
184
+        uint8_t GetbMaxLUN(void) {
185
+                return bMaxLUN; // Max LUN
186
+        }
187
+
188
+        uint8_t GetbTheLUN(void) {
189
+                return bTheLUN; // Active LUN
190
+        }
191
+
192
+        bool WriteProtected(uint8_t lun);
193
+        uint8_t MediaCTL(uint8_t lun, uint8_t ctl);
194
+        uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf);
195
+        uint8_t Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t *buf);
196
+        uint8_t LockMedia(uint8_t lun, uint8_t lock);
197
+
198
+        bool LUNIsGood(uint8_t lun);
199
+        uint32_t GetCapacity(uint8_t lun);
200
+        uint16_t GetSectorSize(uint8_t lun);
201
+        uint8_t SCSITransaction6(SCSI_CDB6_t *cdb, uint16_t buf_size, void *buf, uint8_t dir);
202
+        uint8_t SCSITransaction10(SCSI_CDB10_t *cdb, uint16_t buf_size, void *buf, uint8_t dir);
203
+
204
+
205
+        // Configure and internal methods, these should never be called by a user's sketch.
206
+        uint8_t Start(void);
207
+        bool OKtoEnumerate(ENUMERATION_INFO *ei);
208
+        uint8_t SetInterface(ENUMERATION_INFO *ei);
209
+
210
+        uint8_t GetAddress(void) {
211
+                return bAddress;
212
+        };
213
+
214
+
215
+        void Poll(void);
216
+
217
+        void DriverDefaults(void);
218
+
219
+
220
+private:
221
+        void Reset(void);
222
+        void CheckMedia(void);
223
+
224
+        bool IsValidCBW(uint8_t size, uint8_t *pcbw);
225
+        bool IsMeaningfulCBW(uint8_t size, uint8_t *pcbw);
226
+        bool IsValidCSW(UHS_BULK_CommandStatusWrapper *pcsw, UHS_BULK_CommandBlockWrapperBase *pcbw);
227
+
228
+        bool CheckLUN(uint8_t lun);
229
+
230
+        uint8_t Inquiry(uint8_t lun, uint16_t size, uint8_t *buf);
231
+        uint8_t TestUnitReady(uint8_t lun);
232
+        uint8_t RequestSense(uint8_t lun, uint16_t size, uint8_t *buf);
233
+        uint8_t ModeSense6(uint8_t lun, uint8_t pc, uint8_t page, uint8_t subpage, uint8_t len, uint8_t *buf);
234
+        uint8_t GetMaxLUN(uint8_t *max_lun);
235
+        uint8_t SetCurLUN(uint8_t lun);
236
+        uint8_t ResetRecovery();
237
+        uint8_t ReadCapacity10(uint8_t lun, uint8_t *buf);
238
+        uint8_t Page3F(uint8_t lun);
239
+        uint8_t ClearEpHalt(uint8_t index);
240
+        uint8_t Transaction(UHS_BULK_CommandBlockWrapper *cbw, uint16_t bsize, void *buf);
241
+        uint8_t HandleUsbError(uint8_t error, uint8_t index);
242
+        uint8_t HandleSCSIError(uint8_t status);
243
+
244
+};
245
+
246
+#if defined(LOAD_UHS_BULK_STORAGE) && !defined(UHS_BULK_STORAGE_LOADED)
247
+#include "UHS_BULK_STORAGE_INLINE.h"
248
+#endif
249
+#endif // __MASSTORAGE_H__

+ 1210
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 328
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_SCSI.h 파일 보기

@@ -0,0 +1,328 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+
27
+#ifndef UHS_SCSI_H
28
+#define	UHS_SCSI_H
29
+
30
+/*
31
+ * Reference documents from T10 (http://www.t10.org)
32
+ * SCSI Primary Commands - 3 (SPC-3)
33
+ * SCSI Block Commands - 2 (SBC-2)
34
+ * Multi-Media Commands - 5 (MMC-5)
35
+ */
36
+
37
+/* Group 1 commands (CDB's here are should all be 6-bytes) */
38
+#define SCSI_CMD_TEST_UNIT_READY	0x00U
39
+#define SCSI_CMD_REQUEST_SENSE		0x03U
40
+#define SCSI_CMD_FORMAT_UNIT		0x04U
41
+#define SCSI_CMD_READ_6			0x08U
42
+#define SCSI_CMD_WRITE_6		0x0AU
43
+#define SCSI_CMD_INQUIRY		0x12U
44
+#define SCSI_CMD_MODE_SELECT_6          0x15U
45
+#define SCSI_CMD_MODE_SENSE_6		0x1AU
46
+#define SCSI_CMD_START_STOP_UNIT	0x1BU
47
+#define SCSI_CMD_PREVENT_REMOVAL        0x1EU
48
+/* Group 2 Commands (CDB's here are 10-bytes) */
49
+#define SCSI_CMD_READ_FORMAT_CAPACITIES 0x23U
50
+#define SCSI_CMD_READ_CAPACITY_10	0x25U
51
+#define SCSI_CMD_READ_10		0x28U
52
+#define SCSI_CMD_WRITE_10		0x2AU
53
+#define SCSI_CMD_SEEK_10                0x2BU
54
+#define SCSI_CMD_ERASE_10               0x2CU
55
+#define SCSI_CMD_WRITE_AND_VERIFY_10    0x2EU
56
+#define SCSI_CMD_VERIFY_10              0x2FU
57
+#define SCSI_CMD_SYNCHRONIZE_CACHE      0x35U
58
+#define SCSI_CMD_WRITE_BUFFER           0x3BU
59
+#define SCSI_CMD_READ_BUFFER            0x3CU
60
+#define SCSI_CMD_READ_SUBCHANNEL        0x42U
61
+#define SCSI_CMD_READ_TOC               0x43U
62
+#define SCSI_CMD_READ_HEADER            0x44U
63
+#define SCSI_CMD_PLAY_AUDIO_10          0x45U
64
+#define SCSI_CMD_GET_CONFIGURATION      0x46U
65
+#define SCSI_CMD_PLAY_AUDIO_MSF         0x47U
66
+#define SCSI_CMD_PLAY_AUDIO_TI          0x48U
67
+#define SCSI_CMD_PLAY_TRACK_REL_10      0x49U
68
+#define SCSI_CMD_GET_EVENT_STATUS       0x4AU
69
+#define SCSI_CMD_PAUSE_RESUME           0x4BU
70
+#define SCSI_CMD_READ_DISC_INFORMATION  0x51U
71
+#define SCSI_CMD_READ_TRACK_INFORMATION 0x52U
72
+#define SCSI_CMD_RESERVE_TRACK          0x53U
73
+#define SCSI_CMD_SEND_OPC_INFORMATION   0x54U
74
+#define SCSI_CMD_MODE_SELECT_10         0x55U
75
+#define SCSI_CMD_REPAIR_TRACK           0x58U
76
+#define SCSI_CMD_MODE_SENSE_10          0x5AU
77
+#define SCSI_CMD_CLOSE_TRACK_SESSION    0x5BU
78
+#define SCSI_CMD_READ_BUFFER_CAPACITY   0x5CU
79
+#define SCSI_CMD_SEND_CUE_SHEET         0x5DU
80
+/* Group 5 Commands (CDB's here are 12-bytes) */
81
+#define SCSI_CMD_REPORT_LUNS            0xA0U
82
+#define SCSI_CMD_BLANK                  0xA1U
83
+#define SCSI_CMD_SECURITY_PROTOCOL_IN   0xA2U
84
+#define SCSI_CMD_SEND_KEY               0xA3U
85
+#define SCSI_CMD_REPORT_KEY             0xA4U
86
+#define SCSI_CMD_PLAY_AUDIO_12          0xA5U
87
+#define SCSI_CMD_LOAD_UNLOAD            0xA6U
88
+#define SCSI_CMD_SET_READ_AHEAD         0xA7U
89
+#define SCSI_CMD_READ_12                0xA8U
90
+#define SCSI_CMD_PLAY_TRACK_REL_12      0xA9U
91
+#define SCSI_CMD_WRITE_12               0xAAU
92
+#define SCSI_CMD_READ_MEDIA_SERIAL_12   0xABU
93
+#define SCSI_CMD_GET_PERFORMANCE        0xACU
94
+#define SCSI_CMD_READ_DVD_STRUCTURE     0xADU
95
+#define SCSI_CMD_SECURITY_PROTOCOL_OUT  0xB5U
96
+#define SCSI_CMD_SET_STREAMING          0xB6U
97
+#define SCSI_CMD_READ_MSF               0xB9U
98
+#define SCSI_CMD_SET_SPEED              0xBBU
99
+#define SCSI_CMD_MECHANISM_STATUS       0xBDU
100
+#define SCSI_CMD_READ_CD                0xBEU
101
+#define SCSI_CMD_SEND_DISC_STRUCTURE    0xBFU
102
+/* Vendor-unique Commands, included for completeness */
103
+#define SCSI_CMD_CD_PLAYBACK_STATUS     0xC4U /* SONY unique */
104
+#define SCSI_CMD_PLAYBACK_CONTROL       0xC9U /* SONY unique */
105
+#define SCSI_CMD_READ_CDDA              0xD8U /* Vendor unique */
106
+#define SCSI_CMD_READ_CDXA              0xDBU /* Vendor unique */
107
+#define SCSI_CMD_READ_ALL_SUBCODES      0xDFU /* Vendor unique */
108
+
109
+/* SCSI error codes */
110
+#define SCSI_S_NOT_READY		0x02U
111
+#define SCSI_S_MEDIUM_ERROR		0x03U
112
+#define SCSI_S_ILLEGAL_REQUEST		0x05U
113
+#define SCSI_S_UNIT_ATTENTION		0x06U
114
+#define SCSI_ASC_LBA_OUT_OF_RANGE       0x21U
115
+#define SCSI_ASC_MEDIA_CHANGED          0x28U
116
+#define SCSI_ASC_MEDIUM_NOT_PRESENT     0x3AU
117
+
118
+struct SCSI_Capacity {
119
+        uint8_t data[8];
120
+        //uint32_t dwBlockAddress;
121
+        //uint32_t dwBlockLength;
122
+} __attribute__((packed));
123
+
124
+struct SCSI_CDB_BASE {
125
+        uint8_t Opcode;
126
+
127
+        unsigned unused : 5;
128
+        unsigned LUN : 3;
129
+
130
+        uint8_t info[12];
131
+} __attribute__((packed));
132
+
133
+typedef SCSI_CDB_BASE SCSI_CDB_BASE_t;
134
+
135
+struct SCSI_CDB6 {
136
+        uint8_t Opcode;
137
+
138
+        unsigned LBAMSB : 5;
139
+        unsigned LUN : 3;
140
+
141
+        uint8_t LBAHB;
142
+        uint8_t LBALB;
143
+        uint8_t AllocationLength;
144
+        uint8_t Control;
145
+
146
+public:
147
+
148
+        SCSI_CDB6(uint8_t _Opcode, uint8_t _LUN, uint32_t LBA, uint8_t _AllocationLength, uint8_t _Control) :
149
+        Opcode(_Opcode), LBAMSB(UHS_UINT8_BYTE2(LBA) & 0x1f), LUN(_LUN), LBAHB(UHS_UINT8_BYTE1(LBA)), LBALB(UHS_UINT8_BYTE0(LBA)),
150
+        AllocationLength(_AllocationLength), Control(_Control) {
151
+        }
152
+
153
+        SCSI_CDB6(uint8_t _Opcode, uint8_t _LUN, uint8_t _AllocationLength, uint8_t _Control) :
154
+        Opcode(_Opcode), LBAMSB(0), LUN(_LUN), LBAHB(0), LBALB(0),
155
+        AllocationLength(_AllocationLength), Control(_Control) {
156
+        }
157
+} __attribute__((packed));
158
+
159
+typedef SCSI_CDB6 SCSI_CDB6_t;
160
+
161
+struct SCSI_CDB10 {
162
+        uint8_t Opcode;
163
+
164
+        unsigned Service_Action : 5;
165
+        unsigned LUN : 3;
166
+
167
+        uint8_t LBA_L_M_MB;
168
+        uint8_t LBA_L_M_LB;
169
+        uint8_t LBA_L_L_MB;
170
+        uint8_t LBA_L_L_LB;
171
+
172
+        uint8_t Misc2;
173
+
174
+        uint8_t ALC_MB;
175
+        uint8_t ALC_LB;
176
+
177
+        uint8_t Control;
178
+public:
179
+
180
+        SCSI_CDB10(uint8_t _Opcode, uint8_t _LUN) :
181
+        Opcode(_Opcode), Service_Action(0), LUN(_LUN),
182
+        LBA_L_M_MB(0), LBA_L_M_LB(0), LBA_L_L_MB(0), LBA_L_L_LB(0),
183
+        Misc2(0), ALC_MB(0), ALC_LB(0), Control(0) {
184
+        }
185
+
186
+        SCSI_CDB10(uint8_t _Opcode, uint8_t _LUN, uint16_t xflen, uint32_t _LBA) :
187
+        Opcode(_Opcode), Service_Action(0), LUN(_LUN),
188
+        LBA_L_M_MB(UHS_UINT8_BYTE3(_LBA)), LBA_L_M_LB(UHS_UINT8_BYTE2(_LBA)), LBA_L_L_MB(UHS_UINT8_BYTE1(_LBA)), LBA_L_L_LB(UHS_UINT8_BYTE0(_LBA)),
189
+        Misc2(0), ALC_MB(UHS_UINT8_BYTE1(xflen)), ALC_LB(UHS_UINT8_BYTE0(xflen)), Control(0) {
190
+        }
191
+} __attribute__((packed));
192
+
193
+typedef SCSI_CDB10 SCSI_CDB10_t;
194
+
195
+struct SCSI_CDB12 {
196
+        uint8_t Opcode;
197
+
198
+        unsigned Service_Action : 5;
199
+        unsigned Misc : 3;
200
+
201
+        uint8_t LBA_L_M_LB;
202
+        uint8_t LBA_L_L_MB;
203
+        uint8_t LBA_L_L_LB;
204
+
205
+        uint8_t ALC_M_LB;
206
+        uint8_t ALC_L_MB;
207
+        uint8_t ALC_L_LB;
208
+        uint8_t Control;
209
+} __attribute__((packed));
210
+
211
+typedef SCSI_CDB12 SCSI_CDB12_t;
212
+
213
+struct SCSI_CDB_LBA32_16 {
214
+        uint8_t Opcode;
215
+
216
+        unsigned Service_Action : 5;
217
+        unsigned Misc : 3;
218
+
219
+        uint8_t LBA_L_M_MB;
220
+        uint8_t LBA_L_M_LB;
221
+        uint8_t LBA_L_L_MB;
222
+        uint8_t LBA_L_L_LB;
223
+
224
+        uint8_t A_M_M_MB;
225
+        uint8_t A_M_M_LB;
226
+        uint8_t A_M_L_MB;
227
+        uint8_t A_M_L_LB;
228
+
229
+        uint8_t ALC_M_MB;
230
+        uint8_t ALC_M_LB;
231
+        uint8_t ALC_L_MB;
232
+        uint8_t ALC_L_LB;
233
+
234
+        uint8_t Misc2;
235
+        uint8_t Control;
236
+} __attribute__((packed));
237
+
238
+struct SCSI_CDB_LBA64_16 {
239
+        uint8_t Opcode;
240
+        uint8_t Misc;
241
+
242
+        uint8_t LBA_M_M_MB;
243
+        uint8_t LBA_M_M_LB;
244
+        uint8_t LBA_M_L_MB;
245
+        uint8_t LBA_M_L_LB;
246
+
247
+        uint8_t LBA_L_M_MB;
248
+        uint8_t LBA_L_M_LB;
249
+        uint8_t LBA_L_L_MB;
250
+        uint8_t LBA_L_L_LB;
251
+
252
+        uint8_t ALC_M_MB;
253
+        uint8_t ALC_M_LB;
254
+        uint8_t ALC_L_MB;
255
+        uint8_t ALC_L_LB;
256
+
257
+        uint8_t Misc2;
258
+        uint8_t Control;
259
+} __attribute__((packed));
260
+
261
+struct SCSI_Inquiry_Response {
262
+        uint8_t DeviceType : 5;
263
+        uint8_t PeripheralQualifier : 3;
264
+
265
+        unsigned Reserved : 7;
266
+        unsigned Removable : 1;
267
+
268
+        uint8_t Version;
269
+
270
+        unsigned ResponseDataFormat : 4;
271
+        unsigned HISUP : 1;
272
+        unsigned NormACA : 1;
273
+        unsigned TrmTsk : 1;
274
+        unsigned AERC : 1;
275
+
276
+        uint8_t AdditionalLength;
277
+
278
+        unsigned PROTECT : 1;
279
+        unsigned Res : 2;
280
+        unsigned ThreePC : 1;
281
+        unsigned TPGS : 2;
282
+        unsigned ACC : 1;
283
+        unsigned SCCS : 1;
284
+
285
+        unsigned ADDR16 : 1;
286
+        unsigned R1 : 1;
287
+        unsigned R2 : 1;
288
+        unsigned MCHNGR : 1;
289
+        unsigned MULTIP : 1;
290
+        unsigned VS : 1;
291
+        unsigned ENCSERV : 1;
292
+        unsigned BQUE : 1;
293
+
294
+        unsigned SoftReset : 1;
295
+        unsigned CmdQue : 1;
296
+        unsigned Reserved4 : 1;
297
+        unsigned Linked : 1;
298
+        unsigned Sync : 1;
299
+        unsigned WideBus16Bit : 1;
300
+        unsigned WideBus32Bit : 1;
301
+        unsigned RelAddr : 1;
302
+
303
+        uint8_t VendorID[8];
304
+        uint8_t ProductID[16];
305
+        uint8_t RevisionID[4];
306
+} __attribute__((packed));
307
+
308
+struct SCSI_Request_Sense_Response {
309
+        uint8_t bResponseCode;
310
+        uint8_t bSegmentNumber;
311
+
312
+        uint8_t bmSenseKey : 4;
313
+        uint8_t bmReserved : 1;
314
+        uint8_t bmILI : 1;
315
+        uint8_t bmEOM : 1;
316
+        uint8_t bmFileMark : 1;
317
+
318
+        uint8_t Information[4];
319
+        uint8_t bAdditionalLength;
320
+        uint8_t CmdSpecificInformation[4];
321
+        uint8_t bAdditionalSenseCode;
322
+        uint8_t bAdditionalSenseQualifier;
323
+        uint8_t bFieldReplaceableUnitCode;
324
+        uint8_t SenseKeySpecific[3];
325
+} __attribute__((packed));
326
+
327
+#endif	/* UHS_SCSI_H */
328
+

+ 33
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UNOFFICIAL_IDs.h 파일 보기

@@ -0,0 +1,33 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+#ifndef _UHS_UNOFFICIAL_IDs_h
27
+#define _UHS_UNOFFICIAL_IDs_h
28
+
29
+// Bogus unofficial and unregistered VIDs from cloners to be listed here.
30
+
31
+#define UHS_VID_UNOFFICIAL_JOYTECH 0x162EU  // For unofficial Joytech controllers
32
+
33
+#endif

+ 2995
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_USB_IDs.h
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 336
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_UsbCore.h 파일 보기

@@ -0,0 +1,336 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+
27
+#if !defined(_UHS_host_h_) || defined(USBCORE_H)
28
+#error "Never include UHS_UsbCore.h directly; include UHS_Host.h instead"
29
+#else
30
+#define USBCORE_H
31
+
32
+#ifndef UHS_HOST_MAX_INTERFACE_DRIVERS
33
+#define                UHS_HOST_MAX_INTERFACE_DRIVERS 0x10U // Default maximum number of USB interface drivers
34
+#endif
35
+
36
+#if !defined(SYSTEM_OR_SPECIAL_YIELD)
37
+#define SYSTEM_OR_SPECIAL_YIELD(...) VOID0
38
+#endif
39
+
40
+#if !defined(SYSTEM_OR_SPECIAL_YIELD_FROM_ISR)
41
+#define SYSTEM_OR_SPECIAL_YIELD_FROM_ISR(...) SYSTEM_OR_SPECIAL_YIELD
42
+#endif
43
+
44
+// As we make extensions to a target interface add to UHS_HOST_MAX_INTERFACE_DRIVERS
45
+// This offset gets calculated for supporting wide subclasses, such as HID, BT, etc.
46
+#define                                 UHS_HID_INDEX (UHS_HOST_MAX_INTERFACE_DRIVERS + 1)
47
+
48
+/* Common setup data constant combinations  */
49
+//get descriptor request type
50
+#define                           UHS_bmREQ_GET_DESCR (USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_DEVICE)
51
+
52
+//set request type for all but 'set feature' and 'set interface'
53
+#define                                 UHS_bmREQ_SET (USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_DEVICE)
54
+
55
+//get interface request type
56
+#define                         UHS_bmREQ_CL_GET_INTF (USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE)
57
+
58
+// D7           data transfer direction (0 - host-to-device, 1 - device-to-host)
59
+// D6-5         Type (0- standard, 1 - class, 2 - vendor, 3 - reserved)
60
+// D4-0         Recipient (0 - device, 1 - interface, 2 - endpoint, 3 - other, 4..31 - reserved)
61
+
62
+
63
+// TO-DO: Use the python script to generate these.
64
+// TO-DO: Add _all_ subclasses here.
65
+// USB Device Classes, Subclasses and Protocols
66
+////////////////////////////////////////////////////////////////////////////////
67
+// Use Class Info in the Interface Descriptors
68
+#define                  UHS_USB_CLASS_USE_CLASS_INFO 0x00U
69
+
70
+////////////////////////////////////////////////////////////////////////////////
71
+// Audio
72
+#define                           UHS_USB_CLASS_AUDIO 0x01U
73
+// Subclasses
74
+#define                 UHS_USB_SUBCLASS_AUDIOCONTROL 0x01U
75
+#define               UHS_USB_SUBCLASS_AUDIOSTREAMING 0x02U
76
+#define                UHS_USB_SUBCLASS_MIDISTREAMING 0x03U
77
+
78
+////////////////////////////////////////////////////////////////////////////////
79
+// Communications and CDC Control
80
+#define                UHS_USB_CLASS_COM_AND_CDC_CTRL 0x02U
81
+
82
+////////////////////////////////////////////////////////////////////////////////
83
+// HID
84
+#define                             UHS_USB_CLASS_HID 0x03U
85
+// Subclasses
86
+#define                         UHS_HID_BOOT_SUBCLASS 0x01U
87
+// Protocols
88
+#define             UHS_HID_PROTOCOL_HIDBOOT_KEYBOARD 0x01U
89
+#define                UHS_HID_PROTOCOL_HIDBOOT_MOUSE 0x02U
90
+////////////////////////////////////////////////////////////////////////////////
91
+// Physical
92
+#define                        UHS_USB_CLASS_PHYSICAL 0x05U
93
+
94
+////////////////////////////////////////////////////////////////////////////////
95
+// Image
96
+#define                           UHS_USB_CLASS_IMAGE 0x06U
97
+
98
+////////////////////////////////////////////////////////////////////////////////
99
+// Printer
100
+#define                         UHS_USB_CLASS_PRINTER 0x07U
101
+
102
+////////////////////////////////////////////////////////////////////////////////
103
+// Mass Storage
104
+#define                    UHS_USB_CLASS_MASS_STORAGE 0x08
105
+// Subclasses
106
+#define           UHS_BULK_SUBCLASS_SCSI_NOT_REPORTED 0x00U   // De facto use
107
+#define                         UHS_BULK_SUBCLASS_RBC 0x01U
108
+#define                       UHS_BULK_SUBCLASS_ATAPI 0x02U   // MMC-5 (ATAPI)
109
+#define                   UHS_BULK_SUBCLASS_OBSOLETE1 0x03U   // Was QIC-157
110
+#define                         UHS_BULK_SUBCLASS_UFI 0x04U   // Specifies how to interface Floppy Disk Drives to USB
111
+#define                   UHS_BULK_SUBCLASS_OBSOLETE2 0x05U   // Was SFF-8070i
112
+#define                        UHS_BULK_SUBCLASS_SCSI 0x06U   // SCSI Transparent Command Set
113
+#define                       UHS_BULK_SUBCLASS_LSDFS 0x07U   // Specifies how host has to negotiate access before trying SCSI
114
+#define                    UHS_BULK_SUBCLASS_IEEE1667 0x08U
115
+// Protocols
116
+#define                            UHS_STOR_PROTO_CBI 0x00U   // CBI (with command completion interrupt)
117
+#define                     UHS_STOR_PROTO_CBI_NO_INT 0x01U   // CBI (without command completion interrupt)
118
+#define                       UHS_STOR_PROTO_OBSOLETE 0x02U
119
+#define                            UHS_STOR_PROTO_BBB 0x50U   // Bulk Only Transport
120
+#define                            UHS_STOR_PROTO_UAS 0x62U
121
+
122
+////////////////////////////////////////////////////////////////////////////////
123
+// Hub
124
+#define                             UHS_USB_CLASS_HUB 0x09U
125
+
126
+////////////////////////////////////////////////////////////////////////////////
127
+// CDC-Data
128
+#define                        UHS_USB_CLASS_CDC_DATA 0x0AU
129
+
130
+////////////////////////////////////////////////////////////////////////////////
131
+// Smart-Card
132
+#define                      UHS_USB_CLASS_SMART_CARD 0x0BU
133
+
134
+////////////////////////////////////////////////////////////////////////////////
135
+// Content Security
136
+#define                UHS_USB_CLASS_CONTENT_SECURITY 0x0DU
137
+
138
+////////////////////////////////////////////////////////////////////////////////
139
+// Video
140
+#define                           UHS_USB_CLASS_VIDEO 0x0EU
141
+
142
+////////////////////////////////////////////////////////////////////////////////
143
+// Personal Healthcare
144
+#define                 UHS_USB_CLASS_PERSONAL_HEALTH 0x0FU
145
+
146
+////////////////////////////////////////////////////////////////////////////////
147
+// Diagnostic Device
148
+#define               UHS_USB_CLASS_DIAGNOSTIC_DEVICE 0xDCU
149
+
150
+////////////////////////////////////////////////////////////////////////////////
151
+// Wireless Controller
152
+#define                   UHS_USB_CLASS_WIRELESS_CTRL 0xE0U
153
+
154
+////////////////////////////////////////////////////////////////////////////////
155
+// Miscellaneous
156
+#define                            UHS_USB_CLASS_MISC 0xEFU
157
+
158
+////////////////////////////////////////////////////////////////////////////////
159
+// Application Specific
160
+#define                    UHS_USB_CLASS_APP_SPECIFIC 0xFEU
161
+
162
+////////////////////////////////////////////////////////////////////////////////
163
+// Vendor Specific
164
+#define                 UHS_USB_CLASS_VENDOR_SPECIFIC 0xFFU
165
+
166
+////////////////////////////////////////////////////////////////////////////////
167
+
168
+
169
+/* USB state machine states */
170
+#define                       UHS_USB_HOST_STATE_MASK 0xF0U
171
+
172
+// Configure states, MSN == 0 --------------------------V
173
+#define                   UHS_USB_HOST_STATE_DETACHED 0x00U
174
+#define                   UHS_USB_HOST_STATE_DEBOUNCE 0x01U
175
+#define      UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE 0x02U
176
+#define         UHS_USB_HOST_STATE_RESET_NOT_COMPLETE 0x03U
177
+#define                   UHS_USB_HOST_STATE_WAIT_SOF 0x04U
178
+#define             UHS_USB_HOST_STATE_WAIT_BUS_READY 0x05U
179
+#define               UHS_USB_HOST_STATE_RESET_DEVICE 0x0AU
180
+#define                UHS_USB_HOST_STATE_CONFIGURING 0x0CU // Looks like "CO"nfig (backwards)
181
+#define           UHS_USB_HOST_STATE_CONFIGURING_DONE 0x0DU // Looks like "DO"one (backwards)
182
+#define                      UHS_USB_HOST_STATE_CHECK 0x0EU
183
+#define                    UHS_USB_HOST_STATE_ILLEGAL 0x0FU // Foo
184
+
185
+// Run states, MSN != 0 --------------------------------V
186
+#define                    UHS_USB_HOST_STATE_RUNNING 0x60U // Looks like "GO"
187
+#define                       UHS_USB_HOST_STATE_IDLE 0x1DU // Looks like "ID"le
188
+#define                      UHS_USB_HOST_STATE_ERROR 0xF0U // Looks like "FO"o
189
+#define                 UHS_USB_HOST_STATE_INITIALIZE 0x10U // Looks like "I"nit
190
+
191
+// Host SE result codes.
192
+// Common SE results are stored in the low nybble, all interface drivers understand these plus 0x1f.
193
+// Extended SE results are 0x10-0x1e. SE code only understands these internal to the hardware.
194
+// Values > 0x1F are driver or other internal error conditions.
195
+// Return these result codes from your host controller driver to match the error condition
196
+// ALL Non-zero values are errors.
197
+// Values not listed in this table are not handled in the base class, or any host driver.
198
+
199
+#define                           UHS_HOST_ERROR_NONE 0x00U // No error
200
+#define                           UHS_HOST_ERROR_BUSY 0x01U // transfer pending
201
+#define                         UHS_HOST_ERROR_BADREQ 0x02U // Transfer Launch Request was bad
202
+#define                            UHS_HOST_ERROR_DMA 0x03U // DMA was too short, or too long
203
+#define                            UHS_HOST_ERROR_NAK 0x04U // Peripheral returned NAK
204
+#define                          UHS_HOST_ERROR_STALL 0x05U // Peripheral returned STALL
205
+#define                         UHS_HOST_ERROR_TOGERR 0x06U // Toggle error/ISO over-underrun
206
+#define                       UHS_HOST_ERROR_WRONGPID 0x07U // Received wrong Packet ID
207
+#define                          UHS_HOST_ERROR_BADBC 0x08U // Byte count is bad
208
+#define                         UHS_HOST_ERROR_PIDERR 0x09U // Received Packet ID is corrupted
209
+#define                          UHS_HOST_ERROR_BADRQ 0x0AU // Packet error. Increase max packet.
210
+#define                            UHS_HOST_ERROR_CRC 0x0BU // USB CRC was incorrect
211
+#define                           UHS_HOST_ERROR_KERR 0x0CU // K-state instead of response, usually indicates wrong speed
212
+#define                           UHS_HOST_ERROR_JERR 0x0DU // J-state instead of response, usually indicates wrong speed
213
+#define                        UHS_HOST_ERROR_TIMEOUT 0x0EU // Device did not respond in time
214
+#define                         UHS_HOST_ERROR_BABBLE 0x0FU // Line noise/unexpected data
215
+#define                        UHS_HOST_ERROR_MEM_LAT 0x10U // Error caused by memory latency.
216
+#define                           UHS_HOST_ERROR_NYET 0x11U // OUT transfer accepted with NYET
217
+
218
+// Addressing error codes
219
+#define                      ADDR_ERROR_INVALID_INDEX 0xA0U
220
+#define                    ADDR_ERROR_INVALID_ADDRESS 0xA1U
221
+
222
+// Common Interface Driver error codes
223
+#define           UHS_HOST_ERROR_DEVICE_NOT_SUPPORTED 0xD1U // Driver doesn't support the device or interfaces
224
+#define         UHS_HOST_ERROR_DEVICE_INIT_INCOMPLETE 0xD2U // Init partially finished, but died.
225
+#define     UHS_HOST_ERROR_CANT_REGISTER_DEVICE_CLASS 0xD3U // There was no driver for the interface requested.
226
+#define              UHS_HOST_ERROR_ADDRESS_POOL_FULL 0xD4U // No addresses left in the address pool.
227
+#define           UHS_HOST_ERROR_HUB_ADDRESS_OVERFLOW 0xD5U // No hub addresses left. The maximum is 7.
228
+#define             UHS_HOST_ERROR_NO_ADDRESS_IN_POOL 0xD6U // Address was not allocated in the pool, thus not found.
229
+#define                    UHS_HOST_ERROR_NULL_EPINFO 0xD7U // The supplied endpoint was NULL, indicates a bug or other problem.
230
+#define                   UHS_HOST_ERROR_BAD_ARGUMENT 0xD8U // Indicates a range violation bug.
231
+#define             UHS_HOST_ERROR_DEVICE_DRIVER_BUSY 0xD9U // The interface driver is busy or out buffer is full, try again later.
232
+#define            UHS_HOST_ERROR_BAD_MAX_PACKET_SIZE 0xDAU // The maximum packet size was exceeded. Try again with smaller size.
233
+#define           UHS_HOST_ERROR_NO_ENDPOINT_IN_TABLE 0xDBU // The endpoint could not be found in the endpoint table.
234
+#define                      UHS_HOST_ERROR_UNPLUGGED 0xDEU // Someone removed the USB device, or Vbus was turned off.
235
+#define                          UHS_HOST_ERROR_NOMEM 0xDFU // Out Of Memory.
236
+
237
+// Control request stream errors
238
+#define                UHS_HOST_ERROR_FailGetDevDescr 0xE1U
239
+#define             UHS_HOST_ERROR_FailSetDevTblEntry 0xE2U
240
+#define               UHS_HOST_ERROR_FailGetConfDescr 0xE3U
241
+#define                  UHS_HOST_ERROR_END_OF_STREAM 0xEFU
242
+
243
+// Host base class specific Error codes
244
+#define                UHS_HOST_ERROR_NOT_IMPLEMENTED 0xFEU
245
+#define               UHS_HOST_ERROR_TRANSFER_TIMEOUT 0xFFU
246
+
247
+// SEI interaction defaults
248
+#define                      UHS_HOST_TRANSFER_MAX_MS 10000 // USB transfer timeout in ms, per section 9.2.6.1 of USB 2.0 spec
249
+#define               UHS_HOST_TRANSFER_RETRY_MAXIMUM 3     // 3 retry limit for a transfer
250
+#define                    UHS_HOST_DEBOUNCE_DELAY_MS 500   // settle delay in milliseconds
251
+#define                        UHS_HUB_RESET_DELAY_MS 20    // hub port reset delay, 10ms recomended, but can be up to 20ms
252
+
253
+//
254
+// We only provide the minimum needed information for enumeration.
255
+// Interface drivers should be able to set up what is needed with nothing more.
256
+// A driver needs to know the following information:
257
+// 1: address on the USB network, parent and port (aka UsbDeviceAddress)
258
+// 2: endpoints
259
+// 3: vid:pid, class, subclass, protocol
260
+//
261
+
262
+struct ENDPOINT_INFO {
263
+        uint8_t bEndpointAddress;       // Endpoint address. Bit 7 indicates direction (0=OUT, 1=IN).
264
+        uint8_t bmAttributes;           // Endpoint transfer type.
265
+        uint16_t wMaxPacketSize;        // Maximum packet size.
266
+        uint8_t bInterval;              // Polling interval in frames.
267
+} __attribute__((packed));
268
+
269
+struct INTERFACE_INFO {
270
+        uint8_t bInterfaceNumber;
271
+        uint8_t bAlternateSetting;
272
+        uint8_t numep;
273
+        uint8_t klass;
274
+        uint8_t subklass;
275
+        uint8_t protocol;
276
+        ENDPOINT_INFO epInfo[16];
277
+} __attribute__((packed));
278
+
279
+struct ENUMERATION_INFO {
280
+        uint16_t vid;
281
+        uint16_t pid;
282
+        uint16_t bcdDevice;
283
+        uint8_t klass;
284
+        uint8_t subklass;
285
+        uint8_t protocol;
286
+        uint8_t bMaxPacketSize0;
287
+        uint8_t currentconfig;
288
+        uint8_t parent;
289
+        uint8_t port;
290
+        uint8_t address;
291
+        INTERFACE_INFO interface;
292
+} __attribute__((packed));
293
+
294
+/* USB Setup Packet Structure   */
295
+typedef struct {
296
+        // offset   description
297
+        //   0      Bit-map of request type
298
+         union {
299
+                uint8_t bmRequestType;
300
+
301
+                struct {
302
+                        uint8_t recipient : 5;  // Recipient of the request
303
+                        uint8_t type : 2;       // Type of request
304
+                        uint8_t direction : 1;  // Direction of data transfer
305
+                } __attribute__((packed));
306
+        } ReqType_u;
307
+
308
+        //   1      Request
309
+        uint8_t bRequest;
310
+
311
+        //   2      Depends on bRequest
312
+        union {
313
+                uint16_t wValue;
314
+
315
+                struct {
316
+                        uint8_t wValueLo;
317
+                        uint8_t wValueHi;
318
+                } __attribute__((packed));
319
+        } wVal_u;
320
+        //   4      Depends on bRequest
321
+        uint16_t wIndex;
322
+        //   6      Depends on bRequest
323
+        uint16_t wLength;
324
+        // 8 bytes total
325
+} __attribute__((packed)) SETUP_PKT, *PSETUP_PKT;
326
+
327
+
328
+// little endian :-)                                                                             8                                8                          8                         8                          16                      16
329
+#define mkSETUP_PKT8(bmReqType, bRequest, wValLo, wValHi, wInd, total) ((uint64_t)(((uint64_t)(bmReqType)))|(((uint64_t)(bRequest))<<8)|(((uint64_t)(wValLo))<<16)|(((uint64_t)(wValHi))<<24)|(((uint64_t)(wInd))<<32)|(((uint64_t)(total)<<48)))
330
+#define mkSETUP_PKT16(bmReqType, bRequest, wVal, wInd, total)          ((uint64_t)(((uint64_t)(bmReqType)))|(((uint64_t)(bRequest))<<8)|(((uint64_t)(wVal  ))<<16)                           |(((uint64_t)(wInd))<<32)|(((uint64_t)(total)<<48)))
331
+
332
+// Big endian -- but we aren't able to use this :-/
333
+//#define mkSETUP_PKT8(bmReqType, bRequest, wValLo, wValHi, wInd, total) ((uint64_t)(((uint64_t)(bmReqType))<<56)|(((uint64_t)(bRequest))<<48)|(((uint64_t)(wValLo))<<40)|(((uint64_t)(wValHi))<<32)|(((uint64_t)(wInd))<<16)|((uint64_t)(total)))
334
+//#define mkSETUP_PKT16(bmReqType, bRequest, wVal, wInd, total)          ((uint64_t)(((uint64_t)(bmReqType))<<56)|(((uint64_t)(bRequest))<<48)                           |(((uint64_t)(wVal))<<32)  |(((uint64_t)(wInd))<<16)|((uint64_t)(total)))
335
+
336
+#endif /* USBCORE_H */

+ 248
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_address.h 파일 보기

@@ -0,0 +1,248 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+
27
+#if !defined(_UHS_host_h_) || defined(__ADDRESS_H__)
28
+#error "Never include UHS_address.h directly; include UHS_Usb.h instead"
29
+#else
30
+#define __ADDRESS_H__
31
+
32
+
33
+
34
+/* NAK powers. To save space in endpoint data structure, amount of retries before giving up and returning 0x4 is stored in */
35
+/* bmNakPower as a power of 2. The actual nak_limit is then calculated as nak_limit = ( 2^bmNakPower - 1) */
36
+#define UHS_USB_NAK_MAX_POWER               14      // NAK binary order maximum value
37
+#define UHS_USB_NAK_DEFAULT                 13      // default 16K-1 NAKs before giving up
38
+#define UHS_USB_NAK_NOWAIT                  1       // Single NAK stops transfer
39
+#define UHS_USB_NAK_NONAK                   0       // Do not count NAKs, stop retrying after USB Timeout. Try not to use this.
40
+
41
+#define bmUSB_DEV_ADDR_PORT             0x07
42
+#define bmUSB_DEV_ADDR_PARENT           0x78
43
+#define bmUSB_DEV_ADDR_HUB              0x40
44
+
45
+// TODO: embed parent?
46
+struct UHS_EpInfo {
47
+        uint8_t epAddr; // Endpoint address
48
+        uint8_t bIface;
49
+        uint16_t maxPktSize; // Maximum packet size
50
+
51
+        union {
52
+                uint8_t epAttribs;
53
+
54
+                struct {
55
+                        uint8_t bmSndToggle : 1; // Send toggle, when zero bmSNDTOG0, bmSNDTOG1 otherwise
56
+                        uint8_t bmRcvToggle : 1; // Send toggle, when zero bmRCVTOG0, bmRCVTOG1 otherwise
57
+                        uint8_t bmNeedPing : 1; // 1 == ping protocol needed for next out packet
58
+                        uint8_t bmNakPower : 5; // Binary order for NAK_LIMIT value
59
+                } __attribute__((packed));
60
+        };
61
+} __attribute__((packed));
62
+
63
+// TODO: embed parent address and port into epinfo struct,
64
+// and nuke this address stupidity.
65
+// This is a compact scheme. Should also support full spec.
66
+// This produces a 7 hub limit, 49 devices + 7 hubs, 56 total.
67
+//
68
+//    7   6   5   4   3   2   1   0
69
+//  ---------------------------------
70
+//  |   | H | P | P | P | A | A | A |
71
+//  ---------------------------------
72
+//
73
+// H - if 1 the address is a hub address
74
+// P - parent hub number
75
+// A - port number of parent
76
+//
77
+
78
+struct UHS_DeviceAddress {
79
+
80
+        union {
81
+
82
+                struct {
83
+                        uint8_t bmAddress : 3; // port number
84
+                        uint8_t bmParent : 3; // parent hub address
85
+                        uint8_t bmHub : 1; // hub flag
86
+                        uint8_t bmReserved : 1; // reserved, must be zero
87
+                } __attribute__((packed));
88
+                uint8_t devAddress;
89
+        };
90
+} __attribute__((packed));
91
+
92
+struct UHS_Device {
93
+        volatile UHS_EpInfo *epinfo[UHS_HOST_MAX_INTERFACE_DRIVERS]; // endpoint info pointer
94
+        UHS_DeviceAddress address;
95
+        uint8_t epcount; // number of endpoints
96
+        uint8_t speed; // indicates device speed
97
+} __attribute__((packed));
98
+
99
+typedef void (*UsbDeviceHandleFunc)(UHS_Device *pdev);
100
+
101
+class AddressPool {
102
+        UHS_EpInfo dev0ep; //Endpoint data structure used during enumeration for uninitialized device
103
+
104
+        // In order to avoid hub address duplication, this should use bits
105
+        uint8_t hubCounter; // hub counter
106
+
107
+        UHS_Device thePool[UHS_HOST_MAX_INTERFACE_DRIVERS];
108
+
109
+        // Initializes address pool entry
110
+
111
+        void UHS_NI InitEntry(uint8_t index) {
112
+                thePool[index].address.devAddress = 0;
113
+                thePool[index].epcount = 1;
114
+                thePool[index].speed = 0;
115
+                for(uint8_t i = 0; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) {
116
+                        thePool[index].epinfo[i] = &dev0ep;
117
+                }
118
+        };
119
+
120
+        // Returns thePool index for a given address
121
+
122
+        uint8_t UHS_NI FindAddressIndex(uint8_t address = 0) {
123
+                for(uint8_t i = 1; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) {
124
+                        if(thePool[i].address.devAddress == address)
125
+                                return i;
126
+                }
127
+                return 0;
128
+        };
129
+
130
+        // Returns thePool child index for a given parent
131
+
132
+        uint8_t UHS_NI FindChildIndex(UHS_DeviceAddress addr, uint8_t start = 1) {
133
+                for(uint8_t i = (start < 1 || start >= UHS_HOST_MAX_INTERFACE_DRIVERS) ? 1 : start; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) {
134
+                        if(thePool[i].address.bmParent == addr.bmAddress)
135
+                                return i;
136
+                }
137
+                return 0;
138
+        };
139
+
140
+        // Frees address entry specified by index parameter
141
+
142
+        void UHS_NI FreeAddressByIndex(uint8_t index) {
143
+                // Zero field is reserved and should not be affected
144
+                if(index == 0)
145
+                        return;
146
+
147
+                UHS_DeviceAddress uda = thePool[index].address;
148
+                // If a hub was switched off all port addresses should be freed
149
+                if(uda.bmHub == 1) {
150
+                        for(uint8_t i = 1; (i = FindChildIndex(uda, i));)
151
+                                FreeAddressByIndex(i);
152
+
153
+                        // FIXME: use BIT MASKS
154
+                        // If the hub had the last allocated address, hubCounter should be decremented
155
+                        if(hubCounter == uda.bmAddress)
156
+                                hubCounter--;
157
+                }
158
+                InitEntry(index);
159
+        }
160
+
161
+        void InitAllAddresses(void) {
162
+                for(uint8_t i = 1; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) InitEntry(i);
163
+                hubCounter = 0;
164
+        };
165
+public:
166
+
167
+        AddressPool() {
168
+                hubCounter = 0;
169
+                // Zero address is reserved
170
+                InitEntry(0);
171
+
172
+                thePool[0].epinfo[0] = &dev0ep;
173
+                dev0ep.epAddr = 0;
174
+#if UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE
175
+                dev0ep.maxPktSize = 0x40; //starting at 0x40 and work down
176
+#else
177
+                dev0ep.maxPktSize = 0x08;
178
+#endif
179
+                dev0ep.epAttribs = 0; //set DATA0/1 toggles to 0
180
+                dev0ep.bmNakPower = UHS_USB_NAK_MAX_POWER;
181
+                InitAllAddresses();
182
+        };
183
+
184
+        // Returns a pointer to a specified address entry
185
+
186
+        UHS_Device* UHS_NI GetUsbDevicePtr(uint8_t addr) {
187
+                if(!addr)
188
+                        return thePool;
189
+
190
+                uint8_t index = FindAddressIndex(addr);
191
+
192
+                return (!index) ? NULL : &thePool[index];
193
+        };
194
+
195
+
196
+        // Allocates new address
197
+
198
+        uint8_t UHS_NI AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 1) {
199
+                /* if (parent != 0 && port == 0)
200
+                        USB_HOST_SERIAL.println("PRT:0"); */
201
+                UHS_DeviceAddress _parent;
202
+                _parent.devAddress = parent;
203
+                if(_parent.bmReserved || port > 7)
204
+                        //if(parent > 127 || port > 7)
205
+                        return 0;
206
+
207
+                // FIXME: use BIT MASKS
208
+                if(is_hub && hubCounter == 7)
209
+                        return 0;
210
+
211
+                // finds first empty address entry starting from one
212
+                uint8_t index = FindAddressIndex(0);
213
+
214
+                if(!index) // if empty entry is not found
215
+                        return 0;
216
+
217
+                UHS_DeviceAddress addr;
218
+                addr.devAddress = port;
219
+                addr.bmParent = _parent.bmAddress;
220
+
221
+                // FIXME: use BIT MASKS
222
+                if(is_hub) {
223
+                        hubCounter++;
224
+                        addr.bmHub = 1;
225
+                        addr.bmAddress = hubCounter;
226
+                }
227
+                thePool[index].address = addr;
228
+#if DEBUG_PRINTF_EXTRA_HUGE
229
+#if defined(UHS_DEBUG_USB_ADDRESS)
230
+                printf("Address: %x (%x.%x.%x)\r\n", addr.devAddress, addr.bmHub, addr.bmParent, addr.bmAddress);
231
+#endif
232
+#endif
233
+                return thePool[index].address.devAddress;
234
+        };
235
+
236
+        void UHS_NI FreeAddress(uint8_t addr) {
237
+                // if the root hub is disconnected all the addresses should be initialized
238
+                if(addr == 0x41) {
239
+                        InitAllAddresses();
240
+                        return;
241
+                }
242
+                uint8_t index = FindAddressIndex(addr);
243
+                FreeAddressByIndex(index);
244
+        };
245
+
246
+};
247
+
248
+#endif // __ADDRESS_H__

+ 70
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_hexdump.h 파일 보기

@@ -0,0 +1,70 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+#if !defined(_usb_h_) || defined(__HEXDUMP_H__)
27
+#error "Never include UHS_hexdump.h directly; include UHS_Usb.h instead"
28
+#else
29
+#define __HEXDUMP_H__
30
+
31
+extern int UsbDEBUGlvl;
32
+
33
+template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
34
+class HexDumper : public BASE_CLASS {
35
+        uint8_t byteCount;
36
+        OFFSET_TYPE byteTotal;
37
+
38
+public:
39
+
40
+        HexDumper() : byteCount(0), byteTotal(0) {
41
+        };
42
+
43
+        void Initialize(void) {
44
+                byteCount = 0;
45
+                byteTotal = 0;
46
+        };
47
+
48
+        virtual void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset);
49
+};
50
+
51
+template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
52
+void HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) {
53
+        if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug.
54
+                for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) {
55
+                        if(!byteCount) {
56
+                                PrintHex<OFFSET_TYPE > (byteTotal, 0x80);
57
+                                E_Notify(PSTR(": "), 0x80);
58
+                        }
59
+                        PrintHex<uint8_t > (pbuf[j], 0x80);
60
+                        E_Notify(PSTR(" "), 0x80);
61
+
62
+                        if(byteCount == 15) {
63
+                                E_Notify(PSTR("\r\n"), 0x80);
64
+                                byteCount = 0xFF;
65
+                        }
66
+                }
67
+        }
68
+}
69
+
70
+#endif // __HEXDUMP_H__

+ 111
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host.h 파일 보기

@@ -0,0 +1,111 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+/* USB functions */
27
+#ifndef _UHS_host_h_
28
+#define _UHS_host_h_
29
+
30
+// WARNING: Do not change the order of includes, or stuff will break!
31
+#include <inttypes.h>
32
+#include <stddef.h>
33
+#include <stdio.h>
34
+#include <stdint.h>
35
+
36
+#if DISABLED(USE_UHS3_USB)
37
+#include <ISR_safe_memory.h>
38
+#include <Wire.h>
39
+#include <SPI.h>
40
+#include <UHS_ByteBuffer.h>
41
+#endif
42
+#include "UHS_macros.h"
43
+
44
+// None of these should ever be directly included by a driver, or a user's sketch.
45
+#include "../dyn_SWI/dyn_SWI.h"
46
+#include "UHS_USB_IDs.h"
47
+#include "UHS_settings.h"
48
+#include "UHS_usb_ch9.h"
49
+#include "UHS_UsbCore.h"
50
+#include "UHS_address.h"
51
+#include "UHS_usbhost.h"
52
+#include "UHS_printhex.h"
53
+#include "UHS_message.h"
54
+
55
+// Load system components as required
56
+#if defined(LOAD_USB_HOST_SYSTEM) && !defined(USB_HOST_SYSTEM_LOADED)
57
+#include "UHS_util_INLINE.h"
58
+#include "UHS_host_INLINE.h"
59
+#include "UHS_printf_HELPER.h"
60
+
61
+#if defined(LOAD_USB_HOST_SHIELD)
62
+#include "USB_HOST_SHIELD/USB_HOST_SHIELD.h"
63
+#endif
64
+
65
+#if defined(LOAD_UHS_KINETIS_FS_HOST) && !defined(UHS_KINETIS_FS_HOST_LOADED)
66
+#include "UHS_KINETIS_FS_HOST/UHS_KINETIS_FS_HOST.h"
67
+#endif
68
+
69
+#if defined(LOAD_UHS_KINETIS_EHCI) && !defined(UHS_KINETIS_EHCI_LOADED)
70
+#include "UHS_KINETIS_EHCI/UHS_KINETIS_EHCI.h"
71
+#endif
72
+
73
+// Load USB drivers and multiplexers
74
+
75
+#if defined(LOAD_UHS_HUB)
76
+#include "UHS_HUB/UHS_HUB.h"
77
+#endif // HUB loaded
78
+
79
+#if defined(LOAD_UHS_BULK_STORAGE)
80
+#include "UHS_BULK_STORAGE/UHS_BULK_STORAGE.h"
81
+#endif
82
+
83
+#if defined(LOAD_GENERIC_STORAGE)
84
+#include "../UHS_FS/UHS_FS.h"
85
+#endif
86
+// Add BT and optionally HID if directed to do so
87
+#if defined(LOAD_UHS_BT)
88
+#include "UHS_BT/UHS_BT.h"
89
+#endif // BT and optionally HID loaded
90
+
91
+// Add HID
92
+#if defined(LOAD_UHS_HID)
93
+#include "UHS_HID/UHS_HID.h"
94
+#endif // HID loaded
95
+
96
+// Add CDC multiplexers (currently only ACM)
97
+#if defined(LOAD_UHS_CDC_ACM) || defined(LOAD_UHS_CDC_ACM_FTDI) || defined(LOAD_UHS_CDC_ACM_PROLIFIC) || defined(LOAD_UHS_CDC_ACM_XR21B1411)
98
+#include "UHS_CDC/UHS_CDC.h"
99
+#endif // CDC loaded
100
+
101
+#if defined(LOAD_UHS_ADK)
102
+#include "UHS_ADK/UHS_ADK.h"
103
+#endif
104
+
105
+#if defined(LOAD_UHS_MIDI)
106
+#include "UHS_MIDI/UHS_MIDI.h"
107
+#endif
108
+
109
+#endif // System code loaded
110
+
111
+#endif // _UHS_host_h_

+ 1224
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 393
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_macros.h 파일 보기

@@ -0,0 +1,393 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+
27
+#if !defined(MACROS_H)
28
+#define MACROS_H
29
+#include "macro_logic.h"
30
+/*
31
+ * Universal Arduino(tm) "IDE" fixups.
32
+ */
33
+
34
+
35
+// Just in case...
36
+#ifndef SERIAL_PORT_MONITOR
37
+#define SERIAL_PORT_MONITOR Serial
38
+#endif
39
+
40
+#ifndef INT16_MIN
41
+#define INT16_MIN -32768
42
+#endif
43
+// require 10607+
44
+#if defined(ARDUINO) && ARDUINO >=10607
45
+// nop :-)
46
+#else
47
+#error "Arduino version too old, and must be at least 1.6.7"
48
+#endif
49
+
50
+// Nuke screwed up macro junk from the IDE.
51
+#ifdef __cplusplus
52
+#if defined(true)
53
+#undef true
54
+#endif
55
+#if defined(false)
56
+#undef false
57
+#endif
58
+#endif
59
+
60
+
61
+#if !defined(UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE)
62
+
63
+#if !defined(UHS_BIG_FLASH)
64
+
65
+#if defined(FLASHEND) && defined(FLASHSTART)
66
+#if (FLASHEND - FLASHSTART) > 0x0FFFFU
67
+#define UHS_BIG_FLASH 1
68
+#else
69
+#define UHS_BIG_FLASH 0
70
+#endif
71
+
72
+#elif defined(__PIC32_FLASH_SIZE)
73
+#if __PIC32_FLASH_SIZE > 511
74
+#define UHS_BIG_FLASH 1
75
+#else
76
+#define UHS_BIG_FLASH 0
77
+#endif
78
+
79
+#elif defined(FLASHEND) && !defined(FLASHSTART)
80
+// Assumes flash starts at 0x00000, is this a safe assumption?
81
+// 192K + should be OK
82
+#if FLASHEND > 0x02FFFFU
83
+#define UHS_BIG_FLASH 1
84
+#else
85
+#define UHS_BIG_FLASH 0
86
+#endif
87
+
88
+#elif defined(IFLASH_SIZE)
89
+#if IFLASH_SIZE > 0x0FFFFU
90
+#define UHS_BIG_FLASH 1
91
+#else
92
+#define UHS_BIG_FLASH 0
93
+#endif
94
+
95
+#elif defined(ESP8266)
96
+#define UHS_BIG_FLASH 1
97
+#define SYSTEM_OR_SPECIAL_YIELD(...) yield()
98
+
99
+#elif defined(__arm__) && defined(CORE_TEENSY)
100
+#define UHS_BIG_FLASH 1
101
+
102
+#elif defined(ARDUINO_spresense_ast)
103
+#define UHS_BIG_FLASH 1
104
+#else
105
+// safe default
106
+#warning Small flash?
107
+#define UHS_BIG_FLASH 0
108
+#endif
109
+#endif
110
+
111
+#if UHS_BIG_FLASH
112
+#define UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE 1
113
+#else
114
+#define UHS_DEVICE_WINDOWS_USB_SPEC_VIOLATION_DESCRIPTOR_DEVICE 0
115
+#endif
116
+#endif
117
+
118
+#if defined(__arm__) && defined(CORE_TEENSY)
119
+#define UHS_PIN_WRITE(p, v) digitalWriteFast(p, v)
120
+#define UHS_PIN_READ(p) digitalReadFast(p)
121
+#endif
122
+// TODO: Fast inline code for AVR and SAM based microcontrollers
123
+//       This can be done pretty easily.
124
+//       For now, this will just work out-of-the-box.
125
+#if !defined(UHS_PIN_WRITE)
126
+#define UHS_PIN_WRITE(p, v) digitalWrite(p, v)
127
+#endif
128
+#if !defined(UHS_PIN_READ)
129
+#define UHS_PIN_READ(p) digitalRead(p)
130
+#endif
131
+
132
+#if defined( __PIC32MX__ ) && !defined(interrupts) // compiling with Microchip XC32 compiler
133
+#define interrupts() __builtin_enable_interrupts()
134
+#edfine noInterrupts() __builtin_disable_interrupts()
135
+#endif
136
+
137
+#if !defined(ARDUINO_SAMD_ZERO)
138
+#if defined(ARDUINO_AVR_ADK)
139
+#define UHS_GET_DPI(x) (x == 54 ? 6 : digitalPinToInterrupt(x))
140
+#else
141
+#define UHS_GET_DPI(x) digitalPinToInterrupt(x)
142
+#endif
143
+#else
144
+#define UHS_GET_DPI(x) (x)
145
+#endif
146
+
147
+#ifndef __AVR__
148
+#ifndef __PGMSPACE_H_
149
+// This define should prevent reading the system pgmspace.h if included elsewhere
150
+// This is not normally needed.
151
+#define __PGMSPACE_H_ 1
152
+#endif
153
+
154
+#ifndef PROGMEM
155
+#define PROGMEM
156
+#endif
157
+#ifndef PGM_P
158
+#define PGM_P  const char *
159
+#endif
160
+#ifndef PSTR
161
+#define PSTR(str) (str)
162
+#endif
163
+#ifndef F
164
+#define F(str) (str)
165
+#endif
166
+#ifndef _SFR_BYTE
167
+#define _SFR_BYTE(n) (n)
168
+#endif
169
+#ifndef memchr_P
170
+#define memchr_P(str, c, len) memchr((str), (c), (len))
171
+#endif
172
+#ifndef memcmp_P
173
+#define memcmp_P(a, b, n) memcmp((a), (b), (n))
174
+#endif
175
+#ifndef memcpy_P
176
+#define memcpy_P(dest, src, num) memcpy((dest), (src), (num))
177
+#endif
178
+#ifndef memmem_P
179
+#define memmem_P(a, alen, b, blen) memmem((a), (alen), (b), (blen))
180
+#endif
181
+#ifndef memrchr_P
182
+#define memrchr_P(str, val, len) memrchr((str), (val), (len))
183
+#endif
184
+#ifndef strcat_P
185
+#define strcat_P(dest, src) strcat((dest), (src))
186
+#endif
187
+#ifndef strchr_P
188
+#define strchr_P(str, c) strchr((str), (c))
189
+#endif
190
+#ifndef strchrnul_P
191
+#define strchrnul_P(str, c) strchrnul((str), (c))
192
+#endif
193
+#ifndef strcmp_P
194
+#define strcmp_P(a, b) strcmp((a), (b))
195
+#endif
196
+#ifndef strcpy_P
197
+#define strcpy_P(dest, src) strcpy((dest), (src))
198
+#endif
199
+#ifndef strcasecmp_P
200
+#define strcasecmp_P(a, b) strcasecmp((a), (b))
201
+#endif
202
+#ifndef strcasestr_P
203
+#define strcasestr_P(a, b) strcasestr((a), (b))
204
+#endif
205
+#ifndef strlcat_P
206
+#define strlcat_P(dest, src, len) strlcat((dest), (src), (len))
207
+#endif
208
+#ifndef strlcpy_P
209
+#define strlcpy_P(dest, src, len) strlcpy((dest), (src), (len))
210
+#endif
211
+#ifndef strlen_P
212
+#define strlen_P(s) strlen((const char *)(s))
213
+#endif
214
+#ifndef strnlen_P
215
+#define strnlen_P(str, len) strnlen((str), (len))
216
+#endif
217
+#ifndef strncmp_P
218
+#define strncmp_P(a, b, n) strncmp((a), (b), (n))
219
+#endif
220
+#ifndef strncasecmp_P
221
+#define strncasecmp_P(a, b, n) strncasecmp((a), (b), (n))
222
+#endif
223
+#ifndef strncat_P
224
+#define strncat_P(a, b, n) strncat((a), (b), (n))
225
+#endif
226
+#ifndef strncpy_P
227
+#define strncpy_P(a, b, n) strncmp((a), (b), (n))
228
+#endif
229
+#ifndef strpbrk_P
230
+#define strpbrk_P(str, chrs) strpbrk((str), (chrs))
231
+#endif
232
+#ifndef strrchr_P
233
+#define strrchr_P(str, c) strrchr((str), (c))
234
+#endif
235
+#ifndef strsep_P
236
+#define strsep_P(strp, delim) strsep((strp), (delim))
237
+#endif
238
+#ifndef strspn_P
239
+#define strspn_P(str, chrs) strspn((str), (chrs))
240
+#endif
241
+#ifndef strstr_P
242
+#define strstr_P(a, b) strstr((a), (b))
243
+#endif
244
+#ifndef sprintf_P
245
+#define sprintf_P(s, ...) sprintf((s), __VA_ARGS__)
246
+#endif
247
+#ifndef vfprintf_P
248
+#define vfprintf_P(s, ...) vfprintf((s), __VA_ARGS__)
249
+#endif
250
+#ifndef printf_P
251
+#define printf_P(...) printf(__VA_ARGS__)
252
+#endif
253
+#ifndef snprintf_P
254
+#define snprintf_P(s, n, ...) ((s), (n), __VA_ARGS__)
255
+#endif
256
+#ifndef vsprintf_P
257
+#define vsprintf_P(s, ...) ((s),__VA_ARGS__)
258
+#endif
259
+#ifndef vsnprintf_P
260
+#define vsnprintf_P(s, n, ...) ((s), (n),__VA_ARGS__)
261
+#endif
262
+#ifndef fprintf_P
263
+#define fprintf_P(s, ...) ((s), __VA_ARGS__)
264
+#endif
265
+
266
+#ifndef pgm_read_byte
267
+#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
268
+#endif
269
+#ifndef pgm_read_word
270
+#define pgm_read_word(addr) (*(const unsigned short *)(addr))
271
+#endif
272
+#ifndef pgm_read_dword
273
+#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
274
+#endif
275
+#ifndef pgm_read_float
276
+#define pgm_read_float(addr) (*(const float *)(addr))
277
+#endif
278
+
279
+#ifndef pgm_read_byte_near
280
+#define pgm_read_byte_near(addr) pgm_read_byte(addr)
281
+#endif
282
+#ifndef pgm_read_word_near
283
+#define pgm_read_word_near(addr) pgm_read_word(addr)
284
+#endif
285
+#ifndef pgm_read_dword_near
286
+#define pgm_read_dword_near(addr) pgm_read_dword(addr)
287
+#endif
288
+#ifndef pgm_read_float_near
289
+#define pgm_read_float_near(addr) pgm_read_float(addr)
290
+#endif
291
+#ifndef pgm_read_byte_far
292
+#define pgm_read_byte_far(addr) pgm_read_byte(addr)
293
+#endif
294
+#ifndef pgm_read_word_far
295
+#define pgm_read_word_far(addr) pgm_read_word(addr)
296
+#endif
297
+#ifndef pgm_read_dword_far
298
+#define pgm_read_dword_far(addr) pgm_read_dword(addr)
299
+#endif
300
+#ifndef pgm_read_float_far
301
+#define pgm_read_float_far(addr) pgm_read_float(addr)
302
+#endif
303
+
304
+#ifndef pgm_read_pointer
305
+#define pgm_read_pointer
306
+#endif
307
+
308
+#endif
309
+
310
+
311
+////////////////////////////////////////////////////////////////////////////////
312
+// HANDY MACROS
313
+////////////////////////////////////////////////////////////////////////////////
314
+
315
+// Atmoically set/clear single bits using bitbands.
316
+// Believe it or not, this boils down to a constant,
317
+// and is less code than using |= &= operators.
318
+// Bonus, it makes code easier to read too.
319
+// Bitbanding is a wonderful thing.
320
+#define BITNR(i) (i&0x1?0:i&0x2?1:i&0x4?2:i&0x8?3:i&0x10?4:i&0x20?5:i&0x40?6:i&0x80?7:i&0x100?8:i&0x200?9:i&0x400?10:i&0x800?11:i&0x1000?12:i&0x2000?13:i&0x4000?14:i&0x8000?15:i&0x10000?16:i&0x20000?17:i&0x40000?18:i&0x80000?19:i&0x100000?20:i&0x200000?21:i&0x400000?22:i&0x800000?23:i&0x1000000?24:i&0x2000000?25:i&0x4000000?26:i&0x8000000?27:i&0x10000000?28:i&0x20000000?29:i&0x40000000?30:i&0x80000000?31:32)
321
+#define UHS_KIO_BITBAND_ADDR(r, i) (((uint32_t)&(r) - 0x40000000) * 32 + (i) * 4 + 0x42000000)
322
+#define UHS_KIO_SETBIT_ATOMIC(r, m) (*(uint32_t *)UHS_KIO_BITBAND_ADDR((r), BITNR((m)))) = 1
323
+#define UHS_KIO_CLRBIT_ATOMIC(r, m) (*(uint32_t *)UHS_KIO_BITBAND_ADDR((r), BITNR((m)))) = 0
324
+
325
+
326
+#define VALUE_BETWEEN(v,l,h) (((v)>(l)) && ((v)<(h)))
327
+#define VALUE_WITHIN(v,l,h) (((v)>=(l)) && ((v)<=(h)))
328
+#define output_pgm_message(wa,fp,mp,el) wa = &mp, fp((char *)pgm_read_pointer(wa), el)
329
+#define output_if_between(v,l,h,wa,fp,mp,el) if(VALUE_BETWEEN(v,l,h)) output_pgm_message(wa,fp,mp[v-(l+1)],el);
330
+
331
+#define UHS_SWAP_VALUES(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b)))
332
+#ifndef __BYTE_GRABBING_DEFINED__
333
+#define __BYTE_GRABBING_DEFINED__ 1
334
+#ifdef BROKEN_OPTIMIZER_LITTLE_ENDIAN
335
+// Note: Use this if your compiler generates horrible assembler!
336
+#define UHS_UINT8_BYTE0(__usi__)  (((uint8_t *)&(__usi__))[0])
337
+#define UHS_UINT8_BYTE1(__usi__)  (((uint8_t *)&(__usi__))[1])
338
+#define UHS_UINT8_BYTE2(__usi__)  (((uint8_t *)&(__usi__))[2])
339
+#define UHS_UINT8_BYTE3(__usi__)  (((uint8_t *)&(__usi__))[3])
340
+#define UHS_UINT8_BYTE4(__usi__)  (((uint8_t *)&(__usi__))[4])
341
+#define UHS_UINT8_BYTE5(__usi__)  (((uint8_t *)&(__usi__))[5])
342
+#define UHS_UINT8_BYTE6(__usi__)  (((uint8_t *)&(__usi__))[6])
343
+#define UHS_UINT8_BYTE7(__usi__)  (((uint8_t *)&(__usi__))[7])
344
+#else
345
+// Note: The cast alone to uint8_t is actually enough.
346
+// GCC throws out the "& 0xff", and the size is no different.
347
+// Some compilers need it.
348
+#define UHS_UINT8_BYTE0(__usi__)  ((uint8_t)((__usi__) & 0xff ))
349
+#define UHS_UINT8_BYTE1(__usi__)  ((uint8_t)(((__usi__) >> 8) & 0xff))
350
+#define UHS_UINT8_BYTE2(__usi__)  ((uint8_t)(((__usi__) >> 16) & 0xff))
351
+#define UHS_UINT8_BYTE3(__usi__)  ((uint8_t)(((__usi__) >> 24) & 0xff))
352
+#define UHS_UINT8_BYTE4(__usi__)  ((uint8_t)(((__usi__) >> 32) & 0xff))
353
+#define UHS_UINT8_BYTE5(__usi__)  ((uint8_t)(((__usi__) >> 40) & 0xff))
354
+#define UHS_UINT8_BYTE6(__usi__)  ((uint8_t)(((__usi__) >> 48) & 0xff))
355
+#define UHS_UINT8_BYTE7(__usi__)  ((uint8_t)(((__usi__) >> 56) & 0xff))
356
+#endif
357
+#define UHS_UINT16_SET_BYTE1(__usi__)  ((uint16_t)(__usi__) << 8)
358
+#define UHS_UINT32_SET_BYTE1(__usi__)  ((uint32_t)(__usi__) << 8)
359
+#define UHS_UINT64_SET_BYTE1(__usi__)  ((uint64_t)(__usi__) << 8)
360
+#define UHS_UINT32_SET_BYTE2(__usi__)  ((uint32_t)(__usi__) << 16)
361
+#define UHS_UINT64_SET_BYTE2(__usi__)  ((uint64_t)(__usi__) << 16)
362
+#define UHS_UINT32_SET_BYTE3(__usi__)  ((uint32_t)(__usi__) << 24)
363
+#define UHS_UINT64_SET_BYTE3(__usi__)  ((uint64_t)(__usi__) << 24)
364
+#define UHS_UINT64_SET_BYTE4(__usi__)  ((uint64_t)(__usi__) << 32)
365
+#define UHS_UINT64_SET_BYTE5(__usi__)  ((uint64_t)(__usi__) << 40)
366
+#define UHS_UINT64_SET_BYTE6(__usi__)  ((uint64_t)(__usi__) << 48)
367
+#define UHS_UINT64_SET_BYTE7(__usi__)  ((uint64_t)(__usi__) << 56)
368
+
369
+// These are the smallest and fastest ways I have found so far in pure C/C++.
370
+#define UHS_BYTES_TO_UINT16(__usc1__,__usc0__) ((uint16_t)((uint16_t)(__usc0__) | (uint16_t)UHS_UINT16_SET_BYTE1(__usc1__)))
371
+#define UHS_BYTES_TO_UINT32(__usc3__,__usc2__,__usc1__,__usc0__) ((uint32_t)((uint32_t)(__usc0__) | UHS_UINT32_SET_BYTE1(__usc1__) | UHS_UINT32_SET_BYTE2(__usc2__) | UHS_UINT32_SET_BYTE3(__usc3__)))
372
+#define UHS_BYTES_TO_UINT64(__usc7__,__usc6__,__usc5__,__usc4__,__usc3__,__usc2__,__usc1__,__usc0__) ((uint64_t)((uint64_t)__usc0__ | UHS_UINT64_SET_BYTE1(__usc1__) | UHS_UINT64_SET_BYTE2(__usc2__) | UHS_UINT64_SET_BYTE3(__usc3__) | UHS_UINT64_SET_BYTE4(__usc4__) | UHS_UINT64_SET_BYTE5(__usc5__) | UHS_UINT64_SET_BYTE6(__usc6__) | UHS_UINT64_SET_BYTE7(__usc7__)))
373
+#endif
374
+/*
375
+ * Debug macros.
376
+ * Useful when porting from UHS2.
377
+ * Do not use these for any new code.
378
+ * Change to better debugging after port is completed.
379
+ * Strings are stored in progmem (flash) instead of RAM.
380
+ */
381
+#define USBTRACE1(s,l) (Notify(PSTR(s), l))
382
+#define USBTRACE(s) (USBTRACE1((s), 0x80)); USB_HOST_SERIAL.flush()
383
+#define USBTRACE3(s,r,l) (Notify(PSTR(s), l), D_PrintHex((r), l), Notify(PSTR("\r\n"), l))
384
+#define USBTRACE3X(s,r,l) (Notify(PSTR(s), l), D_PrintHex((r), l))
385
+#define USBTRACE2(s,r) (USBTRACE3((s),(r),0x80)); USB_HOST_SERIAL.flush()
386
+#define USBTRACE2X(s,r) (USBTRACE3X((s),(r),0x80)); USB_HOST_SERIAL.flush()
387
+
388
+#define VOID0 ((void)0)
389
+#if !defined(NOTUSED)
390
+#define NOTUSED(...)  __VA_ARGS__ __attribute__((unused))
391
+#endif
392
+#endif /* MACROS_H */
393
+

+ 91
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_message.h 파일 보기

@@ -0,0 +1,91 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+#if !defined(_UHS_host_h_) || defined(__MESSAGE_H__)
27
+#error "Never include UHS_message.h directly; include UHS_Usb.h instead"
28
+#else
29
+#define __MESSAGE_H__
30
+
31
+extern int UsbDEBUGlvl;
32
+
33
+void E_Notify(char const * msg, int lvl);
34
+void E_Notify(uint8_t b, int lvl);
35
+void E_NotifyStr(char const * msg, int lvl);
36
+void E_Notifyc(char c, int lvl);
37
+
38
+#ifdef DEBUG_USB_HOST
39
+#define Notify E_Notify
40
+#define NotifyStr E_NotifyStr
41
+#define Notifyc E_Notifyc
42
+void NotifyFailGetDevDescr(uint8_t reason);
43
+void NotifyFailSetDevTblEntry(uint8_t reason);
44
+void NotifyFailGetConfDescr(uint8_t reason);
45
+void NotifyFailSetConfDescr(uint8_t reason);
46
+void NotifyFailGetDevDescr(void);
47
+void NotifyFailSetDevTblEntry(void);
48
+void NotifyFailGetConfDescr(void);
49
+void NotifyFailSetConfDescr(void);
50
+void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID);
51
+void NotifyFail(uint8_t rcode);
52
+#else
53
+#define Notify(...) VOID0
54
+#define NotifyStr(...) VOID0
55
+#define Notifyc(...) VOID0
56
+#define NotifyFailGetDevDescr(...) VOID0
57
+#define NotifyFailSetDevTblEntry(...) VOID0
58
+#define NotifyFailGetConfDescr(...) VOID0
59
+#define NotifyFailGetDevDescr(...) VOID0
60
+#define NotifyFailSetDevTblEntry(...) VOID0
61
+#define NotifyFailGetConfDescr(...) VOID0
62
+#define NotifyFailSetConfDescr(...) VOID0
63
+#define NotifyFailUnknownDevice(...) VOID0
64
+#define NotifyFail(...) VOID0
65
+#endif
66
+
67
+#ifdef DEBUG_USB_HOST
68
+template <class ERROR_TYPE> void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) {
69
+        Notify(msg, level);
70
+        Notify(PSTR(": "), level);
71
+        D_PrintHex<ERROR_TYPE > (rcode, level);
72
+        Notify(PSTR("\r\n"), level);
73
+#else
74
+template <class ERROR_TYPE> void ErrorMessage(NOTUSED(uint8_t level), NOTUSED(char const * msg), ERROR_TYPE rcode = 0) {
75
+        (void)rcode;
76
+#endif
77
+}
78
+
79
+#ifdef DEBUG_USB_HOST
80
+template <class ERROR_TYPE> void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
81
+        Notify(msg, 0x80);
82
+        Notify(PSTR(": "), 0x80);
83
+        D_PrintHex<ERROR_TYPE > (rcode, 0x80);
84
+        Notify(PSTR("\r\n"), 0x80);
85
+#else
86
+template <class ERROR_TYPE> void ErrorMessage(NOTUSED(char const * msg), ERROR_TYPE rcode = 0) {
87
+        (void)rcode;
88
+#endif
89
+}
90
+
91
+#endif // __MESSAGE_H__

+ 201
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printf_HELPER.h 파일 보기

@@ -0,0 +1,201 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+
27
+#ifndef UHS_PRINTF_HELPER_H
28
+#define	UHS_PRINTF_HELPER_H
29
+
30
+#if defined(LOAD_UHS_PRINTF_HELPER)
31
+#include <Arduino.h>
32
+#ifdef true
33
+#undef true
34
+#endif
35
+#ifdef false
36
+#undef false
37
+#endif
38
+
39
+#if !defined(STDIO_IS_OK_TO_USE_AS_IS)
40
+#if defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAM_DUE) || defined(ARDUINO_spresense_ast)
41
+// STDIO patching not required.
42
+#define STDIO_IS_OK_TO_USE_AS_IS
43
+#endif
44
+#endif
45
+
46
+#if !defined(STDIO_IS_OK_TO_USE_AS_IS)
47
+// We need to patch STDIO so it can be used.
48
+
49
+#ifndef SERIAL_PORT_MONITOR
50
+// Some don't define this.
51
+#define SERIAL_PORT_MONITOR Serial
52
+#endif
53
+
54
+#ifndef SERIAL_PORT_HARDWARE
55
+// Some don't define this.
56
+#define SERIAL_PORT_HARDWARE SERIAL_PORT_MONITOR
57
+#endif
58
+
59
+#ifndef USB_HOST_SERIAL
60
+#if defined(SERIAL_PORT_USBVIRTUAL) && defined(LOAD_UHS_KINETIS_FS_HOST)
61
+#define USB_HOST_SERIAL SERIAL_PORT_HARDWARE
62
+#else
63
+#define USB_HOST_SERIAL SERIAL_PORT_MONITOR
64
+#endif
65
+#endif
66
+
67
+#if !defined(NOTUSED)
68
+#define NOTUSED(...)  __VA_ARGS__ __attribute__((unused))
69
+#endif
70
+
71
+#ifndef __AVR__
72
+#ifndef printf_P
73
+#define printf_P(...) printf(__VA_ARGS__)
74
+#endif
75
+#endif
76
+
77
+#if defined(ARDUINO_ARCH_PIC32)
78
+/*
79
+ * For printf() output with pic32 Arduino
80
+ */
81
+extern "C" {
82
+
83
+        void _mon_putc(char s) {
84
+                USB_HOST_SERIAL.write(s);
85
+        }
86
+
87
+        int _mon_getc() {
88
+                while(!USB_HOST_SERIAL.available());
89
+                return USB_HOST_SERIAL.read();
90
+        }
91
+}
92
+
93
+#elif defined(__AVR__)
94
+extern "C" {
95
+
96
+        static FILE tty_stdio;
97
+        static FILE tty_stderr;
98
+
99
+        static int NOTUSED(tty_stderr_putc(char c, NOTUSED(FILE *t)));
100
+        static int NOTUSED(tty_stderr_flush(NOTUSED(FILE *t)));
101
+        static int NOTUSED(tty_std_putc(char c, NOTUSED(FILE *t)));
102
+        static int NOTUSED(tty_std_getc(NOTUSED(FILE *t)));
103
+        static int NOTUSED(tty_std_flush(NOTUSED(FILE *t)));
104
+
105
+        static int tty_stderr_putc(char c, NOTUSED(FILE *t)) {
106
+                USB_HOST_SERIAL.write(c);
107
+                return 0;
108
+        }
109
+
110
+        static int tty_stderr_flush(NOTUSED(FILE *t)) {
111
+                USB_HOST_SERIAL.flush();
112
+                return 0;
113
+        }
114
+
115
+        static int tty_std_putc(char c, NOTUSED(FILE *t)) {
116
+                USB_HOST_SERIAL.write(c);
117
+                return 0;
118
+        }
119
+
120
+        static int tty_std_getc(NOTUSED(FILE *t)) {
121
+                while(!USB_HOST_SERIAL.available());
122
+                return USB_HOST_SERIAL.read();
123
+        }
124
+
125
+        static int tty_std_flush(NOTUSED(FILE *t)) {
126
+                USB_HOST_SERIAL.flush();
127
+                return 0;
128
+        }
129
+}
130
+#elif defined(CORE_TEENSY)
131
+extern "C" {
132
+
133
+        int _write(int fd, const char *ptr, int len) {
134
+                int j;
135
+                for(j = 0; j < len; j++) {
136
+                        if(fd == 1)
137
+                                USB_HOST_SERIAL.write(*ptr++);
138
+                        else if(fd == 2)
139
+                                USB_HOST_SERIAL.write(*ptr++);
140
+                }
141
+                return len;
142
+        }
143
+
144
+        int _read(int fd, char *ptr, int len) {
145
+                if(len > 0 && fd == 0) {
146
+                        while(!USB_HOST_SERIAL.available());
147
+                        *ptr = USB_HOST_SERIAL.read();
148
+                        return 1;
149
+                }
150
+                return 0;
151
+        }
152
+
153
+#include <sys/stat.h>
154
+
155
+        int _fstat(int fd, struct stat *st) {
156
+                memset(st, 0, sizeof (*st));
157
+                st->st_mode = S_IFCHR;
158
+                st->st_blksize = 1024;
159
+                return 0;
160
+        }
161
+
162
+        int _isatty(int fd) {
163
+                return (fd < 3) ? 1 : 0;
164
+        }
165
+}
166
+#else
167
+#error no STDIO
168
+#endif // defined(ARDUINO_ARCH_PIC32)
169
+
170
+
171
+
172
+#if defined(__AVR__)
173
+// The only wierdo in the bunch...
174
+void UHS_AVR_printf_HELPER_init(void) {
175
+        // Set up stdio/stderr
176
+        tty_stdio.put = tty_std_putc;
177
+        tty_stdio.get = tty_std_getc;
178
+        tty_stdio.flags = _FDEV_SETUP_RW;
179
+        tty_stdio.udata = 0;
180
+
181
+        tty_stderr.put = tty_stderr_putc;
182
+        tty_stderr.get = NULL;
183
+        tty_stderr.flags = _FDEV_SETUP_WRITE;
184
+        tty_stderr.udata = 0;
185
+
186
+        stdout = &tty_stdio;
187
+        stdin = &tty_stdio;
188
+        stderr = &tty_stderr;
189
+
190
+}
191
+#define UHS_printf_HELPER_init() UHS_AVR_printf_HELPER_init()
192
+#endif
193
+
194
+#endif /* STDIO_IS_OK_TO_USE_AS_IS */
195
+#endif  /* load.... */
196
+
197
+#if !defined(UHS_printf_HELPER_init)
198
+#define UHS_printf_HELPER_init() (void(0))
199
+#endif
200
+#endif	/* UHS_PRINTF_HELPER_H */
201
+

+ 96
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_printhex.h 파일 보기

@@ -0,0 +1,96 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+
27
+#if !defined(_UHS_host_h_) || defined(__PRINTHEX_H__)
28
+#error "Never include UHS_printhex.h directly; include UHS_Usb.h instead"
29
+#else
30
+#define __PRINTHEX_H__
31
+
32
+void E_Notifyc(char c, int lvl);
33
+
34
+template <class T>
35
+void PrintHex(T val, int lvl) {
36
+        int num_nibbles = sizeof (T) * 2;
37
+
38
+        do {
39
+                char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f);
40
+                if(v > 57) v += 7;
41
+                E_Notifyc(v, lvl);
42
+        } while(--num_nibbles);
43
+}
44
+
45
+template <class T>
46
+void PrintBin(T val, int lvl) {
47
+        for(T mask = (((T)1) << ((sizeof (T) << 3) - 1)); mask; mask >>= 1)
48
+                if(val & mask)
49
+                        E_Notifyc('1', lvl);
50
+                else
51
+                        E_Notifyc('0', lvl);
52
+}
53
+
54
+template <class T>
55
+void SerialPrintHex(T val) {
56
+        int num_nibbles = sizeof (T) * 2;
57
+
58
+        do {
59
+                char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f);
60
+                if(v > 57) v += 7;
61
+                USB_HOST_SERIAL.print(v);
62
+        } while(--num_nibbles);
63
+}
64
+
65
+template <class T>
66
+void PrintHex2(Print *prn, T val) {
67
+        T mask = (((T)1) << (((sizeof (T) << 1) - 1) << 2));
68
+
69
+        while(mask > 1) {
70
+                if(val < mask)
71
+                        prn->print("0");
72
+
73
+                mask >>= 4;
74
+        }
75
+        prn->print((T)val, HEX);
76
+}
77
+
78
+#ifdef DEBUG_USB_HOST
79
+template <class T> void D_PrintHex(T val, int lvl) {
80
+        PrintHex<T > (val, lvl);
81
+#else
82
+template <class T> void D_PrintHex(NOTUSED(T val), NOTUSED(int lvl)) {
83
+#endif
84
+}
85
+
86
+#ifdef DEBUG_USB_HOST
87
+template <class T> void D_PrintBin(T val, int lvl) {
88
+        PrintBin<T > (val, lvl);
89
+#else
90
+template <class T> void D_PrintBin(NOTUSED(T val), NOTUSED(int lvl)) {
91
+#endif
92
+}
93
+
94
+
95
+
96
+#endif // __PRINTHEX_H__

+ 141
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_settings.h 파일 보기

@@ -0,0 +1,141 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+
27
+#ifndef UHS_SETTINGS_H
28
+#define UHS_SETTINGS_H
29
+
30
+// TO-DO: Move specific settings to modules which use them.
31
+
32
+////////////////////////////////////////////////////////////////////////////////
33
+// Define any of these options at the top of your sketch to override
34
+// the defaults contained herewith. Do NOT do modifications here.
35
+// Individual Components have their own settings.
36
+//
37
+// Macro                        | Settings and notes    | Default
38
+// -----------------------------+-----------------------+-----------------------
39
+//                              |  Any class that does  |
40
+// USB_HOST_SERIAL              |  text streaming       | SERIAL_PORT_MONITOR
41
+//                              |  e.g. Serial2         |
42
+// -----------------------------+-----------------------+-----------------------
43
+// ENABLE_UHS_DEBUGGING         | 0 = off, 1 = on       | 0
44
+// -----------------------------+-----------------------+-----------------------
45
+//                              | 0 = off, 1 = on       |
46
+//                              | Caution! Can make     |
47
+// DEBUG_PRINTF_EXTRA_HUGE      | program too large!    | 0
48
+//                              | Other modules depend  |
49
+//                              | on this setting.      |
50
+// -----------------------------+-----------------------+-----------------------
51
+// USE_UHS_BLACK_WIDDOW         | 0 = no, 1 = yes       | 0
52
+// -----------------------------+-----------------------+-----------------------
53
+// ENABLE_WII_IR_CAMERA         | 0 = no, 1 = yes       | 0
54
+// -----------------------------^-----------------------^-----------------------
55
+//
56
+////////////////////////////////////////////////////////////////////////////////
57
+
58
+
59
+////////////////////////////////////////////////////////////////////////////////
60
+// DEBUGGING
61
+////////////////////////////////////////////////////////////////////////////////
62
+
63
+#ifndef USB_HOST_SERIAL
64
+#if defined(SERIAL_PORT_USBVIRTUAL) && defined(LOAD_UHS_KINETIS_FS_HOST)
65
+#define USB_HOST_SERIAL SERIAL_PORT_HARDWARE
66
+#else
67
+#define USB_HOST_SERIAL SERIAL_PORT_MONITOR
68
+#endif
69
+#endif
70
+
71
+#ifndef ENABLE_UHS_DEBUGGING
72
+#define ENABLE_UHS_DEBUGGING 0
73
+#endif
74
+
75
+#ifndef DEBUG_PRINTF_EXTRA_HUGE
76
+#define DEBUG_PRINTF_EXTRA_HUGE 0
77
+#endif
78
+
79
+////////////////////////////////////////////////////////////////////////////////
80
+// Manual board activation
81
+////////////////////////////////////////////////////////////////////////////////
82
+
83
+/* Set this to 1 if you are using a Black Widdow */
84
+#ifndef USE_UHS_BLACK_WIDDOW
85
+#define USE_UHS_BLACK_WIDDOW 0
86
+#endif
87
+
88
+////////////////////////////////////////////////////////////////////////////////
89
+// Wii IR camera
90
+////////////////////////////////////////////////////////////////////////////////
91
+
92
+/* Set this to 1 to activate code for the Wii IR camera */
93
+#ifndef ENABLE_WII_IR_CAMERA
94
+#define ENABLE_WII_IR_CAMERA 0
95
+#endif
96
+
97
+////////////////////////////////////////////////////////////////////////////////
98
+// Set to 1 to use the faster spi4teensy3 driver. (not used yet))
99
+////////////////////////////////////////////////////////////////////////////////
100
+#ifndef USE_SPI4TEENSY3
101
+#define USE_SPI4TEENSY3 0
102
+#endif
103
+
104
+////////////////////////////////////////////////////////////////////////////////
105
+// AUTOMATIC Settings
106
+////////////////////////////////////////////////////////////////////////////////
107
+
108
+// No user serviceable parts below this line.
109
+// DO NOT change anything below here unless you are a developer!
110
+
111
+#if defined(__GNUC__) && defined(__AVR__)
112
+#ifndef GCC_VERSION
113
+#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
114
+#endif
115
+#if GCC_VERSION < 40602 // Test for GCC < 4.6.2
116
+#ifdef PROGMEM
117
+#undef PROGMEM
118
+#define PROGMEM __attribute__((section(".progmem.data"))) // Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734#c4
119
+#ifdef PSTR
120
+#undef PSTR
121
+#define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];})) // Copied from pgmspace.h in avr-libc source
122
+#endif
123
+#endif
124
+#endif
125
+#endif
126
+
127
+#if !defined(DEBUG_USB_HOST) && ENABLE_UHS_DEBUGGING
128
+#define DEBUG_USB_HOST
129
+#endif
130
+
131
+#if !defined(WIICAMERA) && ENABLE_WII_IR_CAMERA
132
+#define WIICAMERA
133
+#endif
134
+
135
+#define UHS_SLEEP_MS(v) pUsb->sof_delay(v)
136
+
137
+#ifndef UHS_NI
138
+#define UHS_NI __attribute__((noinline))
139
+#endif
140
+
141
+#endif /* SETTINGS_H */

+ 222
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usb_ch9.h 파일 보기

@@ -0,0 +1,222 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+
27
+#if !defined(_UHS_host_h_) || defined(_UHS_ch9_h_)
28
+#error "Never include UHS_usb_ch9.h directly; include UHS_Usb.h instead"
29
+#else
30
+
31
+/* USB chapter 9 structures */
32
+#define _UHS_ch9_h_
33
+
34
+/* Misc.USB constants */
35
+#define                           DEV_DESCR_LEN 18      //device descriptor length
36
+#define                          CONF_DESCR_LEN 9       //configuration descriptor length
37
+#define                          INTR_DESCR_LEN 9       //interface descriptor length
38
+#define                            EP_DESCR_LEN 7       //endpoint descriptor length
39
+
40
+/* Standard Device Requests */
41
+#define                  USB_REQUEST_GET_STATUS 0       // Standard Device Request - GET STATUS
42
+#define               USB_REQUEST_CLEAR_FEATURE 1       // Standard Device Request - CLEAR FEATURE
43
+#define                 USB_REQUEST_SET_FEATURE 3       // Standard Device Request - SET FEATURE
44
+#define                 USB_REQUEST_SET_ADDRESS 5       // Standard Device Request - SET ADDRESS
45
+#define              USB_REQUEST_GET_DESCRIPTOR 6       // Standard Device Request - GET DESCRIPTOR
46
+#define              USB_REQUEST_SET_DESCRIPTOR 7       // Standard Device Request - SET DESCRIPTOR
47
+#define           USB_REQUEST_GET_CONFIGURATION 8       // Standard Device Request - GET CONFIGURATION
48
+#define           USB_REQUEST_SET_CONFIGURATION 9       // Standard Device Request - SET CONFIGURATION
49
+#define               USB_REQUEST_GET_INTERFACE 10      // Standard Device Request - GET INTERFACE
50
+#define               USB_REQUEST_SET_INTERFACE 11      // Standard Device Request - SET INTERFACE
51
+#define                 USB_REQUEST_SYNCH_FRAME 12      // Standard Device Request - SYNCH FRAME
52
+
53
+/* Wireless USB Device Requests */
54
+#define                  USB_REQ_SET_ENCRYPTION 0x0D
55
+#define                  USB_REQ_GET_ENCRYPTION 0x0E
56
+#define                     USB_REQ_RPIPE_ABORT 0x0E
57
+#define                   USB_REQ_SET_HANDSHAKE 0x0F
58
+#define                     USB_REQ_RPIPE_RESET 0x0F
59
+#define                   USB_REQ_GET_HANDSHAKE 0x10
60
+#define                  USB_REQ_SET_CONNECTION 0x11
61
+#define               USB_REQ_SET_SECURITY_DATA 0x12
62
+#define               USB_REQ_GET_SECURITY_DATA 0x13
63
+#define                   USB_REQ_SET_WUSB_DATA 0x14
64
+#define             USB_REQ_LOOPBACK_DATA_WRITE 0x15
65
+#define              USB_REQ_LOOPBACK_DATA_READ 0x16
66
+#define                USB_REQ_SET_INTERFACE_DS 0x17
67
+
68
+/* USB feature flags */
69
+#define                 USB_DEVICE_SELF_POWERED 0   /* (read only) */
70
+#define                USB_DEVICE_REMOTE_WAKEUP 1   /* dev may initiate wakeup */
71
+#define                    USB_DEVICE_TEST_MODE 2   /* (wired high speed only) */
72
+#define                      USB_DEVICE_BATTERY 2   /* (wireless) */
73
+#define                 USB_DEVICE_B_HNP_ENABLE 3   /* (otg) dev may initiate HNP */
74
+#define                  USB_DEVICE_WUSB_DEVICE 3   /* (wireless)*/
75
+#define                USB_DEVICE_A_HNP_SUPPORT 4   /* (otg) RH port supports HNP */
76
+#define            USB_DEVICE_A_ALT_HNP_SUPPORT 5   /* (otg) other RH port does */
77
+#define                   USB_DEVICE_DEBUG_MODE 6   /* (special devices only) */
78
+
79
+#define               USB_FEATURE_ENDPOINT_HALT 0       // CLEAR/SET FEATURE - Endpoint Halt
80
+#define        USB_FEATURE_DEVICE_REMOTE_WAKEUP 1       // CLEAR/SET FEATURE - Device remote wake-up
81
+#define                   USB_FEATURE_TEST_MODE 2       // CLEAR/SET FEATURE - Test mode
82
+/* OTG SET FEATURE Constants    */
83
+#define               OTG_FEATURE_B_HNP_ENABLE  3       // SET FEATURE OTG - Enable B device to perform HNP
84
+#define               OTG_FEATURE_A_HNP_SUPPORT 4       // SET FEATURE OTG - A device supports HNP
85
+#define           OTG_FEATURE_A_ALT_HNP_SUPPORT 5       // SET FEATURE OTG - Another port on the A device supports HNP
86
+
87
+/* Setup Data Constants */
88
+#define                USB_SETUP_HOST_TO_DEVICE 0x00    // Device Request bmRequestType transfer direction - host to device transfer
89
+#define                USB_SETUP_DEVICE_TO_HOST 0x80    // Device Request bmRequestType transfer direction - device to host transfer
90
+#define                 USB_SETUP_TYPE_STANDARD 0x00    // Device Request bmRequestType type - standard
91
+#define                    USB_SETUP_TYPE_CLASS 0x20    // Device Request bmRequestType type - class
92
+#define                   USB_SETUP_TYPE_VENDOR 0x40    // Device Request bmRequestType type - vendor
93
+#define              USB_SETUP_RECIPIENT_DEVICE 0x00    // Device Request bmRequestType recipient - device
94
+#define           USB_SETUP_RECIPIENT_INTERFACE 0x01    // Device Request bmRequestType recipient - interface
95
+#define            USB_SETUP_RECIPIENT_ENDPOINT 0x02    // Device Request bmRequestType recipient - endpoint
96
+#define               USB_SETUP_RECIPIENT_OTHER 0x03    // Device Request bmRequestType recipient - other
97
+#define                USB_SETUP_RECIPIENT_PORT 0x04    // Wireless USB 1.0
98
+#define               USB_SETUP_RECIPIENT_RPIPE 0x05    // Wireless USB 1.0
99
+
100
+
101
+/* USB descriptors  */
102
+#define                   USB_DESCRIPTOR_DEVICE 0x01    // bDescriptorType for a Device Descriptor.
103
+#define            USB_DESCRIPTOR_CONFIGURATION 0x02    // bDescriptorType for a Configuration Descriptor.
104
+#define                   USB_DESCRIPTOR_STRING 0x03    // bDescriptorType for a String Descriptor.
105
+#define                USB_DESCRIPTOR_INTERFACE 0x04    // bDescriptorType for an Interface Descriptor.
106
+#define                 USB_DESCRIPTOR_ENDPOINT 0x05    // bDescriptorType for an Endpoint Descriptor.
107
+#define         USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06    // bDescriptorType for a Device Qualifier.
108
+#define              USB_DESCRIPTOR_OTHER_SPEED 0x07    // bDescriptorType for a Other Speed Configuration.
109
+#define          USB_DESCRIPTOR_INTERFACE_POWER 0x08    // bDescriptorType for Interface Power.
110
+#define                      USB_DESCRIPTOR_OTG 0x09    // bDescriptorType for an OTG Descriptor.
111
+#define                    USB_DESCRIPTOR_DEBUG 0x0a
112
+#define    USB_DESCRIPTOR_INTERFACE_ASSOCIATION 0x0b
113
+#define                 USB_DESCRIPTOR_SECURITY 0x0c
114
+#define                      USB_DESCRIPTOR_KEY 0x0d
115
+#define          USB_DESCRIPTOR_ENCRYPTION_TYPE 0x0e
116
+#define                      USB_DESCRIPTOR_BOS 0x0f
117
+#define        USB_DESCRIPTOR_DEVICE_CAPABILITY 0x10
118
+#define   USB_DESCRIPTOR_WIRELESS_ENDPOINT_COMP 0x11
119
+#define             USB_DESCRIPTOR_WIRE_ADAPTER 0x21
120
+#define                    USB_DESCRIPTOR_RPIPE 0x22
121
+#define         USB_DESCRIPTOR_CS_RADIO_CONTROL 0x23
122
+#define         USB_DESCRIPTOR_SS_ENDPOINT_COMP 0x30
123
+
124
+#define                      USB_HID_DESCRIPTOR 0x21
125
+
126
+
127
+// Conventional codes for class-specific descriptors. "Common Class" Spec (3.11)
128
+#define                USB_DESCRIPTOR_CS_DEVICE 0x21
129
+#define                USB_DESCRIPTOR_CS_CONFIG 0x22
130
+#define                USB_DESCRIPTOR_CS_STRING 0x23
131
+#define             USB_DESCRIPTOR_CS_INTERFACE 0x24
132
+#define              USB_DESCRIPTOR_CS_ENDPOINT 0x25
133
+
134
+
135
+
136
+/* USB Endpoint Transfer Types  */
137
+#define               USB_TRANSFER_TYPE_CONTROL 0x00    // Endpoint is a control endpoint.
138
+#define           USB_TRANSFER_TYPE_ISOCHRONOUS 0x01    // Endpoint is an isochronous endpoint.
139
+#define                  USB_TRANSFER_TYPE_BULK 0x02    // Endpoint is a bulk endpoint.
140
+#define             USB_TRANSFER_TYPE_INTERRUPT 0x03    // Endpoint is an interrupt endpoint.
141
+#define                     bmUSB_TRANSFER_TYPE 0x03    // bit mask to separate transfer type from ISO attributes
142
+#define               USB_TRANSFER_DIRECTION_IN 0x80    // Indicate direction is IN
143
+
144
+/* Standard Feature Selectors for CLEAR_FEATURE Requests    */
145
+#define              USB_FEATURE_ENDPOINT_STALL 0       // Endpoint recipient
146
+#define        USB_FEATURE_DEVICE_REMOTE_WAKEUP 1       // Device recipient
147
+#define                   USB_FEATURE_TEST_MODE 2       // Device recipient
148
+
149
+/* descriptor data structures */
150
+
151
+/* Device descriptor structure */
152
+typedef struct {
153
+        uint8_t bLength; // Length of this descriptor.
154
+        uint8_t bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE).
155
+        uint16_t bcdUSB; // USB Spec Release Number (BCD).
156
+        uint8_t bDeviceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific.
157
+        uint8_t bDeviceSubClass; // Subclass code (assigned by the USB-IF).
158
+        uint8_t bDeviceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific.
159
+        uint8_t bMaxPacketSize0; // Maximum packet size for endpoint 0.
160
+        uint16_t idVendor; // Vendor ID (assigned by the USB-IF).
161
+        uint16_t idProduct; // Product ID (assigned by the manufacturer).
162
+        uint16_t bcdDevice; // Device release number (BCD).
163
+        uint8_t iManufacturer; // Index of String Descriptor describing the manufacturer.
164
+        uint8_t iProduct; // Index of String Descriptor describing the product.
165
+        uint8_t iSerialNumber; // Index of String Descriptor with the device's serial number.
166
+        uint8_t bNumConfigurations; // Number of possible configurations.
167
+} __attribute__((packed)) USB_DEVICE_DESCRIPTOR;
168
+
169
+/* Configuration descriptor structure */
170
+typedef struct {
171
+        uint8_t bLength; // Length of this descriptor.
172
+        uint8_t bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION).
173
+        uint16_t wTotalLength; // Total length of all descriptors for this configuration.
174
+        uint8_t bNumInterfaces; // Number of interfaces in this configuration.
175
+        uint8_t bConfigurationValue; // Value of this configuration (1 based).
176
+        uint8_t iConfiguration; // Index of String Descriptor describing the configuration.
177
+        uint8_t bmAttributes; // Configuration characteristics.
178
+        uint8_t bMaxPower; // Maximum power consumed by this configuration.
179
+} __attribute__((packed)) USB_CONFIGURATION_DESCRIPTOR;
180
+
181
+/* Interface descriptor structure */
182
+typedef struct {
183
+        uint8_t bLength; // Length of this descriptor.
184
+        uint8_t bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE).
185
+        uint8_t bInterfaceNumber; // Number of this interface (0 based).
186
+        uint8_t bAlternateSetting; // Value of this alternate interface setting.
187
+        uint8_t bNumEndpoints; // Number of endpoints in this interface.
188
+        uint8_t bInterfaceClass; // Class code (assigned by the USB-IF).  0xFF-Vendor specific.
189
+        uint8_t bInterfaceSubClass; // Subclass code (assigned by the USB-IF).
190
+        uint8_t bInterfaceProtocol; // Protocol code (assigned by the USB-IF).  0xFF-Vendor specific.
191
+        uint8_t iInterface; // Index of String Descriptor describing the interface.
192
+} __attribute__((packed)) USB_INTERFACE_DESCRIPTOR;
193
+
194
+/* Endpoint descriptor structure */
195
+typedef struct {
196
+        uint8_t bLength; // Length of this descriptor.
197
+        uint8_t bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT).
198
+        uint8_t bEndpointAddress; // Endpoint address. Bit 7 indicates direction (0=OUT, 1=IN).
199
+        uint8_t bmAttributes; // Endpoint transfer type.
200
+        uint16_t wMaxPacketSize; // Maximum packet size.
201
+        uint8_t bInterval; // Polling interval in frames.
202
+} __attribute__((packed)) USB_ENDPOINT_DESCRIPTOR;
203
+
204
+/* HID descriptor */
205
+/*
206
+typedef struct {
207
+        uint8_t bLength;
208
+        uint8_t bDescriptorType;
209
+        uint16_t bcdHID; // HID class specification release
210
+        uint8_t bCountryCode;
211
+        uint8_t bNumDescriptors; // Number of additional class specific descriptors
212
+        uint8_t bDescrType; // Type of class descriptor
213
+        uint16_t wDescriptorLength; // Total size of the Report descriptor
214
+} __attribute__((packed)) USB_HID_DESCRIPTOR;
215
+*/
216
+
217
+typedef struct {
218
+        uint8_t bDescrType; // Type of class descriptor
219
+        uint16_t wDescriptorLength; // Total size of the Report descriptor
220
+} __attribute__((packed)) HID_CLASS_DESCRIPTOR_LEN_AND_TYPE;
221
+
222
+#endif // _ch9_h_

+ 452
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h 파일 보기

@@ -0,0 +1,452 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+
27
+#if !defined(_UHS_host_h_)
28
+#error "Never include UHS_usbhost.h directly; include UHS_host.h instead"
29
+#else
30
+#if !defined(_USBHOST_H_)
31
+#define _USBHOST_H_
32
+
33
+// Very early prototypes
34
+#if defined(UHS_LOAD_BT)
35
+void UHS_BT_SetUSBInterface(UHS_USB_HOST_BASE *host, ENUMERATION_INFO *ei);
36
+void UHS_BT_ScanUninitialized(UHS_USB_HOST_BASE *host);
37
+void UHS_BT_Poll(UHS_USB_HOST_BASE *host);
38
+#endif
39
+#if defined(UHS_LOAD_HID)
40
+void UHS_HID_SetUSBInterface(UHS_USB_HOST_BASE *host, ENUMERATION_INFO *ei);
41
+void UHS_HID_ScanUninitialized(UHS_USB_HOST_BASE *host);
42
+void UHS_HID_Poll(UHS_USB_HOST_BASE *host);
43
+#endif
44
+
45
+//#if defined(LOAD_UHS_CDC_ACM) || defined(LOAD_UHS_CDC_ACM_FTDI) || defined(LOAD_UHS_CDC_ACM_PROLIFIC) || defined(LOAD_UHS_CDC_ACM_XR21B1411)
46
+//void UHS_CDC_ACM_SetUSBInterface(UHS_USB_HOST_BASE *host, ENUMERATION_INFO *ei);
47
+//void UHS_CDC_ACM_ScanUninitialized(UHS_USB_HOST_BASE *host);
48
+//void UHS_CDC_ACM_Poll(UHS_USB_HOST_BASE *host);
49
+//#endif
50
+
51
+class UHS_USBInterface; // forward class declaration
52
+
53
+// enumerator to turn the VBUS on/off
54
+
55
+typedef enum {
56
+        vbus_on = 0,
57
+        vbus_off = 1
58
+} VBUS_t;
59
+
60
+// All host SEI use this base class
61
+
62
+class UHS_USB_HOST_BASE {
63
+public:
64
+        AddressPool addrPool;
65
+        UHS_USBInterface* devConfig[UHS_HOST_MAX_INTERFACE_DRIVERS];
66
+        volatile uint8_t usb_error;
67
+        volatile uint8_t usb_task_state;
68
+        volatile uint8_t usb_task_polling_disabled;
69
+        volatile uint8_t usb_host_speed;
70
+        volatile uint8_t hub_present;
71
+
72
+        UHS_USB_HOST_BASE(void) {
73
+                for(uint16_t i = 0; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) {
74
+                        devConfig[i] = NULL;
75
+                }
76
+                usb_task_polling_disabled = 0;
77
+                usb_task_state = UHS_USB_HOST_STATE_INITIALIZE; //set up state machine
78
+                usb_host_speed = 0;
79
+                usb_error = 0;
80
+        };
81
+
82
+        /////////////////////////////////////////////
83
+        //
84
+        // Virtual methods that interface to the SIE
85
+        // Overriding each is mandatory.
86
+        //
87
+        /////////////////////////////////////////////
88
+
89
+        /**
90
+         * Delay for x milliseconds
91
+         * Override if your controller provides an SOF IRQ, which may involve
92
+         * some sort of reentrant ISR or workaround with interrupts enabled.
93
+         *
94
+         * @param x how many milliseconds to delay
95
+         * @return true if delay completed without a state change, false if delay aborted
96
+         */
97
+        virtual bool UHS_NI sof_delay(uint16_t x) {
98
+                if(!(usb_task_state & UHS_USB_HOST_STATE_MASK)) return false;
99
+                uint8_t current_state = usb_task_state;
100
+                while(current_state == usb_task_state && x--) {
101
+                        delay(1);
102
+                }
103
+                return (current_state == usb_task_state);
104
+        };
105
+
106
+        virtual UHS_EpInfo * UHS_NI ctrlReqOpen(NOTUSED(uint8_t addr), NOTUSED(uint64_t Request), NOTUSED(uint8_t* dataptr)) {
107
+                return NULL;
108
+        };
109
+
110
+        virtual void UHS_NI vbusPower(NOTUSED(VBUS_t state)) {
111
+        };
112
+
113
+        virtual void UHS_NI Task(void) {
114
+        };
115
+
116
+        virtual uint8_t UHS_NI SetAddress(NOTUSED(uint8_t addr), NOTUSED(uint8_t ep), NOTUSED(UHS_EpInfo **ppep), NOTUSED(uint16_t &nak_limit)) {
117
+                return UHS_HOST_ERROR_NOT_IMPLEMENTED;
118
+        };
119
+
120
+        virtual uint8_t UHS_NI OutTransfer(NOTUSED(UHS_EpInfo *pep), NOTUSED(uint16_t nak_limit), NOTUSED(uint16_t nbytes), NOTUSED(uint8_t *data)) {
121
+                return UHS_HOST_ERROR_NOT_IMPLEMENTED;
122
+        };
123
+
124
+        virtual uint8_t UHS_NI InTransfer(NOTUSED(UHS_EpInfo *pep), NOTUSED(uint16_t nak_limit), NOTUSED(uint16_t *nbytesptr), NOTUSED(uint8_t *data)) {
125
+                return UHS_HOST_ERROR_NOT_IMPLEMENTED;
126
+        };
127
+
128
+        virtual uint8_t UHS_NI ctrlReqClose(NOTUSED(UHS_EpInfo *pep), NOTUSED(uint8_t bmReqType), NOTUSED(uint16_t left), NOTUSED(uint16_t nbytes), NOTUSED(uint8_t *dataptr)) {
129
+                return UHS_HOST_ERROR_NOT_IMPLEMENTED;
130
+        };
131
+
132
+        virtual uint8_t UHS_NI ctrlReqRead(NOTUSED(UHS_EpInfo *pep), NOTUSED(uint16_t *left), NOTUSED(uint16_t *read), NOTUSED(uint16_t nbytes), NOTUSED(uint8_t *dataptr)) {
133
+                return UHS_HOST_ERROR_NOT_IMPLEMENTED;
134
+        };
135
+
136
+        virtual uint8_t UHS_NI dispatchPkt(NOTUSED(uint8_t token), NOTUSED(uint8_t ep), NOTUSED(uint16_t nak_limit)) {
137
+                return UHS_HOST_ERROR_NOT_IMPLEMENTED;
138
+        };
139
+
140
+        virtual uint8_t UHS_NI init(void) {
141
+                return 0;
142
+        };
143
+
144
+        virtual void UHS_NI doHostReset(void) {
145
+        };
146
+
147
+        virtual int16_t UHS_NI Init(NOTUSED(int16_t mseconds)) {
148
+                return -1;
149
+        };
150
+
151
+        virtual int16_t UHS_NI Init(void) {
152
+                return Init(INT16_MIN);
153
+        };
154
+
155
+        virtual uint8_t hwlPowerUp(void) {
156
+                /* This is for machine specific support to enable/power up the USB HW to operate*/
157
+                return UHS_HOST_ERROR_NOT_IMPLEMENTED;
158
+        };
159
+
160
+        virtual uint8_t hwPowerDown(void) {
161
+                /* This is for machine specific support to disable/powerdown the USB Hw */
162
+                return UHS_HOST_ERROR_NOT_IMPLEMENTED;
163
+        };
164
+
165
+        virtual bool IsHub(uint8_t klass) {
166
+                return (klass == UHS_USB_CLASS_HUB);
167
+        };
168
+
169
+        virtual void UHS_NI suspend_host(void) {
170
+                // Used on MCU that lack control of IRQ priority (AVR).
171
+                // Suspends ISRs, for critical code. IRQ will be serviced after it is resumed.
172
+                // NOTE: you must track the state yourself!
173
+        };
174
+
175
+        virtual void UHS_NI resume_host(void) {
176
+                // Used on MCU that lack control of IRQ priority (AVR).
177
+                // Resumes ISRs.
178
+                // NOTE: you must track the state yourself!
179
+        };
180
+
181
+        /////////////////////////////////////////////
182
+        //
183
+        // Built-ins, No need to override
184
+        //
185
+        /////////////////////////////////////////////
186
+        // these two probably will go away, and won't be used, TBD
187
+        inline void Poll_Others(void) {
188
+#if defined(UHS_LOAD_BT)
189
+                UHS_BT_Poll(this);
190
+#endif
191
+#if defined(UHS_LOAD_HID)
192
+                UHS_HID_Poll(this);
193
+#endif
194
+        }
195
+
196
+        inline void DisablePoll(void) {
197
+                noInterrupts();
198
+                usb_task_polling_disabled++;
199
+                DDSB();
200
+                interrupts();
201
+        }
202
+
203
+        inline void EnablePoll(void) {
204
+                noInterrupts();
205
+                usb_task_polling_disabled--;
206
+                DDSB();
207
+                interrupts();
208
+        }
209
+
210
+        uint8_t UHS_NI seekInterface(ENUMERATION_INFO *ei, uint16_t inf, USB_CONFIGURATION_DESCRIPTOR *ucd);
211
+
212
+        uint8_t UHS_NI setEpInfoEntry(uint8_t addr, uint8_t iface, uint8_t epcount, volatile UHS_EpInfo* eprecord_ptr);
213
+
214
+        uint8_t UHS_NI EPClearHalt(uint8_t addr, uint8_t ep);
215
+
216
+        uint8_t UHS_NI ctrlReq(uint8_t addr, uint64_t Request, uint16_t nbytes, uint8_t* dataptr);
217
+
218
+        uint8_t UHS_NI getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t* dataptr);
219
+
220
+        uint8_t UHS_NI getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t conf, uint8_t* dataptr);
221
+
222
+        uint8_t UHS_NI setAddr(uint8_t oldaddr, uint8_t newaddr);
223
+
224
+        uint8_t UHS_NI setConf(uint8_t addr, uint8_t conf_value);
225
+
226
+        uint8_t UHS_NI getStrDescr(uint8_t addr, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t* dataptr);
227
+
228
+        void UHS_NI ReleaseDevice(uint8_t addr);
229
+
230
+        uint8_t UHS_NI Configuring(uint8_t parent, uint8_t port, uint8_t speed);
231
+
232
+        void UHS_NI DeviceDefaults(uint8_t maxep, UHS_USBInterface *device);
233
+
234
+        UHS_EpInfo* UHS_NI getEpInfoEntry(uint8_t addr, uint8_t ep);
235
+
236
+        inline uint8_t getUsbTaskState(void) {
237
+                return ( usb_task_state);
238
+        };
239
+
240
+        inline AddressPool* GetAddressPool(void) {
241
+                return &addrPool;
242
+        };
243
+
244
+        int UHS_NI RegisterDeviceClass(UHS_USBInterface *pdev) {
245
+                for(uint8_t i = 0; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++) {
246
+                        if(!devConfig[i]) {
247
+                                devConfig[i] = pdev;
248
+                                return i;
249
+                        }
250
+                }
251
+                //return UHS_HOST_ERROR_CANT_REGISTER_DEVICE_CLASS;
252
+                return -1;
253
+        };
254
+#if 0
255
+
256
+        inline void ForEachUsbDevice(UsbDeviceHandleFunc pfunc) {
257
+                addrPool.ForEachUsbDevice(pfunc);
258
+        };
259
+#endif
260
+
261
+        uint8_t TestInterface(ENUMERATION_INFO *ei);
262
+        uint8_t enumerateInterface(ENUMERATION_INFO *ei);
263
+        uint8_t getNextInterface(ENUMERATION_INFO *ei, UHS_EpInfo *pep, uint8_t data[], uint16_t *left, uint16_t *read, uint8_t *offset);
264
+        uint8_t initDescrStream(ENUMERATION_INFO *ei, USB_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset);
265
+        uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data);
266
+        uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data);
267
+        uint8_t doSoftReset(uint8_t parent, uint8_t port, uint8_t address);
268
+        uint8_t getone(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint8_t *dataptr, uint8_t *offset);
269
+        uint8_t eat(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint8_t *dataptr, uint8_t *offset, uint16_t *yum);
270
+
271
+};
272
+
273
+// All device interface drivers use this subclass
274
+
275
+class UHS_USBInterface {
276
+public:
277
+
278
+        UHS_USB_HOST_BASE *pUsb; // Parent USB host
279
+        volatile uint8_t bNumEP; // total number of EP in this interface
280
+        volatile UHS_EpInfo epInfo[16]; // This is a stub, override in the driver.
281
+
282
+        volatile uint8_t bAddress; // address of the device
283
+        volatile uint8_t bConfNum; // configuration number
284
+        volatile uint8_t bIface; // interface value
285
+        volatile bool bPollEnable; // poll enable flag, operating status
286
+        volatile uint32_t qNextPollTime; // next poll time
287
+
288
+        /**
289
+         * Resets interface driver to unused state. You should override this in
290
+         * your driver if it requires extra class variable cleanup.
291
+         */
292
+        virtual void DriverDefaults(void) {
293
+                printf("Default driver defaults.\r\n");
294
+                pUsb->DeviceDefaults(bNumEP, this);
295
+        };
296
+
297
+        /**
298
+         * Checks if this interface is supported.
299
+         * Executed called when new devices are connected.
300
+         *
301
+         * @param ei
302
+         * @return true if the interface is supported
303
+         */
304
+        virtual bool OKtoEnumerate(NOTUSED(ENUMERATION_INFO *ei)) {
305
+                return false;
306
+        };
307
+
308
+        /**
309
+         * Configures any needed endpoint information for an interface.
310
+         * You must provide this in your driver.
311
+         * Executed when new devices are connected and OKtoEnumerate()
312
+         * returned true.
313
+         *
314
+         * @param ei
315
+         * @return zero on success
316
+         */
317
+        virtual uint8_t SetInterface(NOTUSED(ENUMERATION_INFO *ei)) {
318
+                return UHS_HOST_ERROR_NOT_IMPLEMENTED;
319
+        };
320
+
321
+        /**
322
+         * Interface specific additional setup and enumeration that
323
+         * can't occur when the descriptor stream is open.
324
+         * Also used for collection of unclaimed interfaces, to link to the master.
325
+         *
326
+         * @return zero on success
327
+         */
328
+        virtual uint8_t Finalize(void) {
329
+                return 0;
330
+        };
331
+
332
+        /**
333
+         *  Executed after interface is finalized but, before polling has started.
334
+         *
335
+         * @return 0 on success
336
+         */
337
+        virtual uint8_t OnStart(void) {
338
+                return 0;
339
+        };
340
+
341
+        /**
342
+         * Start interface polling
343
+         * @return
344
+         */
345
+        virtual uint8_t Start(void) {
346
+                uint8_t rcode = OnStart();
347
+                if(!rcode) bPollEnable = true;
348
+                return rcode;
349
+        };
350
+
351
+        /**
352
+         * Executed before anything else in Release().
353
+         *
354
+         */
355
+        virtual void OnRelease(void) {
356
+                return;
357
+        };
358
+
359
+        /**
360
+         * Release resources when device is disconnected.
361
+         * Normally this does not need to be overridden.
362
+         */
363
+        virtual void Release(void) {
364
+                OnRelease();
365
+                DriverDefaults();
366
+                return;
367
+        };
368
+
369
+        /**
370
+         * Executed After driver polls.
371
+         * Can be used when there is an important change detected during polling
372
+         * and you want to handle it elsewhere.
373
+         * Examples:
374
+         * Media status change for bulk, e.g. ready, not-ready, media changed, door opened.
375
+         * Button state/joystick position/etc changes on a HID device.
376
+         * Flow control status change on a communication device, e.g. CTS on serial
377
+         */
378
+        virtual void OnPoll(void) {
379
+                return;
380
+        };
381
+
382
+        /**
383
+         * Poll interface driver. You should override this in your driver if you
384
+         * require polling faster or slower than every 100 milliseconds, or your
385
+         * driver requires special housekeeping.
386
+         */
387
+        virtual void Poll() {
388
+                OnPoll();
389
+                qNextPollTime = millis() + 100;
390
+        };
391
+
392
+        virtual bool UHS_NI Polling(void) {
393
+                return bPollEnable;
394
+        }
395
+
396
+        /**
397
+         * This is only for a hub.
398
+         * @param port
399
+         */
400
+        virtual void ResetHubPort(NOTUSED(uint8_t port)) {
401
+                return;
402
+        };
403
+
404
+#if 0
405
+        /**
406
+         *
407
+         * @return true if this interface is Vendor Specific.
408
+         */
409
+        virtual bool IsVSI() {
410
+                return false;
411
+        }
412
+#endif
413
+};
414
+
415
+#if 0
416
+/**
417
+ *
418
+ * Vendor Specific interface class.
419
+ * This is used by a partner interface.
420
+ * It can also be used to force-enumerate an interface that
421
+ * can use this interface directly.
422
+ * You can also add an instance of this class within the interface constructor
423
+ * if you expect the interface.
424
+ *
425
+ * If this is not needed, it may be removed. Nothing I have written needs this.
426
+ * Let me know if it is not required, then IsVSI method can also be shit-canned.
427
+ * -- AJK
428
+ */
429
+
430
+class UHS_VSI : public UHS_USBInterface {
431
+public:
432
+        volatile UHS_EpInfo epInfo[1];
433
+        volatile ENUMERATION_INFO eInfo;
434
+        UHS_VSI(UHS_USB_HOST_BASE *p);
435
+        bool OKtoEnumerate(ENUMERATION_INFO *ei);
436
+        uint8_t SetInterface(ENUMERATION_INFO *ei);
437
+        virtual void DriverDefaults(void);
438
+        virtual void Release(void);
439
+
440
+        uint8_t GetAddress(void) {
441
+                return bAddress;
442
+        };
443
+
444
+        virtual bool IsVSI() {
445
+                return true;
446
+        }
447
+
448
+};
449
+#endif
450
+
451
+#endif //_USBHOST_H_
452
+#endif

+ 129
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_util_INLINE.h 파일 보기

@@ -0,0 +1,129 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This program is free software; you can redistribute it and/or modify
6
+it under the terms of the GNU General Public License as published by
7
+the Free Software Foundation; either version 2 of the License, or
8
+(at your option) any later version.
9
+
10
+This program is distributed in the hope that it will be useful,
11
+but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+GNU General Public License for more details.
14
+
15
+You should have received a copy of the GNU General Public License
16
+along with this program; if not, write to the Free Software
17
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+
19
+Contact information
20
+-------------------
21
+
22
+Circuits At Home, LTD
23
+Web      :  http://www.circuitsathome.com
24
+e-mail   :  support@circuitsathome.com
25
+ */
26
+
27
+#if defined(LOAD_USB_HOST_SYSTEM) && !defined(USB_HOST_SYSTEM_UTIL_LOADED)
28
+#define USB_HOST_SYSTEM_UTIL_LOADED
29
+
30
+// 0x80 is the default (i.e. trace) to turn off set this global to something lower.
31
+// this allows for 126 other debugging levels.
32
+// TO-DO: Allow assignment to a different serial port by software
33
+int UsbDEBUGlvl = 0x80;
34
+
35
+void E_Notifyc(char c, int lvl) {
36
+        if(UsbDEBUGlvl < lvl) return;
37
+#if defined(ARDUINO) && ARDUINO >=100
38
+        USB_HOST_SERIAL.print(c);
39
+#else
40
+        USB_HOST_SERIAL.print(c, BYTE);
41
+#endif
42
+        //USB_HOST_SERIAL.flush();
43
+}
44
+
45
+void E_Notify(char const * msg, int lvl) {
46
+        if(UsbDEBUGlvl < lvl) return;
47
+        if(!msg) return;
48
+        char c;
49
+
50
+        while((c = pgm_read_byte(msg++))) E_Notifyc(c, lvl);
51
+}
52
+
53
+void E_NotifyStr(char const * msg, int lvl) {
54
+        if(UsbDEBUGlvl < lvl) return;
55
+        if(!msg) return;
56
+        char c;
57
+
58
+        while((c = *msg++)) E_Notifyc(c, lvl);
59
+}
60
+
61
+void E_Notify(uint8_t b, int lvl) {
62
+        if(UsbDEBUGlvl < lvl) return;
63
+#if defined(ARDUINO) && ARDUINO >=100
64
+        USB_HOST_SERIAL.print(b);
65
+#else
66
+        USB_HOST_SERIAL.print(b, DEC);
67
+#endif
68
+}
69
+
70
+void E_Notify(double d, int lvl) {
71
+        if(UsbDEBUGlvl < lvl) return;
72
+        USB_HOST_SERIAL.print(d);
73
+}
74
+
75
+#ifdef DEBUG_USB_HOST
76
+
77
+void NotifyFailGetDevDescr(void) {
78
+        Notify(PSTR("\r\ngetDevDescr "), 0x80);
79
+}
80
+
81
+void NotifyFailSetDevTblEntry(void) {
82
+        Notify(PSTR("\r\nsetDevTblEn "), 0x80);
83
+}
84
+
85
+void NotifyFailGetConfDescr(void) {
86
+        Notify(PSTR("\r\ngetConf "), 0x80);
87
+}
88
+
89
+void NotifyFailSetConfDescr(void) {
90
+        Notify(PSTR("\r\nsetConf "), 0x80);
91
+}
92
+
93
+void NotifyFailGetDevDescr(uint8_t reason) {
94
+        NotifyFailGetDevDescr();
95
+        NotifyFail(reason);
96
+}
97
+
98
+void NotifyFailSetDevTblEntry(uint8_t reason) {
99
+        NotifyFailSetDevTblEntry();
100
+        NotifyFail(reason);
101
+
102
+}
103
+
104
+void NotifyFailGetConfDescr(uint8_t reason) {
105
+        NotifyFailGetConfDescr();
106
+        NotifyFail(reason);
107
+}
108
+
109
+void NotifyFailSetConfDescr(uint8_t reason) {
110
+        NotifyFailSetConfDescr();
111
+        NotifyFail(reason);
112
+}
113
+
114
+void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) {
115
+        Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
116
+        D_PrintHex<uint16_t > (VID, 0x80);
117
+        Notify(PSTR(" PID: "), 0x80);
118
+        D_PrintHex<uint16_t > (PID, 0x80);
119
+}
120
+
121
+void NotifyFail(uint8_t rcode) {
122
+        D_PrintHex<uint8_t > (rcode, 0x80);
123
+        Notify(PSTR("\r\n"), 0x80);
124
+}
125
+#endif
126
+
127
+#else
128
+#error "Never include UHS_util_INLINE.h, include UHS_host.h instead"
129
+#endif

+ 226
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/UHS_max3421e.h 파일 보기

@@ -0,0 +1,226 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This software may be distributed and modified under the terms of the GNU
6
+General Public License version 2 (GPL2) as published by the Free Software
7
+Foundation and appearing in the file GPL2.TXT included in the packaging of
8
+this file. Please note that GPL2 Section 2[b] requires that all works based
9
+on this software must also be made publicly available under the terms of
10
+the GPL2 ("Copyleft").
11
+
12
+Contact information
13
+-------------------
14
+
15
+Circuits At Home, LTD
16
+Web      :  http://www.circuitsathome.com
17
+e-mail   :  support@circuitsathome.com
18
+ */
19
+#if !defined(USB_HOST_SHIELD_H) || defined(_max3421e_h_)
20
+#error "Never include UHS_max3421e.h directly; include USB_HOST_SHIELD.h instead"
21
+#else
22
+
23
+#define _max3421e_h_
24
+
25
+/* MAX3421E register/bit names and bitmasks */
26
+
27
+#define SE0     0
28
+#define SE1     1
29
+#define FSHOST  2
30
+#define LSHOST  3
31
+
32
+/* MAX3421E command byte format: rrrrr0wa where 'r' is register number  */
33
+
34
+//
35
+// MAX3421E Registers in HOST mode.
36
+//
37
+#define        rRCVFIFO 0x08            // Receive FIFO Register
38
+#define        rSNDFIFO 0x10            // Send FIFO Register
39
+#define        rSUDFIFO 0x20            // Set Up Data FIFO Register
40
+#define          rRCVBC 0x30            // Receive FIFO Byte Count Register
41
+#define          rSNDBC 0x38            // Send FIFO Byte Count Register
42
+
43
+// USB Interrupt Request Status (USBIRQ)
44
+#define         rUSBIRQ 0x68            // USB Interrupt Request Register
45
+#define       bmVBUSIRQ 0x40            // Vbus Present Interrupt Request
46
+#define     bmNOVBUSIRQ 0x20            // Vbus Absent Interrupt Request
47
+#define      bmOSCOKIRQ 0x01            // Oscillator OK Interrupt Request
48
+
49
+// USB Interrupt Request Control (USBIEN)
50
+#define         rUSBIEN 0x70            // USB Interrupt Request Enable Register
51
+#define        bmVBUSIE bmVBUSIRQ       // Vbus Present Interrupt Request Enable
52
+#define      bmNOVBUSIE bmNOVBUSIRQ     // Vbus Absent Interrupt Request Enable
53
+#define       bmOSCOKIE bmOSCOKIRQ      // Oscillator OK Interrupt Request Enable
54
+
55
+// (USBCTL)
56
+#define         rUSBCTL 0x78            //15<<3
57
+#define       bmCHIPRES 0x20            //b5
58
+#define       bmPWRDOWN 0x10            //b4
59
+
60
+// (CPUCTL)
61
+#define         rCPUCTL 0x80            //16<<3
62
+#define     bmPUSLEWID1 0x80            //b7
63
+#define     bmPULSEWID0 0x40            //b6
64
+#define            bmIE 0x01            //b0
65
+
66
+// bmPUSLEWID1 bmPULSEWID0 Pulse width
67
+// 0           0           10.6uS
68
+// 0           1            5.3uS
69
+// 1           0            2.6uS
70
+// 1           1            1.3uS
71
+#define  PUSLEWIDTH10_6 (0)
72
+#define   PUSLEWIDTH5_3 (bmPULSEWID0)
73
+#define   PUSLEWIDTH2_6 (bmPUSLEWID1)
74
+#define   PUSLEWIDTH1_3 (bmPULSEWID0 | bmPUSLEWID1)
75
+
76
+// (PINCTL)
77
+#define         rPINCTL 0x88            //17<<3
78
+#define       bmFDUPSPI 0x10            //b4
79
+#define      bmINTLEVEL 0x08            //b3
80
+#define        bmPOSINT 0x04            //b2
81
+#define          bmGPXB 0x02            //b1
82
+#define          bmGPXA 0x01            //b0
83
+
84
+// GPX pin selections
85
+#define     GPX_OPERATE 0x00            //
86
+#define       GPX_VBDET 0x01            //
87
+#define      GPX_BUSACT 0x02            //
88
+#define         GPX_SOF 0x03            //
89
+
90
+#define       rREVISION 0x90            //18<<3
91
+
92
+// (IOPINS1)
93
+#define        rIOPINS1 0xa0            //20<<3
94
+#define        bmGPOUT0 0x01            //
95
+#define        bmGPOUT1 0x02            //
96
+#define        bmGPOUT2 0x04            //
97
+#define        bmGPOUT3 0x08            //
98
+#define         bmGPIN0 0x10            //
99
+#define         bmGPIN1 0x20            //
100
+#define         bmGPIN2 0x40            //
101
+#define         bmGPIN3 0x80            //
102
+
103
+// (IOPINS2)
104
+#define        rIOPINS2 0xa8            //21<<3
105
+#define        bmGPOUT4 0x01            //
106
+#define        bmGPOUT5 0x02            //
107
+#define        bmGPOUT6 0x04            //
108
+#define        bmGPOUT7 0x08            //
109
+#define         bmGPIN4 0x10            //
110
+#define         bmGPIN5 0x20            //
111
+#define         bmGPIN6 0x40            //
112
+#define         bmGPIN7 0x80            //
113
+
114
+// (GPINIRQ)
115
+#define        rGPINIRQ 0xb0            //22<<3
116
+#define      bmGPINIRQ0 0x01            //
117
+#define      bmGPINIRQ1 0x02            //
118
+#define      bmGPINIRQ2 0x04            //
119
+#define      bmGPINIRQ3 0x08            //
120
+#define      bmGPINIRQ4 0x10            //
121
+#define      bmGPINIRQ5 0x20            //
122
+#define      bmGPINIRQ6 0x40            //
123
+#define      bmGPINIRQ7 0x80            //
124
+
125
+// (GPINIEN)
126
+#define        rGPINIEN 0xb8            //23<<3
127
+#define      bmGPINIEN0 0x01            //
128
+#define      bmGPINIEN1 0x02            //
129
+#define      bmGPINIEN2 0x04            //
130
+#define      bmGPINIEN3 0x08            //
131
+#define      bmGPINIEN4 0x10            //
132
+#define      bmGPINIEN5 0x20            //
133
+#define      bmGPINIEN6 0x40            //
134
+#define      bmGPINIEN7 0x80            //
135
+
136
+// (GPINPOL)
137
+#define        rGPINPOL 0xc0            //24<<3
138
+#define      bmGPINPOL0 0x01            //
139
+#define      bmGPINPOL1 0x02            //
140
+#define      bmGPINPOL2 0x04            //
141
+#define      bmGPINPOL3 0x08            //
142
+#define      bmGPINPOL4 0x10            //
143
+#define      bmGPINPOL5 0x20            //
144
+#define      bmGPINPOL6 0x40            //
145
+#define      bmGPINPOL7 0x80            //
146
+
147
+//
148
+// If any data transfer errors occur, the HXFRDNIRQ asserts, while the RCVDAVIRQ does not.
149
+//
150
+// The CPU clears the SNDBAVIRQ by writing the SNDBC register.
151
+// The CPU should never directly clear the SNDBAVIRQ bit.
152
+
153
+// Host Interrupt Request Status (HIRQ)
154
+#define           rHIRQ 0xc8            // Host Interrupt Request Register
155
+#define   bmBUSEVENTIRQ 0x01            // BUS Reset Done or BUS Resume Interrupt Request
156
+#define        bmRWUIRQ 0x02            // Remote Wakeup Interrupt Request
157
+#define     bmRCVDAVIRQ 0x04            // Receive FIFO Data Available Interrupt Request
158
+#define     bmSNDBAVIRQ 0x08            // Send Buffer Available Interrupt Request
159
+#define      bmSUSDNIRQ 0x10            // Suspend operation Done Interrupt Request
160
+#define     bmCONDETIRQ 0x20            // Peripheral Connect/Disconnect Interrupt Request
161
+#define      bmFRAMEIRQ 0x40            // Frame Generator Interrupt Request
162
+#define     bmHXFRDNIRQ 0x80            // Host Transfer Done Interrupt Request
163
+
164
+// IRQs that are OK for the CPU to clear
165
+#define     ICLRALLBITS (bmBUSEVENTIRQ | bmRWUIRQ | bmRCVDAVIRQ | bmSUSDNIRQ | bmCONDETIRQ | bmFRAMEIRQ | bmHXFRDNIRQ)
166
+
167
+// Host Interrupt Request Control (HIEN)
168
+#define           rHIEN 0xd0            //
169
+#define    bmBUSEVENTIE bmBUSEVENTIRQ   // BUS Reset Done or BUS Resume Interrupt Request Enable
170
+#define         bmRWUIE bmRWUIRQ        // Remote Wakeup Interrupt Request Enable
171
+#define      bmRCVDAVIE bmRCVDAVIRQ     // Receive FIFO Data Available Interrupt Request Enable
172
+#define      bmSNDBAVIE bmSNDBAVIRQ     // Send Buffer Available Interrupt Request Enable
173
+#define       bmSUSDNIE bmSUSDNIRQ      // Suspend operation Done Interrupt Request Enable
174
+#define      bmCONDETIE bmCONDETIRQ     // Peripheral Connect/Disconnect Interrupt Request Enable
175
+#define       bmFRAMEIE bmFRAMEIRQ      // Frame Generator Interrupt Request Enable
176
+#define      bmHXFRDNIE bmHXFRDNIRQ     // Host Transfer Done Interrupt Request Enable
177
+
178
+// (MODE))
179
+#define           rMODE 0xd8            //27<<3
180
+#define          bmHOST 0x01            //
181
+#define      bmLOWSPEED 0x02            //
182
+#define        bmHUBPRE 0x04            //
183
+#define     bmSOFKAENAB 0x08            //
184
+#define        bmSEPIRQ 0x10            //
185
+#define      bmDELAYISO 0x20            //
186
+#define      bmDMPULLDN 0x40            //
187
+#define      bmDPPULLDN 0x80            //
188
+
189
+#define        rPERADDR 0xe0            //28<<3
190
+
191
+// (HCTL)
192
+#define           rHCTL 0xe8            //29<<3
193
+#define        bmBUSRST 0x01            //
194
+#define        bmFRMRST 0x02            //
195
+#define     bmSAMPLEBUS 0x04            //
196
+#define        bmSIGRSM 0x08            //
197
+#define       bmRCVTOG0 0x10            //
198
+#define       bmRCVTOG1 0x20            //
199
+#define       bmSNDTOG0 0x40            //
200
+#define       bmSNDTOG1 0x80            //
201
+
202
+// Host transfer (HXFR)
203
+#define           rHXFR 0xf0            //30<<3
204
+/* Host transfer token values for writing the HXFR register (R30)   */
205
+/* OR this bit field with the endpoint number in bits 3:0               */
206
+#define       MAX3421E_tokSETUP 0x10    // HS=0, ISO=0, OUTNIN=0, SETUP=1
207
+#define          MAX3421E_tokIN 0x00    // HS=0, ISO=0, OUTNIN=0, SETUP=0
208
+#define         MAX3421E_tokOUT 0x20    // HS=0, ISO=0, OUTNIN=1, SETUP=0
209
+#define        MAX3421E_tokINHS 0x80    // HS=1, ISO=0, OUTNIN=0, SETUP=0
210
+#define       MAX3421E_tokOUTHS 0xA0    // HS=1, ISO=0, OUTNIN=1, SETUP=0
211
+#define       MAX3421E_tokISOIN 0x40    // HS=0, ISO=1, OUTNIN=0, SETUP=0
212
+#define      MAX3421E_tokISOOUT 0x60    // HS=0, ISO=1, OUTNIN=1, SETUP=0
213
+
214
+// (HRSL)
215
+#define           rHRSL 0xf8            //31<<3
216
+#define      bmRCVTOGRD 0x10            //
217
+#define      bmSNDTOGRD 0x20            //
218
+#define       bmKSTATUS 0x40            //
219
+#define       bmJSTATUS 0x80            //
220
+#define           bmSE0 0x00            //SE0 - disconnect state
221
+#define           bmSE1 0xc0            //SE1 - illegal state
222
+
223
+#define    MODE_FS_HOST (bmDPPULLDN|bmDMPULLDN|bmHOST|bmSOFKAENAB)
224
+#define    MODE_LS_HOST (bmDPPULLDN|bmDMPULLDN|bmHOST|bmLOWSPEED|bmSOFKAENAB)
225
+
226
+#endif //_max3421e_h_

+ 519
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD.h 파일 보기

@@ -0,0 +1,519 @@
1
+/* Copyright (C) 2015-2016 Andrew J. Kroll
2
+   and
3
+Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
4
+
5
+This software may be distributed and modified under the terms of the GNU
6
+General Public License version 2 (GPL2) as published by the Free Software
7
+Foundation and appearing in the file GPL2.TXT included in the packaging of
8
+this file. Please note that GPL2 Section 2[b] requires that all works based
9
+on this software must also be made publicly available under the terms of
10
+the GPL2 ("Copyleft").
11
+
12
+Contact information
13
+-------------------
14
+
15
+Circuits At Home, LTD
16
+Web      :  http://www.circuitsathome.com
17
+e-mail   :  support@circuitsathome.com
18
+ */
19
+
20
+#ifndef USB_HOST_SHIELD_H
21
+#define USB_HOST_SHIELD_H
22
+
23
+// uncomment to get 'printf' console debugging. NOT FOR UNO!
24
+//#define DEBUG_PRINTF_EXTRA_HUGE_USB_HOST_SHIELD
25
+
26
+#ifdef LOAD_USB_HOST_SHIELD
27
+#include "UHS_max3421e.h"
28
+#include <SPI.h>
29
+
30
+
31
+#if !defined(SPI_HAS_TRANSACTION)
32
+#error "Your SPI library installation is too old."
33
+#else
34
+#if !defined(SPI_ATOMIC_VERSION)
35
+#warning "Your SPI library installation lacks 'SPI_ATOMIC_VERSION'. Please complain to the maintainer."
36
+#elif SPI_ATOMIC_VERSION < 1
37
+#error "Your SPI library installation is too old."
38
+#endif
39
+
40
+#endif
41
+#if DEBUG_PRINTF_EXTRA_HUGE
42
+#ifdef DEBUG_PRINTF_EXTRA_HUGE_USB_HOST_SHIELD
43
+#define MAX_HOST_DEBUG(...) printf_P(__VA_ARGS__)
44
+#else
45
+#define MAX_HOST_DEBUG(...) VOID0
46
+#endif
47
+#else
48
+#define MAX_HOST_DEBUG(...) VOID0
49
+#endif
50
+
51
+#if !defined(USB_HOST_SHIELD_USE_ISR)
52
+#if defined(USE_MULTIPLE_APP_API)
53
+#define USB_HOST_SHIELD_USE_ISR 0
54
+#else
55
+#define USB_HOST_SHIELD_USE_ISR 1
56
+#endif
57
+#else
58
+#define USB_HOST_SHIELD_USE_ISR 1
59
+#endif
60
+
61
+
62
+
63
+#if !USB_HOST_SHIELD_USE_ISR
64
+#error NOISR Polled mode _NOT SUPPORTED YET_
65
+
66
+//
67
+// Polled defaults
68
+//
69
+#if defined(BOARD_BLACK_WIDDOW)
70
+#define UHS_MAX3421E_SS_ 6
71
+#define UHS_MAX3421E_INT_ 3
72
+#elif defined(CORE_TEENSY) && (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__))
73
+#if EXT_RAM
74
+// Teensy++ 2.0 with XMEM2
75
+#define UHS_MAX3421E_SS_ 20
76
+#define UHS_MAX3421E_INT_ 7
77
+#else
78
+#define UHS_MAX3421E_SS_ 9
79
+#define UHS_MAX3421E_INT_ 8
80
+#endif
81
+#define UHS_MAX3421E_SPD
82
+#elif defined(ARDUINO_AVR_ADK)
83
+#define UHS_MAX3421E_SS_ 53
84
+#define UHS_MAX3421E_INT_ 54
85
+#elif defined(ARDUINO_AVR_BALANDUINO)
86
+#define UHS_MAX3421E_SS_ 20
87
+#define UHS_MAX3421E_INT_ 19
88
+#else
89
+#define UHS_MAX3421E_SS_ 10
90
+#define UHS_MAX3421E_INT_ 9
91
+#endif
92
+
93
+#else
94
+#if defined(ARDUINO_ARCH_PIC32)
95
+// PIC32 only allows edge interrupts, isn't that lovely? We'll emulate it...
96
+#if CHANGE < 2
97
+#error core too old.
98
+#endif
99
+
100
+#define IRQ_IS_EDGE 0
101
+#ifndef digitalPinToInterrupt
102
+// great, this isn't implemented.
103
+#warning digitalPinToInterrupt is not defined, complain here https://github.com/chipKIT32/chipKIT-core/issues/114
104
+#if defined(_BOARD_UNO_) || defined(_BOARD_UC32_)
105
+#define digitalPinToInterrupt(p) ((p) == 2 ? 1 : ((p) == 7 ? 2 : ((p) == 8 ? 3 : ((p) == 35 ? 4 : ((p) == 38 ? 0 : NOT_AN_INTERRUPT)))))
106
+#warning digitalPinToInterrupt is now defined until this is taken care of.
107
+#else
108
+#error digitalPinToInterrupt not defined for your board, complain here https://github.com/chipKIT32/chipKIT-core/issues/114
109
+#endif
110
+#endif
111
+#else
112
+#define IRQ_IS_EDGE 0
113
+#endif
114
+
115
+// More stupidity from our friends @ Sony...
116
+#if defined(ARDUINO_spresense_ast)
117
+#if !defined(NOT_AN_INTERRUPT)
118
+#define NOT_AN_INTERRUPT -1
119
+#endif
120
+#endif
121
+
122
+// SAMD uses an enum for this instead of a define. Isn't that just dandy?
123
+#if !defined(NOT_AN_INTERRUPT) && !defined(ARDUINO_ARCH_SAMD)
124
+#warning NOT_AN_INTERRUPT not defined, possible problems ahead.
125
+#warning If NOT_AN_INTERRUPT is an enum or something else, complain to UHS30 developers on github.
126
+#warning Otherwise complain to your board core developer/maintainer.
127
+#define NOT_AN_INTERRUPT -1
128
+#endif
129
+
130
+//
131
+// Interrupt defaults. Int0 or Int1
132
+//
133
+#ifdef BOARD_BLACK_WIDDOW
134
+#error "HELP! Please send us an email, I don't know the values for Int0 and Int1 on the Black Widow board!"
135
+#elif defined(ARDUINO_AVR_ADK)
136
+#define UHS_MAX3421E_SS_ 53
137
+#define UHS_MAX3421E_INT_ 54
138
+#elif defined(ARDUINO_spresense_ast)
139
+#define UHS_MAX3421E_SS_ 21
140
+#define UHS_MAX3421E_INT_ 20
141
+#define SPIclass SPI5
142
+//#define UHS_MAX3421E_SPD 100000
143
+#elif defined(CORE_TEENSY) && (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__))
144
+
145
+// TO-DO!
146
+
147
+#if EXT_RAM
148
+// Teensy++ 2.0 with XMEM2
149
+#define UHS_MAX3421E_SS_ 20
150
+#define UHS_MAX3421E_INT_ 7
151
+#else
152
+#define UHS_MAX3421E_SS_ 9
153
+#define UHS_MAX3421E_INT_ 8
154
+#endif
155
+
156
+#elif defined(ARDUINO_AVR_BALANDUINO)
157
+#error "ISR mode is currently not supported on the Balanduino. Please set USB_HOST_SHIELD_USE_ISR to 0."
158
+#else
159
+#define UHS_MAX3421E_SS_ 10
160
+#ifdef __AVR__
161
+#if defined(__AVR_ATmega32U4__)
162
+#define INT_FOR_PIN2 1
163
+#define INT_FOR_PIN3 0
164
+#else
165
+// Everybody else???
166
+#define INT_FOR_PIN2 0
167
+#define INT_FOR_PIN3 1
168
+#endif
169
+#define UHS_MAX3421E_INT_ 3
170
+#else
171
+// Non-avr
172
+#if defined(ARDUINO_ARCH_PIC32)
173
+// UNO32 External Interrupts:
174
+// Pin 38 (INT0), Pin 2 (INT1), Pin 7 (INT2), Pin 8 (INT3), Pin 35 (INT4)
175
+#define UHS_MAX3421E_INT_ 7
176
+#else
177
+#define UHS_MAX3421E_INT_ 9
178
+#endif
179
+#endif
180
+#endif
181
+#endif
182
+
183
+
184
+
185
+#if defined(NO_AUTO_SPEED)
186
+// Ugly details section...
187
+// MAX3421E characteristics
188
+// SPI Serial - Clock Input. An external SPI master supplies SCLK with frequencies up to 26MHz. The
189
+// logic level is referenced to the voltage on VL. Data is clocked into the SPI slave inter face on the
190
+// rising edge of SCLK. Data is clocked out of the SPI slave interface on the falling edge of SCLK.
191
+// Serial Clock (SCLK) Period 38.4ns minimum. 17ns minimum pulse width. VL >2.5V
192
+// SCLK Fall to MISO Propagation Delay 14.2ns
193
+// SCLK Fall to MOSI Propagation Delay 14.2ns
194
+// SCLK Fall to MOSI Drive 3.5ns
195
+// Theoretical deadline for reply 17.7ns
196
+// 26MHz 38.4615ns period <-- MAX3421E theoretical maximum
197
+
198
+#if !defined(UHS_MAX3421E_SPD)
199
+#if defined(ARDUINO_SAMD_ZERO)
200
+// Zero violates spec early, needs a long setup time, or doesn't like high latency.
201
+#define UHS_MAX3421E_SPD 10000000
202
+#elif defined(ARDUINO_ARCH_PIC32)
203
+// PIC MX 5/6/7 characteristics
204
+// 25MHZ 40ns period <-- PIC MX  5/6/7 theoretical maximum
205
+// pulse width minimum Tsclk/2ns
206
+// Trise/fall 10ns maximum. 5ns is typical but not guaranteed.
207
+// Tsetup minimum for MISO 10ns.
208
+// We are in violation by 7.7ns @ 25MHz due to latency alone.
209
+// Even reading at end of data cycle, we only have a 2.3ns window.
210
+// This is too narrow to to compensate for capacitance, trace lengths, and noise.
211
+
212
+// 17.7ns + 10ns = 27.7ns
213
+// 18MHz fits and has enough slack time to compensate for capacitance, trace lengths, and noise.
214
+// For high speeds the SMP bit is recommended too, which samples at the end instead of the middle.
215
+// 20Mhz seems to work.
216
+
217
+#define UHS_MAX3421E_SPD 20000000
218
+#else
219
+#define UHS_MAX3421E_SPD 25000000
220
+#endif
221
+#endif
222
+#else
223
+// We start at 25MHz, and back down until hardware can take it.
224
+// Of course, SPI library can adjust this for us too.
225
+// Why not 26MHz? Because I have not found any MCU board that
226
+// can actually go that fast without problems.
227
+// Could be a shield limitation too.
228
+#if !defined(UHS_MAX3421E_SPD)
229
+#define UHS_MAX3421E_SPD 25000000
230
+#endif
231
+#endif
232
+
233
+#ifndef UHS_MAX3421E_INT
234
+#define UHS_MAX3421E_INT UHS_MAX3421E_INT_
235
+#endif
236
+
237
+#ifndef UHS_MAX3421E_SS
238
+#define UHS_MAX3421E_SS UHS_MAX3421E_SS_
239
+#endif
240
+
241
+// NOTE: On the max3421e the irq enable and irq bits are in the same position.
242
+
243
+// IRQs used if CPU polls
244
+#define   ENIBITSPOLLED (bmCONDETIE | bmBUSEVENTIE  | bmFRAMEIE)
245
+// IRQs used if CPU is interrupted
246
+#define      ENIBITSISR (bmCONDETIE | bmBUSEVENTIE | bmFRAMEIE /* | bmRCVDAVIRQ | bmSNDBAVIRQ | bmHXFRDNIRQ */ )
247
+
248
+#if !USB_HOST_SHIELD_USE_ISR
249
+#define IRQ_CHECK_MASK (ENIBITSPOLLED & ICLRALLBITS)
250
+#define IRQ_IS_EDGE 0
251
+#else
252
+#define IRQ_CHECK_MASK (ENIBITSISR & ICLRALLBITS)
253
+#endif
254
+
255
+#if IRQ_IS_EDGE
256
+// Note: UNO32 Interrupts can only be RISING, or FALLING.
257
+// This poses an interesting problem, since we want to use a LOW level.
258
+// The MAX3421E provides for pulse width control for an IRQ.
259
+// We do need to watch the timing on this, as a second IRQ could cause
260
+// a missed IRQ, since we read the level of the line to check if the IRQ
261
+// is actually for this chip. The only other alternative is to add a capacitor
262
+// and an NPN transistor, and use two lines. We can try this first, though.
263
+// Worse case, we can ignore reading the pin for verification on UNO32.
264
+// Too bad there is no minimum low width setting.
265
+//
266
+//   Single    Clear     First  Second   Clear first      Clear last
267
+//   IRQ       Single    IRQ    IRQ      Second active    pending IRQ
268
+//      |      |         |      |        |                |
269
+//      V      V         V      V        V                V
270
+// _____        _________        _        _                _______
271
+//      |______|         |______| |______| |______________|
272
+//
273
+#define IRQ_SENSE FALLING
274
+#if defined(ARDUINO_ARCH_PIC32)
275
+//#define bmPULSEWIDTH PUSLEWIDTH10_6
276
+#define bmPULSEWIDTH 0
277
+#define bmIRQ_SENSE 0
278
+#else
279
+#define bmPULSEWIDTH PUSLEWIDTH1_3
280
+#define bmIRQ_SENSE 0
281
+#endif
282
+#else
283
+#if !defined(IRQ_SENSE)
284
+#define IRQ_SENSE LOW
285
+#endif
286
+#if !defined(bmPULSEWIDTH)
287
+#define bmPULSEWIDTH 0
288
+#endif
289
+#if !defined(bmIRQ_SENSE)
290
+#define bmIRQ_SENSE bmINTLEVEL
291
+#endif
292
+#endif
293
+
294
+class MAX3421E_HOST :
295
+public UHS_USB_HOST_BASE
296
+#if defined(SWI_IRQ_NUM)
297
+, public dyn_SWI
298
+#endif
299
+{
300
+        // TO-DO: move these into the parent class.
301
+        volatile uint8_t vbusState;
302
+        volatile uint16_t sof_countdown;
303
+
304
+        // TO-DO: pack into a struct/union and use one byte
305
+        volatile bool busevent;
306
+        volatile bool sofevent;
307
+        volatile bool counted;
308
+        volatile bool condet;
309
+        volatile bool doingreset;
310
+
311
+        #ifdef USB_HOST_MANUAL_POLL
312
+                volatile bool frame_irq_enabled = false;
313
+
314
+                bool enable_frame_irq(bool enable) {
315
+                        const bool prev_state = frame_irq_enabled;
316
+                        if(prev_state != enable) {
317
+                                if(enable)
318
+                                        regWr(rHIEN, regRd(rHIEN) |  bmFRAMEIE);
319
+                                else
320
+                                        regWr(rHIEN, regRd(rHIEN) & ~bmFRAMEIE);
321
+                                frame_irq_enabled = enable;
322
+                        }
323
+                        return prev_state;
324
+                }
325
+        #endif
326
+
327
+public:
328
+        SPISettings MAX3421E_SPI_Settings;
329
+        uint8_t ss_pin;
330
+        uint8_t irq_pin;
331
+        // Will use the defaults UHS_MAX3421E_SS, UHS_MAX3421E_INT and speed
332
+
333
+        UHS_NI MAX3421E_HOST(void) {
334
+                sof_countdown = 0;
335
+                busevent = false;
336
+                doingreset = false;
337
+                sofevent = false;
338
+                condet = false;
339
+                ss_pin = UHS_MAX3421E_SS;
340
+                irq_pin = UHS_MAX3421E_INT;
341
+                MAX3421E_SPI_Settings = SPISettings(UHS_MAX3421E_SPD, MSBFIRST, SPI_MODE0);
342
+                hub_present = 0;
343
+        };
344
+
345
+        // Will use user supplied pins, and UHS_MAX3421E_SPD
346
+
347
+        UHS_NI MAX3421E_HOST(uint8_t pss, uint8_t pirq) {
348
+                sof_countdown = 0;
349
+                busevent = false;
350
+                doingreset = false;
351
+                sofevent = false;
352
+                condet = false;
353
+                ss_pin = pss;
354
+                irq_pin = pirq;
355
+                MAX3421E_SPI_Settings = SPISettings(UHS_MAX3421E_SPD, MSBFIRST, SPI_MODE0);
356
+                hub_present = 0;
357
+        };
358
+
359
+        // Will use user supplied pins, and speed
360
+
361
+        UHS_NI MAX3421E_HOST(uint8_t pss, uint8_t pirq, uint32_t pspd) {
362
+                sof_countdown = 0;
363
+                doingreset = false;
364
+                busevent = false;
365
+                sofevent = false;
366
+                condet = false;
367
+                ss_pin = pss;
368
+                irq_pin = pirq;
369
+                MAX3421E_SPI_Settings = SPISettings(pspd, MSBFIRST, SPI_MODE0);
370
+                hub_present = 0;
371
+        };
372
+
373
+        virtual bool UHS_NI sof_delay(uint16_t x) {
374
+#ifdef USB_HOST_MANUAL_POLL
375
+                const bool saved_irq_state = enable_frame_irq(true);
376
+#endif
377
+                sof_countdown = x;
378
+                while((sof_countdown != 0) && !condet) {
379
+                        SYSTEM_OR_SPECIAL_YIELD();
380
+#if !USB_HOST_SHIELD_USE_ISR
381
+                        Task();
382
+#endif
383
+                }
384
+#ifdef USB_HOST_MANUAL_POLL
385
+                enable_frame_irq(saved_irq_state);
386
+#endif
387
+                //                Serial.println("...Wake");
388
+                return (!condet);
389
+        };
390
+
391
+        virtual UHS_EpInfo *ctrlReqOpen(uint8_t addr, uint64_t Request, uint8_t* dataptr);
392
+
393
+        virtual void UHS_NI vbusPower(VBUS_t state) {
394
+                regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE) | (uint8_t)(state));
395
+        };
396
+
397
+        void UHS_NI Task(void);
398
+
399
+        virtual uint8_t SetAddress(uint8_t addr, uint8_t ep, UHS_EpInfo **ppep, uint16_t &nak_limit);
400
+        virtual uint8_t OutTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data);
401
+        virtual uint8_t InTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data);
402
+        virtual uint8_t ctrlReqClose(UHS_EpInfo *pep, uint8_t bmReqType, uint16_t left, uint16_t nbytes, uint8_t *dataptr);
403
+        virtual uint8_t ctrlReqRead(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint16_t nbytes, uint8_t *dataptr);
404
+        virtual uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit);
405
+
406
+        void UHS_NI ReleaseChildren(void) {
407
+                for(uint8_t i = 0; i < UHS_HOST_MAX_INTERFACE_DRIVERS; i++)
408
+                        if(devConfig[i])
409
+                                devConfig[i]->Release();
410
+                hub_present = 0;
411
+        };
412
+
413
+        virtual bool IsHub(uint8_t klass) {
414
+                if(klass == UHS_USB_CLASS_HUB) {
415
+                        hub_present = bmHUBPRE;
416
+                        return true;
417
+                }
418
+                return false;
419
+        };
420
+
421
+        virtual void VBUS_changed(void);
422
+
423
+        virtual void UHS_NI doHostReset(void) {
424
+#if USB_HOST_SHIELD_USE_ISR
425
+                // Enable interrupts
426
+                noInterrupts();
427
+#endif
428
+                doingreset = true;
429
+                busevent = true;
430
+                regWr(rHIRQ, bmBUSEVENTIRQ); // see data sheet.
431
+                regWr(rHCTL, bmBUSRST); //issue bus reset
432
+#if USB_HOST_SHIELD_USE_ISR
433
+                DDSB();
434
+                // Enable interrupts
435
+                interrupts();
436
+#endif
437
+                while(busevent) {
438
+                        DDSB();
439
+                        SYSTEM_OR_SPECIAL_YIELD();
440
+                }
441
+#endif
442
+#if USB_HOST_SHIELD_USE_ISR
443
+                // Enable interrupts
444
+                noInterrupts();
445
+#endif
446
+                #ifdef USB_HOST_MANUAL_POLL
447
+                        enable_frame_irq(true);
448
+                #endif
449
+                sofevent = true;
450
+#if USB_HOST_SHIELD_USE_ISR
451
+                DDSB();
452
+                // Enable interrupts
453
+                interrupts();
454
+#endif
455
+                // Wait for SOF
456
+                while(sofevent) {
457
+                }
458
+#if USB_HOST_SHIELD_USE_ISR
459
+                // Enable interrupts
460
+                noInterrupts();
461
+#endif
462
+                doingreset = false;
463
+#if USB_HOST_SHIELD_USE_ISR
464
+                DDSB();
465
+                // Enable interrupts
466
+                interrupts();
467
+        };
468
+
469
+
470
+        int16_t UHS_NI Init(int16_t mseconds);
471
+
472
+        int16_t UHS_NI Init(void) {
473
+                return Init(INT16_MIN);
474
+        };
475
+
476
+        void ISRTask(void);
477
+        void ISRbottom(void);
478
+        void busprobe(void);
479
+        uint16_t reset(void);
480
+
481
+        // MAX3421e specific
482
+        void regWr(uint8_t reg, uint8_t data);
483
+        void gpioWr(uint8_t data);
484
+        uint8_t regRd(uint8_t reg);
485
+        uint8_t gpioRd(void);
486
+        uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
487
+        uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
488
+
489
+        // ARM/NVIC specific, used to emulate reentrant ISR.
490
+#if defined(SWI_IRQ_NUM)
491
+
492
+        void dyn_SWISR(void) {
493
+                ISRbottom();
494
+        };
495
+#endif
496
+
497
+        virtual void UHS_NI suspend_host(void) {
498
+                // Used on MCU that lack control of IRQ priority (AVR).
499
+                // Suspends ISRs, for critical code. IRQ will be serviced after it is resumed.
500
+                // NOTE: you must track the state yourself!
501
+#if defined(__AVR__)
502
+                noInterrupts();
503
+                detachInterrupt(UHS_GET_DPI(irq_pin));
504
+                interrupts();
505
+#endif
506
+        };
507
+
508
+        virtual void UHS_NI resume_host(void);
509
+};
510
+#if !defined(SPIclass)
511
+#define SPIclass SPI
512
+#endif
513
+#if !defined(USB_HOST_SHIELD_LOADED)
514
+#include "USB_HOST_SHIELD_INLINE.h"
515
+#endif
516
+#else
517
+#error "define LOAD_USB_HOST_SHIELD in your sketch, never include USB_HOST_SHIELD.h in a driver."
518
+#endif
519
+#endif /* USB_HOST_SHIELD_H */

+ 1003
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 153
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/macro_logic.h 파일 보기

@@ -0,0 +1,153 @@
1
+/*
2
+ * File:   macro_logic.h
3
+ * Author: root
4
+ *
5
+ * Created on December 22, 2018, 4:49 AM
6
+ *
7
+ * To test:
8
+ * gcc -DAJK_TEST_MACRO_LOGIC -E macro_logic.h
9
+ *
10
+ */
11
+
12
+#ifndef MACRO_LOGIC_H
13
+#define	MACRO_LOGIC_H
14
+
15
+#define AJK_CAT(a, ...) AJK_PRIMITIVE_CAT(a, __VA_ARGS__)
16
+#define AJK_PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
17
+
18
+#define AJK_COMPL(b) AJK_PRIMITIVE_CAT(AJK_COMPL_, b)
19
+#define AJK_COMPL_0 1
20
+#define AJK_COMPL_1 0
21
+
22
+#define AJK_BITAND(x) AJK_PRIMITIVE_CAT(AJK_BITAND_, x)
23
+#define AJK_BITAND_0(y) 0
24
+#define AJK_BITAND_1(y) y
25
+
26
+#define AJK_INC(x) AJK_PRIMITIVE_CAT(AJK_INC_, x)
27
+#define AJK_INC_0 1
28
+#define AJK_INC_1 2
29
+#define AJK_INC_2 3
30
+#define AJK_INC_3 4
31
+#define AJK_INC_4 5
32
+#define AJK_INC_5 6
33
+#define AJK_INC_6 7
34
+#define AJK_INC_7 8
35
+#define AJK_INC_8 9
36
+#define AJK_INC_9 10
37
+#define AJK_INC_10 10
38
+
39
+#define AJK_DEC(x) AJK_PRIMITIVE_CAT(AJK_DEC_, x)
40
+#define AJK_DEC_0 0
41
+#define AJK_DEC_1 0
42
+#define AJK_DEC_2 1
43
+#define AJK_DEC_3 2
44
+#define AJK_DEC_4 3
45
+#define AJK_DEC_5 4
46
+#define AJK_DEC_6 5
47
+#define AJK_DEC_7 6
48
+#define AJK_DEC_8 7
49
+#define AJK_DEC_9 8
50
+#define AJK_DEC_10 9
51
+
52
+#define AJK_CHECK_N(x, n, ...) n
53
+#define AJK_CHECK(...) AJK_CHECK_N(__VA_ARGS__, 0,)
54
+#define AJK_PROBE(x) x, 1,
55
+
56
+#define AJK_IS_PAREN(x) AJK_CHECK(AJK_IS_PAREN_PROBE x)
57
+#define AJK_IS_PAREN_PROBE(...) AJK_PROBE(~)
58
+
59
+#define AJK_NOT(x) AJK_CHECK(AJK_PRIMITIVE_CAT(AJK_NOT_, x))
60
+#define AJK_NOT_0 AJK_PROBE(~)
61
+
62
+#define AJK_COMPL(b) AJK_PRIMITIVE_CAT(AJK_COMPL_, b)
63
+#define AJK_COMPL_0 1
64
+#define AJK_COMPL_1 0
65
+
66
+#define AJK_BOOL(x) AJK_COMPL(AJK_NOT(x))
67
+
68
+#define AJK_IIF(c) AJK_PRIMITIVE_CAT(AJK_IIF_, c)
69
+#define AJK_IIF_0(t, ...) __VA_ARGS__
70
+#define AJK_IIF_1(t, ...) t
71
+
72
+#define AJK_IF(c) AJK_IIF(AJK_BOOL(c))
73
+
74
+#define AJK_EAT(...)
75
+#define AJK_EXPAND(...) __VA_ARGS__
76
+#define AJK_WHEN(c) AJK_IF(c)(AJK_EXPAND, AJK_EAT)
77
+
78
+#define AJK_EMPTY()
79
+#define AJK_DEFER(id) id AJK_EMPTY()
80
+#define AJK_OBSTRUCT(id) id AJK_DEFER(AJK_EMPTY)()
81
+
82
+#define AJK_EVAL(...)  AJK_EVAL1(AJK_EVAL1(AJK_EVAL1(__VA_ARGS__)))
83
+#define AJK_EVAL1(...) AJK_EVAL2(AJK_EVAL2(AJK_EVAL2(__VA_ARGS__)))
84
+#define AJK_EVAL2(...) AJK_EVAL3(AJK_EVAL3(AJK_EVAL3(__VA_ARGS__)))
85
+#define AJK_EVAL3(...) AJK_EVAL4(AJK_EVAL4(AJK_EVAL4(__VA_ARGS__)))
86
+#define AJK_EVAL4(...) AJK_EVAL5(AJK_EVAL5(AJK_EVAL5(__VA_ARGS__)))
87
+#define AJK_EVAL5(...) __VA_ARGS__
88
+
89
+#define AJK_REPEAT(AJK_count, AJK_macro, ...) \
90
+    AJK_WHEN(AJK_count) \
91
+    ( \
92
+        AJK_OBSTRUCT(AJK_REPEAT_INDIRECT) () \
93
+        ( \
94
+            AJK_DEC(AJK_count), AJK_macro, __VA_ARGS__ \
95
+        ) \
96
+        AJK_OBSTRUCT(AJK_macro) \
97
+        ( \
98
+            AJK_DEC(AJK_count), __VA_ARGS__ \
99
+        ) \
100
+    )
101
+#define AJK_REPEAT_INDIRECT() AJK_REPEAT
102
+
103
+#define AJK_WHILE(AJK_pred, AJK_op, ...) \
104
+    IF(AJK_pred(__VA_ARGS__)) \
105
+    ( \
106
+        AJK_OBSTRUCT(AJK_WHILE_INDIRECT) () \
107
+        ( \
108
+            AJK_pred, AJK_op, AJK_op(__VA_ARGS__) \
109
+        ), \
110
+        __VA_ARGS__ \
111
+    )
112
+#define AJK_WHILE_INDIRECT() AJK_WHILE
113
+
114
+#define AJK_PRIMITIVE_COMPARE(x, y) AJK_IS_PAREN \
115
+( \
116
+    AJK_COMPARE_ ## x ( AJK_COMPARE_ ## y) (())  \
117
+)
118
+
119
+#define AJK_IS_COMPARABLE(x) AJK_IS_PAREN( AJK_CAT(AJK_COMPARE_, x) (()) )
120
+
121
+#define AJK_NOT_EQUAL(x, y) \
122
+AJK_IIF(AJK_BITAND(AJK_IS_COMPARABLE(x))(AJK_IS_COMPARABLE(y)) ) \
123
+( \
124
+   AJK_PRIMITIVE_COMPARE, \
125
+   1 AJK_EAT \
126
+)(x, y)
127
+
128
+#define AJK_EQUAL(x, y) AJK_COMPL(AJK_NOT_EQUAL(x, y))
129
+
130
+
131
+#define AJK_COMMA() ,
132
+
133
+#define AJK_COMMA_IF(n) AJK_IF(n)(AJK_COMMA, AJK_EAT)()
134
+
135
+
136
+#define AJK_COMMA_VAR(AJK_count, AJK_v) AJK_COMMA_IF(AJK_count) AJK_v ## AJK_count
137
+
138
+#define AJK_MAKE_LIST(AJK_v, AJK_count) AJK_EVAL(AJK_REPEAT(AJK_count, AJK_COMMA_VAR, AJK_v))
139
+
140
+#define AJK_FUN(AJK_count, AJK_v, AJK_args, AJK_body) AJK_v ## AJK_count (AJK_args) { AJK_body(AJK_count) }
141
+#define AJK_MAKE_FUNS(AJK_v, AJK_args, AJK_count, AJK_body) AJK_EVAL(AJK_REPEAT(AJK_count, AJK_FUN, AJK_v, AJK_args, AJK_body))
142
+#if defined(AJK_TEST_MACRO_LOGIC)
143
+
144
+#define BODY(AJKindex) some(C, statement); contaning(a, test[AJKindex]);
145
+#define ZERO_TIMES_TEST 0
146
+#define THREE_TIMES_TEST 3
147
+blank > AJK_MAKE_LIST(VARIABLE_, ZERO_TIMES_TEST) < because zero repeats
148
+Make 3 comma separated indexed variables : AJK_MAKE_LIST(VARIABLE_, THREE_TIMES_TEST)
149
+Make 3 bogus function bodies
150
+AJK_MAKE_FUNS(unsigned Cfunc,(arg1, arg2),3,BODY)
151
+#endif
152
+
153
+#endif	/* MACRO_LOGIC_H */

+ 246
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/dyn_SWI/SWI_INLINE.h 파일 보기

@@ -0,0 +1,246 @@
1
+/*
2
+ * File:   SWI_INLINE.h
3
+ * Author: xxxajk@gmail.com
4
+ *
5
+ * Created on December 5, 2014, 9:40 AM
6
+ *
7
+ * This is the actual library.
8
+ * There are no 'c' or 'cpp' files.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+ * GNU General Public License for more details.
19
+
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program; if not, write to the Free Software
22
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
+ */
24
+#ifdef DYN_SWI_H
25
+#ifndef SWI_INLINE_H
26
+#define	SWI_INLINE_H
27
+
28
+#ifndef SWI_MAXIMUM_ALLOWED
29
+#define SWI_MAXIMUM_ALLOWED 4
30
+#endif
31
+
32
+
33
+
34
+#if defined(__arm__) || defined(ARDUINO_ARCH_PIC32)
35
+static char dyn_SWI_initied = 0;
36
+static dyn_SWI* dyn_SWI_LIST[SWI_MAXIMUM_ALLOWED];
37
+static dyn_SWI* dyn_SWI_EXEC[SWI_MAXIMUM_ALLOWED];
38
+#if defined(__arm__)
39
+#if defined(__USE_CMSIS_VECTORS__)
40
+extern "C" {
41
+        void (*_VectorsRam[VECTORTABLE_SIZE])(void)__attribute__((aligned(VECTORTABLE_ALIGNMENT)));
42
+}
43
+#else
44
+
45
+__attribute__((always_inline)) static inline void __DSB(void) {
46
+        __asm__ volatile ("dsb");
47
+}
48
+#endif // defined(__USE_CMSIS_VECTORS__)
49
+#else // defined(__arm__)
50
+__attribute__((always_inline)) static inline void __DSB(void) {
51
+        __asm__ volatile ("sync" : : : "memory");
52
+}
53
+#endif // defined(__arm__)
54
+
55
+/**
56
+ * Execute queued class ISR routines.
57
+ */
58
+#if defined(ARDUINO_ARCH_PIC32)
59
+static p32_regset *ifs = ((p32_regset *) & IFS0) + (SWI_IRQ_NUM / 32); //interrupt flag register set
60
+static p32_regset *iec = ((p32_regset *) & IEC0) + (SWI_IRQ_NUM / 32); //interrupt enable control reg set
61
+static uint32_t swibit = 1 << (SWI_IRQ_NUM % 32);
62
+
63
+void
64
+#if defined(__PIC32MZXX__)
65
+        __attribute__((nomips16,at_vector(SWI_VECTOR),interrupt(SWI_IPL)))
66
+#else
67
+        __attribute__((interrupt(),nomips16))
68
+#endif
69
+        softISR(void) {
70
+#else
71
+#if defined(ARDUINO_spresense_ast)
72
+unsigned int softISR(void) {
73
+#else
74
+void softISR(void) {
75
+#endif
76
+#endif
77
+
78
+        //
79
+        // TO-DO: Perhaps limit to 8, and inline this?
80
+        //
81
+
82
+
83
+        // Make a working copy, while clearing the queue.
84
+        noInterrupts();
85
+#if defined(ARDUINO_ARCH_PIC32)
86
+        //ifs->clr = swibit;
87
+#endif
88
+        for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) {
89
+                dyn_SWI_EXEC[i] = dyn_SWI_LIST[i];
90
+                dyn_SWI_LIST[i] = NULL;
91
+        }
92
+        __DSB();
93
+        interrupts();
94
+
95
+        // Execute each class SWI
96
+        for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) {
97
+                if(dyn_SWI_EXEC[i]) {
98
+#if defined(__DYN_SWI_DEBUG_LED__)
99
+                        digitalWrite(__DYN_SWI_DEBUG_LED__, HIGH);
100
+#endif
101
+                        dyn_SWI_EXEC[i]->dyn_SWISR();
102
+#if defined(__DYN_SWI_DEBUG_LED__)
103
+                        digitalWrite(__DYN_SWI_DEBUG_LED__, LOW);
104
+#endif
105
+                }
106
+        }
107
+#if defined(ARDUINO_ARCH_PIC32)
108
+        noInterrupts();
109
+        if(!dyn_SWI_EXEC[0]) ifs->clr = swibit;
110
+        interrupts();
111
+#endif
112
+#if defined(ARDUINO_spresense_ast)
113
+        return 0;
114
+#endif
115
+}
116
+
117
+#define DDSB() __DSB()
118
+#endif
119
+
120
+
121
+#if defined(__arm__)
122
+#ifndef interruptsStatus
123
+#define interruptsStatus() __interruptsStatus()
124
+static inline unsigned char __interruptsStatus(void) __attribute__((always_inline, unused));
125
+
126
+static inline unsigned char __interruptsStatus(void) {
127
+        unsigned int primask;
128
+        asm volatile ("mrs %0, primask" : "=r" (primask));
129
+        if(primask) return 0;
130
+        return 1;
131
+}
132
+#endif
133
+
134
+/**
135
+ * Initialize the Dynamic (class) Software Interrupt
136
+ */
137
+static void Init_dyn_SWI(void) {
138
+        if(!dyn_SWI_initied) {
139
+#if defined(__USE_CMSIS_VECTORS__)
140
+                uint32_t *X_Vectors = (uint32_t*)SCB->VTOR;
141
+                for(int i = 0; i < VECTORTABLE_SIZE; i++) {
142
+                        _VectorsRam[i] = reinterpret_cast<void (*)()>(X_Vectors[i]); /* copy vector table to RAM */
143
+                }
144
+                /* relocate vector table */
145
+                noInterrupts();
146
+                SCB->VTOR = reinterpret_cast<uint32_t>(&_VectorsRam);
147
+                DDSB();
148
+                interrupts();
149
+#endif
150
+#if !defined(ARDUINO_spresense_ast)
151
+                for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) dyn_SWI_LIST[i] = NULL;
152
+                noInterrupts();
153
+                _VectorsRam[SWI_IRQ_NUM + 16] = reinterpret_cast<void (*)()>(softISR);
154
+                DDSB();
155
+                interrupts();
156
+                NVIC_SET_PRIORITY(SWI_IRQ_NUM, 255);
157
+                NVIC_ENABLE_IRQ(SWI_IRQ_NUM);
158
+#endif
159
+#if defined(__DYN_SWI_DEBUG_LED__)
160
+                pinMode(__DYN_SWI_DEBUG_LED__, OUTPUT);
161
+                digitalWrite(__DYN_SWI_DEBUG_LED__, LOW);
162
+#endif
163
+                dyn_SWI_initied = 1;
164
+        }
165
+}
166
+
167
+/**
168
+ *
169
+ * @param klass class that extends dyn_SWI
170
+ * @return 0 on queue full, else returns queue position (ones based)
171
+ */
172
+int exec_SWI(const dyn_SWI* klass) {
173
+        int rc = 0;
174
+
175
+        uint8_t irestore = interruptsStatus();
176
+        // Allow use from inside a critical section...
177
+        // ... and prevent races if also used inside an ISR
178
+        noInterrupts();
179
+        for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) {
180
+                if(!dyn_SWI_LIST[i]) {
181
+                        rc = 1 + i; // Success!
182
+                        dyn_SWI_LIST[i] = (dyn_SWI*)klass;
183
+#if !defined(ARDUINO_spresense_ast)
184
+                        if(!NVIC_GET_PENDING(SWI_IRQ_NUM)) NVIC_SET_PENDING(SWI_IRQ_NUM);
185
+#else
186
+                        // Launch 1-shot timer as an emulated SWI
187
+                        // Hopefully the value of Zero is legal.
188
+                        // 1 microsecond latency would suck!
189
+                        attachTimerInterrupt(softISR, 100);
190
+#endif
191
+                        DDSB();
192
+                        break;
193
+                }
194
+        }
195
+        // Restore interrupts, if they were on.
196
+        if(irestore) interrupts();
197
+        return rc;
198
+}
199
+#elif defined(ARDUINO_ARCH_PIC32)
200
+
201
+/**
202
+ * Initialize the Dynamic (class) Software Interrupt
203
+ */
204
+static void Init_dyn_SWI(void) {
205
+        if(!dyn_SWI_initied) {
206
+                uint32_t sreg = disableInterrupts();
207
+
208
+                setIntVector(SWI_VECTOR, softISR);
209
+                setIntPriority(SWI_VECTOR, 1, 1); // Lowest priority, ever.
210
+                ifs->clr = swibit;
211
+                iec->clr = swibit;
212
+                iec->set = swibit;
213
+                restoreInterrupts(sreg);
214
+#if defined(__DYN_SWI_DEBUG_LED__)
215
+                pinMode(__DYN_SWI_DEBUG_LED__, OUTPUT);
216
+                UHS_PIN_WRITE(__DYN_SWI_DEBUG_LED__, LOW);
217
+#endif
218
+        }
219
+}
220
+
221
+/**
222
+ *
223
+ * @param klass class that extends dyn_SWI
224
+ * @return 0 on queue full, else returns queue position (ones based)
225
+ */
226
+int exec_SWI(const dyn_SWI* klass) {
227
+        int rc = 0;
228
+        uint32_t sreg = disableInterrupts();
229
+        for(int i = 0; i < SWI_MAXIMUM_ALLOWED; i++) {
230
+                if(!dyn_SWI_LIST[i]) {
231
+                        rc = 1 + i; // Success!
232
+                        dyn_SWI_LIST[i] = (dyn_SWI*)klass;
233
+                        if(!(ifs->reg & swibit)) ifs->set = swibit;
234
+                        ;
235
+                        break;
236
+                }
237
+        }
238
+        restoreInterrupts(sreg);
239
+        return rc;
240
+}
241
+
242
+#endif /* defined(__arm__) */
243
+#endif	/* SWI_INLINE_H */
244
+#else
245
+#error "Never include SWI_INLINE.h directly, include dyn_SWI.h instead"
246
+#endif

+ 172
- 0
Marlin/src/sd/usb_flashdrive/lib-uhs3/dyn_SWI/dyn_SWI.h 파일 보기

@@ -0,0 +1,172 @@
1
+/*
2
+ * File:   dyn_SWI.h
3
+ * Author: xxxajk@gmail.com
4
+ *
5
+ * Created on December 5, 2014, 9:12 AM
6
+ *
7
+ * This program is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 2 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program; if not, write to the Free Software
19
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
+ */
21
+
22
+#ifndef DYN_SWI_H
23
+#define	DYN_SWI_H
24
+
25
+
26
+#if defined(__arm__) || defined(ARDUINO_ARCH_PIC32)
27
+#if defined(ARDUINO_ARCH_PIC32)
28
+#include <p32xxxx.h>
29
+#endif
30
+#ifdef __cplusplus
31
+
32
+#if defined(true)
33
+#undef true
34
+#endif
35
+
36
+#if defined(false)
37
+#undef false
38
+#endif
39
+
40
+#endif
41
+
42
+#if defined(ARDUINO_spresense_ast)
43
+#define SWI_IRQ_NUM 666 // because this board is totally evil.
44
+#elif defined(ARDUINO_ARCH_PIC32)
45
+#ifndef SWI_IRQ_NUM
46
+#if defined(_DSPI0_IPL_ISR)
47
+#define SWI_IPL _DSPI0_IPL_ISR
48
+#define SWI_VECTOR _DSPI0_ERR_IRQ
49
+#define SWI_IRQ_NUM _DSPI0_ERR_IRQ
50
+#elif defined(_PMP_ERROR_IRQ)
51
+#define SWI_IRQ_NUM _PMP_ERROR_IRQ
52
+#define SWI_VECTOR _PMP_VECTOR
53
+#else
54
+#error SWI_IRQ_NUM and SWI_VECTOR need a definition
55
+#endif
56
+#ifdef __cplusplus
57
+extern "C"
58
+{
59
+        void
60
+#if defined(__PIC32MZXX__)
61
+                __attribute__((nomips16,at_vector(SWI_VECTOR),interrupt(SWI_IPL)))
62
+#else
63
+                __attribute__((interrupt(),nomips16))
64
+#endif
65
+                softISR(void);
66
+}
67
+#endif
68
+#endif
69
+#elif !defined(NVIC_NUM_INTERRUPTS)
70
+// Assume CMSIS
71
+#define __USE_CMSIS_VECTORS__
72
+#if defined(NUMBER_OF_INT_VECTORS)
73
+#define NVIC_NUM_INTERRUPTS (NUMBER_OF_INT_VECTORS-16)
74
+#else
75
+#define NVIC_NUM_INTERRUPTS ((int)PERIPH_COUNT_IRQn)
76
+#endif
77
+#define VECTORTABLE_SIZE (NVIC_NUM_INTERRUPTS+16)
78
+#define VECTORTABLE_ALIGNMENT (0x100ul)
79
+#define NVIC_GET_ACTIVE(n) NVIC_GetActive((IRQn_Type)n)
80
+#define NVIC_GET_PENDING(n) NVIC_GetPendingIRQ((IRQn_Type)n)
81
+#define NVIC_SET_PENDING(n) NVIC_SetPendingIRQ((IRQn_Type)n)
82
+#define NVIC_ENABLE_IRQ(n) NVIC_EnableIRQ((IRQn_Type)n)
83
+#define NVIC_SET_PRIORITY(n ,p) NVIC_SetPriority((IRQn_Type)n, (uint32_t) p)
84
+//extern "C" {
85
+//        extern uint32_t _VectorsRam[VECTORTABLE_SIZE] __attribute__((aligned(VECTORTABLE_ALIGNMENT)));
86
+//}
87
+
88
+#ifndef SWI_IRQ_NUM
89
+#if defined(__SAM3X8E__) && defined(_VARIANT_ARDUINO_DUE_X_)
90
+// DUE
91
+// Choices available:
92
+// HSMCI_IRQn Multimedia Card Interface (HSMCI)
93
+// EMAC_IRQn Ethernet MAC (EMAC)
94
+// EMAC is not broken out on the official DUE, but is on clones.
95
+// SPI0_IRQn Serial Peripheral Interface (SPI0)
96
+// SPI0_IRQn seems to be the best choice, as long as nobody uses an ISR based master
97
+#define SWI_IRQ_NUM SPI0_IRQn
98
+#elif defined(ARDUINO_SAMD_ZERO)
99
+// Just use sercom4's unused IRQ vector.
100
+#define SWI_IRQ_NUM I2S_IRQn
101
+//#define SWI_IRQ_NUM SERCOM4_IRQn
102
+#endif
103
+#endif
104
+
105
+#ifndef SWI_IRQ_NUM
106
+#error SWI_IRQ_NUM not defined (CMSIS)
107
+#endif
108
+
109
+#elif defined(CORE_TEENSY)
110
+
111
+#ifndef NVIC_GET_ACTIVE
112
+#define NVIC_GET_ACTIVE(n)	(*((volatile uint32_t *)0xE000E300 + ((n) >> 5)) & (1 << ((n) & 31)))
113
+#endif
114
+#ifndef NVIC_GET_PENDING
115
+#define NVIC_GET_PENDING(n)	(*((volatile uint32_t *)0xE000E200 + ((n) >> 5)) & (1 << ((n) & 31)))
116
+#ifndef SWI_IRQ_NUM
117
+#if defined(__MK20DX256__)
118
+#define SWI_IRQ_NUM 17
119
+#elif defined(__MK20DX128__)
120
+#define SWI_IRQ_NUM 5
121
+#elif defined(__MKL26Z64__)
122
+#define SWI_IRQ_NUM 4
123
+#elif defined(__MK66FX1M0__)
124
+#define SWI_IRQ_NUM 30
125
+#elif defined(__MK64FX512__)
126
+#define SWI_IRQ_NUM 30
127
+#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
128
+#define SWI_IRQ_NUM 71
129
+#else
130
+#error Do not know how to relocate IRQ vectors for this pjrc product
131
+#endif
132
+#endif
133
+#endif
134
+#else // Not CMSIS or PJRC CORE_TEENSY or PIC32 or SPRESENSE
135
+#error Do not know how to relocate IRQ vectors or perform SWI
136
+#endif // SWI_IRQ_NUM
137
+
138
+
139
+#ifndef SWI_IRQ_NUM
140
+#error SWI_IRQ_NUM not defined
141
+#else
142
+/**
143
+ * Use this class to extend your class, in order to provide
144
+ * a C++ context callable SWI.
145
+ */
146
+class dyn_SWI {
147
+public:
148
+
149
+        /**
150
+         * Override this method with your code.
151
+         */
152
+        virtual void dyn_SWISR(void) {
153
+        };
154
+};
155
+
156
+extern int exec_SWI(const dyn_SWI* klass);
157
+
158
+#include "SWI_INLINE.h"
159
+
160
+// IMPORTANT! Define this so that you do NOT end up with a NULL stub!
161
+#define SWI_NO_STUB
162
+#endif /* SWI_IRQ_NUM */
163
+#endif /* __arm__ */
164
+
165
+// if no SWI for CPU (e.g. AVR) make a void stub.
166
+#ifndef SWI_NO_STUB
167
+#define Init_dyn_SWI() (void(0))
168
+#if !defined(DDSB)
169
+#define DDSB() (void(0))
170
+#endif
171
+#endif
172
+#endif	/* DYN_SWI_H */

+ 0
- 187
Marlin/src/sd/usb_flashdrive/usb-2.0-host-library-changes.patch 파일 보기

@@ -1,187 +0,0 @@
1
-diff -Naur /home/aleph/Downloads/USB_Host_Shield_2.0-master/masstorage.cpp lib/masstorage.cpp
2
---- /home/aleph/Downloads/USB_Host_Shield_2.0-master/masstorage.cpp	2018-09-21 10:19:36.107502252 -0600
3
-+++ lib/masstorage.cpp	2018-09-21 09:46:19.620175519 -0600
4
-@@ -24,6 +24,8 @@
5
- 
6
- #include "masstorage.h"
7
- 
8
-+#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
9
-+
10
- const uint8_t BulkOnly::epDataInIndex = 1;
11
- const uint8_t BulkOnly::epDataOutIndex = 2;
12
- const uint8_t BulkOnly::epInterruptInIndex = 3;
13
-@@ -796,6 +798,9 @@
14
-                 buf[i] = 0x00;
15
-         }
16
-         WriteOk[lun] = true;
17
-+        #if ENABLED(USB_FLASH_DRIVE_SUPPORT) && defined(SKIP_WRITE_PROTECT)
18
-+          return 0;
19
-+        #endif
20
-         uint8_t rc = ModeSense6(lun, 0, 0x3f, 0, 192, buf);
21
-         if(!rc) {
22
-                 WriteOk[lun] = ((buf[2] & 0x80) == 0);
23
-@@ -1271,3 +1276,5 @@
24
-         return MASS_ERR_NOT_IMPLEMENTED;
25
- #endif
26
- }
27
-+
28
-+#endif // USB_FLASH_DRIVE_SUPPORT
29
-\ No newline at end of file
30
-diff -Naur /home/aleph/Downloads/USB_Host_Shield_2.0-master/message.cpp lib/message.cpp
31
---- /home/aleph/Downloads/USB_Host_Shield_2.0-master/message.cpp	2018-09-21 10:20:15.995647957 -0600
32
-+++ lib/message.cpp	2018-09-19 07:43:46.520339375 -0600
33
-@@ -23,6 +23,9 @@
34
-  */
35
- 
36
- #include "Usb.h"
37
-+
38
-+#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
39
-+
40
- // 0x80 is the default (i.e. trace) to turn off set this global to something lower.
41
- // this allows for 126 other debugging levels.
42
- // TO-DO: Allow assignment to a different serial port by software
43
-@@ -120,4 +123,6 @@
44
-         D_PrintHex<uint8_t > (rcode, 0x80);
45
-         Notify(PSTR("\r\n"), 0x80);
46
- }
47
--#endif
48
-+#endif // DEBUG_USB_HOST
49
-+
50
-+#endif // USB_FLASH_DRIVE_SUPPORT
51
-\ No newline at end of file
52
-diff -Naur /home/aleph/Downloads/USB_Host_Shield_2.0-master/parsetools.cpp lib/parsetools.cpp
53
---- /home/aleph/Downloads/USB_Host_Shield_2.0-master/parsetools.cpp	2018-09-21 10:21:16.215867769 -0600
54
-+++ lib/parsetools.cpp	2018-09-19 07:43:46.520339375 -0600
55
-@@ -23,6 +23,8 @@
56
-  */
57
- #include "Usb.h"
58
- 
59
-+#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
60
-+
61
- bool MultiByteValueParser::Parse(uint8_t **pp, uint16_t *pcntdn) {
62
-         if(!pBuf) {
63
-                 Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80);
64
-@@ -72,3 +74,5 @@
65
-         }
66
-         return true;
67
- }
68
-+
69
-+#endif // USB_FLASH_DRIVE_SUPPORT
70
-\ No newline at end of file
71
-diff -Naur /home/aleph/Downloads/USB_Host_Shield_2.0-master/settings.h lib/settings.h
72
---- /home/aleph/Downloads/USB_Host_Shield_2.0-master/settings.h	2018-09-21 10:22:21.792106872 -0600
73
-+++ lib/settings.h	2018-09-21 10:01:53.383594081 -0600
74
-@@ -25,7 +25,21 @@
75
- #ifndef USB_HOST_SHIELD_SETTINGS_H
76
- #define USB_HOST_SHIELD_SETTINGS_H
77
- #include "macros.h"
78
--
79
-+#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
80
-+  ////////////////////////////////////////////////////////////////////////////////
81
-+  /* Added by Bill Greiman to speed up mass storage initialization with USB
82
-+   * flash drives and simple USB hard drives.
83
-+   * Disable this by defining DELAY(x) to be delay(x).
84
-+   */
85
-+  #define delay(x)  if((x) < 200) safe_delay(x)
86
-+  /* Almost all USB flash drives and simple USB hard drives fail the write
87
-+   * protect test and add 20 - 30 seconds to USB init.  Set SKIP_WRITE_PROTECT
88
-+   * to nonzero to skip the test and assume the drive is writable.
89
-+   */
90
-+  #define SKIP_WRITE_PROTECT 1
91
-+  /* Since Marlin only cares about USB flash drives, we only need one LUN. */
92
-+  #define MASS_MAX_SUPPORTED_LUN 1
93
-+#endif
94
- ////////////////////////////////////////////////////////////////////////////////
95
- // SPI Configuration
96
- ////////////////////////////////////////////////////////////////////////////////
97
-@@ -45,6 +59,10 @@
98
-  * multiple serial ports are available.
99
-  * For example Serial3.
100
-  */
101
-+#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
102
-+  #define USB_HOST_SERIAL MYSERIAL0
103
-+#endif
104
-+
105
- #ifndef USB_HOST_SERIAL
106
- #define USB_HOST_SERIAL Serial
107
- #endif
108
-@@ -99,7 +117,7 @@
109
- // No user serviceable parts below this line.
110
- // DO NOT change anything below here unless you are a developer!
111
- 
112
--#include "version_helper.h"
113
-+//#include "version_helper.h"
114
- 
115
- #if defined(__GNUC__) && defined(__AVR__)
116
- #ifndef GCC_VERSION
117
-@@ -149,7 +167,6 @@
118
- #else
119
- #define USING_SPI4TEENSY3 0
120
- #endif
121
--
122
- #if ((defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(__ARDUINO_X86__) || ARDUINO >= 10600) && !USING_SPI4TEENSY3
123
- #include <SPI.h> // Use the Arduino SPI library for the Arduino Due, Intel Galileo 1 & 2, Intel Edison or if the SPI library with transaction is available
124
- #endif
125
-diff -Naur /home/aleph/Downloads/USB_Host_Shield_2.0-master/UsbCore.h lib/UsbCore.h
126
---- /home/aleph/Downloads/USB_Host_Shield_2.0-master/UsbCore.h	2018-09-21 10:23:09.348280107 -0600
127
-+++ lib/UsbCore.h	2018-09-19 07:43:46.520339375 -0600
128
-@@ -32,7 +32,10 @@
129
- //#define USB_METHODS_INLINE
130
- 
131
- /* shield pins. First parameter - SS pin, second parameter - INT pin */
132
--#ifdef BOARD_BLACK_WIDDOW
133
-+
134
-+#if defined(__MARLIN_H__)
135
-+typedef MAX3421e MAX3421E; // Marlin redefines this class in "../usb_host.h"
136
-+#elif defined(BOARD_BLACK_WIDDOW)
137
- typedef MAX3421e<P6, P3> MAX3421E; // Black Widow
138
- #elif defined(CORE_TEENSY) && (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__))
139
- #if EXT_RAM
140
-diff -Naur /home/aleph/Downloads/USB_Host_Shield_2.0-master/Usb.cpp lib/Usb.cpp
141
---- /home/aleph/Downloads/USB_Host_Shield_2.0-master/Usb.cpp	2018-09-21 10:23:20.732321559 -0600
142
-+++ lib/Usb.cpp	2018-09-19 07:43:46.520339375 -0600
143
-@@ -25,6 +25,8 @@
144
- 
145
- #include "Usb.h"
146
- 
147
-+#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
148
-+
149
- static uint8_t usb_error = 0;
150
- static uint8_t usb_task_state;
151
- 
152
-@@ -825,3 +827,4 @@
153
- }
154
- 
155
- #endif // defined(USB_METHODS_INLINE)
156
-+#endif // USB_FLASH_DRIVE_SUPPORT
157
-diff -Naur /home/aleph/Downloads/USB_Host_Shield_2.0-master/Usb.h lib/Usb.h
158
---- /home/aleph/Downloads/USB_Host_Shield_2.0-master/Usb.h	2018-09-21 10:23:33.756368972 -0600
159
-+++ lib/Usb.h	2018-09-19 07:43:46.520339375 -0600
160
-@@ -25,6 +25,8 @@
161
- #ifndef _usb_h_
162
- #define _usb_h_
163
- 
164
-+#include "../../../Marlin.h"
165
-+
166
- // WARNING: Do not change the order of includes, or stuff will break!
167
- #include <inttypes.h>
168
- #include <stddef.h>
169
-@@ -34,13 +36,15 @@
170
- #include "settings.h"
171
- #include "printhex.h"
172
- #include "message.h"
173
-+
174
- #include "hexdump.h"
175
--#include "sink_parser.h"
176
-+//#include "sink_parser.h"
177
- #include "max3421e.h"
178
- #include "address.h"
179
--#include "avrpins.h"
180
-+//#include "avrpins.h"
181
- #include "usb_ch9.h"
182
--#include "usbhost.h"
183
-+//#include "usbhost.h"
184
-+#include "../usb_host.h"
185
- #include "UsbCore.h"
186
- #include "parsetools.h"
187
- #include "confdescparser.h"

+ 18
- 4
config/default/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/3DFabXYZ/Migbot/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/ADIMLab/Granty v2/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is required for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/AlephObjects/TAZ4/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Alfawise/U20/Configuration_adv.h 파일 보기

@@ -1021,17 +1021,31 @@
1021 1021
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1022 1022
    * to Marlin as an SD card.
1023 1023
    *
1024
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1024
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1025 1025
    * the following pin mapping:
1026 1026
    *
1027 1027
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1028
-   *    INT              --> SD_DETECT_PIN
1028
+   *    INT              --> SD_DETECT_PIN [1]
1029 1029
    *    SS               --> SDSS
1030
+   *
1031
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1030 1032
    */
1031 1033
   //#define USB_FLASH_DRIVE_SUPPORT
1032 1034
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1033
-    #define USB_CS_PIN         SDSS
1034
-    #define USB_INTR_PIN       SD_DETECT_PIN
1035
+    #define USB_CS_PIN    SDSS
1036
+    #define USB_INTR_PIN  SD_DETECT_PIN
1037
+
1038
+    /**
1039
+     * USB Host Shield Library
1040
+     *
1041
+     * - UHS2 uses no interrupts and has been production-tested
1042
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1043
+     *
1044
+     * - UHS3 is newer code with better USB compatibility. But it
1045
+     *   is less tested and is known to interfere with Servos.
1046
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1047
+     */
1048
+    //#define USE_UHS3_USB
1035 1049
   #endif
1036 1050
 
1037 1051
   /**

+ 18
- 4
config/examples/AliExpress/UM2pExt/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Anet/A2/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Anet/A2plus/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Anet/A6/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Anet/A8/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Anet/A8plus/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Anet/E16/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/AnyCubic/i3/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/ArmEd/Configuration_adv.h 파일 보기

@@ -1022,17 +1022,31 @@
1022 1022
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1023 1023
    * to Marlin as an SD card.
1024 1024
    *
1025
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1025
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1026 1026
    * the following pin mapping:
1027 1027
    *
1028 1028
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1029
-   *    INT              --> SD_DETECT_PIN
1029
+   *    INT              --> SD_DETECT_PIN [1]
1030 1030
    *    SS               --> SDSS
1031
+   *
1032
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1031 1033
    */
1032 1034
   //#define USB_FLASH_DRIVE_SUPPORT
1033 1035
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1034
-    #define USB_CS_PIN         SDSS
1035
-    #define USB_INTR_PIN       SD_DETECT_PIN
1036
+    #define USB_CS_PIN    SDSS
1037
+    #define USB_INTR_PIN  SD_DETECT_PIN
1038
+
1039
+    /**
1040
+     * USB Host Shield Library
1041
+     *
1042
+     * - UHS2 uses no interrupts and has been production-tested
1043
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1044
+     *
1045
+     * - UHS3 is newer code with better USB compatibility. But it
1046
+     *   is less tested and is known to interfere with Servos.
1047
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1048
+     */
1049
+    //#define USE_UHS3_USB
1036 1050
   #endif
1037 1051
 
1038 1052
   /**

+ 18
- 4
config/examples/BIBO/TouchX/cyclops/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/BIBO/TouchX/default/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/BQ/Hephestos/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/BQ/Hephestos_2/Configuration_adv.h 파일 보기

@@ -1026,17 +1026,31 @@
1026 1026
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1027 1027
    * to Marlin as an SD card.
1028 1028
    *
1029
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1029
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1030 1030
    * the following pin mapping:
1031 1031
    *
1032 1032
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1033
-   *    INT              --> SD_DETECT_PIN
1033
+   *    INT              --> SD_DETECT_PIN [1]
1034 1034
    *    SS               --> SDSS
1035
+   *
1036
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1035 1037
    */
1036 1038
   //#define USB_FLASH_DRIVE_SUPPORT
1037 1039
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1038
-    #define USB_CS_PIN         SDSS
1039
-    #define USB_INTR_PIN       SD_DETECT_PIN
1040
+    #define USB_CS_PIN    SDSS
1041
+    #define USB_INTR_PIN  SD_DETECT_PIN
1042
+
1043
+    /**
1044
+     * USB Host Shield Library
1045
+     *
1046
+     * - UHS2 uses no interrupts and has been production-tested
1047
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1048
+     *
1049
+     * - UHS3 is newer code with better USB compatibility. But it
1050
+     *   is less tested and is known to interfere with Servos.
1051
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1052
+     */
1053
+    //#define USE_UHS3_USB
1040 1054
   #endif
1041 1055
 
1042 1056
   /**

+ 18
- 4
config/examples/BQ/WITBOX/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Cartesio/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Creality/CR-10/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Creality/CR-10S/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Creality/CR-10_5S/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Creality/CR-10mini/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Creality/CR-20 Pro/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Creality/CR-20/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Creality/CR-8/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Creality/Ender-2/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Creality/Ender-3/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Creality/Ender-4/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Creality/Ender-5/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Dagoma/Disco Ultimate/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/EVNOVO (Artillery)/Sidewinder X1/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Einstart-S/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/FYSETC/AIO_II/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/FYSETC/Cheetah 1.2/BLTouch/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/FYSETC/Cheetah 1.2/base/Configuration_adv.h 파일 보기

@@ -1017,17 +1017,31 @@
1017 1017
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1018 1018
    * to Marlin as an SD card.
1019 1019
    *
1020
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1020
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1021 1021
    * the following pin mapping:
1022 1022
    *
1023 1023
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1024
-   *    INT              --> SD_DETECT_PIN
1024
+   *    INT              --> SD_DETECT_PIN [1]
1025 1025
    *    SS               --> SDSS
1026
+   *
1027
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1026 1028
    */
1027 1029
   //#define USB_FLASH_DRIVE_SUPPORT
1028 1030
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1029
-    #define USB_CS_PIN         SDSS
1030
-    #define USB_INTR_PIN       SD_DETECT_PIN
1031
+    #define USB_CS_PIN    SDSS
1032
+    #define USB_INTR_PIN  SD_DETECT_PIN
1033
+
1034
+    /**
1035
+     * USB Host Shield Library
1036
+     *
1037
+     * - UHS2 uses no interrupts and has been production-tested
1038
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1039
+     *
1040
+     * - UHS3 is newer code with better USB compatibility. But it
1041
+     *   is less tested and is known to interfere with Servos.
1042
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1043
+     */
1044
+    //#define USE_UHS3_USB
1031 1045
   #endif
1032 1046
 
1033 1047
   /**

+ 18
- 4
config/examples/FYSETC/Cheetah/BLTouch/Configuration_adv.h 파일 보기

@@ -1017,17 +1017,31 @@
1017 1017
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1018 1018
    * to Marlin as an SD card.
1019 1019
    *
1020
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1020
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1021 1021
    * the following pin mapping:
1022 1022
    *
1023 1023
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1024
-   *    INT              --> SD_DETECT_PIN
1024
+   *    INT              --> SD_DETECT_PIN [1]
1025 1025
    *    SS               --> SDSS
1026
+   *
1027
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1026 1028
    */
1027 1029
   //#define USB_FLASH_DRIVE_SUPPORT
1028 1030
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1029
-    #define USB_CS_PIN         SDSS
1030
-    #define USB_INTR_PIN       SD_DETECT_PIN
1031
+    #define USB_CS_PIN    SDSS
1032
+    #define USB_INTR_PIN  SD_DETECT_PIN
1033
+
1034
+    /**
1035
+     * USB Host Shield Library
1036
+     *
1037
+     * - UHS2 uses no interrupts and has been production-tested
1038
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1039
+     *
1040
+     * - UHS3 is newer code with better USB compatibility. But it
1041
+     *   is less tested and is known to interfere with Servos.
1042
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1043
+     */
1044
+    //#define USE_UHS3_USB
1031 1045
   #endif
1032 1046
 
1033 1047
   /**

+ 18
- 4
config/examples/FYSETC/Cheetah/base/Configuration_adv.h 파일 보기

@@ -1017,17 +1017,31 @@
1017 1017
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1018 1018
    * to Marlin as an SD card.
1019 1019
    *
1020
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1020
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1021 1021
    * the following pin mapping:
1022 1022
    *
1023 1023
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1024
-   *    INT              --> SD_DETECT_PIN
1024
+   *    INT              --> SD_DETECT_PIN [1]
1025 1025
    *    SS               --> SDSS
1026
+   *
1027
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1026 1028
    */
1027 1029
   //#define USB_FLASH_DRIVE_SUPPORT
1028 1030
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1029
-    #define USB_CS_PIN         SDSS
1030
-    #define USB_INTR_PIN       SD_DETECT_PIN
1031
+    #define USB_CS_PIN    SDSS
1032
+    #define USB_INTR_PIN  SD_DETECT_PIN
1033
+
1034
+    /**
1035
+     * USB Host Shield Library
1036
+     *
1037
+     * - UHS2 uses no interrupts and has been production-tested
1038
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1039
+     *
1040
+     * - UHS3 is newer code with better USB compatibility. But it
1041
+     *   is less tested and is known to interfere with Servos.
1042
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1043
+     */
1044
+    //#define USE_UHS3_USB
1031 1045
   #endif
1032 1046
 
1033 1047
   /**

+ 2
- 2
config/examples/FYSETC/F6_13/Configuration_adv.h 파일 보기

@@ -1027,8 +1027,8 @@
1027 1027
    */
1028 1028
   #define USB_FLASH_DRIVE_SUPPORT
1029 1029
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1030
+    #define USB_CS_PIN    SDSS
1031
+    #define USB_INTR_PIN  SD_DETECT_PIN
1032 1032
   #endif
1033 1033
 
1034 1034
   /**

+ 18
- 4
config/examples/Felix/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/FlashForge/CreatorPro/Configuration_adv.h 파일 보기

@@ -1017,17 +1017,31 @@
1017 1017
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1018 1018
    * to Marlin as an SD card.
1019 1019
    *
1020
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1020
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1021 1021
    * the following pin mapping:
1022 1022
    *
1023 1023
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1024
-   *    INT              --> SD_DETECT_PIN
1024
+   *    INT              --> SD_DETECT_PIN [1]
1025 1025
    *    SS               --> SDSS
1026
+   *
1027
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1026 1028
    */
1027 1029
   //#define USB_FLASH_DRIVE_SUPPORT
1028 1030
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1029
-    #define USB_CS_PIN         SDSS
1030
-    #define USB_INTR_PIN       SD_DETECT_PIN
1031
+    #define USB_CS_PIN    SDSS
1032
+    #define USB_INTR_PIN  SD_DETECT_PIN
1033
+
1034
+    /**
1035
+     * USB Host Shield Library
1036
+     *
1037
+     * - UHS2 uses no interrupts and has been production-tested
1038
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1039
+     *
1040
+     * - UHS3 is newer code with better USB compatibility. But it
1041
+     *   is less tested and is known to interfere with Servos.
1042
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1043
+     */
1044
+    //#define USE_UHS3_USB
1031 1045
   #endif
1032 1046
 
1033 1047
   /**

+ 18
- 4
config/examples/FolgerTech/i3-2020/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Formbot/Raptor/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Formbot/T_Rex_2+/Configuration_adv.h 파일 보기

@@ -1022,17 +1022,31 @@
1022 1022
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1023 1023
    * to Marlin as an SD card.
1024 1024
    *
1025
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1025
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1026 1026
    * the following pin mapping:
1027 1027
    *
1028 1028
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1029
-   *    INT              --> SD_DETECT_PIN
1029
+   *    INT              --> SD_DETECT_PIN [1]
1030 1030
    *    SS               --> SDSS
1031
+   *
1032
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1031 1033
    */
1032 1034
   //#define USB_FLASH_DRIVE_SUPPORT
1033 1035
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1034
-    #define USB_CS_PIN         SDSS
1035
-    #define USB_INTR_PIN       SD_DETECT_PIN
1036
+    #define USB_CS_PIN    SDSS
1037
+    #define USB_INTR_PIN  SD_DETECT_PIN
1038
+
1039
+    /**
1040
+     * USB Host Shield Library
1041
+     *
1042
+     * - UHS2 uses no interrupts and has been production-tested
1043
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1044
+     *
1045
+     * - UHS3 is newer code with better USB compatibility. But it
1046
+     *   is less tested and is known to interfere with Servos.
1047
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1048
+     */
1049
+    //#define USE_UHS3_USB
1036 1050
   #endif
1037 1051
 
1038 1052
   /**

+ 18
- 4
config/examples/Formbot/T_Rex_3/Configuration_adv.h 파일 보기

@@ -1022,17 +1022,31 @@
1022 1022
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1023 1023
    * to Marlin as an SD card.
1024 1024
    *
1025
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1025
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1026 1026
    * the following pin mapping:
1027 1027
    *
1028 1028
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1029
-   *    INT              --> SD_DETECT_PIN
1029
+   *    INT              --> SD_DETECT_PIN [1]
1030 1030
    *    SS               --> SDSS
1031
+   *
1032
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1031 1033
    */
1032 1034
   //#define USB_FLASH_DRIVE_SUPPORT
1033 1035
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1034
-    #define USB_CS_PIN         SDSS
1035
-    #define USB_INTR_PIN       SD_DETECT_PIN
1036
+    #define USB_CS_PIN    SDSS
1037
+    #define USB_INTR_PIN  SD_DETECT_PIN
1038
+
1039
+    /**
1040
+     * USB Host Shield Library
1041
+     *
1042
+     * - UHS2 uses no interrupts and has been production-tested
1043
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1044
+     *
1045
+     * - UHS3 is newer code with better USB compatibility. But it
1046
+     *   is less tested and is known to interfere with Servos.
1047
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1048
+     */
1049
+    //#define USE_UHS3_USB
1036 1050
   #endif
1037 1051
 
1038 1052
   /**

+ 18
- 4
config/examples/Geeetech/A10/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Geeetech/A10M/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Geeetech/A20M/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 18
- 4
config/examples/Geeetech/MeCreator2/Configuration_adv.h 파일 보기

@@ -1018,17 +1018,31 @@
1018 1018
    * equivalent MAX3421E breakout board. The USB thumb drive will appear
1019 1019
    * to Marlin as an SD card.
1020 1020
    *
1021
-   * The MAX3421E must be assigned the same pins as the SD card reader, with
1021
+   * The MAX3421E can be assigned the same pins as the SD card reader, with
1022 1022
    * the following pin mapping:
1023 1023
    *
1024 1024
    *    SCLK, MOSI, MISO --> SCLK, MOSI, MISO
1025
-   *    INT              --> SD_DETECT_PIN
1025
+   *    INT              --> SD_DETECT_PIN [1]
1026 1026
    *    SS               --> SDSS
1027
+   *
1028
+   * [1] On AVR an interrupt-capable pin is best for UHS3 compatibility.
1027 1029
    */
1028 1030
   //#define USB_FLASH_DRIVE_SUPPORT
1029 1031
   #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
1030
-    #define USB_CS_PIN         SDSS
1031
-    #define USB_INTR_PIN       SD_DETECT_PIN
1032
+    #define USB_CS_PIN    SDSS
1033
+    #define USB_INTR_PIN  SD_DETECT_PIN
1034
+
1035
+    /**
1036
+     * USB Host Shield Library
1037
+     *
1038
+     * - UHS2 uses no interrupts and has been production-tested
1039
+     *   on a LulzBot TAZ Pro with a 32-bit Archim board.
1040
+     *
1041
+     * - UHS3 is newer code with better USB compatibility. But it
1042
+     *   is less tested and is known to interfere with Servos.
1043
+     *   [1] This requires USB_INTR_PIN to be interrupt-capable.
1044
+     */
1045
+    //#define USE_UHS3_USB
1032 1046
   #endif
1033 1047
 
1034 1048
   /**

+ 0
- 0
config/examples/Geeetech/Prusa i3 Pro C/Configuration_adv.h 파일 보기


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.

Loading…
취소
저장