Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

7 лет назад
7 лет назад
7 лет назад
7 лет назад
7 лет назад
7 лет назад
7 лет назад
7 лет назад
7 лет назад
7 лет назад
7 лет назад
7 лет назад
7 лет назад
7 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* USB EHCI Host for Teensy 3.6
  2. * Copyright 2017 Paul Stoffregen (paul@pjrc.com)
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the
  6. * "Software"), to deal in the Software without restriction, including
  7. * without limitation the rights to use, copy, modify, merge, publish,
  8. * distribute, sublicense, and/or sell copies of the Software, and to
  9. * permit persons to whom the Software is furnished to do so, subject to
  10. * the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included
  13. * in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  16. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  19. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  20. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  21. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #include <Arduino.h>
  24. #include "USBHost_t36.h" // Read this header first for key info
  25. #ifdef USBHOST_PRINT_DEBUG
  26. void USBHost::print(const Transfer_t *transfer)
  27. {
  28. if (!((uint32_t)transfer & 0xFFFFFFE0)) return;
  29. Serial.print("Transfer @ ");
  30. Serial.println(((uint32_t)transfer & 0xFFFFFFE0), HEX);
  31. Serial.print(" next: ");
  32. Serial.println(transfer->qtd.next, HEX);
  33. Serial.print(" anext: ");
  34. Serial.println(transfer->qtd.alt_next, HEX);
  35. Serial.print(" token: ");
  36. Serial.println(transfer->qtd.token, HEX);
  37. Serial.print(" bufs: ");
  38. for (int i=0; i < 5; i++) {
  39. Serial.print(transfer->qtd.buffer[i], HEX);
  40. if (i < 4) Serial.print(',');
  41. }
  42. Serial.println();
  43. }
  44. void USBHost::print(const Transfer_t *first, const Transfer_t *last)
  45. {
  46. Serial.print("Transfer Followup List ");
  47. Serial.print((uint32_t)first, HEX);
  48. Serial.print(" to ");
  49. Serial.println((uint32_t)last, HEX);
  50. Serial.println(" forward:");
  51. while (first) {
  52. Serial.print(" ");
  53. Serial.print((uint32_t)first, HEX);
  54. print_token(first->qtd.token);
  55. first = first->next_followup;
  56. }
  57. Serial.println(" backward:");
  58. while (last) {
  59. Serial.print(" ");
  60. Serial.print((uint32_t)last, HEX);
  61. print_token(last->qtd.token);
  62. last = last->prev_followup;
  63. }
  64. }
  65. void USBHost::print_token(uint32_t token)
  66. {
  67. switch ((token >> 8) & 3) {
  68. case 0:
  69. Serial.print(" OUT ");
  70. Serial.println((token >> 16) & 0x7FFF);
  71. break;
  72. case 1:
  73. Serial.print(" IN ");
  74. Serial.println((token >> 16) & 0x7FFF);
  75. break;
  76. case 2:
  77. Serial.println(" SETUP");
  78. break;
  79. default:
  80. Serial.println(" unknown");
  81. }
  82. }
  83. void USBHost::print(const Pipe_t *pipe)
  84. {
  85. if (!((uint32_t)pipe & 0xFFFFFFE0)) return;
  86. Serial.print("Pipe ");
  87. if (pipe->type == 0) Serial.print("control");
  88. else if (pipe->type == 1) Serial.print("isochronous");
  89. else if (pipe->type == 2) Serial.print("bulk");
  90. else if (pipe->type == 3) Serial.print("interrupt");
  91. Serial.print(pipe->direction ? " IN" : " OUT");
  92. Serial.print(" @ ");
  93. Serial.println((uint32_t)pipe, HEX);
  94. Serial.print(" horiz link: ");
  95. Serial.println(pipe->qh.horizontal_link, HEX);
  96. Serial.print(" capabilities: ");
  97. Serial.print(pipe->qh.capabilities[0], HEX);
  98. Serial.print(',');
  99. Serial.println(pipe->qh.capabilities[1], HEX);
  100. Serial.println(" overlay:");
  101. Serial.print(" cur: ");
  102. Serial.println(pipe->qh.current, HEX);
  103. Serial.print(" next: ");
  104. Serial.println(pipe->qh.next, HEX);
  105. Serial.print(" anext: ");
  106. Serial.println(pipe->qh.alt_next, HEX);
  107. Serial.print(" token: ");
  108. Serial.println(pipe->qh.token, HEX);
  109. Serial.print(" bufs: ");
  110. for (int i=0; i < 5; i++) {
  111. Serial.print(pipe->qh.buffer[i], HEX);
  112. if (i < 4) Serial.print(',');
  113. }
  114. Serial.println();
  115. const Transfer_t *t = (Transfer_t *)pipe->qh.next;
  116. while (((uint32_t)t & 0xFFFFFFE0)) {
  117. print(t);
  118. t = (Transfer_t *)t->qtd.next;
  119. }
  120. //Serial.print();
  121. }
  122. void USBHost::print_driverlist(const char *name, const USBDriver *driver)
  123. {
  124. Serial.print("USBDriver (");
  125. Serial.print(name);
  126. Serial.print(") list: ");
  127. if (driver == NULL) {
  128. Serial.println("(empty");
  129. return;
  130. }
  131. uint32_t count=0;
  132. for (const USBDriver *p = driver; p; p = p->next) {
  133. Serial.print((uint32_t)p, HEX);
  134. if (p->next) Serial.print(" -> ");
  135. if (++count > 30) {
  136. Serial.println("abort:list too long");
  137. return;
  138. }
  139. }
  140. Serial.println();
  141. }
  142. void USBHost::print_qh_list(const Pipe_t *list)
  143. {
  144. if (!list) {
  145. Serial.println("(empty)");
  146. return;
  147. }
  148. const Pipe_t *node = list;
  149. while (1) {
  150. Serial.print((uint32_t)node, HEX);
  151. node = (const Pipe_t *)(node->qh.horizontal_link & 0xFFFFFFE0);
  152. if (!node) break;
  153. if (node == list) {
  154. Serial.print(" (loops)");
  155. break;
  156. }
  157. Serial.print(" -> ");
  158. }
  159. Serial.println();
  160. }
  161. void USBHost::print_hexbytes(const void *ptr, uint32_t len)
  162. {
  163. if (ptr == NULL || len == 0) return;
  164. const uint8_t *p = (const uint8_t *)ptr;
  165. do {
  166. if (*p < 16) Serial.print('0');
  167. Serial.print(*p++, HEX);
  168. Serial.print(' ');
  169. } while (--len);
  170. Serial.println();
  171. }
  172. #endif