Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

97 Zeilen
3.2KB

  1. //Copyright 2020 by Warren Watson
  2. // Version 02-Feb-20
  3. //
  4. #include "Arduino.h"
  5. #include "USBHost_t36.h"
  6. USBHost myusb;
  7. USBHub hub1(myusb);
  8. USBHub hub2(myusb);
  9. USBHub hub3(myusb);
  10. USBHub hub4(myusb);
  11. msController msDrive1(myusb);
  12. msController msDrive2(myusb);
  13. // Show USB drive information for the selected USB drive.
  14. int showUSBDriveInfo(msController *drive) {
  15. if(drive == &msDrive1) {
  16. Serial.printf(F("msDrive1 is "));
  17. } else {
  18. Serial.printf(F("msDrive2 is "));
  19. }
  20. if(drive->msDriveInfo.mounted == true) {// check if mounted.
  21. Serial.printf(F("Mounted\n\n"));
  22. } else {
  23. Serial.printf(F("NOT Mounted\n\n"));
  24. }
  25. // Now we will print out the information.
  26. Serial.printf(F(" connected %d\n"),drive->msDriveInfo.connected);
  27. Serial.printf(F(" initialized %d\n"),drive->msDriveInfo.initialized);
  28. Serial.printf(F(" USB Vendor ID: %4.4x\n"),drive->msDriveInfo.idVendor);
  29. Serial.printf(F(" USB Product ID: %4.4x\n"),drive->msDriveInfo.idProduct);
  30. Serial.printf(F(" HUB Number: %d\n"),drive->msDriveInfo.hubNumber);
  31. Serial.printf(F(" HUB Port: %d\n"),drive->msDriveInfo.hubPort);
  32. Serial.printf(F(" Device Address: %d\n"),drive->msDriveInfo.deviceAddress);
  33. Serial.printf(F("Removable Device: "));
  34. if(drive->msDriveInfo.inquiry.Removable == 1)
  35. Serial.printf(F("YES\n"));
  36. else
  37. Serial.printf(F("NO\n"));
  38. Serial.printf(F(" VendorID: %8.8s\n"),drive->msDriveInfo.inquiry.VendorID);
  39. Serial.printf(F(" ProductID: %16.16s\n"),drive->msDriveInfo.inquiry.ProductID);
  40. Serial.printf(F(" RevisionID: %4.4s\n"),drive->msDriveInfo.inquiry.RevisionID);
  41. Serial.printf(F(" Version: %d\n"),drive->msDriveInfo.inquiry.Version);
  42. Serial.printf(F(" Sector Count: %ld\n"),drive->msDriveInfo.capacity.Blocks);
  43. Serial.printf(F(" Sector size: %ld\n"),drive->msDriveInfo.capacity.BlockSize);
  44. Serial.printf(F(" Disk Capacity: %.f Bytes\n\n"),(double_t)drive->msDriveInfo.capacity.Blocks *
  45. (double_t)drive->msDriveInfo.capacity.BlockSize);
  46. return 0;
  47. }
  48. static uint8_t mscError = 0;
  49. void setup() {
  50. while(!Serial);
  51. Serial.printf("\n\nMSC TEST\n\n");
  52. Serial.printf("Initializing USB Drive(s)\n");
  53. myusb.begin();
  54. if(mscError = msDrive1.mscInit())
  55. Serial.printf("msDrive1 not connected: Code: %d\n\n", mscError);
  56. else
  57. Serial.printf("msDrive1 connected\n");
  58. if(mscError = msDrive2.mscInit())
  59. Serial.printf("msDrive2 not connected: Code: %d\n\n", mscError);
  60. else
  61. Serial.printf("msDrive2 connected\n");
  62. }
  63. void loop() {
  64. char op = 0;
  65. Serial.printf(F("\nPress a key to show USB drive info:\n\n"));
  66. while(!Serial.available()) yield();
  67. op = Serial.read();
  68. if(Serial.available()) Serial.read(); // Get rid of CR or LF if there.
  69. // Check if msDrive1 is plugged in and initialized
  70. if((mscError = msDrive1.checkConnectedInitialized()) != MS_INIT_PASS) {
  71. Serial.printf("msDrive1 not connected: Code: %d\n\n", mscError);
  72. } else {
  73. Serial.printf("msDrive1 connected/initilized\n");
  74. showUSBDriveInfo(&msDrive1);
  75. }
  76. // Check if msDrive2 is plugged in and initialized
  77. if((mscError = msDrive2.checkConnectedInitialized()) != MS_INIT_PASS) {
  78. Serial.printf("msDrive2 not connected: Code: %d\n\n", mscError);
  79. } else {
  80. Serial.printf("msDrive2 connected/initilized\n");
  81. showUSBDriveInfo(&msDrive2);
  82. }
  83. }