diff --git a/Doxyfile b/Doxyfile index cc11cf0d..7cdc79b6 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.3.1 +# Doxyfile 1.8.4 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project @@ -70,9 +70,9 @@ CREATE_SUBDIRS = NO # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. +# messages), Korean, Korean-en, Latvian, Lithuanian, Norwegian, Macedonian, +# Persian, Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, +# Slovak, Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English @@ -262,10 +262,10 @@ EXTENSION_MAPPING = MARKDOWN_SUPPORT = YES -# When enabled doxygen tries to link words that correspond to documented classes, -# or namespaces to their corresponding documentation. Such a link can be -# prevented in individual cases by by putting a % sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by by putting a % sign in front of the word +# or globally by setting AUTOLINK_SUPPORT to NO. AUTOLINK_SUPPORT = YES @@ -321,11 +321,11 @@ SUBGROUPING = YES INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). +# unions with only public data fields or simple typedef fields will be shown +# inline in the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO (the default), structs, classes, and unions are shown on a separate +# page (for HTML and Man pages) or section (for LaTeX and RTF). INLINE_SIMPLE_STRUCTS = NO @@ -339,30 +339,14 @@ INLINE_SIMPLE_STRUCTS = NO TYPEDEF_HIDES_STRUCT = NO -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -SYMBOL_CACHE_SIZE = 0 - -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can +# be an expensive process and often the same symbol appear multiple times in +# the code, doxygen keeps a cache of pre-resolved symbols. If the cache is too +# small doxygen will become slower. If the cache is too large, memory is wasted. +# The cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid +# range is 0..9, the default is 0, corresponding to a cache size of 2^16 = 65536 +# symbols. LOOKUP_CACHE_SIZE = 0 @@ -373,7 +357,7 @@ LOOKUP_CACHE_SIZE = 0 # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES +# the EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES @@ -797,8 +781,10 @@ IMAGE_PATH = # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. +# to standard output. If FILTER_PATTERNS is specified, this tag will be ignored. +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. INPUT_FILTER = @@ -826,9 +812,9 @@ FILTER_SOURCE_FILES = NO FILTER_SOURCE_PATTERNS = # If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page (index.html). -# This can be useful if you have a project on for instance GitHub and want reuse -# the introduction page also for the doxygen output. +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want reuse the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = README.md @@ -887,6 +873,20 @@ USE_HTAGS = NO VERBATIM_HEADERS = YES +# If CLANG_ASSISTED_PARSING is set to YES, then doxygen will use the clang parser +# for more acurate parsing at the cost of reduced performance. This can be +# particularly helpful with template rich C++ code for which doxygen's built-in +# parser lacks the necessairy type information. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified at INPUT and INCLUDE_PATH. + +CLANG_OPTIONS = + #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -972,7 +972,7 @@ HTML_EXTRA_STYLESHEET = imageStyle.css # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that # the files will be copied as-is; there are no commands or markers available. @@ -1241,7 +1241,7 @@ FORMULA_TRANSPARENT = YES USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for -# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and +# the MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and # SVG. The default value is HTML-CSS, which is slower, but has the best # compatibility. @@ -1263,6 +1263,11 @@ MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest MATHJAX_EXTENSIONS = +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript +# pieces of code that will be used on startup of the MathJax code. + +MATHJAX_CODEFILE = + # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using @@ -1288,8 +1293,8 @@ SERVER_BASED_SEARCH = NO # which needs to be processed by an external indexer. Doxygen will invoke an # external search engine pointed to by the SEARCHENGINE_URL option to obtain # the search results. Doxygen ships with an example indexer (doxyindexer) and -# search engine (doxysearch.cgi) which are based on the open source search engine -# library Xapian. See the manual for configuration details. +# search engine (doxysearch.cgi) which are based on the open source search +# engine library Xapian. See the manual for configuration details. EXTERNAL_SEARCH = NO @@ -1360,7 +1365,7 @@ COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. +# executive. If left blank a4 will be used. PAPER_TYPE = a4 @@ -1383,6 +1388,13 @@ LATEX_HEADER = LATEX_FOOTER = +# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images +# or other source files which should be copied to the LaTeX output directory. +# Note that the files will be copied as-is; there are no commands or markers +# available. + +LATEX_EXTRA_FILES = + # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references @@ -1527,6 +1539,21 @@ XML_DTD = XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options related to the DOCBOOK output +#--------------------------------------------------------------------------- + +# If the GENERATE_DOCBOOK tag is set to YES Doxygen will generate DOCBOOK files +# that can be used to generate PDF. + +GENERATE_DOCBOOK = NO + +# The DOCBOOK_OUTPUT tag is used to specify where the DOCBOOK pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in +# front of it. If left blank docbook will be used as the default path. + +DOCBOOK_OUTPUT = docbook + #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- @@ -1675,6 +1702,12 @@ ALLEXTERNALS = NO EXTERNAL_GROUPS = YES +# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed +# in the related pages index. If set to NO, only the current project's +# pages will be listed. + +EXTERNAL_PAGES = YES + # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). @@ -1771,7 +1804,7 @@ UML_LOOK = NO # the class node. If there are many fields or methods and many nodes the # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be +# manageable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 diff --git a/_b_t_d_8cpp_source.html b/_b_t_d_8cpp_source.html index b6a74956..7c23735f 100644 --- a/_b_t_d_8cpp_source.html +++ b/_b_t_d_8cpp_source.html @@ -145,12 +145,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
54  // get memory address of USB device address pool
55  AddressPool &addrPool = pUsb->GetAddressPool();
56 #ifdef EXTRADEBUG
-
57  Notify(PSTR("\r\nBTD Init"), 0x80);
+
57  Notify(PSTR("\r\nBTD Init"), 0x80);
58 #endif
59  // check if address has already been assigned to an instance
60  if (bAddress) {
61 #ifdef DEBUG_USB_HOST
-
62  Notify(PSTR("\r\nAddress in use"), 0x80);
+
62  Notify(PSTR("\r\nAddress in use"), 0x80);
63 #endif
65  }
@@ -160,14 +160,14 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
69 
70  if (!p) {
71 #ifdef DEBUG_USB_HOST
-
72  Notify(PSTR("\r\nAddress not found"), 0x80);
+
72  Notify(PSTR("\r\nAddress not found"), 0x80);
73 #endif
75  }
76 
77  if (!p->epinfo) {
78 #ifdef DEBUG_USB_HOST
-
79  Notify(PSTR("\r\nepinfo is null"), 0x80);
+
79  Notify(PSTR("\r\nepinfo is null"), 0x80);
80 #endif
82  }
@@ -205,14 +205,14 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
114  addrPool.FreeAddress(bAddress);
115  bAddress = 0;
116 #ifdef DEBUG_USB_HOST
-
117  Notify(PSTR("\r\nsetAddr: "), 0x80);
+
117  Notify(PSTR("\r\nsetAddr: "), 0x80);
118 #endif
-
119  PrintHex<uint8_t > (rcode, 0x80);
+
119  D_PrintHex<uint8_t > (rcode, 0x80);
120  return rcode;
121  }
122 #ifdef EXTRADEBUG
-
123  Notify(PSTR("\r\nAddr: "), 0x80);
-
124  PrintHex<uint8_t > (bAddress, 0x80);
+
123  Notify(PSTR("\r\nAddr: "), 0x80);
+
124  D_PrintHex<uint8_t > (bAddress, 0x80);
125 #endif
126  p->lowspeed = false;
127 
@@ -239,16 +239,16 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
148 #ifdef DEBUG_USB_HOST
149  if (PID == PS3_PID || PID == PS3NAVIGATION_PID) {
150  if (PID == PS3_PID)
-
151  Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80);
+
151  Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80);
152  else // It must be a navigation controller
-
153  Notify(PSTR("\r\nNavigation Controller Connected"), 0x80);
+
153  Notify(PSTR("\r\nNavigation Controller Connected"), 0x80);
154  } else // It must be a Motion controller
-
155  Notify(PSTR("\r\nMotion Controller Connected"), 0x80);
+
155  Notify(PSTR("\r\nMotion Controller Connected"), 0x80);
156 #endif
157 
158  if (my_bdaddr[0] == 0x00 && my_bdaddr[1] == 0x00 && my_bdaddr[2] == 0x00 && my_bdaddr[3] == 0x00 && my_bdaddr[4] == 0x00 && my_bdaddr[5] == 0x00) {
159 #ifdef DEBUG_USB_HOST
-
160  Notify(PSTR("\r\nPlease plug in the dongle before trying to pair with the PS3 Controller\n\rOr set the Bluetooth address in the constructor of the PS3BT class"), 0x80);
+
160  Notify(PSTR("\r\nPlease plug in the dongle before trying to pair with the PS3 Controller\n\rOr set the Bluetooth address in the constructor of the PS3BT class"), 0x80);
161 #endif
162  } else {
163  if (PID == PS3_PID || PID == PS3NAVIGATION_PID)
@@ -256,12 +256,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
165  else
166  setMoveBdaddr(my_bdaddr); // Set internal Bluetooth address
167 #ifdef DEBUG_USB_HOST
-
168  Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
+
168  Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
169  for (int8_t i = 5; i > 0; i--) {
-
170  PrintHex<uint8_t > (my_bdaddr[i], 0x80);
-
171  Notify(PSTR(":"), 0x80);
+
170  D_PrintHex<uint8_t > (my_bdaddr[i], 0x80);
+
171  Notify(PSTR(":"), 0x80);
172  }
-
173  PrintHex<uint8_t > (my_bdaddr[0], 0x80);
+
173  D_PrintHex<uint8_t > (my_bdaddr[0], 0x80);
174 #endif
175  }
176 
@@ -306,7 +306,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
215  bPollEnable = true;
216 
217 #ifdef DEBUG_USB_HOST
-
218  Notify(PSTR("\r\nBluetooth Dongle Initialized"), 0x80);
+
218  Notify(PSTR("\r\nBluetooth Dongle Initialized"), 0x80);
219 #endif
220  }
221  return 0; // Successful configuration
@@ -314,38 +314,38 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
223  /* diagnostic messages */
224 FailGetDevDescr:
225 #ifdef DEBUG_USB_HOST
- +
227  goto Fail;
228 #endif
229 
230 FailSetDevTblEntry:
231 #ifdef DEBUG_USB_HOST
- +
233  goto Fail;
234 #endif
235 
236 FailGetConfDescr:
237 #ifdef DEBUG_USB_HOST
- +
239  goto Fail;
240 #endif
241 
242 FailSetConfDescr:
243 #ifdef DEBUG_USB_HOST
- +
245 #endif
246  goto Fail;
247 
248 FailUnknownDevice:
249 #ifdef DEBUG_USB_HOST
-
250  NotifyFailUnknownDevice(VID, PID);
+
250  NotifyFailUnknownDevice(VID, PID);
251 #endif
252  pUsb->setAddr(bAddress, 0, 0); // Reset address
254 Fail:
255 #ifdef DEBUG_USB_HOST
-
256  Notify(PSTR("\r\nBTD Init Failed, error code: "), 0x80);
-
257  NotifyFail(rcode);
+
256  Notify(PSTR("\r\nBTD Init Failed, error code: "), 0x80);
+
257  NotifyFail(rcode);
258 #endif
259  Release();
260  return rcode;
@@ -386,19 +386,19 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
295 
297 #ifdef EXTRADEBUG
-
298  Notify(PSTR("\r\nEndpoint descriptor:"), 0x80);
-
299  Notify(PSTR("\r\nLength:\t\t"), 0x80);
-
300  PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
-
301  Notify(PSTR("\r\nType:\t\t"), 0x80);
-
302  PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
-
303  Notify(PSTR("\r\nAddress:\t"), 0x80);
-
304  PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
-
305  Notify(PSTR("\r\nAttributes:\t"), 0x80);
-
306  PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
-
307  Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
-
308  PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
-
309  Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
-
310  PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
+
298  Notify(PSTR("\r\nEndpoint descriptor:"), 0x80);
+
299  Notify(PSTR("\r\nLength:\t\t"), 0x80);
+
300  D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
+
301  Notify(PSTR("\r\nType:\t\t"), 0x80);
+
302  D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
+
303  Notify(PSTR("\r\nAddress:\t"), 0x80);
+
304  D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
+
305  Notify(PSTR("\r\nAttributes:\t"), 0x80);
+
306  D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
+
307  Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
+
308  D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
+
309  Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
+
310  D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
311 #endif
312 }
313 
@@ -452,12 +452,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
361  case EV_COMMAND_STATUS:
362  if (hcibuf[2]) { // show status on serial if not OK
363 #ifdef DEBUG_USB_HOST
-
364  Notify(PSTR("\r\nHCI Command Failed: "), 0x80);
-
365  PrintHex<uint8_t > (hcibuf[2], 0x80);
-
366  Notify(PSTR(" "), 0x80);
-
367  PrintHex<uint8_t > (hcibuf[4], 0x80);
-
368  Notify(PSTR(" "), 0x80);
-
369  PrintHex<uint8_t > (hcibuf[5], 0x80);
+
364  Notify(PSTR("\r\nHCI Command Failed: "), 0x80);
+
365  D_PrintHex<uint8_t > (hcibuf[2], 0x80);
+
366  Notify(PSTR(" "), 0x80);
+
367  D_PrintHex<uint8_t > (hcibuf[4], 0x80);
+
368  Notify(PSTR(" "), 0x80);
+
369  D_PrintHex<uint8_t > (hcibuf[5], 0x80);
370 #endif
371  }
372  break;
@@ -466,7 +466,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
375  if (inquiry_counter >= 5) {
376  inquiry_counter = 0;
377 #ifdef DEBUG_USB_HOST
-
378  Notify(PSTR("\r\nCouldn't find Wiimote"), 0x80);
+
378  Notify(PSTR("\r\nCouldn't find Wiimote"), 0x80);
379 #endif
380  connectToWii = false;
381  pairWithWii = false;
@@ -478,8 +478,8 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
387  case EV_INQUIRY_RESULT:
388  if (hcibuf[2]) { // Check that there is more than zero responses
389 #ifdef EXTRADEBUG
-
390  Notify(PSTR("\r\nNumber of responses: "), 0x80);
-
391  Notify(hcibuf[2], 0x80);
+
390  Notify(PSTR("\r\nNumber of responses: "), 0x80);
+
391  Notify(hcibuf[2], 0x80);
392 #endif
393  for (uint8_t i = 0; i < hcibuf[2]; i++) {
394  if ((hcibuf[4 + 8 * hcibuf[2] + 3 * i] == 0x04 && hcibuf[5 + 8 * hcibuf[2] + 3 * i] == 0x25 && hcibuf[6 + 8 * hcibuf[2] + 3 * i] == 0x00) || (hcibuf[4 + 8 * hcibuf[2] + 3 * i] == 0x08 && hcibuf[5 + 8 * hcibuf[2] + 3 * i] == 0x05 && hcibuf[6 + 8 * hcibuf[2] + 3 * i] == 0x00)) { // See http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html and http://wiibrew.org/wiki/Wiimote#SDP_information
@@ -498,12 +498,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
407  }
408 #ifdef EXTRADEBUG
409  else {
-
410  Notify(PSTR("\r\nClass of device: "), 0x80);
-
411  PrintHex<uint8_t > (hcibuf[6 + 8 * hcibuf[2] + 3 * i], 0x80);
-
412  Notify(PSTR(" "), 0x80);
-
413  PrintHex<uint8_t > (hcibuf[5 + 8 * hcibuf[2] + 3 * i], 0x80);
-
414  Notify(PSTR(" "), 0x80);
-
415  PrintHex<uint8_t > (hcibuf[4 + 8 * hcibuf[2] + 3 * i], 0x80);
+
410  Notify(PSTR("\r\nClass of device: "), 0x80);
+
411  D_PrintHex<uint8_t > (hcibuf[6 + 8 * hcibuf[2] + 3 * i], 0x80);
+
412  Notify(PSTR(" "), 0x80);
+
413  D_PrintHex<uint8_t > (hcibuf[5 + 8 * hcibuf[2] + 3 * i], 0x80);
+
414  Notify(PSTR(" "), 0x80);
+
415  D_PrintHex<uint8_t > (hcibuf[4 + 8 * hcibuf[2] + 3 * i], 0x80);
416  }
417 #endif
418  }
@@ -518,7 +518,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
427  }
428 #ifdef EXTRADEBUG
429  else {
-
430  Notify(PSTR("\r\nConnection Failed"), 0x80);
+
430  Notify(PSTR("\r\nConnection Failed"), 0x80);
431  hci_state = HCI_CHECK_WII_SERVICE;
432  }
433 #endif
@@ -547,12 +547,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
456  disc_bdaddr[4] = hcibuf[6];
457  disc_bdaddr[5] = hcibuf[7];
458 #ifdef EXTRADEBUG
-
459  Notify(PSTR("\r\nClass of device: "), 0x80);
-
460  PrintHex<uint8_t > (hcibuf[10], 0x80);
-
461  Notify(PSTR(" "), 0x80);
-
462  PrintHex<uint8_t > (hcibuf[9], 0x80);
-
463  Notify(PSTR(" "), 0x80);
-
464  PrintHex<uint8_t > (hcibuf[8], 0x80);
+
459  Notify(PSTR("\r\nClass of device: "), 0x80);
+
460  D_PrintHex<uint8_t > (hcibuf[10], 0x80);
+
461  Notify(PSTR(" "), 0x80);
+
462  D_PrintHex<uint8_t > (hcibuf[9], 0x80);
+
463  Notify(PSTR(" "), 0x80);
+
464  D_PrintHex<uint8_t > (hcibuf[8], 0x80);
465 #endif
466  hci_event_flag |= HCI_FLAG_INCOMING_REQUEST;
467  break;
@@ -560,18 +560,18 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
469  case EV_PIN_CODE_REQUEST:
470  if (pairWithWii) {
471 #ifdef DEBUG_USB_HOST
-
472  Notify(PSTR("\r\nPairing with wiimote"), 0x80);
+
472  Notify(PSTR("\r\nPairing with wiimote"), 0x80);
473 #endif
475  } else if (btdPin != NULL) {
476 #ifdef DEBUG_USB_HOST
-
477  Notify(PSTR("\r\nBluetooth pin is set too: "), 0x80);
-
478  NotifyStr(btdPin, 0x80);
+
477  Notify(PSTR("\r\nBluetooth pin is set too: "), 0x80);
+
478  NotifyStr(btdPin, 0x80);
479 #endif
481  } else {
482 #ifdef DEBUG_USB_HOST
-
483  Notify(PSTR("\r\nNo pin was set"), 0x80);
+
483  Notify(PSTR("\r\nNo pin was set"), 0x80);
484 #endif
486  }
@@ -579,7 +579,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
488 
489  case EV_LINK_KEY_REQUEST:
490 #ifdef DEBUG_USB_HOST
-
491  Notify(PSTR("\r\nReceived Key Request"), 0x80);
+
491  Notify(PSTR("\r\nReceived Key Request"), 0x80);
492 #endif
494  break;
@@ -587,7 +587,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
497  if (pairWithWii && !connectToWii) {
498 #ifdef DEBUG_USB_HOST
-
499  Notify(PSTR("\r\nPairing successful"), 0x80);
+
499  Notify(PSTR("\r\nPairing successful"), 0x80);
500 #endif
501  connectToWii = true; // Only send the ACL data to the Wii service
502  }
@@ -608,8 +608,8 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
517 #ifdef EXTRADEBUG
518  default:
519  if (hcibuf[0] != 0x00) {
-
520  Notify(PSTR("\r\nUnmanaged HCI Event: "), 0x80);
-
521  PrintHex<uint8_t > (hcibuf[0], 0x80);
+
520  Notify(PSTR("\r\nUnmanaged HCI Event: "), 0x80);
+
521  D_PrintHex<uint8_t > (hcibuf[0], 0x80);
522  }
523  break;
524 #endif
@@ -617,8 +617,8 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
526  }
527 #ifdef EXTRADEBUG
528  else if (rcode != hrNAK) {
-
529  Notify(PSTR("\r\nHCI event error: "), 0x80);
-
530  PrintHex<uint8_t > (rcode, 0x80);
+
529  Notify(PSTR("\r\nHCI event error: "), 0x80);
+
530  D_PrintHex<uint8_t > (rcode, 0x80);
531  }
532 #endif
533  HCI_task();
@@ -641,7 +641,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
550  if (hci_cmd_complete) {
551  hci_counter = 0;
552 #ifdef DEBUG_USB_HOST
-
553  Notify(PSTR("\r\nHCI Reset complete"), 0x80);
+
553  Notify(PSTR("\r\nHCI Reset complete"), 0x80);
554 #endif
555  hci_state = HCI_CLASS_STATE;
@@ -650,7 +650,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
559  if (hci_num_reset_loops > 2000)
560  hci_num_reset_loops = 2000;
561 #ifdef DEBUG_USB_HOST
-
562  Notify(PSTR("\r\nNo response to HCI Reset"), 0x80);
+
562  Notify(PSTR("\r\nNo response to HCI Reset"), 0x80);
563 #endif
564  hci_state = HCI_INIT_STATE;
565  hci_counter = 0;
@@ -660,7 +660,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
569  case HCI_CLASS_STATE:
570  if (hci_cmd_complete) {
571 #ifdef DEBUG_USB_HOST
-
572  Notify(PSTR("\r\nWrite class of device"), 0x80);
+
572  Notify(PSTR("\r\nWrite class of device"), 0x80);
573 #endif
574  hci_state = HCI_BDADDR_STATE;
575  hci_read_bdaddr();
@@ -670,12 +670,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
579  case HCI_BDADDR_STATE:
581 #ifdef DEBUG_USB_HOST
-
582  Notify(PSTR("\r\nLocal Bluetooth Address: "), 0x80);
+
582  Notify(PSTR("\r\nLocal Bluetooth Address: "), 0x80);
583  for (int8_t i = 5; i > 0; i--) {
-
584  PrintHex<uint8_t > (my_bdaddr[i], 0x80);
-
585  Notify(PSTR(":"), 0x80);
+
584  D_PrintHex<uint8_t > (my_bdaddr[i], 0x80);
+
585  Notify(PSTR(":"), 0x80);
586  }
-
587  PrintHex<uint8_t > (my_bdaddr[0], 0x80);
+
587  D_PrintHex<uint8_t > (my_bdaddr[0], 0x80);
588 #endif
590  hci_state = HCI_LOCAL_VERSION_STATE;
@@ -695,8 +695,8 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
604  case HCI_SET_NAME_STATE:
605  if (hci_cmd_complete) {
606 #ifdef DEBUG_USB_HOST
-
607  Notify(PSTR("\r\nThe name is set to: "), 0x80);
-
608  NotifyStr(btdName, 0x80);
+
607  Notify(PSTR("\r\nThe name is set to: "), 0x80);
+
608  NotifyStr(btdName, 0x80);
609 #endif
610  hci_state = HCI_CHECK_WII_SERVICE;
611  }
@@ -705,7 +705,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
615  if (pairWithWii) { // Check if it should try to connect to a wiimote
616 #ifdef DEBUG_USB_HOST
-
617  Notify(PSTR("\r\nStarting inquiry\r\nPress 1 & 2 on the Wiimote\r\nOr press sync if you are using a Wii U Pro Controller"), 0x80);
+
617  Notify(PSTR("\r\nStarting inquiry\r\nPress 1 & 2 on the Wiimote\r\nOr press sync if you are using a Wii U Pro Controller"), 0x80);
618 #endif
619  hci_inquiry();
620  hci_state = HCI_INQUIRY_STATE;
@@ -717,10 +717,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
626  if (hci_wii_found) {
627  hci_inquiry_cancel(); // Stop inquiry
628 #ifdef DEBUG_USB_HOST
-
629  Notify(PSTR("\r\nWiimote found"), 0x80);
-
630  Notify(PSTR("\r\nNow just create the instance like so:"), 0x80);
-
631  Notify(PSTR("\r\nWII Wii(&Btd);"), 0x80);
-
632  Notify(PSTR("\r\nAnd then press any button on the Wiimote"), 0x80);
+
629  Notify(PSTR("\r\nWiimote found"), 0x80);
+
630  Notify(PSTR("\r\nNow just create the instance like so:"), 0x80);
+
631  Notify(PSTR("\r\nWII Wii(&Btd);"), 0x80);
+
632  Notify(PSTR("\r\nAnd then press any button on the Wiimote"), 0x80);
633 #endif
634  if (motionPlusInside) {
635  hci_remote_name(); // We need to know the name to distinguish between a Wiimote and a Wii U Pro Controller
@@ -733,7 +733,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
643  if (hci_cmd_complete) {
644 #ifdef DEBUG_USB_HOST
-
645  Notify(PSTR("\r\nConnecting to Wiimote"), 0x80);
+
645  Notify(PSTR("\r\nConnecting to Wiimote"), 0x80);
646 #endif
647  hci_connect();
648  hci_state = HCI_CONNECTED_WII_STATE;
@@ -744,13 +744,13 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
653  if (hci_connect_event) {
654  if (hci_connect_complete) {
655 #ifdef DEBUG_USB_HOST
-
656  Notify(PSTR("\r\nConnected to Wiimote"), 0x80);
+
656  Notify(PSTR("\r\nConnected to Wiimote"), 0x80);
657 #endif
658  hci_authentication_request(); // This will start the pairing with the wiimote
659  hci_state = HCI_SCANNING_STATE;
660  } else {
661 #ifdef DEBUG_USB_HOST
-
662  Notify(PSTR("\r\nTrying to connect one more time..."), 0x80);
+
662  Notify(PSTR("\r\nTrying to connect one more time..."), 0x80);
663 #endif
664  hci_connect(); // Try to connect one more time
665  }
@@ -760,7 +760,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
669  case HCI_SCANNING_STATE:
670  if (!connectToWii && !pairWithWii) {
671 #ifdef DEBUG_USB_HOST
-
672  Notify(PSTR("\r\nWait For Incoming Connection Request"), 0x80);
+
672  Notify(PSTR("\r\nWait For Incoming Connection Request"), 0x80);
673 #endif
675  watingForConnection = true;
@@ -772,7 +772,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
682  watingForConnection = false;
683 #ifdef DEBUG_USB_HOST
-
684  Notify(PSTR("\r\nIncoming Connection Request"), 0x80);
+
684  Notify(PSTR("\r\nIncoming Connection Request"), 0x80);
685 #endif
686  hci_remote_name();
687  hci_state = HCI_REMOTE_NAME_STATE;
@@ -783,26 +783,26 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
694 #ifdef DEBUG_USB_HOST
-
695  Notify(PSTR("\r\nRemote Name: "), 0x80);
+
695  Notify(PSTR("\r\nRemote Name: "), 0x80);
696  for (uint8_t i = 0; i < 30; i++) {
697  if (remote_name[i] == NULL)
698  break;
-
699  Notifyc(remote_name[i], 0x80);
+
699  Notifyc(remote_name[i], 0x80);
700  }
701 #endif
702  if (strncmp((const char*)remote_name, "Nintendo", 8) == 0) {
703  incomingWii = true;
704 #ifdef DEBUG_USB_HOST
-
705  Notify(PSTR("\r\nWiimote is connecting"), 0x80);
+
705  Notify(PSTR("\r\nWiimote is connecting"), 0x80);
706 #endif
707  if (strncmp((const char*)remote_name, "Nintendo RVL-CNT-01-TR", 22) == 0) {
708 #ifdef DEBUG_USB_HOST
-
709  Notify(PSTR(" with Motion Plus Inside"), 0x80);
+
709  Notify(PSTR(" with Motion Plus Inside"), 0x80);
710 #endif
711  motionPlusInside = true;
712  } else if (strncmp((const char*)remote_name, "Nintendo RVL-CNT-01-UC", 22) == 0) {
713 #ifdef DEBUG_USB_HOST
-
714  Notify(PSTR(" - Wii U Pro Controller"), 0x80);
+
714  Notify(PSTR(" - Wii U Pro Controller"), 0x80);
715 #endif
716  motionPlusInside = true;
717  wiiUProController = true;
@@ -823,12 +823,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
732  case HCI_CONNECTED_STATE:
733  if (hci_connect_complete) {
734 #ifdef DEBUG_USB_HOST
-
735  Notify(PSTR("\r\nConnected to Device: "), 0x80);
+
735  Notify(PSTR("\r\nConnected to Device: "), 0x80);
736  for (int8_t i = 5; i > 0; i--) {
-
737  PrintHex<uint8_t > (disc_bdaddr[i], 0x80);
-
738  Notify(PSTR(":"), 0x80);
+
737  D_PrintHex<uint8_t > (disc_bdaddr[i], 0x80);
+
738  Notify(PSTR(":"), 0x80);
739  }
-
740  PrintHex<uint8_t > (disc_bdaddr[0], 0x80);
+
740  D_PrintHex<uint8_t > (disc_bdaddr[0], 0x80);
741 #endif
742  // Clear these flags for a new connection
743  l2capConnectionClaimed = false;
@@ -851,7 +851,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
762 #ifdef DEBUG_USB_HOST
-
763  Notify(PSTR("\r\nHCI Disconnected from Device"), 0x80);
+
763  Notify(PSTR("\r\nHCI Disconnected from Device"), 0x80);
764 #endif
765  hci_event_flag = 0; // Clear all flags
766 
@@ -879,8 +879,8 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
788  }
789 #ifdef EXTRADEBUG
790  else if (rcode != hrNAK) {
-
791  Notify(PSTR("\r\nACL data in error: "), 0x80);
-
792  PrintHex<uint8_t > (rcode, 0x80);
+
791  Notify(PSTR("\r\nACL data in error: "), 0x80);
+
792  D_PrintHex<uint8_t > (rcode, 0x80);
793  }
794 #endif
795  for (uint8_t i = 0; i < BTD_NUMSERVICES; i++)
@@ -1049,7 +1049,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
958  hcibuf[9] = 6; // Pin length is the length of the Bluetooth address
959  if (wiiUProController) {
960 #ifdef DEBUG_USB_HOST
-
961  Notify(PSTR("\r\nParing with Wii U Pro Controller"), 0x80);
+
961  Notify(PSTR("\r\nParing with Wii U Pro Controller"), 0x80);
962 #endif
963  for (uint8_t i = 0; i < 6; i++)
964  hcibuf[10 + i] = my_bdaddr[i]; // The pin is the Bluetooth dongles Bluetooth address backwards
@@ -1175,12 +1175,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
1084  if (rcode) {
1085  delay(100); // This small delay prevents it from overflowing if it fails
1086 #ifdef DEBUG_USB_HOST
-
1087  Notify(PSTR("\r\nError sending L2CAP message: 0x"), 0x80);
-
1088  PrintHex<uint8_t > (rcode, 0x80);
-
1089  Notify(PSTR(" - Channel ID: "), 0x80);
-
1090  PrintHex<uint8_t > (channelHigh, 0x80);
-
1091  Notify(PSTR(" "), 0x80);
-
1092  PrintHex<uint8_t > (channelLow, 0x80);
+
1087  Notify(PSTR("\r\nError sending L2CAP message: 0x"), 0x80);
+
1088  D_PrintHex<uint8_t > (rcode, 0x80);
+
1089  Notify(PSTR(" - Channel ID: "), 0x80);
+
1090  D_PrintHex<uint8_t > (channelHigh, 0x80);
+
1091  Notify(PSTR(" "), 0x80);
+
1092  D_PrintHex<uint8_t > (channelLow, 0x80);
1093 #endif
1094  }
1095 }
diff --git a/_p_s3_b_t_8cpp_source.html b/_p_s3_b_t_8cpp_source.html index b6239ae1..c9cd3925 100644 --- a/_p_s3_b_t_8cpp_source.html +++ b/_p_s3_b_t_8cpp_source.html @@ -346,11 +346,11 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
255  l2cap_state = L2CAP_WAIT;
256  for (uint8_t i = 0; i < 30; i++)
257  remote_name[i] = pBtd->remote_name[i]; // Store the remote name for the connection
-
258 #ifdef DEBUG_USB_HOST
+
258 #ifdef DEBUG_USB_HOST
259  if (pBtd->hci_version < 3) { // Check the HCI Version of the Bluetooth dongle
-
260  Notify(PSTR("\r\nYour dongle may not support reading the analog buttons, sensors and status\r\nYour HCI Version is: "), 0x80);
-
261  Notify(pBtd->hci_version, 0x80);
-
262  Notify(PSTR("\r\nBut should be at least 3\r\nThis means that it doesn't support Bluetooth Version 2.0+EDR"), 0x80);
+
260  Notify(PSTR("\r\nYour dongle may not support reading the analog buttons, sensors and status\r\nYour HCI Version is: "), 0x80);
+
261  Notify(pBtd->hci_version, 0x80);
+
262  Notify(PSTR("\r\nBut should be at least 3\r\nThis means that it doesn't support Bluetooth Version 2.0+EDR"), 0x80);
263  }
264 #endif
265  }
@@ -362,31 +362,31 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
271  if ((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001) { //l2cap_control - Channel ID for ACL-U
272  if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
273 #ifdef DEBUG_USB_HOST
-
274  Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
-
275  PrintHex<uint8_t > (l2capinbuf[13], 0x80);
-
276  Notify(PSTR(" "), 0x80);
-
277  PrintHex<uint8_t > (l2capinbuf[12], 0x80);
-
278  Notify(PSTR(" Data: "), 0x80);
-
279  PrintHex<uint8_t > (l2capinbuf[17], 0x80);
-
280  Notify(PSTR(" "), 0x80);
-
281  PrintHex<uint8_t > (l2capinbuf[16], 0x80);
-
282  Notify(PSTR(" "), 0x80);
-
283  PrintHex<uint8_t > (l2capinbuf[15], 0x80);
-
284  Notify(PSTR(" "), 0x80);
-
285  PrintHex<uint8_t > (l2capinbuf[14], 0x80);
+
274  Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
+
275  D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
+
276  Notify(PSTR(" "), 0x80);
+
277  D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
+
278  Notify(PSTR(" Data: "), 0x80);
+
279  D_PrintHex<uint8_t > (l2capinbuf[17], 0x80);
+
280  Notify(PSTR(" "), 0x80);
+
281  D_PrintHex<uint8_t > (l2capinbuf[16], 0x80);
+
282  Notify(PSTR(" "), 0x80);
+
283  D_PrintHex<uint8_t > (l2capinbuf[15], 0x80);
+
284  Notify(PSTR(" "), 0x80);
+
285  D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
286 #endif
287  } else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
288 #ifdef EXTRADEBUG
-
289  Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80);
-
290  PrintHex<uint8_t > (l2capinbuf[13], 0x80);
-
291  Notify(PSTR(" "), 0x80);
-
292  PrintHex<uint8_t > (l2capinbuf[12], 0x80);
-
293  Notify(PSTR(" SCID: "), 0x80);
-
294  PrintHex<uint8_t > (l2capinbuf[15], 0x80);
-
295  Notify(PSTR(" "), 0x80);
-
296  PrintHex<uint8_t > (l2capinbuf[14], 0x80);
-
297  Notify(PSTR(" Identifier: "), 0x80);
-
298  PrintHex<uint8_t > (l2capinbuf[9], 0x80);
+
289  Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80);
+
290  D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
+
291  Notify(PSTR(" "), 0x80);
+
292  D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
+
293  Notify(PSTR(" SCID: "), 0x80);
+
294  D_PrintHex<uint8_t > (l2capinbuf[15], 0x80);
+
295  Notify(PSTR(" "), 0x80);
+
296  D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
+
297  Notify(PSTR(" Identifier: "), 0x80);
+
298  D_PrintHex<uint8_t > (l2capinbuf[9], 0x80);
299 #endif
300  if ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_CTRL_PSM) {
301  identifier = l2capinbuf[9];
@@ -422,14 +422,14 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
331  } else if (l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) {
332  if (l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) {
333 #ifdef DEBUG_USB_HOST
-
334  Notify(PSTR("\r\nDisconnect Request: Control Channel"), 0x80);
+
334  Notify(PSTR("\r\nDisconnect Request: Control Channel"), 0x80);
335 #endif
336  identifier = l2capinbuf[9];
337  pBtd->l2cap_disconnection_response(hci_handle, identifier, control_dcid, control_scid);
338  Reset();
339  } else if (l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) {
340 #ifdef DEBUG_USB_HOST
-
341  Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"), 0x80);
+
341  Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"), 0x80);
342 #endif
343  identifier = l2capinbuf[9];
344  pBtd->l2cap_disconnection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid);
@@ -448,8 +448,8 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
357  }
358 #ifdef EXTRADEBUG
359  else {
-
360  Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80);
-
361  PrintHex<uint8_t > (l2capinbuf[8], 0x80);
+
360  Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80);
+
361  D_PrintHex<uint8_t > (l2capinbuf[8], 0x80);
362  }
363 #endif
364  } else if (l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) { // l2cap_interrupt
@@ -472,10 +472,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
381 
382 #ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers
383  for (uint8_t i = 10; i < 58; i++) {
-
384  PrintHex<uint8_t > (l2capinbuf[i], 0x80);
-
385  Notify(PSTR(" "), 0x80);
+
384  D_PrintHex<uint8_t > (l2capinbuf[i], 0x80);
+
385  Notify(PSTR(" "), 0x80);
386  }
-
387  Notify(PSTR("\r\n"), 0x80);
+
387  Notify(PSTR("\r\n"), 0x80);
388 #endif
389  }
390  }
@@ -489,7 +489,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
398  case L2CAP_WAIT:
400 #ifdef DEBUG_USB_HOST
-
401  Notify(PSTR("\r\nHID Control Incoming Connection Request"), 0x80);
+
401  Notify(PSTR("\r\nHID Control Incoming Connection Request"), 0x80);
402 #endif
403  pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, PENDING);
404  delay(1);
@@ -503,7 +503,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
414 #ifdef DEBUG_USB_HOST
-
415  Notify(PSTR("\r\nHID Control Configuration Request"), 0x80);
+
415  Notify(PSTR("\r\nHID Control Configuration Request"), 0x80);
416 #endif
417  pBtd->l2cap_config_response(hci_handle, identifier, control_scid);
418  l2cap_state = L2CAP_CONTROL_SUCCESS;
@@ -513,7 +513,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
424 #ifdef DEBUG_USB_HOST
-
425  Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80);
+
425  Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80);
426 #endif
427  l2cap_state = L2CAP_INTERRUPT_SETUP;
428  }
@@ -521,7 +521,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
432 #ifdef DEBUG_USB_HOST
-
433  Notify(PSTR("\r\nHID Interrupt Incoming Connection Request"), 0x80);
+
433  Notify(PSTR("\r\nHID Interrupt Incoming Connection Request"), 0x80);
434 #endif
435  pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, PENDING);
436  delay(1);
@@ -536,7 +536,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
447 #ifdef DEBUG_USB_HOST
-
448  Notify(PSTR("\r\nHID Interrupt Configuration Request"), 0x80);
+
448  Notify(PSTR("\r\nHID Interrupt Configuration Request"), 0x80);
449 #endif
450  pBtd->l2cap_config_response(hci_handle, identifier, interrupt_scid);
451  l2cap_state = L2CAP_INTERRUPT_SUCCESS;
@@ -545,7 +545,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
456 #ifdef DEBUG_USB_HOST
-
457  Notify(PSTR("\r\nHID Interrupt Successfully Configured"), 0x80);
+
457  Notify(PSTR("\r\nHID Interrupt Successfully Configured"), 0x80);
458 #endif
459  if (remote_name[0] == 'M') { // First letter in Motion Controller ('M')
460  for (uint8_t i = 0; i < BULK_MAXPKTSIZE; i++) // Reset l2cap in buffer as it sometimes read it as a button has been pressed
@@ -565,7 +565,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
476 #ifdef DEBUG_USB_HOST
-
477  Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80);
+
477  Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80);
478 #endif
479  identifier++;
480  pBtd->l2cap_disconnection_request(hci_handle, identifier, control_scid, control_dcid);
@@ -576,7 +576,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
487 #ifdef DEBUG_USB_HOST
-
488  Notify(PSTR("\r\nDisconnected Control Channel"), 0x80);
+
488  Notify(PSTR("\r\nDisconnected Control Channel"), 0x80);
489 #endif
490  pBtd->hci_disconnect(hci_handle);
491  hci_handle = -1; // Reset handle
@@ -609,20 +609,20 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
518  if (remote_name[0] == 'P') { // First letter in PLAYSTATION(R)3 Controller ('P')
519  setLedOn(LED1);
520 #ifdef DEBUG_USB_HOST
-
521  Notify(PSTR("\r\nDualshock 3 Controller Enabled\r\n"), 0x80);
+
521  Notify(PSTR("\r\nDualshock 3 Controller Enabled\r\n"), 0x80);
522 #endif
523  PS3Connected = true;
524  } else if (remote_name[0] == 'N') { // First letter in Navigation Controller ('N')
525  setLedOn(LED1); // This just turns LED constantly on, on the Navigation controller
526 #ifdef DEBUG_USB_HOST
-
527  Notify(PSTR("\r\nNavigation Controller Enabled\r\n"), 0x80);
+
527  Notify(PSTR("\r\nNavigation Controller Enabled\r\n"), 0x80);
528 #endif
529  PS3NavigationConnected = true;
530  } else if (remote_name[0] == 'M') { // First letter in Motion Controller ('M')
531  moveSetBulb(Red);
532  timerBulbRumble = millis();
533 #ifdef DEBUG_USB_HOST
-
534  Notify(PSTR("\r\nMotion Controller Enabled\r\n"), 0x80);
+
534  Notify(PSTR("\r\nMotion Controller Enabled\r\n"), 0x80);
535 #endif
536  PS3MoveConnected = true;
537  }
@@ -743,7 +743,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
652 void PS3BT::moveSetRumble(uint8_t rumble) {
653 #ifdef DEBUG_USB_HOST
654  if (rumble < 64 && rumble != 0) // The rumble value has to at least 64, or approximately 25% (64/255*100)
-
655  Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80);
+
655  Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80);
656 #endif
657  //set the rumble value into the write buffer
658  HIDMoveBuffer[7] = rumble;
diff --git a/_p_s3_u_s_b_8cpp_source.html b/_p_s3_u_s_b_8cpp_source.html index d63e3e0d..031cc00b 100644 --- a/_p_s3_u_s_b_8cpp_source.html +++ b/_p_s3_u_s_b_8cpp_source.html @@ -145,12 +145,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
54  // get memory address of USB device address pool
55  AddressPool &addrPool = pUsb->GetAddressPool();
56 #ifdef EXTRADEBUG
-
57  Notify(PSTR("\r\nPS3USB Init"), 0x80);
+
57  Notify(PSTR("\r\nPS3USB Init"), 0x80);
58 #endif
59  // check if address has already been assigned to an instance
60  if (bAddress) {
61 #ifdef DEBUG_USB_HOST
-
62  Notify(PSTR("\r\nAddress in use"), 0x80);
+
62  Notify(PSTR("\r\nAddress in use"), 0x80);
63 #endif
65  }
@@ -160,14 +160,14 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
69 
70  if (!p) {
71 #ifdef DEBUG_USB_HOST
-
72  Notify(PSTR("\r\nAddress not found"), 0x80);
+
72  Notify(PSTR("\r\nAddress not found"), 0x80);
73 #endif
75  }
76 
77  if (!p->epinfo) {
78 #ifdef DEBUG_USB_HOST
-
79  Notify(PSTR("\r\nepinfo is null"), 0x80);
+
79  Notify(PSTR("\r\nepinfo is null"), 0x80);
80 #endif
82  }
@@ -210,14 +210,14 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
119  addrPool.FreeAddress(bAddress);
120  bAddress = 0;
121 #ifdef DEBUG_USB_HOST
-
122  Notify(PSTR("\r\nsetAddr: "), 0x80);
+
122  Notify(PSTR("\r\nsetAddr: "), 0x80);
123 #endif
-
124  PrintHex<uint8_t > (rcode, 0x80);
+
124  D_PrintHex<uint8_t > (rcode, 0x80);
125  return rcode;
126  }
127 #ifdef EXTRADEBUG
-
128  Notify(PSTR("\r\nAddr: "), 0x80);
-
129  PrintHex<uint8_t > (bAddress, 0x80);
+
128  Notify(PSTR("\r\nAddr: "), 0x80);
+
129  D_PrintHex<uint8_t > (bAddress, 0x80);
130 #endif
131  p->lowspeed = false;
132 
@@ -265,12 +265,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
174  if (PID == PS3_PID || PID == PS3NAVIGATION_PID) {
175  if (PID == PS3_PID) {
176 #ifdef DEBUG_USB_HOST
-
177  Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80);
+
177  Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80);
178 #endif
179  PS3Connected = true;
180  } else { // must be a navigation controller
181 #ifdef DEBUG_USB_HOST
-
182  Notify(PSTR("\r\nNavigation Controller Connected"), 0x80);
+
182  Notify(PSTR("\r\nNavigation Controller Connected"), 0x80);
183 #endif
184  PS3NavigationConnected = true;
185  }
@@ -287,7 +287,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
196  readBuf[i] = 0x7F; // Set the analog joystick values to center position
197  } else { // must be a Motion controller
198 #ifdef DEBUG_USB_HOST
-
199  Notify(PSTR("\r\nMotion Controller Connected"), 0x80);
+
199  Notify(PSTR("\r\nMotion Controller Connected"), 0x80);
200 #endif
201  PS3MoveConnected = true;
202  setMoveBdaddr(my_bdaddr); // Set internal bluetooth address
@@ -297,46 +297,46 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
206  }
207 
208 #ifdef DEBUG_USB_HOST
-
209  Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
+
209  Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
210  for (int8_t i = 5; i > 0; i--) {
-
211  PrintHex<uint8_t > (my_bdaddr[i], 0x80);
-
212  Notify(PSTR(":"), 0x80);
+
211  D_PrintHex<uint8_t > (my_bdaddr[i], 0x80);
+
212  Notify(PSTR(":"), 0x80);
213  }
-
214  PrintHex<uint8_t > (my_bdaddr[0], 0x80);
+
214  D_PrintHex<uint8_t > (my_bdaddr[0], 0x80);
215 #endif
216 
217  bPollEnable = true;
-
218  Notify(PSTR("\r\n"), 0x80);
+
218  Notify(PSTR("\r\n"), 0x80);
219  timer = millis();
220  return 0; // successful configuration
221 
222  /* diagnostic messages */
223 FailGetDevDescr:
224 #ifdef DEBUG_USB_HOST
- +
226  goto Fail;
227 #endif
228 FailSetDevTblEntry:
229 #ifdef DEBUG_USB_HOST
- +
231  goto Fail;
232 #endif
233 
234 FailSetConfDescr:
235 #ifdef DEBUG_USB_HOST
- +
237 #endif
238  goto Fail;
239 FailUnknownDevice:
240 #ifdef DEBUG_USB_HOST
-
241  NotifyFailUnknownDevice(VID, PID);
+
241  NotifyFailUnknownDevice(VID, PID);
242 #endif
244 Fail:
245 
246 #ifdef DEBUG_USB_HOST
-
247  Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
-
248  NotifyFail(rcode);
+
247  Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
+
248  NotifyFail(rcode);
249 #endif
250  Release();
251  return rcode;
@@ -396,10 +396,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
305  if (readBuf == NULL)
306  return;
307  for (uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++) {
-
308  PrintHex<uint8_t > (readBuf[i], 0x80);
-
309  Notify(PSTR(" "), 0x80);
+
308  D_PrintHex<uint8_t > (readBuf[i], 0x80);
+
309  Notify(PSTR(" "), 0x80);
310  }
-
311  Notify(PSTR("\r\n"), 0x80);
+
311  Notify(PSTR("\r\n"), 0x80);
312 #endif
313 }
314 
@@ -606,7 +606,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
515 void PS3USB::moveSetRumble(uint8_t rumble) {
516 #ifdef DEBUG_USB_HOST
517  if (rumble < 64 && rumble != 0) // The rumble value has to at least 64, or approximately 25% (64/255*100)
-
518  Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80);
+
518  Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80);
519 #endif
520  //set the rumble value into the write buffer
521  writeBuf[6] = rumble;
diff --git a/_s_p_p_8cpp_source.html b/_s_p_p_8cpp_source.html index e0fff753..c84a30c1 100644 --- a/_s_p_p_8cpp_source.html +++ b/_s_p_p_8cpp_source.html @@ -191,31 +191,31 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
100  if ((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001) { //l2cap_control - Channel ID for ACL-U
101  if (l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
102 #ifdef DEBUG_USB_HOST
-
103  Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
-
104  PrintHex<uint8_t > (l2capinbuf[13], 0x80);
-
105  Notify(PSTR(" "), 0x80);
-
106  PrintHex<uint8_t > (l2capinbuf[12], 0x80);
-
107  Notify(PSTR(" Data: "), 0x80);
-
108  PrintHex<uint8_t > (l2capinbuf[17], 0x80);
-
109  Notify(PSTR(" "), 0x80);
-
110  PrintHex<uint8_t > (l2capinbuf[16], 0x80);
-
111  Notify(PSTR(" "), 0x80);
-
112  PrintHex<uint8_t > (l2capinbuf[15], 0x80);
-
113  Notify(PSTR(" "), 0x80);
-
114  PrintHex<uint8_t > (l2capinbuf[14], 0x80);
+
103  Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
+
104  D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
+
105  Notify(PSTR(" "), 0x80);
+
106  D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
+
107  Notify(PSTR(" Data: "), 0x80);
+
108  D_PrintHex<uint8_t > (l2capinbuf[17], 0x80);
+
109  Notify(PSTR(" "), 0x80);
+
110  D_PrintHex<uint8_t > (l2capinbuf[16], 0x80);
+
111  Notify(PSTR(" "), 0x80);
+
112  D_PrintHex<uint8_t > (l2capinbuf[15], 0x80);
+
113  Notify(PSTR(" "), 0x80);
+
114  D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
115 #endif
116  } else if (l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) {
117 #ifdef EXTRADEBUG
-
118  Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80);
-
119  PrintHex<uint8_t > (l2capinbuf[13], 0x80);
-
120  Notify(PSTR(" "), 0x80);
-
121  PrintHex<uint8_t > (l2capinbuf[12], 0x80);
-
122  Notify(PSTR(" SCID: "), 0x80);
-
123  PrintHex<uint8_t > (l2capinbuf[15], 0x80);
-
124  Notify(PSTR(" "), 0x80);
-
125  PrintHex<uint8_t > (l2capinbuf[14], 0x80);
-
126  Notify(PSTR(" Identifier: "), 0x80);
-
127  PrintHex<uint8_t > (l2capinbuf[9], 0x80);
+
118  Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80);
+
119  D_PrintHex<uint8_t > (l2capinbuf[13], 0x80);
+
120  Notify(PSTR(" "), 0x80);
+
121  D_PrintHex<uint8_t > (l2capinbuf[12], 0x80);
+
122  Notify(PSTR(" SCID: "), 0x80);
+
123  D_PrintHex<uint8_t > (l2capinbuf[15], 0x80);
+
124  Notify(PSTR(" "), 0x80);
+
125  D_PrintHex<uint8_t > (l2capinbuf[14], 0x80);
+
126  Notify(PSTR(" Identifier: "), 0x80);
+
127  D_PrintHex<uint8_t > (l2capinbuf[9], 0x80);
128 #endif
129  if ((l2capinbuf[12] | (l2capinbuf[13] << 8)) == SDP_PSM) { // It doesn't matter if it receives another reqeust, since it waits for the channel to disconnect in the L2CAP_SDP_DONE state, and the l2cap_event_flag will be cleared if so
130  identifier = l2capinbuf[9];
@@ -270,15 +270,15 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
179  }
180  } else if (l2capinbuf[8] == L2CAP_CMD_INFORMATION_REQUEST) {
181 #ifdef DEBUG_USB_HOST
-
182  Notify(PSTR("\r\nInformation request"), 0x80);
+
182  Notify(PSTR("\r\nInformation request"), 0x80);
183 #endif
184  identifier = l2capinbuf[9];
185  pBtd->l2cap_information_response(hci_handle, identifier, l2capinbuf[12], l2capinbuf[13]);
186  }
187 #ifdef EXTRADEBUG
188  else {
-
189  Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80);
-
190  PrintHex<uint8_t > (l2capinbuf[8], 0x80);
+
189  Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80);
+
190  D_PrintHex<uint8_t > (l2capinbuf[8], 0x80);
191  }
192 #endif
193  } else if (l2capinbuf[6] == sdp_dcid[0] && l2capinbuf[7] == sdp_dcid[1]) { // SDP
@@ -302,28 +302,28 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
211  } else
212  serviceNotSupported(l2capinbuf[9], l2capinbuf[10]); // The service is not supported
213 #ifdef EXTRADEBUG
-
214  Notify(PSTR("\r\nUUID: "), 0x80);
+
214  Notify(PSTR("\r\nUUID: "), 0x80);
215  uint16_t uuid;
216  if((l2capinbuf[16] << 8 | l2capinbuf[17]) == 0x0000) // Check if it's sending the UUID as a 128-bit UUID
217  uuid = (l2capinbuf[18] << 8 | l2capinbuf[19]);
218  else // Short UUID
219  uuid = (l2capinbuf[16] << 8 | l2capinbuf[17]);
-
220  PrintHex<uint16_t> (uuid, 0x80);
+
220  D_PrintHex<uint16_t> (uuid, 0x80);
221 
-
222  Notify(PSTR("\r\nLength: "), 0x80);
+
222  Notify(PSTR("\r\nLength: "), 0x80);
223  uint16_t length = l2capinbuf[11] << 8 | l2capinbuf[12];
-
224  PrintHex<uint16_t> (length, 0x80);
-
225  Notify(PSTR("\r\nData: "), 0x80);
+
224  D_PrintHex<uint16_t> (length, 0x80);
+
225  Notify(PSTR("\r\nData: "), 0x80);
226  for (uint8_t i = 0; i < length; i++) {
-
227  PrintHex<uint8_t> (l2capinbuf[13+i], 0x80);
-
228  Notify(PSTR(" "), 0x80);
+
227  D_PrintHex<uint8_t> (l2capinbuf[13+i], 0x80);
+
228  Notify(PSTR(" "), 0x80);
229  }
230 #endif
231  }
232 #ifdef EXTRADEBUG
233  else {
-
234  Notify(PSTR("\r\nUnknown PDU: "));
-
235  PrintHex<uint8_t > (l2capinbuf[8], 0x80);
+
234  Notify(PSTR("\r\nUnknown PDU: "));
+
235  D_PrintHex<uint8_t > (l2capinbuf[8], 0x80);
236  }
237 #endif
238  } else if (l2capinbuf[6] == rfcomm_dcid[0] && l2capinbuf[7] == rfcomm_dcid[1]) { // RFCOMM
@@ -337,21 +337,21 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
246  rfcommChannelConnection = rfcommChannel;
247 
248 #ifdef EXTRADEBUG
-
249  Notify(PSTR("\r\nRFCOMM Channel: "), 0x80);
-
250  PrintHex<uint8_t > (rfcommChannel >> 3, 0x80);
-
251  Notify(PSTR(" Direction: "), 0x80);
-
252  PrintHex<uint8_t > (rfcommDirection >> 2, 0x80);
-
253  Notify(PSTR(" CommandResponse: "), 0x80);
-
254  PrintHex<uint8_t > (rfcommCommandResponse >> 1, 0x80);
-
255  Notify(PSTR(" ChannelType: "), 0x80);
-
256  PrintHex<uint8_t > (rfcommChannelType, 0x80);
-
257  Notify(PSTR(" PF_BIT: "), 0x80);
-
258  PrintHex<uint8_t > (rfcommPfBit, 0x80);
+
249  Notify(PSTR("\r\nRFCOMM Channel: "), 0x80);
+
250  D_PrintHex<uint8_t > (rfcommChannel >> 3, 0x80);
+
251  Notify(PSTR(" Direction: "), 0x80);
+
252  D_PrintHex<uint8_t > (rfcommDirection >> 2, 0x80);
+
253  Notify(PSTR(" CommandResponse: "), 0x80);
+
254  D_PrintHex<uint8_t > (rfcommCommandResponse >> 1, 0x80);
+
255  Notify(PSTR(" ChannelType: "), 0x80);
+
256  D_PrintHex<uint8_t > (rfcommChannelType, 0x80);
+
257  Notify(PSTR(" PF_BIT: "), 0x80);
+
258  D_PrintHex<uint8_t > (rfcommPfBit, 0x80);
259 #endif
260  if (rfcommChannelType == RFCOMM_DISC) {
261 #ifdef DEBUG_USB_HOST
-
262  Notify(PSTR("\r\nReceived Disconnect RFCOMM Command on channel: "), 0x80);
-
263  PrintHex<uint8_t > (rfcommChannel >> 3, 0x80);
+
262  Notify(PSTR("\r\nReceived Disconnect RFCOMM Command on channel: "), 0x80);
+
263  D_PrintHex<uint8_t > (rfcommChannel >> 3, 0x80);
264 #endif
265  connected = false;
266  sendRfcomm(rfcommChannel, rfcommDirection, rfcommCommandResponse, RFCOMM_UA, rfcommPfBit, rfcommbuf, 0x00); // UA Command
@@ -367,20 +367,20 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
276  rfcommAvailable += length;
277  }
278 #ifdef EXTRADEBUG
-
279  Notify(PSTR("\r\nRFCOMM Data Available: "), 0x80);
-
280  Notify(rfcommAvailable, 0x80);
+
279  Notify(PSTR("\r\nRFCOMM Data Available: "), 0x80);
+
280  Notify(rfcommAvailable, 0x80);
281  if (offset) {
-
282  Notify(PSTR(" - Credit: 0x"), 0x80);
-
283  PrintHex<uint8_t > (l2capinbuf[11], 0x80);
+
282  Notify(PSTR(" - Credit: 0x"), 0x80);
+
283  D_PrintHex<uint8_t > (l2capinbuf[11], 0x80);
284  }
285 #endif
286 #ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send to the Arduino via Bluetooth
287  for (uint8_t i = 0; i < length; i++)
-
288  Notifyc(l2capinbuf[i + 11 + offset], 0x80);
+
288  Notifyc(l2capinbuf[i + 11 + offset], 0x80);
289 #endif
290  } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command
291 #ifdef DEBUG_USB_HOST
-
292  Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"), 0x80);
+
292  Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"), 0x80);
293 #endif
294  rfcommbuf[0] = BT_RFCOMM_RPN_RSP; // Command
295  rfcommbuf[1] = l2capinbuf[12]; // Length and shiftet like so: length << 1 | 1
@@ -395,7 +395,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
304  sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A); // UIH Remote Port Negotiation Response
305  } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_CMD) { // UIH Modem Status Command
306 #ifdef DEBUG_USB_HOST
-
307  Notify(PSTR("\r\nSend UIH Modem Status Response"), 0x80);
+
307  Notify(PSTR("\r\nSend UIH Modem Status Response"), 0x80);
308 #endif
309  rfcommbuf[0] = BT_RFCOMM_MSC_RSP; // UIH Modem Status Response
310  rfcommbuf[1] = 2 << 1 | 1; // Length and shiftet like so: length << 1 | 1
@@ -406,12 +406,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
315  } else {
316  if (rfcommChannelType == RFCOMM_SABM) { // SABM Command - this is sent twice: once for channel 0 and then for the channel to establish
317 #ifdef DEBUG_USB_HOST
-
318  Notify(PSTR("\r\nReceived SABM Command"), 0x80);
+
318  Notify(PSTR("\r\nReceived SABM Command"), 0x80);
319 #endif
320  sendRfcomm(rfcommChannel, rfcommDirection, rfcommCommandResponse, RFCOMM_UA, rfcommPfBit, rfcommbuf, 0x00); // UA Command
321  } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_PN_CMD) { // UIH Parameter Negotiation Command
322 #ifdef DEBUG_USB_HOST
-
323  Notify(PSTR("\r\nReceived UIH Parameter Negotiation Command"), 0x80);
+
323  Notify(PSTR("\r\nReceived UIH Parameter Negotiation Command"), 0x80);
324 #endif
325  rfcommbuf[0] = BT_RFCOMM_PN_RSP; // UIH Parameter Negotiation Response
326  rfcommbuf[1] = l2capinbuf[12]; // Length and shiftet like so: length << 1 | 1
@@ -426,7 +426,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
335  sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A);
336  } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_CMD) { // UIH Modem Status Command
337 #ifdef DEBUG_USB_HOST
-
338  Notify(PSTR("\r\nSend UIH Modem Status Response"), 0x80);
+
338  Notify(PSTR("\r\nSend UIH Modem Status Response"), 0x80);
339 #endif
340  rfcommbuf[0] = BT_RFCOMM_MSC_RSP; // UIH Modem Status Response
341  rfcommbuf[1] = 2 << 1 | 1; // Length and shiftet like so: length << 1 | 1
@@ -436,7 +436,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
345 
346  delay(1);
347 #ifdef DEBUG_USB_HOST
-
348  Notify(PSTR("\r\nSend UIH Modem Status Command"), 0x80);
+
348  Notify(PSTR("\r\nSend UIH Modem Status Command"), 0x80);
349 #endif
350  rfcommbuf[0] = BT_RFCOMM_MSC_CMD; // UIH Modem Status Command
351  rfcommbuf[1] = 2 << 1 | 1; // Length and shiftet like so: length << 1 | 1
@@ -447,7 +447,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
356  } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_RSP) { // UIH Modem Status Response
357  if (!creditSent) {
358 #ifdef DEBUG_USB_HOST
-
359  Notify(PSTR("\r\nSend UIH Command with credit"), 0x80);
+
359  Notify(PSTR("\r\nSend UIH Command with credit"), 0x80);
360 #endif
361  sendRfcommCredit(rfcommChannelConnection, rfcommDirection, 0, RFCOMM_UIH, 0x10, sizeof (rfcommDataBuffer)); // Send credit
362  creditSent = true;
@@ -456,11 +456,11 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
365  }
366  } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[10] == 0x01) { // UIH Command with credit
367 #ifdef DEBUG_USB_HOST
-
368  Notify(PSTR("\r\nReceived UIH Command with credit"), 0x80);
+
368  Notify(PSTR("\r\nReceived UIH Command with credit"), 0x80);
369 #endif
370  } else if (rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command
371 #ifdef DEBUG_USB_HOST
-
372  Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"), 0x80);
+
372  Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"), 0x80);
373 #endif
374  rfcommbuf[0] = BT_RFCOMM_RPN_RSP; // Command
375  rfcommbuf[1] = l2capinbuf[12]; // Length and shiftet like so: length << 1 | 1
@@ -474,7 +474,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
383  rfcommbuf[9] = l2capinbuf[20]; // Number of Frames
384  sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A); // UIH Remote Port Negotiation Response
385 #ifdef DEBUG_USB_HOST
-
386  Notify(PSTR("\r\nRFCOMM Connection is now established\r\n"), 0x80);
+
386  Notify(PSTR("\r\nRFCOMM Connection is now established\r\n"), 0x80);
387 #endif
388  waitForLastCommand = false;
389  creditSent = false;
@@ -483,20 +483,20 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
392  }
393 #ifdef DEBUG_USB_HOST
394  else if (rfcommChannelType != RFCOMM_DISC) {
-
395  Notify(PSTR("\r\nUnsupported RFCOMM Data - ChannelType: "), 0x80);
-
396  PrintHex<uint8_t > (rfcommChannelType, 0x80);
-
397  Notify(PSTR(" Command: "), 0x80);
-
398  PrintHex<uint8_t > (l2capinbuf[11], 0x80);
+
395  Notify(PSTR("\r\nUnsupported RFCOMM Data - ChannelType: "), 0x80);
+
396  D_PrintHex<uint8_t > (rfcommChannelType, 0x80);
+
397  Notify(PSTR(" Command: "), 0x80);
+
398  D_PrintHex<uint8_t > (l2capinbuf[11], 0x80);
399  }
400 #endif
401  }
402  }
403 #ifdef EXTRADEBUG
404  else {
-
405  Notify(PSTR("\r\nUnsupported L2CAP Data - Channel ID: "), 0x80);
-
406  PrintHex<uint8_t > (l2capinbuf[7], 0x80);
-
407  Notify(PSTR(" "), 0x80);
-
408  PrintHex<uint8_t > (l2capinbuf[6], 0x80);
+
405  Notify(PSTR("\r\nUnsupported L2CAP Data - Channel ID: "), 0x80);
+
406  D_PrintHex<uint8_t > (l2capinbuf[7], 0x80);
+
407  Notify(PSTR(" "), 0x80);
+
408  D_PrintHex<uint8_t > (l2capinbuf[6], 0x80);
409  }
410 #endif
411  SDP_task();
@@ -507,7 +507,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
416 void SPP::Run() {
417  if (waitForLastCommand && (millis() - timer) > 100) { // We will only wait 100ms and see if the UIH Remote Port Negotiation Command is send, as some deviced don't send it
418 #ifdef DEBUG_USB_HOST
-
419  Notify(PSTR("\r\nRFCOMM Connection is now established - Automatic\r\n"), 0x80);
+
419  Notify(PSTR("\r\nRFCOMM Connection is now established - Automatic\r\n"), 0x80);
420 #endif
421  creditSent = false;
422  waitForLastCommand = false;
@@ -523,7 +523,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
433  l2cap_event_flag &= ~L2CAP_FLAG_CONNECTION_SDP_REQUEST; // Clear flag
434 #ifdef DEBUG_USB_HOST
-
435  Notify(PSTR("\r\nSDP Incoming Connection Request"), 0x80);
+
435  Notify(PSTR("\r\nSDP Incoming Connection Request"), 0x80);
436 #endif
437  pBtd->l2cap_connection_response(hci_handle, identifier, sdp_dcid, sdp_scid, PENDING);
438  delay(1);
@@ -538,7 +538,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
448  l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_SDP_REQUEST; // Clear flag
449 #ifdef DEBUG_USB_HOST
-
450  Notify(PSTR("\r\nSDP Configuration Request"), 0x80);
+
450  Notify(PSTR("\r\nSDP Configuration Request"), 0x80);
451 #endif
452  pBtd->l2cap_config_response(hci_handle, identifier, sdp_scid);
453  l2cap_sdp_state = L2CAP_SDP_SUCCESS;
@@ -548,7 +548,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
458  l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_SDP_SUCCESS; // Clear flag
459 #ifdef DEBUG_USB_HOST
-
460  Notify(PSTR("\r\nSDP Successfully Configured"), 0x80);
+
460  Notify(PSTR("\r\nSDP Successfully Configured"), 0x80);
461 #endif
462  firstMessage = true; // Reset bool
463  SDPConnected = true;
@@ -560,7 +560,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
469  l2cap_event_flag &= ~L2CAP_FLAG_DISCONNECT_SDP_REQUEST; // Clear flag
470  SDPConnected = false;
471 #ifdef DEBUG_USB_HOST
-
472  Notify(PSTR("\r\nDisconnected SDP Channel"), 0x80);
+
472  Notify(PSTR("\r\nDisconnected SDP Channel"), 0x80);
473 #endif
474  pBtd->l2cap_disconnection_response(hci_handle, identifier, sdp_dcid, sdp_scid);
475  l2cap_sdp_state = L2CAP_SDP_WAIT;
@@ -570,7 +570,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
479  case L2CAP_DISCONNECT_RESPONSE: // This is for both disconnection response from the RFCOMM and SDP channel if they were connected
481 #ifdef DEBUG_USB_HOST
-
482  Notify(PSTR("\r\nDisconnected L2CAP Connection"), 0x80);
+
482  Notify(PSTR("\r\nDisconnected L2CAP Connection"), 0x80);
483 #endif
484  RFCOMMConnected = false;
485  SDPConnected = false;
@@ -590,7 +590,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
500  l2cap_event_flag &= ~L2CAP_FLAG_CONNECTION_RFCOMM_REQUEST; // Clear flag
501 #ifdef DEBUG_USB_HOST
-
502  Notify(PSTR("\r\nRFCOMM Incoming Connection Request"), 0x80);
+
502  Notify(PSTR("\r\nRFCOMM Incoming Connection Request"), 0x80);
503 #endif
504  pBtd->l2cap_connection_response(hci_handle, identifier, rfcomm_dcid, rfcomm_scid, PENDING);
505  delay(1);
@@ -605,7 +605,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
515  l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_RFCOMM_REQUEST; // Clear flag
516 #ifdef DEBUG_USB_HOST
-
517  Notify(PSTR("\r\nRFCOMM Configuration Request"), 0x80);
+
517  Notify(PSTR("\r\nRFCOMM Configuration Request"), 0x80);
518 #endif
519  pBtd->l2cap_config_response(hci_handle, identifier, rfcomm_scid);
520  l2cap_rfcomm_state = L2CAP_RFCOMM_SUCCESS;
@@ -615,7 +615,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
525  l2cap_event_flag &= ~L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS; // Clear flag
526 #ifdef DEBUG_USB_HOST
-
527  Notify(PSTR("\r\nRFCOMM Successfully Configured"), 0x80);
+
527  Notify(PSTR("\r\nRFCOMM Successfully Configured"), 0x80);
528 #endif
529  rfcommAvailable = 0; // Reset number of bytes available
530  bytesRead = 0; // Reset number of bytes received
@@ -629,7 +629,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
538  RFCOMMConnected = false;
539  connected = false;
540 #ifdef DEBUG_USB_HOST
-
541  Notify(PSTR("\r\nDisconnected RFCOMM Channel"), 0x80);
+
541  Notify(PSTR("\r\nDisconnected RFCOMM Channel"), 0x80);
542 #endif
543  pBtd->l2cap_disconnection_response(hci_handle, identifier, rfcomm_dcid, rfcomm_scid);
544  l2cap_rfcomm_state = L2CAP_RFCOMM_WAIT;
@@ -787,10 +787,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
696  l2capoutbuf[i + 3] = data[i];
697  l2capoutbuf[i + 3] = calcFcs(l2capoutbuf);
698 #ifdef EXTRADEBUG
-
699  Notify(PSTR(" - RFCOMM Data: "), 0x80);
+
699  Notify(PSTR(" - RFCOMM Data: "), 0x80);
700  for (i = 0; i < length + 4; i++) {
-
701  PrintHex<uint8_t > (l2capoutbuf[i], 0x80);
-
702  Notify(PSTR(" "), 0x80);
+
701  D_PrintHex<uint8_t > (l2capoutbuf[i], 0x80);
+
702  Notify(PSTR(" "), 0x80);
703  }
704 #endif
705  RFCOMM_Command(l2capoutbuf, length + 4);
@@ -803,10 +803,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
712  l2capoutbuf[3] = credit; // Credit
713  l2capoutbuf[4] = calcFcs(l2capoutbuf);
714 #ifdef EXTRADEBUG
-
715  Notify(PSTR(" - RFCOMM Credit Data: "), 0x80);
+
715  Notify(PSTR(" - RFCOMM Credit Data: "), 0x80);
716  for (uint8_t i = 0; i < 5; i++) {
-
717  PrintHex<uint8_t > (l2capoutbuf[i], 0x80);
-
718  Notify(PSTR(" "), 0x80);
+
717  D_PrintHex<uint8_t > (l2capoutbuf[i], 0x80);
+
718  Notify(PSTR(" "), 0x80);
719  }
720 #endif
721  RFCOMM_Command(l2capoutbuf, 5);
@@ -834,7 +834,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
743  for(uint8_t i = 0; i < size; i++) {
744  if(sppIndex >= sizeof(sppOutputBuffer)/sizeof(sppOutputBuffer[0]))
745  send(); // Send the current data in the buffer
-
746  sppOutputBuffer[sppIndex++] = data[i]; // All the bytes are put into a buffer and then send using the send() function
+
746  sppOutputBuffer[sppIndex++] = data[i]; // All the bytes are put into a buffer and then send using the send() function
747  }
748  return size;
749 }
@@ -893,9 +893,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
802  bytesRead = 0;
803  sendRfcommCredit(rfcommChannelConnection, rfcommDirection, 0, RFCOMM_UIH, 0x10, sizeof (rfcommDataBuffer)); // Send more credit
804 #ifdef EXTRADEBUG
-
805  Notify(PSTR("\r\nSent "), 0x80);
-
806  Notify((uint8_t)sizeof (rfcommDataBuffer), 0x80);
-
807  Notify(PSTR(" more credit"), 0x80);
+
805  Notify(PSTR("\r\nSent "), 0x80);
+
806  Notify((uint8_t)sizeof (rfcommDataBuffer), 0x80);
+
807  Notify(PSTR(" more credit"), 0x80);
808 #endif
809  }
810  return output;
diff --git a/_usb_8cpp_source.html b/_usb_8cpp_source.html index ff9f1d27..f2392830 100644 --- a/_usb_8cpp_source.html +++ b/_usb_8cpp_source.html @@ -129,7 +129,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
38 
39 /* Initialize data structures */
40 void USB::init() {
-
41  devConfigIndex = 0;
+
41  //devConfigIndex = 0;
42  bmHubPre = 0;
43 }
44 
@@ -201,599 +201,682 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
110  USBTRACE("\r\n");
111  */
112  regWr(rPERADDR, addr); //set peripheral address
-
113 
+
113 
114  uint8_t mode = regRd(rMODE);
-
115 
-
116  // Set bmLOWSPEED and bmHUBPRE in case of low-speed device, reset them otherwise
-
117  regWr(rMODE, (p->lowspeed) ? mode | bmLOWSPEED | bmHubPre : mode & ~(bmHUBPRE | bmLOWSPEED));
-
118 
-
119  return 0;
-
120 }
+
115 
+
116  //Serial.print("\r\nMode: ");
+
117  //Serial.println( mode, HEX);
+
118  //Serial.print("\r\nLS: ");
+
119  //Serial.println(p->lowspeed, HEX);
+
120 
121 
-
122 /* Control transfer. Sets address, endpoint, fills control packet with necessary data, dispatches control packet, and initiates bulk IN transfer, */
-
123 /* depending on request. Actual requests are defined as inlines */
-
124 /* return codes: */
-
125 /* 00 = success */
-
126 
-
127 /* 01-0f = non-zero HRSLT */
-
128 uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
-
129  uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p) {
-
130  bool direction = false; //request direction, IN or OUT
-
131  uint8_t rcode;
-
132  SETUP_PKT setup_pkt;
+
122 
+
123  // Set bmLOWSPEED and bmHUBPRE in case of low-speed device, reset them otherwise
+
124  regWr(rMODE, (p->lowspeed) ? mode | bmLOWSPEED | bmHubPre : mode & ~(bmHUBPRE | bmLOWSPEED));
+
125 
+
126  return 0;
+
127 }
+
128 
+
129 /* Control transfer. Sets address, endpoint, fills control packet with necessary data, dispatches control packet, and initiates bulk IN transfer, */
+
130 /* depending on request. Actual requests are defined as inlines */
+
131 /* return codes: */
+
132 /* 00 = success */
133 
-
134  EpInfo *pep = NULL;
-
135  uint16_t nak_limit = 0;
-
136 
-
137  rcode = SetAddress(addr, ep, &pep, nak_limit);
-
138 
-
139  if (rcode)
-
140  return rcode;
-
141 
-
142  direction = ((bmReqType & 0x80) > 0);
+
134 /* 01-0f = non-zero HRSLT */
+
135 uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
+
136  uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p) {
+
137  bool direction = false; //request direction, IN or OUT
+
138  uint8_t rcode;
+
139  SETUP_PKT setup_pkt;
+
140 
+
141  EpInfo *pep = NULL;
+
142  uint16_t nak_limit = 0;
143 
-
144  /* fill in setup packet */
-
145  setup_pkt.ReqType_u.bmRequestType = bmReqType;
-
146  setup_pkt.bRequest = bRequest;
-
147  setup_pkt.wVal_u.wValueLo = wValLo;
-
148  setup_pkt.wVal_u.wValueHi = wValHi;
-
149  setup_pkt.wIndex = wInd;
-
150  setup_pkt.wLength = total;
-
151 
-
152  bytesWr(rSUDFIFO, 8, (uint8_t*) & setup_pkt); //transfer to setup packet FIFO
-
153 
-
154  rcode = dispatchPkt(tokSETUP, ep, nak_limit); //dispatch packet
-
155 
-
156  if (rcode) //return HRSLT if not zero
-
157  return ( rcode);
+
144  rcode = SetAddress(addr, ep, &pep, nak_limit);
+
145 
+
146  if (rcode)
+
147  return rcode;
+
148 
+
149  direction = ((bmReqType & 0x80) > 0);
+
150 
+
151  /* fill in setup packet */
+
152  setup_pkt.ReqType_u.bmRequestType = bmReqType;
+
153  setup_pkt.bRequest = bRequest;
+
154  setup_pkt.wVal_u.wValueLo = wValLo;
+
155  setup_pkt.wVal_u.wValueHi = wValHi;
+
156  setup_pkt.wIndex = wInd;
+
157  setup_pkt.wLength = total;
158 
-
159  if (dataptr != NULL) //data stage, if present
-
160  {
-
161  if (direction) //IN transfer
-
162  {
-
163  uint16_t left = total;
-
164 
-
165  pep->bmRcvToggle = 1; //bmRCVTOG1;
-
166 
-
167  while (left) {
-
168  // Bytes read into buffer
-
169  uint16_t read = nbytes;
-
170  //uint16_t read = (left<nbytes) ? left : nbytes;
+
159  bytesWr(rSUDFIFO, 8, (uint8_t*) & setup_pkt); //transfer to setup packet FIFO
+
160 
+
161  rcode = dispatchPkt(tokSETUP, ep, nak_limit); //dispatch packet
+
162 
+
163  if (rcode) //return HRSLT if not zero
+
164  return ( rcode);
+
165 
+
166  if (dataptr != NULL) //data stage, if present
+
167  {
+
168  if (direction) //IN transfer
+
169  {
+
170  uint16_t left = total;
171 
-
172  rcode = InTransfer(pep, nak_limit, &read, dataptr);
-
173  if (rcode == hrTOGERR) {
-
174  // yes, we flip it wrong here so that next time it is actually correct!
-
175  pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1;
-
176  continue;
-
177  }
+
172  pep->bmRcvToggle = 1; //bmRCVTOG1;
+
173 
+
174  while (left) {
+
175  // Bytes read into buffer
+
176  uint16_t read = nbytes;
+
177  //uint16_t read = (left<nbytes) ? left : nbytes;
178 
-
179  if (rcode)
-
180  return rcode;
-
181 
-
182  // Invoke callback function if inTransfer completed successfully and callback function pointer is specified
-
183  if (!rcode && p)
-
184  ((USBReadParser*)p)->Parse(read, dataptr, total - left);
+
179  rcode = InTransfer(pep, nak_limit, &read, dataptr);
+
180  if (rcode == hrTOGERR) {
+
181  // yes, we flip it wrong here so that next time it is actually correct!
+
182  pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1;
+
183  continue;
+
184  }
185 
-
186  left -= read;
-
187 
-
188  if (read < nbytes)
-
189  break;
-
190  }
-
191  } else //OUT transfer
-
192  {
-
193  pep->bmSndToggle = 1; //bmSNDTOG1;
-
194  rcode = OutTransfer(pep, nak_limit, nbytes, dataptr);
-
195  }
-
196  if (rcode) //return error
-
197  return ( rcode);
-
198  }
-
199  // Status stage
-
200  return dispatchPkt((direction) ? tokOUTHS : tokINHS, ep, nak_limit); //GET if direction
-
201 }
-
202 
-
203 /* IN transfer to arbitrary endpoint. Assumes PERADDR is set. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */
-
204 /* Keep sending INs and writes data to memory area pointed by 'data' */
-
205 
-
206 /* rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error,
-
207  fe USB xfer timeout */
-
208 uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data) {
-
209  EpInfo *pep = NULL;
-
210  uint16_t nak_limit = 0;
-
211 
-
212  uint8_t rcode = SetAddress(addr, ep, &pep, nak_limit);
-
213 
-
214  if (rcode) {
-
215  //printf("SetAddress Failed");
-
216  return rcode;
-
217  }
-
218  return InTransfer(pep, nak_limit, nbytesptr, data);
-
219 }
+
186  if (rcode)
+
187  return rcode;
+
188 
+
189  // Invoke callback function if inTransfer completed successfully and callback function pointer is specified
+
190  if (!rcode && p)
+
191  ((USBReadParser*)p)->Parse(read, dataptr, total - left);
+
192 
+
193  left -= read;
+
194 
+
195  if (read < nbytes)
+
196  break;
+
197  }
+
198  } else //OUT transfer
+
199  {
+
200  pep->bmSndToggle = 1; //bmSNDTOG1;
+
201  rcode = OutTransfer(pep, nak_limit, nbytes, dataptr);
+
202  }
+
203  if (rcode) //return error
+
204  return ( rcode);
+
205  }
+
206  // Status stage
+
207  return dispatchPkt((direction) ? tokOUTHS : tokINHS, ep, nak_limit); //GET if direction
+
208 }
+
209 
+
210 /* IN transfer to arbitrary endpoint. Assumes PERADDR is set. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */
+
211 /* Keep sending INs and writes data to memory area pointed by 'data' */
+
212 
+
213 /* rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error,
+
214  fe USB xfer timeout */
+
215 uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data) {
+
216  EpInfo *pep = NULL;
+
217  uint16_t nak_limit = 0;
+
218 
+
219  uint8_t rcode = SetAddress(addr, ep, &pep, nak_limit);
220 
-
221 uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t* data) {
-
222  uint8_t rcode = 0;
-
223  uint8_t pktsize;
-
224 
-
225  uint16_t nbytes = *nbytesptr;
-
226  //printf("Requesting %i bytes ", nbytes);
-
227  uint8_t maxpktsize = pep->maxPktSize;
-
228 
-
229  *nbytesptr = 0;
-
230  regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value
+
221  if (rcode) {
+
222  //printf("SetAddress Failed");
+
223  return rcode;
+
224  }
+
225  return InTransfer(pep, nak_limit, nbytesptr, data);
+
226 }
+
227 
+
228 uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t* data) {
+
229  uint8_t rcode = 0;
+
230  uint8_t pktsize;
231 
-
232  while (1) // use a 'return' to exit this loop
-
233  {
-
234  rcode = dispatchPkt(tokIN, pep->epAddr, nak_limit); //IN packet to EP-'endpoint'. Function takes care of NAKS.
-
235  if (rcode == hrTOGERR) {
-
236  // yes, we flip it wrong here so that next time it is actually correct!
-
237  pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1;
-
238  regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value
-
239  continue;
-
240  }
-
241  if (rcode) {
-
242  //printf(">>>>>>>> Problem! dispatchPkt %2.2x\r\n", rcode);
-
243  break; //should be 0, indicating ACK. Else return error code.
-
244  }
-
245  /* check for RCVDAVIRQ and generate error if not present */
-
246  /* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */
-
247  if ((regRd(rHIRQ) & bmRCVDAVIRQ) == 0) {
-
248  //printf(">>>>>>>> Problem! NO RCVDAVIRQ!\r\n");
-
249  rcode = 0xf0; //receive error
-
250  break;
+
232  uint16_t nbytes = *nbytesptr;
+
233  //printf("Requesting %i bytes ", nbytes);
+
234  uint8_t maxpktsize = pep->maxPktSize;
+
235 
+
236  *nbytesptr = 0;
+
237  regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value
+
238 
+
239  while (1) // use a 'return' to exit this loop
+
240  {
+
241  rcode = dispatchPkt(tokIN, pep->epAddr, nak_limit); //IN packet to EP-'endpoint'. Function takes care of NAKS.
+
242  if (rcode == hrTOGERR) {
+
243  // yes, we flip it wrong here so that next time it is actually correct!
+
244  pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1;
+
245  regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value
+
246  continue;
+
247  }
+
248  if (rcode) {
+
249  //printf(">>>>>>>> Problem! dispatchPkt %2.2x\r\n", rcode);
+
250  break; //should be 0, indicating ACK. Else return error code.
251  }
-
252  pktsize = regRd(rRCVBC); //number of received bytes
-
253  //printf("Got %i bytes \r\n", pktsize);
-
254  // This would be OK, but...
-
255  //assert(pktsize <= nbytes);
-
256  if (pktsize > nbytes) {
-
257  // This can happen. Use of assert on Arduino locks up the Arduino.
-
258  // So I will trim the value, and hope for the best.
-
259  //printf(">>>>>>>> Problem! Wanted %i bytes but got %i.\r\n", nbytes, pktsize);
-
260  pktsize = nbytes;
-
261  }
-
262 
-
263  int16_t mem_left = (int16_t)nbytes - *((int16_t*)nbytesptr);
-
264 
-
265  if (mem_left < 0)
-
266  mem_left = 0;
-
267 
-
268  data = bytesRd(rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data);
+
252  /* check for RCVDAVIRQ and generate error if not present */
+
253  /* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */
+
254  if ((regRd(rHIRQ) & bmRCVDAVIRQ) == 0) {
+
255  //printf(">>>>>>>> Problem! NO RCVDAVIRQ!\r\n");
+
256  rcode = 0xf0; //receive error
+
257  break;
+
258  }
+
259  pktsize = regRd(rRCVBC); //number of received bytes
+
260  //printf("Got %i bytes \r\n", pktsize);
+
261  // This would be OK, but...
+
262  //assert(pktsize <= nbytes);
+
263  if (pktsize > nbytes) {
+
264  // This can happen. Use of assert on Arduino locks up the Arduino.
+
265  // So I will trim the value, and hope for the best.
+
266  //printf(">>>>>>>> Problem! Wanted %i bytes but got %i.\r\n", nbytes, pktsize);
+
267  pktsize = nbytes;
+
268  }
269 
-
270  regWr(rHIRQ, bmRCVDAVIRQ); // Clear the IRQ & free the buffer
-
271  *nbytesptr += pktsize; // add this packet's byte count to total transfer length
-
272 
-
273  /* The transfer is complete under two conditions: */
-
274  /* 1. The device sent a short packet (L.T. maxPacketSize) */
-
275  /* 2. 'nbytes' have been transferred. */
-
276  if ((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) // have we transferred 'nbytes' bytes?
-
277  {
-
278  // Save toggle value
-
279  pep->bmRcvToggle = ((regRd(rHRSL) & bmRCVTOGRD)) ? 1 : 0;
-
280  //printf("\r\n");
-
281  rcode = 0;
-
282  break;
-
283  } // if
-
284  } //while( 1 )
-
285  return ( rcode);
-
286 }
-
287 
-
288 /* OUT transfer to arbitrary endpoint. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */
-
289 /* Handles NAK bug per Maxim Application Note 4000 for single buffer transfer */
-
290 
-
291 /* rcode 0 if no errors. rcode 01-0f is relayed from HRSL */
-
292 uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data) {
-
293  EpInfo *pep = NULL;
-
294  uint16_t nak_limit = 0;
-
295 
-
296  uint8_t rcode = SetAddress(addr, ep, &pep, nak_limit);
+
270  int16_t mem_left = (int16_t)nbytes - *((int16_t*)nbytesptr);
+
271 
+
272  if (mem_left < 0)
+
273  mem_left = 0;
+
274 
+
275  data = bytesRd(rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data);
+
276 
+
277  regWr(rHIRQ, bmRCVDAVIRQ); // Clear the IRQ & free the buffer
+
278  *nbytesptr += pktsize; // add this packet's byte count to total transfer length
+
279 
+
280  /* The transfer is complete under two conditions: */
+
281  /* 1. The device sent a short packet (L.T. maxPacketSize) */
+
282  /* 2. 'nbytes' have been transferred. */
+
283  if ((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) // have we transferred 'nbytes' bytes?
+
284  {
+
285  // Save toggle value
+
286  pep->bmRcvToggle = ((regRd(rHRSL) & bmRCVTOGRD)) ? 1 : 0;
+
287  //printf("\r\n");
+
288  rcode = 0;
+
289  break;
+
290  } // if
+
291  } //while( 1 )
+
292  return ( rcode);
+
293 }
+
294 
+
295 /* OUT transfer to arbitrary endpoint. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */
+
296 /* Handles NAK bug per Maxim Application Note 4000 for single buffer transfer */
297 
-
298  if (rcode)
-
299  return rcode;
-
300 
-
301  return OutTransfer(pep, nak_limit, nbytes, data);
-
302 }
-
303 
-
304 uint8_t USB::OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data) {
-
305  uint8_t rcode = hrSUCCESS, retry_count;
-
306  uint8_t *data_p = data; //local copy of the data pointer
-
307  uint16_t bytes_tosend, nak_count;
-
308  uint16_t bytes_left = nbytes;
-
309 
-
310  uint8_t maxpktsize = pep->maxPktSize;
-
311 
-
312  if (maxpktsize < 1 || maxpktsize > 64)
- -
314 
-
315  unsigned long timeout = millis() + USB_XFER_TIMEOUT;
+
298 /* rcode 0 if no errors. rcode 01-0f is relayed from HRSL */
+
299 uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data) {
+
300  EpInfo *pep = NULL;
+
301  uint16_t nak_limit = 0;
+
302 
+
303  uint8_t rcode = SetAddress(addr, ep, &pep, nak_limit);
+
304 
+
305  if (rcode)
+
306  return rcode;
+
307 
+
308  return OutTransfer(pep, nak_limit, nbytes, data);
+
309 }
+
310 
+
311 uint8_t USB::OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data) {
+
312  uint8_t rcode = hrSUCCESS, retry_count;
+
313  uint8_t *data_p = data; //local copy of the data pointer
+
314  uint16_t bytes_tosend, nak_count;
+
315  uint16_t bytes_left = nbytes;
316 
-
317  regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value
+
317  uint8_t maxpktsize = pep->maxPktSize;
318 
-
319  while (bytes_left) {
-
320  retry_count = 0;
-
321  nak_count = 0;
-
322  bytes_tosend = (bytes_left >= maxpktsize) ? maxpktsize : bytes_left;
-
323  bytesWr(rSNDFIFO, bytes_tosend, data_p); //filling output FIFO
-
324  regWr(rSNDBC, bytes_tosend); //set number of bytes
-
325  regWr(rHXFR, (tokOUT | pep->epAddr)); //dispatch packet
-
326  while (!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ
-
327  regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ
-
328  rcode = (regRd(rHRSL) & 0x0f);
-
329 
-
330  while (rcode && (timeout > millis())) {
-
331  switch (rcode) {
-
332  case hrNAK:
-
333  nak_count++;
-
334  if (nak_limit && (nak_count == nak_limit))
-
335  goto breakout;
-
336  //return ( rcode);
-
337  break;
-
338  case hrTIMEOUT:
-
339  retry_count++;
-
340  if (retry_count == USB_RETRY_LIMIT)
-
341  goto breakout;
-
342  //return ( rcode);
-
343  break;
-
344  case hrTOGERR:
-
345  // yes, we flip it wrong here so that next time it is actually correct!
-
346  pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1;
-
347  regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value
-
348  break;
-
349  default:
-
350  goto breakout;
-
351  }//switch( rcode
-
352 
-
353  /* process NAK according to Host out NAK bug */
-
354  regWr(rSNDBC, 0);
-
355  regWr(rSNDFIFO, *data_p);
-
356  regWr(rSNDBC, bytes_tosend);
-
357  regWr(rHXFR, (tokOUT | pep->epAddr)); //dispatch packet
-
358  while (!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ
-
359  regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ
-
360  rcode = (regRd(rHRSL) & 0x0f);
-
361  }//while( rcode && ....
-
362  bytes_left -= bytes_tosend;
-
363  data_p += bytes_tosend;
-
364  }//while( bytes_left...
-
365 breakout:
-
366 
-
367  pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 1 : 0; //bmSNDTOG1 : bmSNDTOG0; //update toggle
-
368  return ( rcode); //should be 0 in all cases
-
369 }
-
370 /* dispatch USB packet. Assumes peripheral address is set and relevant buffer is loaded/empty */
-
371 /* If NAK, tries to re-send up to nak_limit times */
-
372 /* If nak_limit == 0, do not count NAKs, exit after timeout */
-
373 /* If bus timeout, re-sends up to USB_RETRY_LIMIT times */
-
374 
-
375 /* return codes 0x00-0x0f are HRSLT( 0x00 being success ), 0xff means timeout */
-
376 uint8_t USB::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) {
-
377  unsigned long timeout = millis() + USB_XFER_TIMEOUT;
-
378  uint8_t tmpdata;
-
379  uint8_t rcode = hrSUCCESS;
-
380  uint8_t retry_count = 0;
-
381  uint16_t nak_count = 0;
-
382 
-
383  while (timeout > millis()) {
-
384  regWr(rHXFR, (token | ep)); //launch the transfer
- -
386 
-
387  while (timeout > millis()) //wait for transfer completion
-
388  {
-
389  tmpdata = regRd(rHIRQ);
-
390 
-
391  if (tmpdata & bmHXFRDNIRQ) {
-
392  regWr(rHIRQ, bmHXFRDNIRQ); //clear the interrupt
-
393  rcode = 0x00;
-
394  break;
-
395  }//if( tmpdata & bmHXFRDNIRQ
-
396 
-
397  }//while ( millis() < timeout
-
398 
-
399  //if (rcode != 0x00) //exit if timeout
-
400  // return ( rcode);
-
401 
-
402  rcode = (regRd(rHRSL) & 0x0f); //analyze transfer result
+
319  if (maxpktsize < 1 || maxpktsize > 64)
+ +
321 
+
322  unsigned long timeout = millis() + USB_XFER_TIMEOUT;
+
323 
+
324  regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value
+
325 
+
326  while (bytes_left) {
+
327  retry_count = 0;
+
328  nak_count = 0;
+
329  bytes_tosend = (bytes_left >= maxpktsize) ? maxpktsize : bytes_left;
+
330  bytesWr(rSNDFIFO, bytes_tosend, data_p); //filling output FIFO
+
331  regWr(rSNDBC, bytes_tosend); //set number of bytes
+
332  regWr(rHXFR, (tokOUT | pep->epAddr)); //dispatch packet
+
333  while (!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ
+
334  regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ
+
335  rcode = (regRd(rHRSL) & 0x0f);
+
336 
+
337  while (rcode && (timeout > millis())) {
+
338  switch (rcode) {
+
339  case hrNAK:
+
340  nak_count++;
+
341  if (nak_limit && (nak_count == nak_limit))
+
342  goto breakout;
+
343  //return ( rcode);
+
344  break;
+
345  case hrTIMEOUT:
+
346  retry_count++;
+
347  if (retry_count == USB_RETRY_LIMIT)
+
348  goto breakout;
+
349  //return ( rcode);
+
350  break;
+
351  case hrTOGERR:
+
352  // yes, we flip it wrong here so that next time it is actually correct!
+
353  pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1;
+
354  regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value
+
355  break;
+
356  default:
+
357  goto breakout;
+
358  }//switch( rcode
+
359 
+
360  /* process NAK according to Host out NAK bug */
+
361  regWr(rSNDBC, 0);
+
362  regWr(rSNDFIFO, *data_p);
+
363  regWr(rSNDBC, bytes_tosend);
+
364  regWr(rHXFR, (tokOUT | pep->epAddr)); //dispatch packet
+
365  while (!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ
+
366  regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ
+
367  rcode = (regRd(rHRSL) & 0x0f);
+
368  }//while( rcode && ....
+
369  bytes_left -= bytes_tosend;
+
370  data_p += bytes_tosend;
+
371  }//while( bytes_left...
+
372 breakout:
+
373 
+
374  pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 1 : 0; //bmSNDTOG1 : bmSNDTOG0; //update toggle
+
375  return ( rcode); //should be 0 in all cases
+
376 }
+
377 /* dispatch USB packet. Assumes peripheral address is set and relevant buffer is loaded/empty */
+
378 /* If NAK, tries to re-send up to nak_limit times */
+
379 /* If nak_limit == 0, do not count NAKs, exit after timeout */
+
380 /* If bus timeout, re-sends up to USB_RETRY_LIMIT times */
+
381 
+
382 /* return codes 0x00-0x0f are HRSLT( 0x00 being success ), 0xff means timeout */
+
383 uint8_t USB::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) {
+
384  unsigned long timeout = millis() + USB_XFER_TIMEOUT;
+
385  uint8_t tmpdata;
+
386  uint8_t rcode = hrSUCCESS;
+
387  uint8_t retry_count = 0;
+
388  uint16_t nak_count = 0;
+
389 
+
390  while (timeout > millis()) {
+
391  regWr(rHXFR, (token | ep)); //launch the transfer
+ +
393 
+
394  while (timeout > millis()) //wait for transfer completion
+
395  {
+
396  tmpdata = regRd(rHIRQ);
+
397 
+
398  if (tmpdata & bmHXFRDNIRQ) {
+
399  regWr(rHIRQ, bmHXFRDNIRQ); //clear the interrupt
+
400  rcode = 0x00;
+
401  break;
+
402  }//if( tmpdata & bmHXFRDNIRQ
403 
-
404  switch (rcode) {
-
405  case hrNAK:
-
406  nak_count++;
-
407  if (nak_limit && (nak_count == nak_limit))
-
408  return (rcode);
-
409  break;
-
410  case hrTIMEOUT:
-
411  retry_count++;
-
412  if (retry_count == USB_RETRY_LIMIT)
-
413  return (rcode);
-
414  break;
-
415  default:
-
416  return (rcode);
-
417  }//switch( rcode
-
418 
-
419  }//while( timeout > millis()
-
420  return ( rcode);
-
421 }
-
422 
-
423 /* USB main task. Performs enumeration/cleanup */
-
424 void USB::Task(void) //USB state machine
-
425 {
-
426  uint8_t rcode;
-
427  uint8_t tmpdata;
-
428  static unsigned long delay = 0;
-
429  //USB_DEVICE_DESCRIPTOR buf;
-
430  bool lowspeed = false;
-
431 
-
432  MAX3421E::Task();
-
433 
-
434  tmpdata = getVbusState();
-
435 
-
436  /* modify USB task state if Vbus changed */
-
437  switch (tmpdata) {
-
438  case SE1: //illegal state
-
439  usb_task_state = USB_DETACHED_SUBSTATE_ILLEGAL;
-
440  lowspeed = false;
-
441  break;
-
442  case SE0: //disconnected
-
443  if ((usb_task_state & USB_STATE_MASK) != USB_STATE_DETACHED)
-
444  usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE;
-
445  lowspeed = false;
-
446  break;
-
447  case LSHOST:
-
448  if ((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) {
-
449  lowspeed = true;
-
450  }
-
451  case FSHOST: //attached
-
452  if ((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) {
-
453  delay = millis() + USB_SETTLE_DELAY;
-
454  usb_task_state = USB_ATTACHED_SUBSTATE_SETTLE;
-
455  }
-
456  break;
-
457  }// switch( tmpdata
-
458 
-
459  for (uint8_t i = 0; i < USB_NUMDEVICES; i++)
-
460  if (devConfig[i])
-
461  rcode = devConfig[i]->Poll();
-
462 
-
463  switch (usb_task_state) {
- -
465  init();
-
466 
-
467  for (uint8_t i = 0; i < USB_NUMDEVICES; i++)
-
468  if (devConfig[i])
-
469  rcode = devConfig[i]->Release();
-
470 
-
471  usb_task_state = USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE;
-
472  break;
-
473  case USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE: //just sit here
-
474  break;
-
475  case USB_DETACHED_SUBSTATE_ILLEGAL: //just sit here
-
476  break;
-
477  case USB_ATTACHED_SUBSTATE_SETTLE: //settle time for just attached device
-
478  if (delay < millis())
-
479  usb_task_state = USB_ATTACHED_SUBSTATE_RESET_DEVICE;
-
480  break;
- -
482  regWr(rHCTL, bmBUSRST); //issue bus reset
- -
484  break;
- -
486  if ((regRd(rHCTL) & bmBUSRST) == 0) {
-
487  tmpdata = regRd(rMODE) | bmSOFKAENAB; //start SOF generation
-
488  regWr(rMODE, tmpdata);
-
489  usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_SOF;
-
490  //delay = millis() + 20; //20ms wait after reset per USB spec
-
491  }
-
492  break;
-
493  case USB_ATTACHED_SUBSTATE_WAIT_SOF: //todo: change check order
-
494  if (regRd(rHIRQ) & bmFRAMEIRQ) {
-
495  //when first SOF received _and_ 20ms has passed we can continue
-
496  /*
-
497  if (delay < millis()) //20ms passed
-
498  usb_task_state = USB_STATE_CONFIGURING;
-
499  */
-
500  usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_RESET;
-
501  delay = millis() + 20;
-
502  }
-
503  break;
- -
505  if (delay < millis()) usb_task_state = USB_STATE_CONFIGURING;
-
506  break;
- -
508  rcode = Configuring(0, 0, lowspeed);
-
509 
-
510  if (rcode) {
- -
512  usb_error = rcode;
-
513  usb_task_state = USB_STATE_ERROR;
-
514  }
-
515  } else
-
516  usb_task_state = USB_STATE_RUNNING;
-
517  break;
-
518  case USB_STATE_RUNNING:
-
519  break;
-
520  case USB_STATE_ERROR:
-
521  //MAX3421E::Init();
-
522  break;
-
523  } // switch( usb_task_state )
-
524 }
-
525 
-
526 uint8_t USB::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) {
-
527  //uint8_t buf[12];
-
528  uint8_t rcode;
-
529  UsbDevice *p0 = NULL, *p = NULL;
-
530 
-
531  // Get pointer to pseudo device with address 0 assigned
-
532  p0 = addrPool.GetUsbDevicePtr(0);
-
533 
-
534  if (!p0)
- +
404  }//while ( millis() < timeout
+
405 
+
406  //if (rcode != 0x00) //exit if timeout
+
407  // return ( rcode);
+
408 
+
409  rcode = (regRd(rHRSL) & 0x0f); //analyze transfer result
+
410 
+
411  switch (rcode) {
+
412  case hrNAK:
+
413  nak_count++;
+
414  if (nak_limit && (nak_count == nak_limit))
+
415  return (rcode);
+
416  break;
+
417  case hrTIMEOUT:
+
418  retry_count++;
+
419  if (retry_count == USB_RETRY_LIMIT)
+
420  return (rcode);
+
421  break;
+
422  default:
+
423  return (rcode);
+
424  }//switch( rcode
+
425 
+
426  }//while( timeout > millis()
+
427  return ( rcode);
+
428 }
+
429 
+
430 /* USB main task. Performs enumeration/cleanup */
+
431 void USB::Task(void) //USB state machine
+
432 {
+
433  uint8_t rcode;
+
434  uint8_t tmpdata;
+
435  static unsigned long delay = 0;
+
436  //USB_DEVICE_DESCRIPTOR buf;
+
437  bool lowspeed = false;
+
438 
+
439  MAX3421E::Task();
+
440 
+
441  tmpdata = getVbusState();
+
442 
+
443  /* modify USB task state if Vbus changed */
+
444  switch (tmpdata) {
+
445  case SE1: //illegal state
+
446  usb_task_state = USB_DETACHED_SUBSTATE_ILLEGAL;
+
447  lowspeed = false;
+
448  break;
+
449  case SE0: //disconnected
+
450  if ((usb_task_state & USB_STATE_MASK) != USB_STATE_DETACHED)
+
451  usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE;
+
452  lowspeed = false;
+
453  break;
+
454  case LSHOST:
+
455  // if ((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) {
+
456  lowspeed = true;
+
457  // }
+
458  case FSHOST: //attached
+
459  if ((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) {
+
460  delay = millis() + USB_SETTLE_DELAY;
+
461  usb_task_state = USB_ATTACHED_SUBSTATE_SETTLE;
+
462  }
+
463  break;
+
464  }// switch( tmpdata
+
465 
+
466  for (uint8_t i = 0; i < USB_NUMDEVICES; i++)
+
467  if (devConfig[i])
+
468  rcode = devConfig[i]->Poll();
+
469 
+
470  switch (usb_task_state) {
+ +
472  init();
+
473 
+
474  for (uint8_t i = 0; i < USB_NUMDEVICES; i++)
+
475  if (devConfig[i])
+
476  rcode = devConfig[i]->Release();
+
477 
+
478  usb_task_state = USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE;
+
479  break;
+
480  case USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE: //just sit here
+
481  break;
+
482  case USB_DETACHED_SUBSTATE_ILLEGAL: //just sit here
+
483  break;
+
484  case USB_ATTACHED_SUBSTATE_SETTLE: //settle time for just attached device
+
485  if (delay < millis())
+
486  usb_task_state = USB_ATTACHED_SUBSTATE_RESET_DEVICE;
+
487  break;
+ +
489  regWr(rHCTL, bmBUSRST); //issue bus reset
+ +
491  break;
+ +
493  if ((regRd(rHCTL) & bmBUSRST) == 0) {
+
494  tmpdata = regRd(rMODE) | bmSOFKAENAB; //start SOF generation
+
495  regWr(rMODE, tmpdata);
+
496  usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_SOF;
+
497  //delay = millis() + 20; //20ms wait after reset per USB spec
+
498  }
+
499  break;
+
500  case USB_ATTACHED_SUBSTATE_WAIT_SOF: //todo: change check order
+
501  if (regRd(rHIRQ) & bmFRAMEIRQ) {
+
502  //when first SOF received _and_ 20ms has passed we can continue
+
503  /*
+
504  if (delay < millis()) //20ms passed
+
505  usb_task_state = USB_STATE_CONFIGURING;
+
506  */
+
507  usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_RESET;
+
508  delay = millis() + 20;
+
509  }
+
510  break;
+ +
512  if (delay < millis()) usb_task_state = USB_STATE_CONFIGURING;
+
513  break;
+ +
515 
+
516  //Serial.print("\r\nConf.LS: ");
+
517  //Serial.println(lowspeed, HEX);
+
518 
+
519  rcode = Configuring(0, 0, lowspeed);
+
520 
+
521  if (rcode) {
+ +
523  usb_error = rcode;
+
524  usb_task_state = USB_STATE_ERROR;
+
525  }
+
526  } else
+
527  usb_task_state = USB_STATE_RUNNING;
+
528  break;
+
529  case USB_STATE_RUNNING:
+
530  break;
+
531  case USB_STATE_ERROR:
+
532  //MAX3421E::Init();
+
533  break;
+
534  } // switch( usb_task_state )
+
535 }
536 
-
537  if (!p0->epinfo)
- -
539 
-
540  p0->lowspeed = (lowspeed) ? true : false;
+
537 uint8_t USB::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) {
+
538  //uint8_t buf[12];
+
539  uint8_t rcode;
+
540  UsbDevice *p0 = NULL, *p = NULL;
541 
-
542  // Allocate new address according to device class
-
543  uint8_t bAddress = addrPool.AllocAddress(parent, false, port);
+
542  // Get pointer to pseudo device with address 0 assigned
+
543  p0 = addrPool.GetUsbDevicePtr(0);
544 
-
545  if (!bAddress)
- +
545  if (!p0)
+
547 
-
548  p = addrPool.GetUsbDevicePtr(bAddress);
-
549 
-
550  if (!p)
- +
548  if (!p0->epinfo)
+ +
550 
+
551  p0->lowspeed = (lowspeed) ? true : false;
552 
-
553  p->lowspeed = lowspeed;
-
554 
-
555  // Assign new address to the device
-
556  rcode = setAddr(0, 0, bAddress);
-
557 
-
558  if (rcode) {
-
559  addrPool.FreeAddress(bAddress);
-
560  bAddress = 0;
-
561  return rcode;
-
562  }
-
563  return 0;
-
564 };
+
553  // Allocate new address according to device class
+
554  uint8_t bAddress = addrPool.AllocAddress(parent, false, port);
+
555 
+
556  if (!bAddress)
+ +
558 
+
559  p = addrPool.GetUsbDevicePtr(bAddress);
+
560 
+
561  if (!p)
+ +
563 
+
564  p->lowspeed = lowspeed;
565 
-
566 /*
-
567  * This is broken. We need to enumerate differently.
-
568  * It causes major problems with several devices if detected in an unexpected order.
-
569  *
-
570  *
-
571  * Oleg - I wouldn't do anything before the newly connected device is considered sane.
-
572  * i.e.(delays are not indicated for brevity):
-
573  * 1. reset
-
574  * 2. GetDevDescr();
-
575  * 3a. If ACK, continue with allocating address, addressing, etc.
-
576  * 3b. Else reset again, count resets, stop at some number (5?).
-
577  * 4. When max.number of resets is reached, toggle power/fail
-
578  * If desired, this could be modified by performing two resets with GetDevDescr() in the middle - however, from my experience, if a device answers to GDD()
-
579  * it doesn't need to be reset again
-
580  * New steps proposal:
-
581  * 1: get address pool instance. exit on fail
-
582  * 2: pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf). exit on fail.
-
583  * 3: bus reset, 100ms delay
-
584  * 4: set address
-
585  * 5: pUsb->setEpInfoEntry(bAddress, 1, epInfo), exit on fail
-
586  * 6: while (configurations) {
-
587  * for(each configuration) {
-
588  * for (each driver) {
-
589  * 6a: Ask device if it likes configuration. Returns 0 on OK.
-
590  * If successful, the driver configured device.
-
591  * The driver now owns the endpoints, and takes over managing them.
-
592  * The following will need codes:
-
593  * Everything went well, instance consumed, exit with success.
-
594  * Instance already in use, ignore it, try next driver.
-
595  * Not a supported device, ignore it, try next driver.
-
596  * Not a supported configuration for this device, ignore it, try next driver.
-
597  * Could not configure device, fatal, exit with fail.
-
598  * }
-
599  * }
-
600  * }
-
601  * 7: for(each driver) {
-
602  * 7a: Ask device if it knows this VID/PID. Acts exactly like 6a, but using VID/PID
-
603  * 8: if we get here, no driver likes the device plugged in, so exit failure.
-
604  *
-
605  */
-
606 uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
-
607  uint8_t rcode = 0;
-
608 
-
609  for (; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) {
-
610  if (!devConfig[devConfigIndex])
-
611  continue;
-
612 
-
613  rcode = devConfig[devConfigIndex]->ConfigureDevice(parent, port, lowspeed);
- -
615  if (parent == 0) {
-
616  // Send a bus reset on the root interface.
-
617  regWr(rHCTL, bmBUSRST); //issue bus reset
-
618  delay(102); // delay 102ms, compensate for clock inaccuracy.
-
619  } /* else {
-
620  * @Oleg
-
621  * TO-DO:
-
622  * How do we do an individual bus reset on a child interface?
-
623  * Is that even possible with the current code?
-
624  */
-
625  }
-
626  rcode = devConfig[devConfigIndex]->Init(parent, port, lowspeed);
-
627  if (!rcode) {
-
628  devConfigIndex = 0;
-
629  return 0;
-
630  }
-
631  //printf("ERROR ENUMERATING %2.2x\r\n", rcode);
- -
633  // in case of an error dev_index should be reset to 0
-
634  // in order to start from the very beginning the
-
635  // next time the program gets here
- -
637  devConfigIndex = 0;
-
638  return rcode;
-
639  }
-
640  }
-
641  // if we get here that means that the device class is not supported by any of registered classes
-
642  devConfigIndex = 0;
-
643 
-
644  rcode = DefaultAddressing(parent, port, lowspeed);
+
566  // Assign new address to the device
+
567  rcode = setAddr(0, 0, bAddress);
+
568 
+
569  if (rcode) {
+
570  addrPool.FreeAddress(bAddress);
+
571  bAddress = 0;
+
572  return rcode;
+
573  }
+
574  return 0;
+
575 };
+
576 
+
577 uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed) {
+
578  uint8_t rcode = 0;
+
579  //printf("AttemptConfig: parent = %i, port = %i\r\n", parent, port);
+
580 
+
581  rcode = devConfig[driver]->ConfigureDevice(parent, port, lowspeed);
+ +
583  if (parent == 0) {
+
584  // Send a bus reset on the root interface.
+
585  regWr(rHCTL, bmBUSRST); //issue bus reset
+
586  delay(102); // delay 102ms, compensate for clock inaccuracy.
+
587  } else {
+
588  // reset parent port
+
589  devConfig[parent]->ResetHubPort(port);
+
590  }
+
591  }
+
592  rcode = devConfig[driver]->Init(parent, port, lowspeed);
+
593  return rcode;
+
594 }
+
595 
+
596 /*
+
597  * This is broken. We need to enumerate differently.
+
598  * It causes major problems with several devices if detected in an unexpected order.
+
599  *
+
600  *
+
601  * Oleg - I wouldn't do anything before the newly connected device is considered sane.
+
602  * i.e.(delays are not indicated for brevity):
+
603  * 1. reset
+
604  * 2. GetDevDescr();
+
605  * 3a. If ACK, continue with allocating address, addressing, etc.
+
606  * 3b. Else reset again, count resets, stop at some number (5?).
+
607  * 4. When max.number of resets is reached, toggle power/fail
+
608  * If desired, this could be modified by performing two resets with GetDevDescr() in the middle - however, from my experience, if a device answers to GDD()
+
609  * it doesn't need to be reset again
+
610  * New steps proposal:
+
611  * 1: get address pool instance. exit on fail
+
612  * 2: pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf). exit on fail.
+
613  * 3: bus reset, 100ms delay
+
614  * 4: set address
+
615  * 5: pUsb->setEpInfoEntry(bAddress, 1, epInfo), exit on fail
+
616  * 6: while (configurations) {
+
617  * for(each configuration) {
+
618  * for (each driver) {
+
619  * 6a: Ask device if it likes configuration. Returns 0 on OK.
+
620  * If successful, the driver configured device.
+
621  * The driver now owns the endpoints, and takes over managing them.
+
622  * The following will need codes:
+
623  * Everything went well, instance consumed, exit with success.
+
624  * Instance already in use, ignore it, try next driver.
+
625  * Not a supported device, ignore it, try next driver.
+
626  * Not a supported configuration for this device, ignore it, try next driver.
+
627  * Could not configure device, fatal, exit with fail.
+
628  * }
+
629  * }
+
630  * }
+
631  * 7: for(each driver) {
+
632  * 7a: Ask device if it knows this VID/PID. Acts exactly like 6a, but using VID/PID
+
633  * 8: if we get here, no driver likes the device plugged in, so exit failure.
+
634  *
+
635  */
+
636 uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
+
637  //uint8_t bAddress = 0;
+
638  //printf("Configuring: parent = %i, port = %i\r\n", parent, port);
+
639  uint8_t devConfigIndex;
+
640  uint8_t rcode = 0;
+
641  uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
+
642  UsbDevice *p = NULL;
+
643  EpInfo *oldep_ptr = NULL;
+
644  EpInfo epInfo;
645 
-
646  return rcode;
-
647 }
-
648 
-
649 uint8_t USB::ReleaseDevice(uint8_t addr) {
-
650  if (!addr)
-
651  return 0;
-
652 
-
653  for (uint8_t i = 0; i < USB_NUMDEVICES; i++)
-
654  if (devConfig[i]->GetAddress() == addr)
-
655  return devConfig[i]->Release();
-
656 
-
657  return 0;
-
658 }
+
646  epInfo.epAddr = 0;
+
647  epInfo.maxPktSize = 8;
+
648  epInfo.epAttribs = 0;
+
649  epInfo.bmNakPower = USB_NAK_MAX_POWER;
+
650 
+
651  delay(2000);
+
652  AddressPool &addrPool = GetAddressPool();
+
653  // Get pointer to pseudo device with address 0 assigned
+
654  p = addrPool.GetUsbDevicePtr(0);
+
655  if (!p) {
+
656  //printf("Configuring error: USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL\r\n");
+ +
658  }
659 
-
660 #if 1
-
661 //get device descriptor
-
662 
-
663 uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) {
-
664  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, nbytes, dataptr, NULL));
-
665 }
-
666 //get configuration descriptor
+
660  // Save old pointer to EP_RECORD of address 0
+
661  oldep_ptr = p->epinfo;
+
662 
+
663  // Temporary assign new pointer to epInfo to p->epinfo in order to
+
664  // avoid toggle inconsistence
+
665 
+
666  p->epinfo = &epInfo;
667 
-
668 uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) {
-
669  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, nbytes, dataptr, NULL));
-
670 }
+
668  p->lowspeed = lowspeed;
+
669  // Get device descriptor
+
670  rcode = getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf);
671 
-
672 uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p) {
-
673  const uint8_t bufSize = 64;
-
674  uint8_t buf[bufSize];
-
675 
-
676  uint8_t ret = getConfDescr(addr, ep, 8, conf, buf);
-
677 
-
678  if (ret)
-
679  return ret;
-
680 
-
681  uint16_t total = ((USB_CONFIGURATION_DESCRIPTOR*)buf)->wTotalLength;
-
682 
-
683  //USBTRACE2("\r\ntotal conf.size:", total);
-
684 
-
685  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, total, bufSize, buf, p));
-
686 }
-
687 
-
688 //get string descriptor
-
689 
-
690 uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t ns, uint8_t index, uint16_t langid, uint8_t* dataptr) {
-
691  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns, ns, dataptr, NULL));
-
692 }
-
693 //set address
-
694 
-
695 uint8_t USB::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) {
-
696  return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL));
-
697 }
-
698 //set configuration
-
699 
-
700 uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) {
-
701  return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL));
-
702 }
+
672  // Restore p->epinfo
+
673  p->epinfo = oldep_ptr;
+
674 
+
675  if (rcode) {
+
676  //printf("Configuring error: Can't get USB_DEVICE_DESCRIPTOR\r\n");
+
677  return rcode;
+
678  }
+
679 
+
680  // to-do?
+
681  // Allocate new address according to device class
+
682  //bAddress = addrPool.AllocAddress(parent, false, port);
+
683 
+
684  //if (!bAddress)
+
685  // return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
+
686 
+
687  uint16_t vid = (uint16_t)((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
+
688  uint16_t pid = (uint16_t)((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
+
689  uint8_t klass = ((USB_DEVICE_DESCRIPTOR*)buf)->bDeviceClass;
+
690 
+
691  // Attempt to configure if VID/PID or device class matches with a driver
+
692  for (devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) {
+
693  if (!devConfig[devConfigIndex]) continue; // no driver
+
694  if (devConfig[devConfigIndex]->GetAddress()) continue; // consumed
+
695  if (devConfig[devConfigIndex]->VIDPIDOK(vid, pid)) {
+
696  rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed);
+
697  break;
+
698  } else if (devConfig[devConfigIndex]->DEVCLASSOK(klass)) {
+
699  rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed);
+
700  if (!rcode) break;
+
701  }
+
702  }
703 
-
704 #endif // defined(USB_METHODS_INLINE)
-
705 
+
704  if (devConfigIndex < USB_NUMDEVICES) {
+
705  return rcode;
+
706  }
+
707 
+
708 
+
709  // blindly attempt to configure
+
710  for (devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) {
+
711  if (!devConfig[devConfigIndex]) continue;
+
712  if (devConfig[devConfigIndex]->GetAddress()) continue; // consumed
+
713  rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed);
+
714 
+
715  //printf("ERROR ENUMERATING %2.2x\r\n", rcode);
+ +
717  // in case of an error dev_index should be reset to 0
+
718  // in order to start from the very beginning the
+
719  // next time the program gets here
+
720  //if (rcode != USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE)
+
721  // devConfigIndex = 0;
+
722  return rcode;
+
723  }
+
724  }
+
725  // if we get here that means that the device class is not supported by any of registered classes
+
726  rcode = DefaultAddressing(parent, port, lowspeed);
+
727 
+
728  return rcode;
+
729 }
+
730 
+
731 uint8_t USB::ReleaseDevice(uint8_t addr) {
+
732  if (!addr)
+
733  return 0;
+
734 
+
735  for (uint8_t i = 0; i < USB_NUMDEVICES; i++) {
+
736  if(!devConfig[i]) continue;
+
737  if (devConfig[i]->GetAddress() == addr)
+
738  return devConfig[i]->Release();
+
739  }
+
740  return 0;
+
741 }
+
742 
+
743 #if 1
+
744 //get device descriptor
+
745 
+
746 uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) {
+
747  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, nbytes, dataptr, NULL));
+
748 }
+
749 //get configuration descriptor
+
750 
+
751 uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) {
+
752  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, nbytes, dataptr, NULL));
+
753 }
+
754 
+
755 uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p) {
+
756  const uint8_t bufSize = 64;
+
757  uint8_t buf[bufSize];
+
758 
+
759  uint8_t ret = getConfDescr(addr, ep, 8, conf, buf);
+
760 
+
761  if (ret)
+
762  return ret;
+
763 
+
764  uint16_t total = ((USB_CONFIGURATION_DESCRIPTOR*)buf)->wTotalLength;
+
765 
+
766  //USBTRACE2("\r\ntotal conf.size:", total);
+
767 
+
768  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, total, bufSize, buf, p));
+
769 }
+
770 
+
771 //get string descriptor
+
772 
+
773 uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t ns, uint8_t index, uint16_t langid, uint8_t* dataptr) {
+
774  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns, ns, dataptr, NULL));
+
775 }
+
776 //set address
+
777 
+
778 uint8_t USB::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) {
+
779  return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL));
+
780 }
+
781 //set configuration
+
782 
+
783 uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) {
+
784  return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL));
+
785 }
+
786 
+
787 #endif // defined(USB_METHODS_INLINE)
+
788