Browse Source

first commit

wareck 2 years ago
commit
1d965c883d
100 changed files with 16467 additions and 0 deletions
  1. 510 0
      LICENSE
  2. 34 0
      PKG-INFO
  3. 92 0
      README
  4. 65 0
      backup/GekkoScience-2pac.hex
  5. 65 0
      backup/cp210x_amazon.hex
  6. 65 0
      backup/eeprom-content.2pac.hex
  7. 65 0
      backup/eeprom-content.AntU3-custom.hex
  8. 65 0
      backup/eeprom-content.BTCGuild.hex
  9. 65 0
      backup/eeprom-content.BTCOxygen.hex
  10. 65 0
      backup/eeprom-content.Bitfountain.hex
  11. 65 0
      backup/eeprom-content.GekkoScience-Compac-bitshopperde.hex
  12. 65 0
      backup/eeprom-content.GekkoScience-Compac.hex
  13. 65 0
      backup/eeprom-content.GekkoScience-original.hex
  14. 65 0
      backup/eeprom-content.LKETC_usb.hex
  15. 65 0
      backup/eeprom-content.RBOX.hex
  16. 65 0
      backup/eeprom-content.Zeus.hex
  17. 65 0
      backup/eeprom-content.rockminer_original.hex
  18. 18 0
      batch.txt
  19. 20 0
      branding.GekkoScience-Compac.bash
  20. 32 0
      build.sh
  21. 4 0
      build/lib.linux-armv6l-2.7/cp210x/__init__.py
  22. 360 0
      build/lib.linux-armv6l-2.7/cp210x/cp210x.py
  23. 190 0
      build/lib.linux-armv6l-2.7/cp210x/eeprom.py
  24. 234 0
      build/lib.linux-armv6l-2.7/cp210x/valuefile.py
  25. 4 0
      build/lib.linux-x86_64-2.7/cp210x/__init__.py
  26. 360 0
      build/lib.linux-x86_64-2.7/cp210x/cp210x.py
  27. 190 0
      build/lib.linux-x86_64-2.7/cp210x/eeprom.py
  28. 234 0
      build/lib.linux-x86_64-2.7/cp210x/valuefile.py
  29. 263 0
      build/scripts-2.7/cp210x-program
  30. 263 0
      cp210x-program
  31. 83 0
      cp210x-program.doap
  32. 4 0
      cp210x/__init__.py
  33. BIN
      cp210x/__init__.pyc
  34. 360 0
      cp210x/cp210x.py
  35. BIN
      cp210x/cp210x.pyc
  36. 190 0
      cp210x/eeprom.py
  37. BIN
      cp210x/eeprom.pyc
  38. 234 0
      cp210x/valuefile.py
  39. BIN
      cp210x/valuefile.pyc
  40. 9 0
      doc/45-cp210x-programming.rules
  41. 110 0
      doc/cp210x.txt
  42. 28 0
      instruction.md
  43. 16 0
      pyusb/ACKNOWLEDGEMENTS
  44. 700 0
      pyusb/ChangeLog
  45. 27 0
      pyusb/LICENSE
  46. 15 0
      pyusb/PKG-INFO
  47. 78 0
      pyusb/README
  48. 20 0
      pyusb/TODO
  49. 85 0
      pyusb/build/lib.linux-armv6l-2.7/usb/__init__.py
  50. 67 0
      pyusb/build/lib.linux-armv6l-2.7/usb/_debug.py
  51. 135 0
      pyusb/build/lib.linux-armv6l-2.7/usb/_interop.py
  52. 368 0
      pyusb/build/lib.linux-armv6l-2.7/usb/backend/__init__.py
  53. 564 0
      pyusb/build/lib.linux-armv6l-2.7/usb/backend/libusb01.py
  54. 606 0
      pyusb/build/lib.linux-armv6l-2.7/usb/backend/libusb10.py
  55. 604 0
      pyusb/build/lib.linux-armv6l-2.7/usb/backend/openusb.py
  56. 252 0
      pyusb/build/lib.linux-armv6l-2.7/usb/control.py
  57. 839 0
      pyusb/build/lib.linux-armv6l-2.7/usb/core.py
  58. 331 0
      pyusb/build/lib.linux-armv6l-2.7/usb/legacy.py
  59. 260 0
      pyusb/build/lib.linux-armv6l-2.7/usb/util.py
  60. 533 0
      pyusb/docs/tutorial.txt
  61. 50 0
      pyusb/setup.py
  62. 42 0
      pyusb/tests/devinfo.py
  63. 17 0
      pyusb/tests/pic18f4550/Microchip Solutions/IMPORTANT README.txt
  64. 170 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/BDT_transfer.h
  65. 530 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/Benchmark.c
  66. 62 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/Benchmark.h
  67. 91 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/CleanUp.bat
  68. 136 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - Low Pin Count USB Development Kit.h
  69. 127 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC18F46J50 PIM.h
  70. 153 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC18F87J50 PIM.h
  71. 130 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC24F Starter Kit.h
  72. 137 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC24FJ256GB110 PIM.h
  73. 128 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC24FJ64GB002 BreadBoard.h
  74. 137 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC24FJ64GB004 PIM.h
  75. 120 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC32 USB Starter Kit.h
  76. 121 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC32MX460F512L PIM.h
  77. 165 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PICDEM FSUSB.h
  78. 96 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile.h
  79. 318 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PIC24 HID Bootloader Remapping.s
  80. 15 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PicFWCommands.h
  81. 126 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_LowPinCountDevKit.mcp
  82. BIN
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_LowPinCountDevKit.mcw
  83. 126 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_P18F46J50_PIM.mcp
  84. BIN
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_P18F46J50_PIM.mcw
  85. 126 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_P18F87J50_PIM.mcp
  86. BIN
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_P18F87J50_PIM.mcw
  87. 130 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_PICDEM_FSUSB.mcp
  88. 3 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_PICDEM_FSUSB.mcs
  89. BIN
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_PICDEM_FSUSB.mcw
  90. 138 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C30.mcp
  91. BIN
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C30.mcw
  92. 126 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C32_P32MX460F512L_PIM.mcp
  93. BIN
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C32_P32MX460F512L_PIM.mcw
  94. 126 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C32_StarterKit.mcp
  95. 3 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C32_StarterKit.mcs
  96. BIN
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C32_StarterKit.mcw
  97. 1215 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/main.c
  98. 1287 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/p24FJ256GB110 - HID Bootloader.gld
  99. 56 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/procdefs.ld.boot
  100. 24 0
      pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/projects/VStudio/CompilerSettings.txt

+ 510 - 0
LICENSE

@@ -0,0 +1,510 @@
+
+                  GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+	51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes a de-facto standard.  To achieve this, non-free programs must
+be allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+                  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at least
+    three years, to give the same user the materials specified in
+    Subsection 6a, above, for a charge no more than the cost of
+    performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms
+of the ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the "copyright" line and a pointer to where the full
+notice is found.
+
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or
+your school, if any, to sign a "copyright disclaimer" for the library,
+if necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James
+  Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+

+ 34 - 0
PKG-INFO

@@ -0,0 +1,34 @@
+Metadata-Version: 1.1
+Name: cp210x-program
+Version: 1.0
+Summary: Provides access to the EEPROM in an Silabs CP210x
+Home-page: http://cp210x-program.sourceforge.net/
+Author: Petr Tesařík
+Author-email: cp210x@tesarici.cz
+License: GNU LGPL
+Description: 
+        The goal of this library is to provide access to the EEPROM of an Silabs CP210x
+        under Linux. 
+        
+        The CP210x is an USB-to-serial chip used in a lot of USB devices (similar to
+        FTDIs and PL2303). The CP210x has a EEPROM on the chip which can be programmed
+        via USB. Silabs provides already a library and gui programm to program this
+        EEPROM, but only for windows. 
+        
+        For more information see:
+        * http://www.silabs.com/tgwWebApp/public/web_content/products/Microcontrollers/Interface/en/interface.htm
+        * http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/Interface/en/an144.pdf
+        
+        Requires:
+        * libusb: http://libusb.sourceforge.net/
+        * ctypes: http://starship.python.net/crew/theller/ctypes/
+        
+Platform: POSIX
+Classifier: License :: OSI-Approved Open Source :: GNU Library or Lesser General Public License (LGPL)
+Classifier: Intended Audience :: Manufacturing
+Classifier: Development Status :: 4 - Beta
+Classifier: Topic :: System :: Hardware :: Hardware Drivers
+Classifier: Programming Language :: Python
+Classifier: Operating System :: POSIX :: Linux
+Classifier: Operating System :: POSIX :: BSD :: FreeBSD
+Classifier: Operating System :: MacOS :: MacOS X

+ 92 - 0
README

@@ -0,0 +1,92 @@
+
+    cp210x-program
+    ==============
+
+ATTENTION: THIS VERSION OF cp210x-program IS NOT FULLY TESTED. IT MAY RENDER
+           YOUR CP210x USELESS OR DESTROY IT.
+
+Be aware that the current version is only tested on CP2102.
+
+The goal of this library is to provide access to the EEPROM of an Silabs CP210x
+under Linux. 
+
+The CP210x is an USB-to-serial chip used in a lot of USB devices (similar to
+FTDIs and PL2303). The CP210x has a EEPROM on the chip which can be programmed
+via USB. Silabs provides already a library and gui programm to program this
+EEPROM, but only for windows. 
+
+This project uses results from monitoring the USB bus when the windows library
+programms an CP210x. The windows library was not disassembled for this protocol
+analysis.
+
+When the programm is finished, a later goal would be to provide a library which
+can be used to access further functions of the CP210x like the general IO pins
+of the CP2103. The goal is not to provide an tty driver, such driver exists
+already for linux and BSD.
+
+Version: 1.0
+Author: Johannes Hölzl <johannes.hoelzl@gmx.de>
+Maintainer: Petr Tesařík <cp210x@tesarici.cz>
+
+Dependencies
+------------
+
+ * Python >= 2.4
+ * PyUSB
+ 
+Since libusb is available on most Linux, Mac OS X and FreeBSD cp210x-program
+should run flawlessly on these platforms. Currently it is only tested on
+Linux 2.6 (Ubuntu).
+
+If cp210x-program should run as non-root user, add the udev rule found in
+doc/45-cp210x-programming.rules to /etc/udev/rules.d. When devices with already
+programmed IDs are reprogrammed at this IDs to 45-cp210x-programming.rules.
+
+Usage
+-----
+
+Read EEPROM content into hexfile:
+$ cp210x-program --read-cp210x -F eeprom-content.hex
+
+Show EEPROM content from device 002 on bus 001:
+$ cp210x-program --read-cp210x -m 001/002
+
+Write some data to device with vendor id 0x10C4 and product id 0xEA62:
+$ cp210x-program --write-cp210x -m 10C4:EA62 \
+                 --set-product-string="Product String" \
+                 --set-max-power=100 \
+                 --set-bus-powered=no
+
+TODO
+----
+
+ * Test on other than CP2102
+
+ * Implement CP2103 GIOP settings
+ 
+ * Implement GUI
+ 
+Links
+-----
+
+ * CP210x Product page on Silicon Labs:
+    http://www.silabs.com/tgwWebApp/public/web_content/products/Microcontrollers/Interface/en/interface.htm
+    
+ * AN114 Customization Guide:
+    http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/Interface/en/an144.pdf
+    http://www.silabs.com/public/documents/software_doc/othersoftware/Microcontrollers/Interface/en/an144sw.zip
+    
+ * AN205 CP210x Baudrate Guide:
+    http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/Interface/en/an205.pdf
+    http://www.silabs.com/public/documents/software_doc/othersoftware/Microcontrollers/en/AN205SW.zip
+    
+ * AN223 Port Configuration and GPIO for CP210x
+    http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/Interface/en/an223.pdf
+    http://www.silabs.com/public/documents/software_doc/othersoftware/Microcontrollers/Interface/en/AN223SW.zip
+
+License
+-------
+
+The python package 'cp210x' and the python script 'cp210x-program' are provided
+under the terms of the GNU LGPL. See LICENSE.
+

+ 65 - 0
backup/GekkoScience-2pac.hex

@@ -0,0 +1,65 @@
+:10360000fff0fffa010060e31600fff0fffa01008f
+:1036100060e31600ffecfff80100804f1200ffe6a8
+:10362000fff6010000100e00ffd6fff0010000caf7
+:103630000800ffd0ffee010020a10700ffccffec47
+:10364000010000080700ffa2ffdc010000e8030002
+:10365000ffa0ffdc010090d00300ff98ffd901001c
+:1036600000840300ff64ffc5010000580200ff440e
+:10367000ffb9010000f40100ff30ffb2010000c2f9
+:103680000100fec8ff8b0100002c0100fe89ff73c2
+:10369000010000fa0000fe5fff63010000e100008e
+:1036a000fe53ff5f0100c0da0000fe2bff50010057
+:1036b00000c80000fd8fff15010000960000fcbf50
+:1036c000fec7010080700000fb1efe2b0100004bb6
+:1036d0000000fa24fe0c0100803e0000f97dfe0c83
+:1036e000010040380000f63cfe0c0100802500007f
+:1036f000f2fbfe0c0100201c0000ec78fe0c010027
+:10370000c0120000e890fe0c0100a00f0000d8f0ed
+:10371000fe0c010060090000cbebfe0c0100080765
+:103720000000b1e0fe0c0100b004000063c0fe0c1c
+:10373000010058020000b1e0fe0c04002c01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037a0000000000000000000000000000000000019
+:1037b0000000000000000000000000000000000009
+:1037c00000000000000000000000000000000000f9
+:1037d00000000000000000000000000000000000e9
+:1037e00000000000000000000000000000000000d9
+:1037f00000000000000000000000000000000002c7
+:10380000040309040000000034033200500061008a
+:103810006300200042004d003100330038003400c6
+:10382000200042006900740063006f0069006e00b0
+:1038300020004d0069006e00650072006500720096
+:103840006f006e00740072006f006c006c00650009
+:1038500072000000000000000000000000000000f6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038a0000000000000000000000000000000000018
+:1038b0000000000000000000000000000000000008
+:1038c00000000000000000000000000000000000f8
+:1038d00000000000000000000000000000000000e8
+:1038e00000000000000000000000000000000000d8
+:1038f00000000000000000000000000000000000c8
+:10390000000000000000001803470053002d0031a4
+:10391000003000300031003300370038003800003c
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040d1
+:10399000c41060ea000101020301090220000101d4
+:1039a0000080fa0904000002ff00000207058102fe
+:1039b0004000000705010240000000000000000078
+:1039c0000000001a03620069007400730068006f51
+:1039d0000070007000650072006400650000000067
+:1039e00000000000000000000000000000000000d7
+:1039f000000000000000000000000000000000ffc8
+:00000001FF

+ 65 - 0
backup/cp210x_amazon.hex

@@ -0,0 +1,65 @@
+:10360000fff0fffa010060e31600fff0fffa01008f
+:1036100060e31600ffecfff80100804f1200ffe6a8
+:10362000fff6010000100e00ffd6fff0010000caf7
+:103630000800ffd0ffee010020a10700ffccffec47
+:10364000010000080700ffa2ffdc010000e8030002
+:10365000ffa0ffdc010090d00300ff98ffd901001c
+:1036600000840300ff64ffc5010000580200ff440e
+:10367000ffb9010000f40100ff30ffb2010000c2f9
+:103680000100fec8ff8b0100002c0100fe89ff73c2
+:10369000010000fa0000fe5fff63010000e100008e
+:1036a000fe53ff5f0100c0da0000fe2bff50010057
+:1036b00000c80000fd8fff15010000960000fcbf50
+:1036c000fec7010080700000fb1efe2b0100004bb6
+:1036d0000000fa24fe0c0100803e0000f97dfe0c83
+:1036e000010040380000f63cfe0c0100802500007f
+:1036f000f2fbfe0c0100201c0000ec78fe0c010027
+:10370000c0120000e890fe0c0100a00f0000d8f0ed
+:10371000fe0c010060090000cbebfe0c0100080765
+:103720000000b1e0fe0c0100b004000063c0fe0c1c
+:10373000010058020000b1e0fe0c04002c01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037a0000000000000000000000000000000000019
+:1037b0000000000000000000000000000000000009
+:1037c00000000000000000000000000000000000f9
+:1037d00000000000000000000000000000000000e9
+:1037e00000000000000000000000000000000000d9
+:1037f00000000000000000000000000000000002c7
+:1038000004030904000000004a0343005000320092
+:1038100031003000320020005500530042002000eb
+:1038200074006f0020005500410052005400200039
+:1038300042007200690064006700650020004300d8
+:103840006f006e00740072006f006c006c00650009
+:1038500072000000000000000000000000000000f6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038a0000000000000000000000000000000000018
+:1038b0000000000000000000000000000000000008
+:1038c00000000000000000000000000000000000f8
+:1038d00000000000000000000000000000000000e8
+:1038e00000000000000000000000000000000000d8
+:1038f00000000000000000000000000000000000c8
+:10390000000000000000000a0330003000300031e9
+:1039100000000000000000000000000000000000a7
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040d1
+:10399000c41060ea000101020301090220000101d4
+:1039a0000080320904000002ff00000207058102c6
+:1039b0004000000705010240000000000000000078
+:1039c0000000001a03530069006c00690063006f77
+:1039d000006e0020004c00610062007300000000d7
+:1039e00000000000000000000000000000000000d7
+:1039f000000000000000000000000000000000ffc8
+:00000001FF

+ 65 - 0
backup/eeprom-content.2pac.hex

@@ -0,0 +1,65 @@
+:10360000fff0fffa010060e31600fff0fffa01008f
+:1036100060e31600ffecfff80100804f1200ffe6a8
+:10362000fff6010000100e00ffd6fff0010000caf7
+:103630000800ffd0ffee010020a10700ffccffec47
+:10364000010000080700ffa2ffdc010000e8030002
+:10365000ffa0ffdc010090d00300ff98ffd901001c
+:1036600000840300ff64ffc5010000580200ff440e
+:10367000ffb9010000f40100ff30ffb2010000c2f9
+:103680000100fec8ff8b0100002c0100fe89ff73c2
+:10369000010000fa0000fe5fff63010000e100008e
+:1036a000fe53ff5f0100c0da0000fe2bff50010057
+:1036b00000c80000fd8fff15010000960000fcbf50
+:1036c000fec7010080700000fb1efe2b0100004bb6
+:1036d0000000fa24fe0c0100803e0000f97dfe0c83
+:1036e000010040380000f63cfe0c0100802500007f
+:1036f000f2fbfe0c0100201c0000ec78fe0c010027
+:10370000c0120000e890fe0c0100a00f0000d8f0ed
+:10371000fe0c010060090000cbebfe0c0100080765
+:103720000000b1e0fe0c0100b004000063c0fe0c1c
+:10373000010058020000b1e0fe0c04002c01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037a0000000000000000000000000000000000019
+:1037b0000000000000000000000000000000000009
+:1037c00000000000000000000000000000000000f9
+:1037d00000000000000000000000000000000000e9
+:1037e00000000000000000000000000000000000d9
+:1037f00000000000000000000000000000000002c7
+:10380000040309040000000034033200500061008a
+:103810006300200042004d003100330038003400c6
+:10382000200042006900740063006f0069006e00b0
+:1038300020004d0069006e00650072006500720096
+:103840006f006e00740072006f006c006c00650009
+:1038500072000000000000000000000000000000f6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038a0000000000000000000000000000000000018
+:1038b0000000000000000000000000000000000008
+:1038c00000000000000000000000000000000000f8
+:1038d00000000000000000000000000000000000e8
+:1038e00000000000000000000000000000000000d8
+:1038f00000000000000000000000000000000000c8
+:10390000000000000000001803470053002d0031a4
+:10391000003000300031003300370038003800003c
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040d1
+:10399000c41060ea000101020301090220000101d4
+:1039a0000080fa0904000002ff00000207058102fe
+:1039b0004000000705010240000000000000000078
+:1039c0000000001a03620069007400730068006f51
+:1039d0000070007000650072006400650000000067
+:1039e00000000000000000000000000000000000d7
+:1039f000000000000000000000000000000000ffc8
+:00000001FF

+ 65 - 0
backup/eeprom-content.AntU3-custom.hex

@@ -0,0 +1,65 @@
+:10360000fff0fffa010060e31600fff0fffa01008f
+:1036100060e31600ffecfff80100804f1200ffe6a8
+:10362000fff6010000100e00ffd6fff0010000caf7
+:103630000800ffd0ffee010020a10700ffccffec47
+:10364000010000080700ffa2ffdc010000e8030002
+:10365000ffa0ffdc010090d00300ff98ffd901001c
+:1036600000840300ff64ffc5010000580200ff440e
+:10367000ffb9010000f40100ff30ffb2010000c2f9
+:103680000100fec8ff8b0100002c0100fe89ff73c2
+:10369000010000fa0000fe5fff63010000e100008e
+:1036a000fe53ff5f0100c0da0000fe2bff50010057
+:1036b00000c80000fd8fff15010000960000fcbf50
+:1036c000fec7010080700000fb1efe2b0100004bb6
+:1036d0000000fa24fe0c0100803e0000f97dfe0c83
+:1036e000010040380000f63cfe0c0100802500007f
+:1036f000f2fbfe0c0100201c0000ec78fe0c010027
+:10370000c0120000e890fe0c0100a00f0000d8f0ed
+:10371000fe0c010060090000cbebfe0c0100080765
+:103720000000b1e0fe0c0100b004000063c0fe0c1c
+:10373000010058020000b1e0fe0c04002c01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037a0000000000000000000000000000000000019
+:1037b0000000000000000000000000000000000009
+:1037c00000000000000000000000000000000000f9
+:1037d00000000000000000000000000000000000e9
+:1037e00000000000000000000000000000000000d9
+:1037f00000000000000000000000000000000002c7
+:103800000403090400000000180341006e00740066
+:103810006d0069006e0065007200200055003300e5
+:1038200074006f0020005500410052005400200039
+:1038300042007200690064006700650020004300d8
+:103840006f006e00740072006f006c006c00650009
+:1038500072000000000000000000000000000000f6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038a0000000000000000000000000000000000018
+:1038b0000000000000000000000000000000000008
+:1038c00000000000000000000000000000000000f8
+:1038d00000000000000000000000000000000000e8
+:1038e00000000000000000000000000000000000d8
+:1038f00000000000000000000000000000000000c8
+:103900000000000000000010036c006a007200302c
+:103910000030003000310000000000000000000016
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040d1
+:10399000c41060ea000101020301090220000101d4
+:1039a0000080320904000002ff00000207058102c6
+:1039b0004000000705010240000000000000000078
+:1039c0000000001a034200690074006d0061006984
+:1039d000006e0020005400650063006800000000d5
+:1039e00000000000000000000000000000000000d7
+:1039f000000000000000000000000000000000ffc8
+:00000001FF

+ 65 - 0
backup/eeprom-content.BTCGuild.hex

@@ -0,0 +1,65 @@
+:10360000fff0fffa010060e31600fff0fffa01008f
+:1036100060e31600ffecfff80100804f1200ffe6a8
+:10362000fff6010000100e00ffd6fff0010000caf7
+:103630000800ffd0ffee010020a10700ffccffec47
+:10364000010000080700ffa2ffdc010000e8030002
+:10365000ffa0ffdc010090d00300ff98ffd901001c
+:1036600000840300ff64ffc5010000580200ff440e
+:10367000ffb9010000f40100ff30ffb2010000c2f9
+:103680000100fec8ff8b0100002c0100fe89ff73c2
+:10369000010000fa0000fe5fff63010000e100008e
+:1036a000fe53ff5f0100c0da0000fe2bff50010057
+:1036b00000c80000fd8fff15010000960000fcbf50
+:1036c000fec7010080700000fb1efe2b0100004bb6
+:1036d0000000fa24fe0c0100803e0000f97dfe0c83
+:1036e000010040380000f63cfe0c0100802500007f
+:1036f000f2fbfe0c0100201c0000ec78fe0c010027
+:10370000c0120000e890fe0c0100a00f0000d8f0ed
+:10371000fe0c010060090000cbebfe0c0100080765
+:103720000000b1e0fe0c0100b004000063c0fe0c1c
+:10373000010058020000b1e0fe0c04002c01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037a0000000000000000000000000000000000019
+:1037b0000000000000000000000000000000000009
+:1037c00000000000000000000000000000000000f9
+:1037d00000000000000000000000000000000000e9
+:1037e00000000000000000000000000000000000d9
+:1037f00000000000000000000000000000000002c7
+:1038000004030904000000002e0342006c006f0056
+:1038100063006b00200045007200750070007400aa
+:1038200065007200200053006100700070006800a5
+:1038300069007200650064006700650020004300b5
+:103840006f006e00740072006f006c006c00650009
+:1038500072000000000000000000000000000000f6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038a0000000000000000000000000000000000018
+:1038b0000000000000000000000000000000000008
+:1038c00000000000000000000000000000000000f8
+:1038d00000000000000000000000000000000000e8
+:1038e00000000000000000000000000000000000d8
+:1038f00000000000000000000000000000000000c8
+:10390000000000000000000a0330003000300031e9
+:1039100000000000000000000000000000000000a7
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040d1
+:10399000c41060ea000101020301090220000101d4
+:1039a00000c0fa0904000002ff00000207058102be
+:1039b0004000000705010240000000000000000078
+:1039c00000000012034200540043004700750069e4
+:1039d000006c006400000000000000000000000017
+:1039e00000000000000000000000000000000000d7
+:1039f000000000000000000000000000000000ffc8
+:00000001FF

+ 65 - 0
backup/eeprom-content.BTCOxygen.hex

@@ -0,0 +1,65 @@
+:10360000fff0fffa010060e31600fff0fffa01008f
+:1036100060e31600ffecfff80100804f1200ffe6a8
+:10362000fff6010000100e00ffd6fff0010000caf7
+:103630000800ffd0ffee010020a10700ffccffec47
+:10364000010000080700ffa2ffdc010000e8030002
+:10365000ffa0ffdc010090d00300ff98ffd901001c
+:1036600000840300ff64ffc5010000580200ff440e
+:10367000ffb9010000f40100ff30ffb2010000c2f9
+:103680000100fec8ff8b0100002c0100fe89ff73c2
+:10369000010000fa0000fe5fff63010000e100008e
+:1036a000fe53ff5f0100c0da0000fe2bff50010057
+:1036b00000c80000fd8fff15010000960000fcbf50
+:1036c000fec7010080700000fb1efe2b0100004bb6
+:1036d0000000fa24fe0c0100803e0000f97dfe0c83
+:1036e000010040380000f63cfe0c0100802500007f
+:1036f000f2fbfe0c0100201c0000ec78fe0c010027
+:10370000c0120000e890fe0c0100a00f0000d8f0ed
+:10371000fe0c010060090000cbebfe0c0100080765
+:103720000000b1e0fe0c0100b004000063c0fe0c1c
+:10373000010058020000b1e0fe0c04002c01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037a0000000000000000000000000000000000019
+:1037b0000000000000000000000000000000000009
+:1037c00000000000000000000000000000000000f9
+:1037d00000000000000000000000000000000000e9
+:1037e00000000000000000000000000000000000d9
+:1037f00000000000000000000000000000000002c7
+:1038000004030904000000002e0342006c006f0056
+:1038100063006b00200045007200750070007400aa
+:1038200065007200200053006100700070006800a5
+:1038300069007200650064006700650020004300b5
+:103840006f006e00740072006f006c006c00650009
+:1038500072000000000000000000000000000000f6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038a0000000000000000000000000000000000018
+:1038b0000000000000000000000000000000000008
+:1038c00000000000000000000000000000000000f8
+:1038d00000000000000000000000000000000000e8
+:1038e00000000000000000000000000000000000d8
+:1038f00000000000000000000000000000000000c8
+:10390000000000000000000a0330003000300031e9
+:1039100000000000000000000000000000000000a7
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040d1
+:10399000c41060ea000101020301090220000101d4
+:1039a00000c0fa0904000002ff00000207058102be
+:1039b0004000000705010240000000000000000078
+:1039c00000000014034200540043004f00780079c7
+:1039d00000670065006e00000000000000000000ad
+:1039e00000000000000000000000000000000000d7
+:1039f000000000000000000000000000000000ffc8
+:00000001FF

+ 65 - 0
backup/eeprom-content.Bitfountain.hex

@@ -0,0 +1,65 @@
+:10360000fff0fffa010060e31600fff0fffa01008f
+:1036100060e31600ffecfff80100804f1200ffe6a8
+:10362000fff6010000100e00ffd6fff0010000caf7
+:103630000800ffd0ffee010020a10700ffccffec47
+:10364000010000080700ffa2ffdc010000e8030002
+:10365000ffa0ffdc010090d00300ff98ffd901001c
+:1036600000840300ff64ffc5010000580200ff440e
+:10367000ffb9010000f40100ff30ffb2010000c2f9
+:103680000100fec8ff8b0100002c0100fe89ff73c2
+:10369000010000fa0000fe5fff63010000e100008e
+:1036a000fe53ff5f0100c0da0000fe2bff50010057
+:1036b00000c80000fd8fff15010000960000fcbf50
+:1036c000fec7010080700000fb1efe2b0100004bb6
+:1036d0000000fa24fe0c0100803e0000f97dfe0c83
+:1036e000010040380000f63cfe0c0100802500007f
+:1036f000f2fbfe0c0100201c0000ec78fe0c010027
+:10370000c0120000e890fe0c0100a00f0000d8f0ed
+:10371000fe0c010060090000cbebfe0c0100080765
+:103720000000b1e0fe0c0100b004000063c0fe0c1c
+:10373000010058020000b1e0fe0c04002c01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037a0000000000000000000000000000000000019
+:1037b0000000000000000000000000000000000009
+:1037c00000000000000000000000000000000000f9
+:1037d00000000000000000000000000000000000e9
+:1037e00000000000000000000000000000000000d9
+:1037f00000000000000000000000000000000002c7
+:1038000004030904000000002e0342006c006f0056
+:1038100063006b00200045007200750070007400aa
+:1038200065007200200053006100700070006800a5
+:1038300069007200650064006700650020004300b5
+:103840006f006e00740072006f006c006c00650009
+:1038500072000000000000000000000000000000f6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038a0000000000000000000000000000000000018
+:1038b0000000000000000000000000000000000008
+:1038c00000000000000000000000000000000000f8
+:1038d00000000000000000000000000000000000e8
+:1038e00000000000000000000000000000000000d8
+:1038f00000000000000000000000000000000000c8
+:10390000000000000000000a0330003000300031e9
+:1039100000000000000000000000000000000000a7
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040d1
+:10399000c41060ea000101020301090220000101d4
+:1039a00000c0fa0904000002ff00000207058102be
+:1039b0004000000705010240000000000000000078
+:1039c000000000180342006900740066006f007573
+:1039d000006e007400610069006e000000000000cd
+:1039e00000000000000000000000000000000000d7
+:1039f000000000000000000000000000000000ffc8
+:00000001FF

+ 65 - 0
backup/eeprom-content.GekkoScience-Compac-bitshopperde.hex

@@ -0,0 +1,65 @@
+:10360000FFF0FFFA010060E31600FFF0FFFA01008F
+:1036100060E31600FFECFFF80100804F1200FFE6A8
+:10362000FFF6010000100E00FFD6FFF0010000CAF7
+:103630000800FFD0FFEE010020A10700FFCCFFEC47
+:10364000010000080700FFA2FFDC010000E8030002
+:10365000FFA0FFDC010090D00300FF98FFD901001C
+:1036600000840300FF64FFC5010000580200FF440E
+:10367000FFB9010000F40100FF30FFB2010000C2F9
+:103680000100FEC8FF8B0100002C0100FE89FF73C2
+:10369000010000FA0000FE5FFF63010000E100008E
+:1036A000FE53FF5F0100C0DA0000FE2BFF50010057
+:1036B00000C80000FD8FFF15010000960000FCBF50
+:1036C000FEC7010080700000FB1EFE2B0100004BB6
+:1036D0000000FA24FE0C0100803E0000F97DFE0C83
+:1036E000010040380000F63CFE0C0100802500007F
+:1036F000F2FBFE0C0100201C0000EC78FE0C010027
+:10370000C0120000E890FE0C0100A00F0000D8F0ED
+:10371000FE0C010060090000CBEBFE0C0100080765
+:103720000000B1E0FE0C0100B004000063C0FE0C1C
+:10373000010058020000B1E0FE0C04002C01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037A0000000000000000000000000000000000019
+:1037B0000000000000000000000000000000000009
+:1037C00000000000000000000000000000000000F9
+:1037D00000000000000000000000000000000000E9
+:1037E00000000000000000000000000000000000D9
+:1037F00000000000000000000000000000000002C7
+:103800000403090400000000380343006F006D004A
+:10381000700061006300200042004D003100330061
+:1038200038003400200042006900740063006F001B
+:1038300069006E0020004D0069006E006500720096
+:103840006F006E00740072006F006C006C00650009
+:1038500072000000000000000000000000000000F6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038A0000000000000000000000000000000000018
+:1038B0000000000000000000000000000000000008
+:1038C00000000000000000000000000000000000F8
+:1038D00000000000000000000000000000000000E8
+:1038E00000000000000000000000000000000000D8
+:1038F00000000000000000000000000000000000C8
+:1039000000000000000000100330003000300030E4
+:103910000030003000310000000000000000000016
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040D1
+:10399000C41060EA000101020301090220000101D4
+:1039A0000080FA0904000002FF00000207058102FE
+:1039B0004000000705010240000000000000000078
+:1039C0000000001A03620069007400730068006F51
+:1039D0000070007000650072006400650000000067
+:1039E00000000000000000000000000000000000D7
+:1039F000000000000000000000000000000000FFC8
+:00000001FF

+ 65 - 0
backup/eeprom-content.GekkoScience-Compac.hex

@@ -0,0 +1,65 @@
+:10360000FFF0FFFA010060E31600FFF0FFFA01008F
+:1036100060E31600FFECFFF80100804F1200FFE6A8
+:10362000FFF6010000100E00FFD6FFF0010000CAF7
+:103630000800FFD0FFEE010020A10700FFCCFFEC47
+:10364000010000080700FFA2FFDC010000E8030002
+:10365000FFA0FFDC010090D00300FF98FFD901001C
+:1036600000840300FF64FFC5010000580200FF440E
+:10367000FFB9010000F40100FF30FFB2010000C2F9
+:103680000100FEC8FF8B0100002C0100FE89FF73C2
+:10369000010000FA0000FE5FFF63010000E100008E
+:1036A000FE53FF5F0100C0DA0000FE2BFF50010057
+:1036B00000C80000FD8FFF15010000960000FCBF50
+:1036C000FEC7010080700000FB1EFE2B0100004BB6
+:1036D0000000FA24FE0C0100803E0000F97DFE0C83
+:1036E000010040380000F63CFE0C0100802500007F
+:1036F000F2FBFE0C0100201C0000EC78FE0C010027
+:10370000C0120000E890FE0C0100A00F0000D8F0ED
+:10371000FE0C010060090000CBEBFE0C0100080765
+:103720000000B1E0FE0C0100B004000063C0FE0C1C
+:10373000010058020000B1E0FE0C04002C01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037A0000000000000000000000000000000000019
+:1037B0000000000000000000000000000000000009
+:1037C00000000000000000000000000000000000F9
+:1037D00000000000000000000000000000000000E9
+:1037E00000000000000000000000000000000000D9
+:1037F00000000000000000000000000000000002C7
+:103800000403090400000000380343006F006D004A
+:10381000700061006300200042004D003100330061
+:1038200038003400200042006900740063006F001B
+:1038300069006E0020004D0069006E006500720096
+:103840006F006E00740072006F006C006C00650009
+:1038500072000000000000000000000000000000F6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038A0000000000000000000000000000000000018
+:1038B0000000000000000000000000000000000008
+:1038C00000000000000000000000000000000000F8
+:1038D00000000000000000000000000000000000E8
+:1038E00000000000000000000000000000000000D8
+:1038F00000000000000000000000000000000000C8
+:1039000000000000000000100330003000300030E4
+:103910000030003000310000000000000000000016
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040D1
+:10399000C41060EA000101020301090220000101D4
+:1039A0000080FA0904000002FF00000207058102FE
+:1039B0004000000705010240000000000000000078
+:1039C0000000001A03470065006B006B006F005396
+:1039D000006300690065006E006300650000000080
+:1039E00000000000000000000000000000000000D7
+:1039F000000000000000000000000000000000FFC8
+:00000001FF

+ 65 - 0
backup/eeprom-content.GekkoScience-original.hex

@@ -0,0 +1,65 @@
+:10360000fff0fffa010060e31600fff0fffa01008f
+:1036100060e31600ffecfff80100804f1200ffe6a8
+:10362000fff6010000100e00ffd6fff0010000caf7
+:103630000800ffd0ffee010020a10700ffccffec47
+:10364000010000080700ffa2ffdc010000e8030002
+:10365000ffa0ffdc010090d00300ff98ffd901001c
+:1036600000840300ff64ffc5010000580200ff440e
+:10367000ffb9010000f40100ff30ffb2010000c2f9
+:103680000100fec8ff8b0100002c0100fe89ff73c2
+:10369000010000fa0000fe5fff63010000e100008e
+:1036a000fe53ff5f0100c0da0000fe2bff50010057
+:1036b00000c80000fd8fff15010000960000fcbf50
+:1036c000fec7010080700000fb1efe2b0100004bb6
+:1036d0000000fa24fe0c0100803e0000f97dfe0c83
+:1036e000010040380000f63cfe0c0100802500007f
+:1036f000f2fbfe0c0100201c0000ec78fe0c010027
+:10370000c0120000e890fe0c0100a00f0000d8f0ed
+:10371000fe0c010060090000cbebfe0c0100080765
+:103720000000b1e0fe0c0100b004000063c0fe0c1c
+:10373000010058020000b1e0fe0c04002c01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037a0000000000000000000000000000000000019
+:1037b0000000000000000000000000000000000009
+:1037c00000000000000000000000000000000000f9
+:1037d00000000000000000000000000000000000e9
+:1037e00000000000000000000000000000000000d9
+:1037f00000000000000000000000000000000002c7
+:103800000403090400000000380343006f006d004a
+:10381000700061006300200042004d003100330061
+:1038200038003400200042006900740063006f001b
+:1038300069006e0020004d0069006e006500720096
+:103840006f006e00740072006f006c006c00650009
+:1038500072000000000000000000000000000000f6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038a0000000000000000000000000000000000018
+:1038b0000000000000000000000000000000000008
+:1038c00000000000000000000000000000000000f8
+:1038d00000000000000000000000000000000000e8
+:1038e00000000000000000000000000000000000d8
+:1038f00000000000000000000000000000000000c8
+:10390000000000000000001803470053002d0031a4
+:103910000030003000300030003000390039000045
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040d1
+:10399000c41060ea000101020301090220000101d4
+:1039a0000080fa0904000002ff00000207058102fe
+:1039b0004000000705010240000000000000000078
+:1039c0000000001a03620069007400730068006f51
+:1039d0000070007000650072006400650000000067
+:1039e00000000000000000000000000000000000d7
+:1039f000000000000000000000000000000000ffc8
+:00000001FF

+ 65 - 0
backup/eeprom-content.LKETC_usb.hex

@@ -0,0 +1,65 @@
+:10360000fff0fffa010060e31600fff0fffa01008f
+:1036100060e31600ffecfff80100804f1200ffe6a8
+:10362000fff6010000100e00ffd6fff0010000caf7
+:103630000800ffd0ffee010020a10700ffccffec47
+:10364000010000080700ffa2ffdc010000e8030002
+:10365000ffa0ffdc010090d00300ff98ffd901001c
+:1036600000840300ff64ffc5010000580200ff440e
+:10367000ffb9010000f40100ff30ffb2010000c2f9
+:103680000100fec8ff8b0100002c0100fe89ff73c2
+:10369000010000fa0000fe5fff63010000e100008e
+:1036a000fe53ff5f0100c0da0000fe2bff50010057
+:1036b00000c80000fd8fff15010000960000fcbf50
+:1036c000fec7010080700000fb1efe2b0100004bb6
+:1036d0000000fa24fe0c0100803e0000f97dfe0c83
+:1036e000010040380000f63cfe0c0100802500007f
+:1036f000f2fbfe0c0100201c0000ec78fe0c010027
+:10370000c0120000e890fe0c0100a00f0000d8f0ed
+:10371000fe0c010060090000cbebfe0c0100080765
+:103720000000b1e0fe0c0100b004000063c0fe0c1c
+:10373000010058020000b1e0fe0c04002c01000062
+:10374000f05400003ffff05400ab3fff300000009a
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037a0000000000000000000000000000000000019
+:1037b0000000000000000000000000000000000009
+:1037c00000000000000000000000000000000000f9
+:1037d00000000000000000000000000000000000e9
+:1037e00000000000000000000000000000000000d9
+:1037f00000000000000000000000000000000003c6
+:1038000004030904000000004a0343005000320092
+:1038100031003000330020005500530042002000ea
+:1038200074006f0020005500410052005400200039
+:1038300042007200690064006700650020004300d8
+:103840006f006e00740072006f006c006c00650009
+:1038500072000000000000000000000000000000f6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038a0000000000000000000000000000000000018
+:1038b0000000000000000000000000000000000008
+:1038c00000000000000000000000000000000000f8
+:1038d00000000000000000000000000000000000e8
+:1038e00000000000000000000000000000000000d8
+:1038f00000000000000000000000000000000000c8
+:10390000000000000000000a0330003000300031e9
+:1039100000000000000000000000000000000000a7
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000031201100100000040d0
+:10399000c41060ea000101020301090220000101d4
+:1039a0000080320904000002ff00000207058102c6
+:1039b0004000000705010240000000000000000078
+:1039c0000000001a03530069006c00690063006f77
+:1039d000006e0020004c00610062007300000000d7
+:1039e00000000000000000000000000000000000d7
+:1039f000000000000000000000000000000000ffc8
+:00000001FF

+ 65 - 0
backup/eeprom-content.RBOX.hex

@@ -0,0 +1,65 @@
+:10360000FFF0FFFA010060E31600FFF0FFFA01008F
+:1036100060E31600FFECFFF80100804F1200FFE6A8
+:10362000FFF6010000100E00FFD6FFF0010000CAF7
+:103630000800FFD0FFEE010020A10700FFCCFFEC47
+:10364000010000080700FFA2FFDC010000E8030002
+:10365000FFA0FFDC010090D00300FF98FFD901001C
+:1036600000840300FF64FFC5010000580200FF440E
+:10367000FFB9010000F40100FF30FFB2010000C2F9
+:103680000100FEC8FF8B0100002C0100FE89FF73C2
+:10369000010000FA0000FE5FFF63010000E100008E
+:1036A000FE53FF5F0100C0DA0000FE2BFF50010057
+:1036B00000C80000FD8FFF15010000960000FCBF50
+:1036C000FEC7010080700000FB1EFE2B0100004BB6
+:1036D0000000FA24FE0C0100803E0000F97DFE0C83
+:1036E000010040380000F63CFE0C0100802500007F
+:1036F000F2FBFE0C0100201C0000EC78FE0C010027
+:10370000C0120000E890FE0C0100A00F0000D8F0ED
+:10371000FE0C010060090000CBEBFE0C0100080765
+:103720000000B1E0FE0C0100B004000063C0FE0C1C
+:10373000010058020000B1E0FE0C04002C01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037A0000000000000000000000000000000000019
+:1037B0000000000000000000000000000000000009
+:1037C00000000000000000000000000000000000F9
+:1037D00000000000000000000000000000000000E9
+:1037E00000000000000000000000000000000000D9
+:1037F00000000000000000000000000000000002C7
+:1038000004030904000000004A0343005000320092
+:1038100031003000320020005500530042002000EB
+:1038200074006F0020005500410052005400200039
+:1038300042007200690064006700650020004300D8
+:103840006F006E00740072006F006C006C00650009
+:1038500072000000000000000000000000000000F6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038A0000000000000000000000000000000000018
+:1038B0000000000000000000000000000000000008
+:1038C00000000000000000000000000000000000F8
+:1038D00000000000000000000000000000000000E8
+:1038E00000000000000000000000000000000000D8
+:1038F00000000000000000000000000000000000C8
+:10390000000000000000000A0330003000300031E9
+:1039100000000000000000000000000000000000A7
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040D1
+:10399000C41060EA000101020301090220000101D4
+:1039A0000080320904000002FF00000207058102C6
+:1039B0004000000705010240000000000000000078
+:1039C000000000140352004F0043004B004D00491B
+:1039D000004E004500520000000000000000000002
+:1039E00000000000000000000000000000000000D7
+:1039F000000000000000000000000000000000FFC8
+:00000001FF

+ 65 - 0
backup/eeprom-content.Zeus.hex

@@ -0,0 +1,65 @@
+:10360000fff0fffa010060e31600fff0fffa01008f
+:1036100060e31600ffecfff80100804f1200ffe6a8
+:10362000fff6010000100e00ffd6fff0010000caf7
+:103630000800ffd0ffee010020a10700ffccffec47
+:10364000010000080700ffa2ffdc010000e8030002
+:10365000ffa0ffdc010090d00300ff98ffd901001c
+:1036600000840300ff64ffc5010000580200ff440e
+:10367000ffb9010000f40100ff30ffb2010000c2f9
+:103680000100fec8ff8b0100002c0100fe89ff73c2
+:10369000010000fa0000fe5fff63010000e100008e
+:1036a000fe53ff5f0100c0da0000fe2bff50010057
+:1036b00000c80000fd8fff15010000960000fcbf50
+:1036c000fec7010080700000fb1efe2b0100004bb6
+:1036d0000000fa24fe0c0100803e0000f97dfe0c83
+:1036e000010040380000f63cfe0c0100802500007f
+:1036f000f2fbfe0c0100201c0000ec78fe0c010027
+:10370000c0120000e890fe0c0100a00f0000d8f0ed
+:10371000fe0c010060090000cbebfe0c0100080765
+:103720000000b1e0fe0c0100b004000063c0fe0c1c
+:10373000010058020000b1e0fe0c04002c01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037a0000000000000000000000000000000000019
+:1037b0000000000000000000000000000000000009
+:1037c00000000000000000000000000000000000f9
+:1037d00000000000000000000000000000000000e9
+:1037e00000000000000000000000000000000000d9
+:1037f00000000000000000000000000000000002c7
+:1038000004030904000000004a0343005000320092
+:1038100031003000320020005500530042002000eb
+:1038200074006f0020005500410052005400200039
+:1038300042007200690064006700650020004300d8
+:103840006f006e00740072006f006c006c00650009
+:1038500072000000000000000000000000000000f6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038a0000000000000000000000000000000000018
+:1038b0000000000000000000000000000000000008
+:1038c00000000000000000000000000000000000f8
+:1038d00000000000000000000000000000000000e8
+:1038e00000000000000000000000000000000000d8
+:1038f00000000000000000000000000000000000c8
+:10390000000000000000000a0330003000300031e9
+:1039100000000000000000000000000000000000a7
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040d1
+:10399000c41060ea000101020301090220000101d4
+:1039a0000080320904000002ff00000207058102c6
+:1039b0004000000705010240000000000000000078
+:1039c0000000001a03530069006c00690063006f77
+:1039d000006e0020004c00610062007300000000d7
+:1039e00000000000000000000000000000000000d7
+:1039f000000000000000000000000000000000ffc8
+:00000001FF

+ 65 - 0
backup/eeprom-content.rockminer_original.hex

@@ -0,0 +1,65 @@
+:10360000fff0fffa010060e31600fff0fffa01008f
+:1036100060e31600ffecfff80100804f1200ffe6a8
+:10362000fff6010000100e00ffd6fff0010000caf7
+:103630000800ffd0ffee010020a10700ffccffec47
+:10364000010000080700ffa2ffdc010000e8030002
+:10365000ffa0ffdc010090d00300ff98ffd901001c
+:1036600000840300ff64ffc5010000580200ff440e
+:10367000ffb9010000f40100ff30ffb2010000c2f9
+:103680000100fec8ff8b0100002c0100fe89ff73c2
+:10369000010000fa0000fe5fff63010000e100008e
+:1036a000fe53ff5f0100c0da0000fe2bff50010057
+:1036b00000c80000fd8fff15010000960000fcbf50
+:1036c000fec7010080700000fb1efe2b0100004bb6
+:1036d0000000fa24fe0c0100803e0000f97dfe0c83
+:1036e000010040380000f63cfe0c0100802500007f
+:1036f000f2fbfe0c0100201c0000ec78fe0c010027
+:10370000c0120000e890fe0c0100a00f0000d8f0ed
+:10371000fe0c010060090000cbebfe0c0100080765
+:103720000000b1e0fe0c0100b004000063c0fe0c1c
+:10373000010058020000b1e0fe0c04002c01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037a0000000000000000000000000000000000019
+:1037b0000000000000000000000000000000000009
+:1037c00000000000000000000000000000000000f9
+:1037d00000000000000000000000000000000000e9
+:1037e00000000000000000000000000000000000d9
+:1037f00000000000000000000000000000000002c7
+:1038000004030904000000004a0343005000320092
+:1038100031003000320020005500530042002000eb
+:1038200074006f0020005500410052005400200039
+:1038300042007200690064006700650020004300d8
+:103840006f006e00740072006f006c006c00650009
+:1038500072000000000000000000000000000000f6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038a0000000000000000000000000000000000018
+:1038b0000000000000000000000000000000000008
+:1038c00000000000000000000000000000000000f8
+:1038d00000000000000000000000000000000000e8
+:1038e00000000000000000000000000000000000d8
+:1038f00000000000000000000000000000000000c8
+:10390000000000000000000a0330003000300031e9
+:1039100000000000000000000000000000000000a7
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040d1
+:10399000c41060ea000101020301090220000101d4
+:1039a0000080320904000002ff00000207058102c6
+:1039b0004000000705010240000000000000000078
+:1039c0000000001a03530069006c00690063006f77
+:1039d000006e0020004c00610062007300000000d7
+:1039e00000000000000000000000000000000000d7
+:1039f000000000000000000000000000000000ffc8
+:00000001FF

+ 18 - 0
batch.txt

@@ -0,0 +1,18 @@
+#!/bin/bash
+EEPROMHex='eeprom-content.hex'  # File used for manufacturer brand
+Product='Block Erupter Sapphire'
+SerialPrefix='Foo-'  # Prepended before 8-digit serial number
+SerialNoFile='last-serialno'  # File holds the last allocated serial number
+
+if ! [ -e "${SerialNoFile}" ]; then
+	echo "WARNING: Initializing ${SerialNoFile} file (this should only happen ONCE EVER)" >&2
+	echo '10000000' > "${SerialNoFile}"
+fi
+i="$(<"${SerialNoFile}")"
+for dev in $(lsusb | perl -nle 'm/(\d{3}).*?(\d{3}).*CP210x/ && print "$1/$2"'); do
+	let ++i
+	echo "$i" >"${SerialNoFile}"
+	./cp210x-program -m $dev -w -F "$EEPROMHex" \
+	  --set-product-string="$Product" \
+	  --set-serial-number "${SerialPrefix}$i"
+done

+ 20 - 0
branding.GekkoScience-Compac.bash

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+#EEPROMHex='eeprom-content.GekkoScience-Compac.hex'  # File used for manufacturer brand
+EEPROMHex='backup/eeprom-content.GekkoScience-Compac-bitshopperde.hex'
+SerialPrefix='GS-'  # Prepended before 8-digit serial number
+SerialNoFile='last-serialno'  # File holds the last allocated serial number
+
+if ! [ -e "${SerialNoFile}" ]; then
+	echo "WARNING: Initializing ${SerialNoFile} file (this should only happen ONCE EVER)" >&2
+	echo '10000000' > "${SerialNoFile}"
+fi
+i="$(<"${SerialNoFile}")"
+for dev in $(lsusb | perl -nle 'm/(\d{3}).*?(\d{3}).*CP210x/ && print "$1/$2"'); do
+	let ++i
+	echo "$i" >"${SerialNoFile}"
+	FullSerial="${SerialPrefix}$i"
+	echo "Programming serial number ${FullSerial} onto device $dev ..."
+	./cp210x-program -m $dev -w -F "$EEPROMHex" \
+	  --set-serial-number "${FullSerial}"
+done

+ 32 - 0
build.sh

@@ -0,0 +1,32 @@
+#!/bin/bash
+set -e
+echo "cp210x-programm 1.0:"
+if [ $UID -ne 0 ]
+then
+        echo "Please run in sudo.."
+        sleep 3
+        exit
+fi
+
+echo ""
+sudo apt-get install libusb-dev libusb-1.0-0-dev libudev-dev -y
+echo
+
+git submodule init
+git submodule update
+
+echo -e "\e[93mMake PyUSB :\e[0m"
+cd pyusb
+./setup.py build
+./setup.py install
+echo ""
+
+echo -e "\e[93mMake cp210x-program :\e[0m"
+cd ..
+./setup.py build
+./setup.py install
+echo ""
+echo -e "\e[93mInstall rules:\e[0m"
+sudo cp -v doc/45-cp210x-programming.rules /etc/udev/rules
+echo ""
+echo -e "\e[93mDone.\e[0m"

+ 4 - 0
build/lib.linux-armv6l-2.7/cp210x/__init__.py

@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+
+__author__ = "Johannes Hölzl <johannes.hoelzl@gmx.de>"
+__license__ = "GNU LGPL"

+ 360 - 0
build/lib.linux-armv6l-2.7/cp210x/cp210x.py

@@ -0,0 +1,360 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2007 Johannes Hölzl <johannes.hoelzl@gmx.de>
+#
+# This library is covered by the GNU LGPL, read LICENSE for details.
+"""Provides access to the EEPROM of Silabs CP210x devices
+
+The following class is available:
+
+class Cp210xProgrammer:
+    Provides direct access to the CP210x, can be used to write single data
+    directly or via an EEPROM image.
+"""
+
+import usb
+from usb.util import CTRL_IN, CTRL_OUT, CTRL_TYPE_VENDOR
+
+__all__ = ['Cp210xProgrammer', 'Cp210xError']
+
+CP210x_CONFIG       = 0xFF
+
+REG_VENDOR_ID       = 0x3701
+REG_PRODUCT_ID      = 0x3702
+REG_PRODUCT_STRING  = 0x3703
+REG_SERIAL_NUMBER   = 0x3704
+REG_CFG_ATTRIBUTES  = 0x3705
+REG_MAX_POWER       = 0x3706
+REG_VERSION         = 0x3707
+REG_UNKNOWN         = 0x3708
+REG_EEPROM          = 0x3709
+REG_LOCK_VALUE      = 0x370A
+REG_PART_NUMBER     = 0x370B
+
+SIZE_EEPROM         = 0x0400
+SIZE_PRODUCT_STRING = 255
+SIZE_SERIAL_NUMBER  = 128
+SIZE_BAUDRATES      = 32
+SIZE_BAUDRATE_CFG   = 10
+SIZE_BAUDRATE_TABLE = SIZE_BAUDRATES * SIZE_BAUDRATE_CFG
+SIZE_VENDOR_STRING  = 50
+
+# Buffer size limits
+# (see AN721: CP210x/CP211x Device Customization Guide)
+CP210x_MAX_PRODUCT_STRLEN = (SIZE_PRODUCT_STRING - 2) // 2
+CP210x_MAX_SERIAL_STRLEN  = (SIZE_SERIAL_NUMBER - 2) // 2
+
+LCK_LOCKED          = 0xF0
+LCK_UNLOCKED        = 0xFF
+
+VID_SILABS          = 0x10C4
+PID_CP210x          = 0xEA60
+
+VALUES = [
+    ('product_string', 'string'),
+    ('serial_number',  'string'),
+    ('vendor_id',      'id'),
+    ('product_id',     'id'),
+    ('version',        'version'),
+    ('bus_powered',    'boolean'),
+    ('max_power',      'int'),
+    ('locked',         'boolean'),
+    ('part_number',    'int'),
+    ('vendor_string',  'string'),
+    ('baudrate_table', 'list'),
+]
+
+def to_div2(p):
+    value = int(p / 2)
+    if (value * 2) < p:
+        value += 1
+    return value
+    
+def to_bcd(i):
+    assert i >= 0 and i <= 99
+    return (i // 10) << 4 | (i % 10)
+
+def to_bcd2( (i, j) ):
+    return to_bcd(i) << 8 | to_bcd(j)
+
+def from_bcd(num):
+    return num & 0x0F + (num >> 4) * 10
+
+def from_bcd2(data):
+    return (from_bcd(data >> 8), from_bcd(data & 0xFF))
+
+def from_binary(data, le=True):
+    value = 0
+    if le:
+        data = data[::-1]
+    for byte in data:
+        value = value << 8 | ord(byte)
+    return value
+
+def to_binary(value, size=2, le=True):
+    data = ''
+    for i in range(size):
+        data += chr(value & 0xFF)
+        value >>= 8
+    if le:
+        return data
+    else:
+        return data[::-1]
+    
+def parse_baudrate_cfg(data):
+    return (from_binary(data[0:2], le=False), 
+            from_binary(data[2:4], le=False), 
+            from_binary(data[4:5]),
+            from_binary(data[6:10]))
+
+def build_baudrate_cfg(baudgen, timer0reload, prescaler, baudrate):
+    return (to_binary(baudgen, le=False) + to_binary(timer0reload, le=False) + 
+            to_binary(prescaler, 1) + '\x00' + to_binary(baudrate, 4))
+
+class Cp210xError(IOError):
+    pass
+
+class DeviceLocked(Cp210xError):
+    pass
+
+class Cp210xMatch(object):
+    def __init__(self, patterns):
+        self.patterns = patterns
+
+    def __call__(self, dev):
+        for pattern in self.patterns:
+            for name, value in pattern.items():
+                if getattr(dev, name) != value:
+                    return False
+            return True
+        return False
+
+class Cp210xProgrammer(object):
+    """Program a Silabs CP2101, CP2102 or CP2103
+    
+    This module provides access to Silabs CP210x devices to set some USB
+    descriptor fields and some USB descriptor strings. 
+
+    The following fields can be set:
+
+     * Vendor ID
+     * Product ID
+     * Product String
+     * Serial Number
+     * Device Version
+     * Bus Powered
+     * max. Power consumption
+ 
+    Either use PyUSB to find a device, and pass the usb.Device object
+    to the constructor, or use Cp210xProgrammer.list_device() to list all
+    devices matching certain pattern.
+    """
+    
+    TIMEOUT = 300 #ms
+    
+    @classmethod
+    def list_devices(self, patterns=[{ 'idVendor': VID_SILABS, 
+                                       'idProduct': PID_CP210x }]):
+        """Yields a list of devices matching certain patterns.
+        
+        param patterns: This must be a list of dictionaries. Each device
+            in the usb tree is matched against all patterns in the list. 
+            
+            All fields of the descriptors are compared with the corresponding
+            values in the dictionary. A device matches the pattern only if all
+            values match.
+        
+        For example:
+
+        >> list(Cp210xProgrammer.list_device([{ 'idVendor': VID_SILABS, 
+                                           'idProduct': PID_CP210x }]))
+        [device(...)]
+        
+        """
+        
+        return usb.core.find(find_all=True,
+                             custom_match=Cp210xMatch(patterns))
+
+    def __init__(self, usbdev):
+        self.usbdev = usbdev
+        self._locked = None
+        try:
+            self.has_kernel_driver = usbdev.is_kernel_driver_active(0)
+        except NotImplementedError:
+            self.has_kernel_driver = False
+        if self.has_kernel_driver:
+            cfg = usbdev.get_active_configuration()
+            self.intf = cfg[(0,0)].bInterfaceNumber
+            usbdev.detach_kernel_driver(self.intf)
+        usbdev.set_configuration()
+        
+    def reset(self):
+        """Force the USB stack to reset the device.
+        
+        Resets the device through an hard reset over the port to which the
+        device is connected. After that happend the EEPROM content in the device
+        is reread and the device's descriptors are the one written to it.
+        """
+        self.usbdev.reset()
+    
+    def __del__(self):
+        if self.has_kernel_driver:
+            self.usbdev.attach_kernel_driver(self.intf)
+
+    def _set_config(self, value, index=0, data=None, request=CP210x_CONFIG):
+        if self.get_locked():
+            raise DeviceLocked()
+            
+        res = self.usbdev.ctrl_transfer(CTRL_OUT | CTRL_TYPE_VENDOR,
+                                        request, value, index, data)
+        if data is not None and res != len(data):
+            raise Cp210xError("Short write (%d of %d bytes)"
+                              % (res, len(data)))
+
+    def _set_config_string(self, value, content, max_desc_size):
+        assert isinstance(content, basestring)
+        encoded = content.encode('utf-16-le')
+        desc_size = len(encoded) + 2
+        assert desc_size <= max_desc_size
+        self._set_config(value, data=chr(desc_size) + "\x03" + encoded)
+
+    def _get_config(self, value, length, index=0, request=CP210x_CONFIG):
+        res = self.usbdev.ctrl_transfer(CTRL_IN | CTRL_TYPE_VENDOR,
+                                        request, value, index, length)
+        return res.tostring()
+
+    def _get_int8_config(self, value, index=0, request=CP210x_CONFIG):
+        return ord(self._get_config(value, 1, index=index, request=request))
+
+    def _get_int16_config(self, value, index=0, request=CP210x_CONFIG):
+        data = self._get_config(value, 2, index=index, request=request)
+        return ord(data[0]) << 8 | ord(data[1])
+    
+    def get_eeprom_content(self):
+        """Get the entire EEPROM content as one big 1024-byte blob.
+        """
+        return self._get_config(REG_EEPROM, SIZE_EEPROM)
+    
+    def get_baudrate_content(self):
+        """Get the baudrate table as binary data.
+        """
+        return self._get_config(REG_EEPROM, SIZE_BAUDRATE_TABLE)
+
+    def get_baudrate_table(self):
+        """Get the baudrate table.
+        
+        A list containing 4-tuples is returned.
+        Each tuple contains the following data:
+        
+         * BaudGen: Value used to generate the baudrate.
+         * Time0Reset: Value used to generate the usb timeout.
+         * Prescaler: Used to down-scale the baudrate.
+         * Baudrate: The baudrate which activates this entry.
+        """
+        data = self.get_baudrate_content()
+        return [parse_baudrate_cfg(data[pos:pos+SIZE_BAUDRATE_CFG])
+                for pos in range(0, SIZE_BAUDRATE_TABLE, SIZE_BAUDRATE_CFG)]
+        
+    def set_baudrate_table(self, baudrates):
+        """Write the baudrate table.
+        
+        See get_baudrate_table() for the structure of the table.
+        """
+        assert len(baudrates) == SIZE_BAUDRATES
+        self.set_baudrate_content(data=''.join(build_baudrate_cfg(*cfg) 
+                                               for cfg in baudrates))
+    baudrate_table = property(get_baudrate_table, set_baudrate_table)
+        
+    def get_part_number(self):
+        """Get the part number of the device.
+        
+        Returns: 1 for a CP2101
+                 2 for a CP2102
+                 3 for a CP2103
+        """
+        return self._get_int8_config(REG_PART_NUMBER)
+    
+    def get_locked(self):
+        """Read the lock value of the device.
+        
+        When True is returnes no data can be written to the device.
+        """
+        if self._locked is None:
+            self._locked = self._get_int8_config(REG_LOCK_VALUE) == LCK_LOCKED
+        return self._locked
+    
+    def set_eeprom_content(self, content):
+        """Write a 1024-byte blob to the EEPROM
+        """
+        assert len(content) == SIZE_EEPROM, ("EEPROM data must be %i bytes."
+                                             % SIZE_EEPROM)
+        assert isinstance(content, str), "EEPROM data must be string."
+        self._set_config(REG_EEPROM, data=content)
+    
+    def set_product_id(self, pid):
+        """Set the Product ID
+        """
+        assert pid > 0x0000 and pid < 0xFFFF
+        self._set_config(REG_PRODUCT_ID, pid)
+        
+    def set_vendor_id(self, vid):
+        """Set the Vendor ID
+        """
+        assert vid > 0x0000 and vid < 0xFFFF
+        self._set_config(REG_VENDOR_ID, vid)
+    
+    def set_product_string(self, product_string):
+        """Set the product string.
+        
+        The string will be encoded with UTF-16 and must not exceed
+        CP210x_MAX_PRODUCT_STRLEN.
+        For Unicode Plane 0 (BMP; code points 0-FFFF), this specifies
+        the maximum length of the string in characters.
+        """
+        self._set_config_string(REG_PRODUCT_STRING, product_string, 
+                                SIZE_PRODUCT_STRING)
+    
+    def set_serial_number(self, serial_number):
+        """Set the serial number string.
+        
+        The string will be encoded with UTF-16 and must not exceed
+        CP210x_MAX_SERIAL_STRLEN.
+        For Unicode Plane 0 (BMP; code points 0-FFFF), this specifies
+        the maximum length of the string in characters.
+        """
+        self._set_config_string(REG_SERIAL_NUMBER, serial_number, 
+                                SIZE_SERIAL_NUMBER)
+    
+    def set_max_power(self, max_power):
+        """Set maximum power consumption.
+        """
+        assert max_power >= 0 and max_power <= 500
+        self._set_config(REG_MAX_POWER, to_div2(max_power))
+    
+    def set_bus_powered(self, bus_powered):
+        """Set the bus-powered flag in the device descriptor.
+        """
+        if bus_powered:
+            self._set_config(REG_CFG_ATTRIBUTES, 0xC0)
+        else:
+            self._set_config(REG_CFG_ATTRIBUTES, 0x80)
+
+    def set_version(self, version):
+        """Set the device version .
+        """
+        self._set_config(REG_VERSION, to_bcd2(version))
+
+    def set_locked(self, locked):
+        """Set the lock value of the device.
+        
+        When True is returned no data can be written to the device.
+        """
+        if locked:
+            self._set_config(REG_LOCK_VALUE, LCK_LOCKED)
+        else:
+            self._set_config(REG_LOCK_VALUE, LCK_UNLOCKED)
+
+    def set_values(self, values):
+        for name, value in values.items():
+            if name not in ['part_number', 'vendor_string']:
+                getattr(self, "set_" + name) (value)
+            

+ 190 - 0
build/lib.linux-armv6l-2.7/cp210x/eeprom.py

@@ -0,0 +1,190 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2007 Johannes Hölzl <johannes.hoelzl@gmx.de>
+#
+# This library is covered by the GNU LGPL, read LICENSE for details.
+"""Provides logical view of the EEPROM of Silabs CP210x devices
+
+The following class is available:
+
+class EEPROM:
+    Can be used to read or write a hex file containing the EEPROM content
+    of a CP210x. Also provides access to single fields in the EEPROM.
+"""
+
+import cp210x
+from cp210x import from_binary, to_binary, VALUES
+
+__all__ = ['EEPROM', 'HexFileError']
+
+POS_BAUDRATE_TABLE  = 0x0000
+POS_PART_NUMBER     = 0x01FF
+POS_STRING_DESC_0   = 0x0200
+POS_PRODUCT_STRING  = 0x0208
+POS_SERIAL_NUMBER   = 0x0307
+POS_VENDOR_ID       = 0x0390
+POS_PRODUCT_ID      = 0x0392
+POS_VERSION         = 0x0394
+POS_CFG_ATTRIBUTES  = 0x03A1
+POS_MAX_POWER       = 0x03A2
+POS_VENDOR_STRING   = 0x03C3
+POS_LOCK_VALUE      = 0x03FF
+
+class HexFileError(StandardError):
+    pass
+
+def checksum(line):
+    return sum(ord(c) for c in line) & 0xFF
+
+def _int_value(position, size, read=lambda x:x, write=lambda x:x):
+    def get(self):
+        return read(from_binary(self.get(position, size)))
+    def set(self, value):
+        self.set(position, to_binary(write(value), size))
+    return property(get, set)
+    
+def _str_value(position, max_desc_size):
+    def get(self):
+        desc_size = from_binary(self.get(position, 1))
+        assert desc_size <= max_desc_size and desc_size >= 2, "desc_size: %d, max: %d" % (desc_size, max_desc_size)
+        assert self.get(position + 1, 1) == '\x03', "Missing 0x03 at %04X" % (position + 1)
+        return self.get(position + 2, desc_size - 2).decode('utf-16-le')
+        
+    def set(self, value):
+        encoded = value.encode('utf-16-le')
+        desc_size = len(encoded) + 2
+        assert desc_size <= max_desc_size
+        self.set(position, chr(desc_size) + '\x03' + encoded)
+        
+    return property(get, set)
+
+class EEPROM(object):
+    START_ADDRESS = 0x3600
+    def __init__(self, content=None):
+        if isinstance(content, str) or content is None:
+            assert content is None or len(content) == cp210x.SIZE_EEPROM
+            self.content = content
+        elif isinstance(content, cp210x.Cp210xProgrammer):
+            self.content = content.get_eeprom_content()
+        else:
+            self.parse_hex_file(content.read())
+
+    def write_to_cp210x(self, cp210xDevice):
+        cp210xDevice.set_eeprom_content(self.content)
+            
+    def parse_hex_file(self, hex_content):
+        self.content = ''
+        address = self.START_ADDRESS
+        for tag in hex_content.split('\n'):
+            if not tag.startswith(':'):
+                raise HexFileError("Line doesn't start with ':'")
+            
+            try:
+                content = tag[1:].decode('hex')
+            except TypeError:
+                raise HexFileError("Hex data expected")
+            
+            if len(content) < 5:
+                raise HexFileError("Line too short")
+
+            if checksum(content) != 0:
+                raise HexFileError("Checksum error")
+        
+            size = from_binary(content[0])
+            tag_address = from_binary(content[1:3], le=False)
+            tag_type = from_binary(content[3:4])
+            line = content[4:-1]
+            
+            if tag_type == 0x00:
+                if tag_address != address:
+                    raise HexFileError("Expected address %04X but found %04X"
+                                       % (address, tag_address))
+                self.content += line
+                address += len(line)
+            elif tag_type == 0x01:
+                if size != 0 or len(line) != 0:
+                    raise HexFileError("Defect end tag")
+                break
+                
+            else:
+                raise HexFileError("Unknown tag type %02X" % tag_type)
+
+    def build_hex_file(self):
+        for tag_start in range(0, len(self.content), 0x10):
+            line = self.content[tag_start:tag_start+0x10]
+            address = self.START_ADDRESS + tag_start
+            tag = (to_binary(len(line), 1) + 
+                   to_binary(address, le=False) + 
+                   '\x00' + 
+                   line)
+            cs = checksum(tag)
+            if cs == 0:
+                tag += '\x00'
+            else:
+                tag += chr(0x100 - cs)
+            yield ":%s\n" % tag.encode('hex')
+        yield ":00000001FF\n"
+
+    def write_hex_file(self, f):
+        if isinstance(f, str):
+            f = file(f, 'wb')
+            do_close = True
+        else:
+            do_close = False
+        for line in self.build_hex_file():
+            f.write(line)
+        if do_close:
+            f.close()
+
+    def read_hex_file(self, f):
+        if isinstance(f, str):
+            f = file(f, 'rb')
+            do_close = True
+        else:
+            do_close = False
+        self.parse_hex_file(f.read())
+        if do_close:
+            f.close()
+
+    def get(self, pos, length):
+        return self.content[pos:pos+length]
+    
+    def set(self, pos, data):
+        self.content = (self.content[:pos] + 
+                        data + 
+                        self.content[pos + len(data):])
+   
+    def _get_baudrate_table(self):
+        dat = self.get(POS_BAUDRATE_TABLE, cp210x.SIZE_BAUDRATE_TABLE)
+        return [cp210x.parse_baudrate_cfg(dat[pos:pos+cp210x.SIZE_BAUDRATE_CFG])
+                for pos in range(0, cp210x.SIZE_BAUDRATE_TABLE, 
+                                 cp210x.SIZE_BAUDRATE_CFG)]
+    def _set_baudrate_table(self, baudrates):
+        assert len(baudrates) == cp210x.SIZE_BAUDRATES
+        self.set(POS_BAUDRATE_TABLE, 
+                 ''.join(cp210x.build_baudrate_cfg(*cfg) for cfg in baudrates))
+    baudrate_table = property(_get_baudrate_table, _set_baudrate_table)
+    product_string = _str_value(POS_PRODUCT_STRING, cp210x.SIZE_PRODUCT_STRING)
+    serial_number = _str_value(POS_SERIAL_NUMBER, cp210x.SIZE_SERIAL_NUMBER)
+    part_number = _int_value(POS_PART_NUMBER, 1)
+    vendor_id = _int_value(POS_VENDOR_ID, 2)
+    product_id = _int_value(POS_PRODUCT_ID, 2)
+    version = _int_value(POS_VERSION, 2, 
+                         cp210x.from_bcd2, cp210x.to_bcd2)
+    bus_powered = _int_value(POS_CFG_ATTRIBUTES, 1, 
+                             lambda a: bool(a & 0x40), 
+                             lambda a: 0xC0 if a else 0x80)
+    max_power = _int_value(POS_MAX_POWER, 1, lambda p: p*2, cp210x.to_div2)
+    vendor_string = _str_value(POS_VENDOR_STRING, cp210x.SIZE_VENDOR_STRING)
+    locked = _int_value(POS_LOCK_VALUE, 1, 
+                        lambda l: l == cp210x.LCK_LOCKED, 
+                        lambda b: cp210x.LCK_LOCKED if b
+                                  else cp210x.LCK_UNLOCKED)
+        
+    def get_values(self):
+        return dict((name, getattr(self, name)) for name, type in VALUES)
+
+    def set_values(self, values):
+        for name, value in values.items():
+            setattr(self, name, value)
+
+            

+ 234 - 0
build/lib.linux-armv6l-2.7/cp210x/valuefile.py

@@ -0,0 +1,234 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2007 Johannes Hölzl <johannes.hoelzl@gmx.de>
+#
+# This library is covered by the GNU LGPL, read LICENSE for details.
+
+# For documentation of the baudrate table see:
+#
+# [AN205] Silicon Labs Application Note 205 Rev. 0.3
+# http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/Interface/en/an205.pdf
+
+import re
+from ConfigParser import ConfigParser
+
+import cp210x
+from cp210x import VALUES, SIZE_BAUDRATES
+
+__all__ = ['read_file', 'write_file', 'update_values', 'PrescalerIsZero',
+           'ValuesFileError']
+
+class ValuesError(StandardError):
+    pass
+
+class PrescalerIsZero(ValuesError):
+    pass
+
+class ValuesFileError(ValuesError):
+    pass
+
+version_pattern = re.compile(r'^\s*(\d\d?)\.(\d\d?)\s*$')
+def read_version(s):
+    match = version_pattern.match(s)
+    if match is None:
+        raise ValueError("Version does not match 'xx.yy'")
+    return (int(match.group(1)), int(match.group(2)))
+def write_version(v):
+    return "%d.%02d" % v
+
+def read_hex(s):
+    return int(s.strip(), 16)
+
+def write_hex(num):
+    return "%04X" % num
+
+def write_bool(b):
+    if b:
+        return 'yes'
+    else:
+        return 'no'
+
+def read_bool(s):
+    s = s.strip().lower()
+    if s not in ['true', 'yes', 'false', 'no']:
+        raise ValueError("Boolean must be either 'true', 'yes', 'false' or 'no'.")
+    return s in ['true', 'yes']
+
+def read_baudrate_info(s):
+    values = s.split(',')
+    if len(values) != 3:
+         raise ValueError("Baudrate info must be three comma-separated items")
+    try:
+        baudgen = read_hex(values[0])
+    except ValueError:
+        raise ValueError("The first baudrate info must be a hex-value")
+    try:
+        timer0 = read_hex(values[1])
+    except ValueError:
+        raise ValueError("The second baudrate info must be a hex-value")
+    try:
+        prescale = int(values[2])
+    except ValueError:
+        raise ValueError("The thirdbaudrate info must be a number")
+    return (baudgen, timer0, prescale)
+
+TYPES = {
+    'boolean':  (read_bool, write_bool),
+    'int':      (int, str),
+    'id':       (read_hex, write_hex),
+    'string':   (str, str),
+    'version':  (read_version, write_version),
+}
+
+def read_file(fp):
+    cp = ConfigParser()
+    if isinstance(fp, str):
+        cp.read([fp])
+    else:
+        cp.readfp(fp)
+    
+    values = {}
+    
+    for name, type in VALUES:
+        if name is 'baudrate_table':
+            continue
+        reader, _ = TYPES[type]
+        if cp.has_option('usb device', name):
+            try:
+                values[name] = reader(cp.get('usb device', name))
+            except ValueError, err:
+                raise ValuesFileError("Key '%s': %s" % (name, str(err)))
+    
+    if cp.has_section('baudrate table'):
+        baudrate_table = []
+        for name, value in cp.items('baudrate table'):
+            try:
+                baudrate = int(name)
+            except ValueError:
+                raise ValuesFileError("Key names in 'baudrate table' must be"
+                                      " baudrate numbers.")
+            try:
+                baudrate_table.append(read_baudrate_info(value) + (baudrate, ))
+            except ValueError, err:
+                raise ValuesFileError("Wrong baudrate info %i: %s"
+                                      % (baudrate, str(err)))
+        baudrate_table.sort(key=(lambda i: i[3]), reverse=True)
+        
+        values['baudrate_table'] = baudrate_table
+    return values
+
+def write_file(fp, values):
+    fp.write("[usb device]\n")
+    
+    for name, type in VALUES:
+        if name == 'baudrate_table':
+            continue
+        _, writer = TYPES[type]
+        if name in values:
+            fp.write("%s = %s\n" % (name, writer(values[name])))
+
+    if 'baudrate_table' in values:
+        fp.write("\n")
+        fp.write("[baudrate table]\n")
+        for (baudgen, timegen, prescaler, 
+             baudrate) in sorted(values['baudrate_table'], key=(lambda i: i[3]),
+                                 reverse=True):
+            fp.write("%7d = %04X, %04X, %d # %s\n"
+                     % (baudrate, baudgen, timegen, prescaler,
+                        show_baudrate(baudgen, timegen, prescaler)))
+
+def calc_baudrate(baudgen, timegen, prescaler):
+    # This formulas are from AN205 page 5.
+    if prescaler == 0:
+        raise PrescalerIsZero("Prescaler is 0")
+    baudrate = (24000000. / prescaler) / (0x10000 - baudgen)
+    return (baudrate, (0x10000 - timegen) * 2)
+
+def show_baudrate(baudgen, timegen, prescaler):
+    try:
+        baudrate, timeout = calc_baudrate(baudgen, timegen, prescaler)
+    except PrescalerIsZero:
+        return "Wrong data, Prescaler is 0."
+    if timeout >= 1000:
+        timeout = "%1.3f ms" % (float(timeout) / 1000)
+    else:
+        timeout = "%d us" % timeout
+    if baudrate is None:
+        return ", %s" % (baudrate, timeout)
+    else:
+        return "%7.0f Baud, %s" % (baudrate, timeout)
+
+def update_values(v, new, dev):
+    old_baudrate_table = v.get('baudrate_table')
+    new_baudrate_table = new.get('baudrate_table')
+    
+    v.update(new)
+
+    # update baudrate table
+    # it is needed, that the baudrate table has 32 entries when it is written
+    # to the eeprom or device.
+    if ((old_baudrate_table is not None or new_baudrate_table is not None) and
+        (new_baudrate_table is None or 
+         len(new_baudrate_table) < SIZE_BAUDRATES)):
+         
+        if old_baudrate_table is not None:
+            if len(old_baudrate_table) < SIZE_BAUDRATES:
+                baudrate_table = old_baudrate_table
+            else:
+                baudrate_table = list(merge_baudrate_table(dev.baudrate_table, 
+                                                           old_baudrate_table))
+        else:
+            baudrate_table = dev.baudrate_table
+                                                               
+        if new_baudrate_table:
+            baudrate_table = list(merge_baudrate_table(baudrate_table, 
+                                                       new_baudrate_table))        
+        v['baudrate_table'] = baudrate_table
+    
+            
+            
+def merge_baudrate_table(old, new):
+    for (old_info, (start, stop)) in zip(old, REQUEST_BAUDRATE_RANGES):
+        for baudgen, timer, prescaler, baudrate in new:
+            if ((start is None or baudrate <= start) and 
+                baudrate >= stop):
+                yield (baudgen, timer, prescaler, baudrate)
+                break
+        else:
+            yield old_info
+            
+REQUEST_BAUDRATE_RANGES = [
+# The table data is from AN205 Table 1 on page 1.
+#     Start     End       Default Baudrate
+    (None,    2457601), #  Undefined
+    (2457600, 1474561), #  Undefined
+    (1474560, 1053258), #  Undefined
+    (1053257,  670255), #  921600
+    ( 670254,  567139), #  576000
+    ( 567138,  491521), #  500000
+    ( 491520,  273067), #  460800
+    ( 273066,  254235), #  256000
+    ( 254234,  237833), #  250000
+    ( 237832,  156869), #  230400
+    ( 156868,  129348), #  153600
+    ( 129347,  117029), #  128000
+    ( 117028,   77609), #  115200
+    (  77608,   64112), #   76800
+    (  64111,   58054), #   64000
+    (  58053,   56281), #   57600
+    (  56280,   51559), #   56000
+    (  51558,   38602), #   51200
+    (  38601,   28913), #   38400
+    (  28912,   19251), #   28800
+    (  19250,   16063), #   19200
+    (  16062,   14429), #   16000
+    (  14428,    9613), #   14400
+    (   9612,    7208), #    9600
+    (   7207,    4804), #    7200
+    (   4803,    4001), #    4800
+    (   4000,    2401), #    4000
+    (   2400,    1801), #    2400
+    (   1800,    1201), #    1800
+    (   1200,     601), #    1200
+    (    600,     301), #     600
+    (    300,      57), #     300
+]

+ 4 - 0
build/lib.linux-x86_64-2.7/cp210x/__init__.py

@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+
+__author__ = "Johannes Hölzl <johannes.hoelzl@gmx.de>"
+__license__ = "GNU LGPL"

+ 360 - 0
build/lib.linux-x86_64-2.7/cp210x/cp210x.py

@@ -0,0 +1,360 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2007 Johannes Hölzl <johannes.hoelzl@gmx.de>
+#
+# This library is covered by the GNU LGPL, read LICENSE for details.
+"""Provides access to the EEPROM of Silabs CP210x devices
+
+The following class is available:
+
+class Cp210xProgrammer:
+    Provides direct access to the CP210x, can be used to write single data
+    directly or via an EEPROM image.
+"""
+
+import usb
+from usb.util import CTRL_IN, CTRL_OUT, CTRL_TYPE_VENDOR
+
+__all__ = ['Cp210xProgrammer', 'Cp210xError']
+
+CP210x_CONFIG       = 0xFF
+
+REG_VENDOR_ID       = 0x3701
+REG_PRODUCT_ID      = 0x3702
+REG_PRODUCT_STRING  = 0x3703
+REG_SERIAL_NUMBER   = 0x3704
+REG_CFG_ATTRIBUTES  = 0x3705
+REG_MAX_POWER       = 0x3706
+REG_VERSION         = 0x3707
+REG_UNKNOWN         = 0x3708
+REG_EEPROM          = 0x3709
+REG_LOCK_VALUE      = 0x370A
+REG_PART_NUMBER     = 0x370B
+
+SIZE_EEPROM         = 0x0400
+SIZE_PRODUCT_STRING = 255
+SIZE_SERIAL_NUMBER  = 128
+SIZE_BAUDRATES      = 32
+SIZE_BAUDRATE_CFG   = 10
+SIZE_BAUDRATE_TABLE = SIZE_BAUDRATES * SIZE_BAUDRATE_CFG
+SIZE_VENDOR_STRING  = 50
+
+# Buffer size limits
+# (see AN721: CP210x/CP211x Device Customization Guide)
+CP210x_MAX_PRODUCT_STRLEN = (SIZE_PRODUCT_STRING - 2) // 2
+CP210x_MAX_SERIAL_STRLEN  = (SIZE_SERIAL_NUMBER - 2) // 2
+
+LCK_LOCKED          = 0xF0
+LCK_UNLOCKED        = 0xFF
+
+VID_SILABS          = 0x10C4
+PID_CP210x          = 0xEA60
+
+VALUES = [
+    ('product_string', 'string'),
+    ('serial_number',  'string'),
+    ('vendor_id',      'id'),
+    ('product_id',     'id'),
+    ('version',        'version'),
+    ('bus_powered',    'boolean'),
+    ('max_power',      'int'),
+    ('locked',         'boolean'),
+    ('part_number',    'int'),
+    ('vendor_string',  'string'),
+    ('baudrate_table', 'list'),
+]
+
+def to_div2(p):
+    value = int(p / 2)
+    if (value * 2) < p:
+        value += 1
+    return value
+    
+def to_bcd(i):
+    assert i >= 0 and i <= 99
+    return (i // 10) << 4 | (i % 10)
+
+def to_bcd2( (i, j) ):
+    return to_bcd(i) << 8 | to_bcd(j)
+
+def from_bcd(num):
+    return num & 0x0F + (num >> 4) * 10
+
+def from_bcd2(data):
+    return (from_bcd(data >> 8), from_bcd(data & 0xFF))
+
+def from_binary(data, le=True):
+    value = 0
+    if le:
+        data = data[::-1]
+    for byte in data:
+        value = value << 8 | ord(byte)
+    return value
+
+def to_binary(value, size=2, le=True):
+    data = ''
+    for i in range(size):
+        data += chr(value & 0xFF)
+        value >>= 8
+    if le:
+        return data
+    else:
+        return data[::-1]
+    
+def parse_baudrate_cfg(data):
+    return (from_binary(data[0:2], le=False), 
+            from_binary(data[2:4], le=False), 
+            from_binary(data[4:5]),
+            from_binary(data[6:10]))
+
+def build_baudrate_cfg(baudgen, timer0reload, prescaler, baudrate):
+    return (to_binary(baudgen, le=False) + to_binary(timer0reload, le=False) + 
+            to_binary(prescaler, 1) + '\x00' + to_binary(baudrate, 4))
+
+class Cp210xError(IOError):
+    pass
+
+class DeviceLocked(Cp210xError):
+    pass
+
+class Cp210xMatch(object):
+    def __init__(self, patterns):
+        self.patterns = patterns
+
+    def __call__(self, dev):
+        for pattern in self.patterns:
+            for name, value in pattern.items():
+                if getattr(dev, name) != value:
+                    return False
+            return True
+        return False
+
+class Cp210xProgrammer(object):
+    """Program a Silabs CP2101, CP2102 or CP2103
+    
+    This module provides access to Silabs CP210x devices to set some USB
+    descriptor fields and some USB descriptor strings. 
+
+    The following fields can be set:
+
+     * Vendor ID
+     * Product ID
+     * Product String
+     * Serial Number
+     * Device Version
+     * Bus Powered
+     * max. Power consumption
+ 
+    Either use PyUSB to find a device, and pass the usb.Device object
+    to the constructor, or use Cp210xProgrammer.list_device() to list all
+    devices matching certain pattern.
+    """
+    
+    TIMEOUT = 300 #ms
+    
+    @classmethod
+    def list_devices(self, patterns=[{ 'idVendor': VID_SILABS, 
+                                       'idProduct': PID_CP210x }]):
+        """Yields a list of devices matching certain patterns.
+        
+        param patterns: This must be a list of dictionaries. Each device
+            in the usb tree is matched against all patterns in the list. 
+            
+            All fields of the descriptors are compared with the corresponding
+            values in the dictionary. A device matches the pattern only if all
+            values match.
+        
+        For example:
+
+        >> list(Cp210xProgrammer.list_device([{ 'idVendor': VID_SILABS, 
+                                           'idProduct': PID_CP210x }]))
+        [device(...)]
+        
+        """
+        
+        return usb.core.find(find_all=True,
+                             custom_match=Cp210xMatch(patterns))
+
+    def __init__(self, usbdev):
+        self.usbdev = usbdev
+        self._locked = None
+        try:
+            self.has_kernel_driver = usbdev.is_kernel_driver_active(0)
+        except NotImplementedError:
+            self.has_kernel_driver = False
+        if self.has_kernel_driver:
+            cfg = usbdev.get_active_configuration()
+            self.intf = cfg[(0,0)].bInterfaceNumber
+            usbdev.detach_kernel_driver(self.intf)
+        usbdev.set_configuration()
+        
+    def reset(self):
+        """Force the USB stack to reset the device.
+        
+        Resets the device through an hard reset over the port to which the
+        device is connected. After that happend the EEPROM content in the device
+        is reread and the device's descriptors are the one written to it.
+        """
+        self.usbdev.reset()
+    
+    def __del__(self):
+        if self.has_kernel_driver:
+            self.usbdev.attach_kernel_driver(self.intf)
+
+    def _set_config(self, value, index=0, data=None, request=CP210x_CONFIG):
+        if self.get_locked():
+            raise DeviceLocked()
+            
+        res = self.usbdev.ctrl_transfer(CTRL_OUT | CTRL_TYPE_VENDOR,
+                                        request, value, index, data)
+        if data is not None and res != len(data):
+            raise Cp210xError("Short write (%d of %d bytes)"
+                              % (res, len(data)))
+
+    def _set_config_string(self, value, content, max_desc_size):
+        assert isinstance(content, basestring)
+        encoded = content.encode('utf-16-le')
+        desc_size = len(encoded) + 2
+        assert desc_size <= max_desc_size
+        self._set_config(value, data=chr(desc_size) + "\x03" + encoded)
+
+    def _get_config(self, value, length, index=0, request=CP210x_CONFIG):
+        res = self.usbdev.ctrl_transfer(CTRL_IN | CTRL_TYPE_VENDOR,
+                                        request, value, index, length)
+        return res.tostring()
+
+    def _get_int8_config(self, value, index=0, request=CP210x_CONFIG):
+        return ord(self._get_config(value, 1, index=index, request=request))
+
+    def _get_int16_config(self, value, index=0, request=CP210x_CONFIG):
+        data = self._get_config(value, 2, index=index, request=request)
+        return ord(data[0]) << 8 | ord(data[1])
+    
+    def get_eeprom_content(self):
+        """Get the entire EEPROM content as one big 1024-byte blob.
+        """
+        return self._get_config(REG_EEPROM, SIZE_EEPROM)
+    
+    def get_baudrate_content(self):
+        """Get the baudrate table as binary data.
+        """
+        return self._get_config(REG_EEPROM, SIZE_BAUDRATE_TABLE)
+
+    def get_baudrate_table(self):
+        """Get the baudrate table.
+        
+        A list containing 4-tuples is returned.
+        Each tuple contains the following data:
+        
+         * BaudGen: Value used to generate the baudrate.
+         * Time0Reset: Value used to generate the usb timeout.
+         * Prescaler: Used to down-scale the baudrate.
+         * Baudrate: The baudrate which activates this entry.
+        """
+        data = self.get_baudrate_content()
+        return [parse_baudrate_cfg(data[pos:pos+SIZE_BAUDRATE_CFG])
+                for pos in range(0, SIZE_BAUDRATE_TABLE, SIZE_BAUDRATE_CFG)]
+        
+    def set_baudrate_table(self, baudrates):
+        """Write the baudrate table.
+        
+        See get_baudrate_table() for the structure of the table.
+        """
+        assert len(baudrates) == SIZE_BAUDRATES
+        self.set_baudrate_content(data=''.join(build_baudrate_cfg(*cfg) 
+                                               for cfg in baudrates))
+    baudrate_table = property(get_baudrate_table, set_baudrate_table)
+        
+    def get_part_number(self):
+        """Get the part number of the device.
+        
+        Returns: 1 for a CP2101
+                 2 for a CP2102
+                 3 for a CP2103
+        """
+        return self._get_int8_config(REG_PART_NUMBER)
+    
+    def get_locked(self):
+        """Read the lock value of the device.
+        
+        When True is returnes no data can be written to the device.
+        """
+        if self._locked is None:
+            self._locked = self._get_int8_config(REG_LOCK_VALUE) == LCK_LOCKED
+        return self._locked
+    
+    def set_eeprom_content(self, content):
+        """Write a 1024-byte blob to the EEPROM
+        """
+        assert len(content) == SIZE_EEPROM, ("EEPROM data must be %i bytes."
+                                             % SIZE_EEPROM)
+        assert isinstance(content, str), "EEPROM data must be string."
+        self._set_config(REG_EEPROM, data=content)
+    
+    def set_product_id(self, pid):
+        """Set the Product ID
+        """
+        assert pid > 0x0000 and pid < 0xFFFF
+        self._set_config(REG_PRODUCT_ID, pid)
+        
+    def set_vendor_id(self, vid):
+        """Set the Vendor ID
+        """
+        assert vid > 0x0000 and vid < 0xFFFF
+        self._set_config(REG_VENDOR_ID, vid)
+    
+    def set_product_string(self, product_string):
+        """Set the product string.
+        
+        The string will be encoded with UTF-16 and must not exceed
+        CP210x_MAX_PRODUCT_STRLEN.
+        For Unicode Plane 0 (BMP; code points 0-FFFF), this specifies
+        the maximum length of the string in characters.
+        """
+        self._set_config_string(REG_PRODUCT_STRING, product_string, 
+                                SIZE_PRODUCT_STRING)
+    
+    def set_serial_number(self, serial_number):
+        """Set the serial number string.
+        
+        The string will be encoded with UTF-16 and must not exceed
+        CP210x_MAX_SERIAL_STRLEN.
+        For Unicode Plane 0 (BMP; code points 0-FFFF), this specifies
+        the maximum length of the string in characters.
+        """
+        self._set_config_string(REG_SERIAL_NUMBER, serial_number, 
+                                SIZE_SERIAL_NUMBER)
+    
+    def set_max_power(self, max_power):
+        """Set maximum power consumption.
+        """
+        assert max_power >= 0 and max_power <= 500
+        self._set_config(REG_MAX_POWER, to_div2(max_power))
+    
+    def set_bus_powered(self, bus_powered):
+        """Set the bus-powered flag in the device descriptor.
+        """
+        if bus_powered:
+            self._set_config(REG_CFG_ATTRIBUTES, 0xC0)
+        else:
+            self._set_config(REG_CFG_ATTRIBUTES, 0x80)
+
+    def set_version(self, version):
+        """Set the device version .
+        """
+        self._set_config(REG_VERSION, to_bcd2(version))
+
+    def set_locked(self, locked):
+        """Set the lock value of the device.
+        
+        When True is returned no data can be written to the device.
+        """
+        if locked:
+            self._set_config(REG_LOCK_VALUE, LCK_LOCKED)
+        else:
+            self._set_config(REG_LOCK_VALUE, LCK_UNLOCKED)
+
+    def set_values(self, values):
+        for name, value in values.items():
+            if name not in ['part_number', 'vendor_string']:
+                getattr(self, "set_" + name) (value)
+            

+ 190 - 0
build/lib.linux-x86_64-2.7/cp210x/eeprom.py

@@ -0,0 +1,190 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2007 Johannes Hölzl <johannes.hoelzl@gmx.de>
+#
+# This library is covered by the GNU LGPL, read LICENSE for details.
+"""Provides logical view of the EEPROM of Silabs CP210x devices
+
+The following class is available:
+
+class EEPROM:
+    Can be used to read or write a hex file containing the EEPROM content
+    of a CP210x. Also provides access to single fields in the EEPROM.
+"""
+
+import cp210x
+from cp210x import from_binary, to_binary, VALUES
+
+__all__ = ['EEPROM', 'HexFileError']
+
+POS_BAUDRATE_TABLE  = 0x0000
+POS_PART_NUMBER     = 0x01FF
+POS_STRING_DESC_0   = 0x0200
+POS_PRODUCT_STRING  = 0x0208
+POS_SERIAL_NUMBER   = 0x0307
+POS_VENDOR_ID       = 0x0390
+POS_PRODUCT_ID      = 0x0392
+POS_VERSION         = 0x0394
+POS_CFG_ATTRIBUTES  = 0x03A1
+POS_MAX_POWER       = 0x03A2
+POS_VENDOR_STRING   = 0x03C3
+POS_LOCK_VALUE      = 0x03FF
+
+class HexFileError(StandardError):
+    pass
+
+def checksum(line):
+    return sum(ord(c) for c in line) & 0xFF
+
+def _int_value(position, size, read=lambda x:x, write=lambda x:x):
+    def get(self):
+        return read(from_binary(self.get(position, size)))
+    def set(self, value):
+        self.set(position, to_binary(write(value), size))
+    return property(get, set)
+    
+def _str_value(position, max_desc_size):
+    def get(self):
+        desc_size = from_binary(self.get(position, 1))
+        assert desc_size <= max_desc_size and desc_size >= 2, "desc_size: %d, max: %d" % (desc_size, max_desc_size)
+        assert self.get(position + 1, 1) == '\x03', "Missing 0x03 at %04X" % (position + 1)
+        return self.get(position + 2, desc_size - 2).decode('utf-16-le')
+        
+    def set(self, value):
+        encoded = value.encode('utf-16-le')
+        desc_size = len(encoded) + 2
+        assert desc_size <= max_desc_size
+        self.set(position, chr(desc_size) + '\x03' + encoded)
+        
+    return property(get, set)
+
+class EEPROM(object):
+    START_ADDRESS = 0x3600
+    def __init__(self, content=None):
+        if isinstance(content, str) or content is None:
+            assert content is None or len(content) == cp210x.SIZE_EEPROM
+            self.content = content
+        elif isinstance(content, cp210x.Cp210xProgrammer):
+            self.content = content.get_eeprom_content()
+        else:
+            self.parse_hex_file(content.read())
+
+    def write_to_cp210x(self, cp210xDevice):
+        cp210xDevice.set_eeprom_content(self.content)
+            
+    def parse_hex_file(self, hex_content):
+        self.content = ''
+        address = self.START_ADDRESS
+        for tag in hex_content.split('\n'):
+            if not tag.startswith(':'):
+                raise HexFileError("Line doesn't start with ':'")
+            
+            try:
+                content = tag[1:].decode('hex')
+            except TypeError:
+                raise HexFileError("Hex data expected")
+            
+            if len(content) < 5:
+                raise HexFileError("Line too short")
+
+            if checksum(content) != 0:
+                raise HexFileError("Checksum error")
+        
+            size = from_binary(content[0])
+            tag_address = from_binary(content[1:3], le=False)
+            tag_type = from_binary(content[3:4])
+            line = content[4:-1]
+            
+            if tag_type == 0x00:
+                if tag_address != address:
+                    raise HexFileError("Expected address %04X but found %04X"
+                                       % (address, tag_address))
+                self.content += line
+                address += len(line)
+            elif tag_type == 0x01:
+                if size != 0 or len(line) != 0:
+                    raise HexFileError("Defect end tag")
+                break
+                
+            else:
+                raise HexFileError("Unknown tag type %02X" % tag_type)
+
+    def build_hex_file(self):
+        for tag_start in range(0, len(self.content), 0x10):
+            line = self.content[tag_start:tag_start+0x10]
+            address = self.START_ADDRESS + tag_start
+            tag = (to_binary(len(line), 1) + 
+                   to_binary(address, le=False) + 
+                   '\x00' + 
+                   line)
+            cs = checksum(tag)
+            if cs == 0:
+                tag += '\x00'
+            else:
+                tag += chr(0x100 - cs)
+            yield ":%s\n" % tag.encode('hex')
+        yield ":00000001FF\n"
+
+    def write_hex_file(self, f):
+        if isinstance(f, str):
+            f = file(f, 'wb')
+            do_close = True
+        else:
+            do_close = False
+        for line in self.build_hex_file():
+            f.write(line)
+        if do_close:
+            f.close()
+
+    def read_hex_file(self, f):
+        if isinstance(f, str):
+            f = file(f, 'rb')
+            do_close = True
+        else:
+            do_close = False
+        self.parse_hex_file(f.read())
+        if do_close:
+            f.close()
+
+    def get(self, pos, length):
+        return self.content[pos:pos+length]
+    
+    def set(self, pos, data):
+        self.content = (self.content[:pos] + 
+                        data + 
+                        self.content[pos + len(data):])
+   
+    def _get_baudrate_table(self):
+        dat = self.get(POS_BAUDRATE_TABLE, cp210x.SIZE_BAUDRATE_TABLE)
+        return [cp210x.parse_baudrate_cfg(dat[pos:pos+cp210x.SIZE_BAUDRATE_CFG])
+                for pos in range(0, cp210x.SIZE_BAUDRATE_TABLE, 
+                                 cp210x.SIZE_BAUDRATE_CFG)]
+    def _set_baudrate_table(self, baudrates):
+        assert len(baudrates) == cp210x.SIZE_BAUDRATES
+        self.set(POS_BAUDRATE_TABLE, 
+                 ''.join(cp210x.build_baudrate_cfg(*cfg) for cfg in baudrates))
+    baudrate_table = property(_get_baudrate_table, _set_baudrate_table)
+    product_string = _str_value(POS_PRODUCT_STRING, cp210x.SIZE_PRODUCT_STRING)
+    serial_number = _str_value(POS_SERIAL_NUMBER, cp210x.SIZE_SERIAL_NUMBER)
+    part_number = _int_value(POS_PART_NUMBER, 1)
+    vendor_id = _int_value(POS_VENDOR_ID, 2)
+    product_id = _int_value(POS_PRODUCT_ID, 2)
+    version = _int_value(POS_VERSION, 2, 
+                         cp210x.from_bcd2, cp210x.to_bcd2)
+    bus_powered = _int_value(POS_CFG_ATTRIBUTES, 1, 
+                             lambda a: bool(a & 0x40), 
+                             lambda a: 0xC0 if a else 0x80)
+    max_power = _int_value(POS_MAX_POWER, 1, lambda p: p*2, cp210x.to_div2)
+    vendor_string = _str_value(POS_VENDOR_STRING, cp210x.SIZE_VENDOR_STRING)
+    locked = _int_value(POS_LOCK_VALUE, 1, 
+                        lambda l: l == cp210x.LCK_LOCKED, 
+                        lambda b: cp210x.LCK_LOCKED if b
+                                  else cp210x.LCK_UNLOCKED)
+        
+    def get_values(self):
+        return dict((name, getattr(self, name)) for name, type in VALUES)
+
+    def set_values(self, values):
+        for name, value in values.items():
+            setattr(self, name, value)
+
+            

+ 234 - 0
build/lib.linux-x86_64-2.7/cp210x/valuefile.py

@@ -0,0 +1,234 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2007 Johannes Hölzl <johannes.hoelzl@gmx.de>
+#
+# This library is covered by the GNU LGPL, read LICENSE for details.
+
+# For documentation of the baudrate table see:
+#
+# [AN205] Silicon Labs Application Note 205 Rev. 0.3
+# http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/Interface/en/an205.pdf
+
+import re
+from ConfigParser import ConfigParser
+
+import cp210x
+from cp210x import VALUES, SIZE_BAUDRATES
+
+__all__ = ['read_file', 'write_file', 'update_values', 'PrescalerIsZero',
+           'ValuesFileError']
+
+class ValuesError(StandardError):
+    pass
+
+class PrescalerIsZero(ValuesError):
+    pass
+
+class ValuesFileError(ValuesError):
+    pass
+
+version_pattern = re.compile(r'^\s*(\d\d?)\.(\d\d?)\s*$')
+def read_version(s):
+    match = version_pattern.match(s)
+    if match is None:
+        raise ValueError("Version does not match 'xx.yy'")
+    return (int(match.group(1)), int(match.group(2)))
+def write_version(v):
+    return "%d.%02d" % v
+
+def read_hex(s):
+    return int(s.strip(), 16)
+
+def write_hex(num):
+    return "%04X" % num
+
+def write_bool(b):
+    if b:
+        return 'yes'
+    else:
+        return 'no'
+
+def read_bool(s):
+    s = s.strip().lower()
+    if s not in ['true', 'yes', 'false', 'no']:
+        raise ValueError("Boolean must be either 'true', 'yes', 'false' or 'no'.")
+    return s in ['true', 'yes']
+
+def read_baudrate_info(s):
+    values = s.split(',')
+    if len(values) != 3:
+         raise ValueError("Baudrate info must be three comma-separated items")
+    try:
+        baudgen = read_hex(values[0])
+    except ValueError:
+        raise ValueError("The first baudrate info must be a hex-value")
+    try:
+        timer0 = read_hex(values[1])
+    except ValueError:
+        raise ValueError("The second baudrate info must be a hex-value")
+    try:
+        prescale = int(values[2])
+    except ValueError:
+        raise ValueError("The thirdbaudrate info must be a number")
+    return (baudgen, timer0, prescale)
+
+TYPES = {
+    'boolean':  (read_bool, write_bool),
+    'int':      (int, str),
+    'id':       (read_hex, write_hex),
+    'string':   (str, str),
+    'version':  (read_version, write_version),
+}
+
+def read_file(fp):
+    cp = ConfigParser()
+    if isinstance(fp, str):
+        cp.read([fp])
+    else:
+        cp.readfp(fp)
+    
+    values = {}
+    
+    for name, type in VALUES:
+        if name is 'baudrate_table':
+            continue
+        reader, _ = TYPES[type]
+        if cp.has_option('usb device', name):
+            try:
+                values[name] = reader(cp.get('usb device', name))
+            except ValueError, err:
+                raise ValuesFileError("Key '%s': %s" % (name, str(err)))
+    
+    if cp.has_section('baudrate table'):
+        baudrate_table = []
+        for name, value in cp.items('baudrate table'):
+            try:
+                baudrate = int(name)
+            except ValueError:
+                raise ValuesFileError("Key names in 'baudrate table' must be"
+                                      " baudrate numbers.")
+            try:
+                baudrate_table.append(read_baudrate_info(value) + (baudrate, ))
+            except ValueError, err:
+                raise ValuesFileError("Wrong baudrate info %i: %s"
+                                      % (baudrate, str(err)))
+        baudrate_table.sort(key=(lambda i: i[3]), reverse=True)
+        
+        values['baudrate_table'] = baudrate_table
+    return values
+
+def write_file(fp, values):
+    fp.write("[usb device]\n")
+    
+    for name, type in VALUES:
+        if name == 'baudrate_table':
+            continue
+        _, writer = TYPES[type]
+        if name in values:
+            fp.write("%s = %s\n" % (name, writer(values[name])))
+
+    if 'baudrate_table' in values:
+        fp.write("\n")
+        fp.write("[baudrate table]\n")
+        for (baudgen, timegen, prescaler, 
+             baudrate) in sorted(values['baudrate_table'], key=(lambda i: i[3]),
+                                 reverse=True):
+            fp.write("%7d = %04X, %04X, %d # %s\n"
+                     % (baudrate, baudgen, timegen, prescaler,
+                        show_baudrate(baudgen, timegen, prescaler)))
+
+def calc_baudrate(baudgen, timegen, prescaler):
+    # This formulas are from AN205 page 5.
+    if prescaler == 0:
+        raise PrescalerIsZero("Prescaler is 0")
+    baudrate = (24000000. / prescaler) / (0x10000 - baudgen)
+    return (baudrate, (0x10000 - timegen) * 2)
+
+def show_baudrate(baudgen, timegen, prescaler):
+    try:
+        baudrate, timeout = calc_baudrate(baudgen, timegen, prescaler)
+    except PrescalerIsZero:
+        return "Wrong data, Prescaler is 0."
+    if timeout >= 1000:
+        timeout = "%1.3f ms" % (float(timeout) / 1000)
+    else:
+        timeout = "%d us" % timeout
+    if baudrate is None:
+        return ", %s" % (baudrate, timeout)
+    else:
+        return "%7.0f Baud, %s" % (baudrate, timeout)
+
+def update_values(v, new, dev):
+    old_baudrate_table = v.get('baudrate_table')
+    new_baudrate_table = new.get('baudrate_table')
+    
+    v.update(new)
+
+    # update baudrate table
+    # it is needed, that the baudrate table has 32 entries when it is written
+    # to the eeprom or device.
+    if ((old_baudrate_table is not None or new_baudrate_table is not None) and
+        (new_baudrate_table is None or 
+         len(new_baudrate_table) < SIZE_BAUDRATES)):
+         
+        if old_baudrate_table is not None:
+            if len(old_baudrate_table) < SIZE_BAUDRATES:
+                baudrate_table = old_baudrate_table
+            else:
+                baudrate_table = list(merge_baudrate_table(dev.baudrate_table, 
+                                                           old_baudrate_table))
+        else:
+            baudrate_table = dev.baudrate_table
+                                                               
+        if new_baudrate_table:
+            baudrate_table = list(merge_baudrate_table(baudrate_table, 
+                                                       new_baudrate_table))        
+        v['baudrate_table'] = baudrate_table
+    
+            
+            
+def merge_baudrate_table(old, new):
+    for (old_info, (start, stop)) in zip(old, REQUEST_BAUDRATE_RANGES):
+        for baudgen, timer, prescaler, baudrate in new:
+            if ((start is None or baudrate <= start) and 
+                baudrate >= stop):
+                yield (baudgen, timer, prescaler, baudrate)
+                break
+        else:
+            yield old_info
+            
+REQUEST_BAUDRATE_RANGES = [
+# The table data is from AN205 Table 1 on page 1.
+#     Start     End       Default Baudrate
+    (None,    2457601), #  Undefined
+    (2457600, 1474561), #  Undefined
+    (1474560, 1053258), #  Undefined
+    (1053257,  670255), #  921600
+    ( 670254,  567139), #  576000
+    ( 567138,  491521), #  500000
+    ( 491520,  273067), #  460800
+    ( 273066,  254235), #  256000
+    ( 254234,  237833), #  250000
+    ( 237832,  156869), #  230400
+    ( 156868,  129348), #  153600
+    ( 129347,  117029), #  128000
+    ( 117028,   77609), #  115200
+    (  77608,   64112), #   76800
+    (  64111,   58054), #   64000
+    (  58053,   56281), #   57600
+    (  56280,   51559), #   56000
+    (  51558,   38602), #   51200
+    (  38601,   28913), #   38400
+    (  28912,   19251), #   28800
+    (  19250,   16063), #   19200
+    (  16062,   14429), #   16000
+    (  14428,    9613), #   14400
+    (   9612,    7208), #    9600
+    (   7207,    4804), #    7200
+    (   4803,    4001), #    4800
+    (   4000,    2401), #    4000
+    (   2400,    1801), #    2400
+    (   1800,    1201), #    1800
+    (   1200,     601), #    1200
+    (    600,     301), #     600
+    (    300,      57), #     300
+]

+ 263 - 0
build/scripts-2.7/cp210x-program

@@ -0,0 +1,263 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# Copyright (c) 2007 Johannes Hölzl <johannes.hoelzl@gmx.de>
+#
+# This library is covered by the GNU LGPL, read LICENSE for details.
+"""\
+Provides access to the EEPROM of a Silabs CP210x. The data can be directly
+read from or written to the device.
+"""
+__author__ = "Johannes Hölzl <johannes.hoelzl@gmx.de>"
+__license__ = "GNU LGPL"
+__version__ = "1.0"
+
+import sys
+import re
+import string
+import traceback
+import optparse
+
+from cp210x import valuefile, cp210x
+from cp210x.eeprom import EEPROM, HexFileError
+from cp210x.valuefile import read_baudrate_info, update_values, ValuesFileError
+TRANS_UNDERSCORE = string.maketrans('_', '-')
+    
+ERR_OK = 0
+ERR_WRONG_INPUT = -1
+ERR_INTERNAL = -2
+ERR_DEVICE_LOCKED = -3
+ERR_DEVICE_NOT_FOUND = -4
+ERR_DEVICE_ERROR = -5
+ERR_OTHER = -100
+
+def error(message, retval=-1):
+    sys.stderr.write(message + "\n")
+    sys.exit(retval)
+    
+class Option(optparse.Option):
+    TYPES = list(optparse.Option.TYPES)
+    TYPE_CHECKER = dict(optparse.Option.TYPE_CHECKER)
+    for type, (reader, _) in valuefile.TYPES.items():
+        if type in TYPES:
+            continue
+        TYPES.append(type)
+        def checker(self, name, value, reader=reader):
+            try:
+                return reader(value)
+            except ValueError, err:
+                raise optparse.OptionValueError("option %s: %s" % (name,
+                                                                   str(err)))
+        TYPE_CHECKER[type] = checker
+    
+class OptionParser(optparse.OptionParser):
+    def error(self, msg):
+        error(msg, ERR_WRONG_INPUT)
+
+    def __init__(self, *args, **kwargs):
+        if 'option_class' not in kwargs:
+            kwargs['option_class'] = Option
+        optparse.OptionParser.__init__(self, *args, **kwargs)
+        
+def input_file(arg):
+    if arg is None or arg == '-':
+        return sys.stdin
+    else:
+        return file(arg, 'rb')
+
+def output_file(arg):
+    if arg is None or arg == '-':
+        return sys.stdout
+    else:
+        return file(arg, 'wb')
+
+def options_to_values(options):
+    values = {}
+    for name, type in cp210x.VALUES:
+        if name == "baudrate_table":
+            continue
+        value = getattr(options, name)
+        if value is not None:
+            values[name] = value
+      
+    if options.baudrate_table:
+        baudrate_table = []
+        for s in options.baudrate_table:
+            try:
+                baudrate, info = s.split(':')
+            except TypeError:
+                error("option --set-baudrate: need two parts separated by ':'", 
+                      ERR_WRONG_INPUT)
+            try:
+                baudrate_table.append(read_baudrate_info(info) + 
+                                      (int(baudrate), ))
+            except ValueError, err:
+                error("option --set-baudrate: %s" % str(err), 
+                      ERR_WRONG_INPUT)
+            
+        values['baudrate_table'] = baudrate_table
+    return values
+
+def find_device(patterns):
+    usb_patterns = []
+    for pattern in patterns:
+        if ':' in pattern:
+            try:
+                vidString, pidString = pattern.split(':')
+                vid = int(vidString, 16)
+                pid = int(pidString, 16)
+                
+            except (TypeError, ValueError):
+                error("Match be either 'ddd/ddd' or 'hhhh:hhhh'.",
+                      ERR_WRONG_INPUT)
+                
+            usb_patterns.append(dict(idVendor=vid, idProduct=pid))
+
+        elif '/' in pattern:
+            try:
+                busString, addressString = pattern.split('/')
+                bus = int(busString)
+                address = int(addressString)
+
+            except (TypeError, ValueError):
+                error("Match be either 'ddd/ddd' or 'hhhh:hhhh'.",
+                      ERR_WRONG_INPUT)
+
+            usb_patterns.append(dict(bus=bus, address=address))
+
+        else:
+            error("Match be either 'ddd/ddd' or 'hhhh:hhhh'.",
+                  ERR_WRONG_INPUT)
+                  
+    for dev in cp210x.Cp210xProgrammer.list_devices(usb_patterns):
+        return dev
+
+    error("No devices found", ERR_DEVICE_NOT_FOUND)
+    
+def read_cp210x(options):
+    usbdev = find_device(options.match)
+    dev = cp210x.Cp210xProgrammer(usbdev)
+
+    eeprom = EEPROM(dev)
+        
+    if options.hex_output:
+        eeprom.write_hex_file(output_file(options.hex_output))
+    if options.ini_output or not options.hex_output:
+        valuefile.write_file(output_file(options.ini_output), eeprom.get_values())
+
+def write_cp210x(options):
+    usbdev = find_device(options.match)
+    dev = cp210x.Cp210xProgrammer(usbdev)
+
+    if options.hex_input or options.force_eeprom:
+                
+            if options.hex_input:
+                eeprom = EEPROM(input_file(options.hex_input))
+            else:
+                eeprom = EEPROM(dev)
+                
+            values = eeprom.get_values()
+            if options.ini_input:
+                values = valuefile.read_file(input_file(options.ini_input))
+            update_values(values, options_to_values(options), eeprom)
+            
+            eeprom.set_values(values)
+            
+            eeprom.write_to_cp210x(dev)
+
+    else:
+            if options.ini_input:
+                values = valuefile.read_file(input_file(options.ini_input))
+            else:
+                values = {}
+            update_values(values, options_to_values(options), dev)
+            dev.set_values(values)
+            
+    if options.reset_device:
+        dev.reset()
+
+def change_hexfile(options):
+    eeprom = EEPROM(input_file(options.hex_input))
+    values =  {}
+    if options.ini_input:
+        update_values(values, 
+                      valuefile.read_file(input_file(options.ini_input)), 
+                      eeprom)
+    update_values(values, options_to_values(options), eeprom)
+    eeprom.set_values(values)
+    if options.ini_output:
+        valuefile.write_file(output_file(options.ini_output), 
+                             eeprom.get_values())
+    eeprom.write_hex_file(output_file(options.hex_output))
+    
+def parse_hexfile(options):
+    eeprom = EEPROM(input_file(options.hex_input))
+    valuefile.write_file(output_file(options.ini_output), eeprom.get_values())
+        
+parser = OptionParser(version=__version__, description=__doc__)
+parser.add_option("-r", "--read-cp210x", const=read_cp210x, 
+                  dest="action", action="store_const")
+parser.add_option("-w", "--write-cp210x", const=write_cp210x,
+                  dest="action", action="store_const")
+parser.add_option("-c", "--change-hexfile", const=change_hexfile,
+                  dest="action", action="store_const")
+parser.add_option("-p", "--parse-hexfile", const=parse_hexfile,
+                  dest="action", action="store_const")
+parser.add_option("-F", "--hex-input", metavar="FILE")
+parser.add_option("-f", "--hex-output", metavar="FILE")
+parser.add_option("-I", "--ini-input", metavar="FILE")
+parser.add_option("-i", "--ini-output", metavar="FILE")
+for name, type in cp210x.VALUES:
+    if name == 'baudrate_table':
+        continue
+    parser.add_option("--set-" + name.translate(TRANS_UNDERSCORE), 
+                      dest=name, metavar=name.upper(), type=type)
+parser.add_option("--set-baudrate", action="append", dest="baudrate_table")
+parser.add_option("-m", "--match", action="append", metavar="PATTERN")
+parser.add_option("--reset-device", action="store_true")
+parser.add_option("--force-eeprom", action="store_true")
+
+parser.set_defaults(
+    action=read_cp210x,
+    hex_input=None,
+    hex_output=None,
+    ini_input=None,
+    ini_output=None,
+    match=[],
+    baudrate_table=[],
+    reset_device=False,
+    force_eeprom=False,
+)
+
+def main():
+    (options, _) = parser.parse_args()
+    if not options.match:
+        options.match = ['10C4:EA60', '10C4:EA61']
+    options.action(options)
+
+if __name__ == '__main__':
+    try:
+        main()
+        
+    except cp210x.DeviceLocked:
+        error("Can not write data to device. Device is locked.", 
+              ERR_DEVICE_LOCKED)
+
+    except cp210x.Cp210xError, err:
+        error(str(err), ERR_DEVICE_ERROR)
+
+    except IOError, err:
+        error(str(err), ERR_OTHER)
+
+    except HexFileError, err:
+        error(str(err), ERR_OTHER)
+        
+    except ValuesFileError, err:
+        error(str(err), ERR_OTHER)
+
+    except SystemExit, err:
+        raise
+
+    except:
+        traceback.print_exc()
+        sys.exit(ERR_INTERNAL)
+        

+ 263 - 0
cp210x-program

@@ -0,0 +1,263 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (c) 2007 Johannes Hölzl <johannes.hoelzl@gmx.de>
+#
+# This library is covered by the GNU LGPL, read LICENSE for details.
+"""\
+Provides access to the EEPROM of a Silabs CP210x. The data can be directly
+read from or written to the device.
+"""
+__author__ = "Johannes Hölzl <johannes.hoelzl@gmx.de>"
+__license__ = "GNU LGPL"
+__version__ = "1.0"
+
+import sys
+import re
+import string
+import traceback
+import optparse
+
+from cp210x import valuefile, cp210x
+from cp210x.eeprom import EEPROM, HexFileError
+from cp210x.valuefile import read_baudrate_info, update_values, ValuesFileError
+TRANS_UNDERSCORE = string.maketrans('_', '-')
+    
+ERR_OK = 0
+ERR_WRONG_INPUT = -1
+ERR_INTERNAL = -2
+ERR_DEVICE_LOCKED = -3
+ERR_DEVICE_NOT_FOUND = -4
+ERR_DEVICE_ERROR = -5
+ERR_OTHER = -100
+
+def error(message, retval=-1):
+    sys.stderr.write(message + "\n")
+    sys.exit(retval)
+    
+class Option(optparse.Option):
+    TYPES = list(optparse.Option.TYPES)
+    TYPE_CHECKER = dict(optparse.Option.TYPE_CHECKER)
+    for type, (reader, _) in valuefile.TYPES.items():
+        if type in TYPES:
+            continue
+        TYPES.append(type)
+        def checker(self, name, value, reader=reader):
+            try:
+                return reader(value)
+            except ValueError, err:
+                raise optparse.OptionValueError("option %s: %s" % (name,
+                                                                   str(err)))
+        TYPE_CHECKER[type] = checker
+    
+class OptionParser(optparse.OptionParser):
+    def error(self, msg):
+        error(msg, ERR_WRONG_INPUT)
+
+    def __init__(self, *args, **kwargs):
+        if 'option_class' not in kwargs:
+            kwargs['option_class'] = Option
+        optparse.OptionParser.__init__(self, *args, **kwargs)
+        
+def input_file(arg):
+    if arg is None or arg == '-':
+        return sys.stdin
+    else:
+        return file(arg, 'rb')
+
+def output_file(arg):
+    if arg is None or arg == '-':
+        return sys.stdout
+    else:
+        return file(arg, 'wb')
+
+def options_to_values(options):
+    values = {}
+    for name, type in cp210x.VALUES:
+        if name == "baudrate_table":
+            continue
+        value = getattr(options, name)
+        if value is not None:
+            values[name] = value
+      
+    if options.baudrate_table:
+        baudrate_table = []
+        for s in options.baudrate_table:
+            try:
+                baudrate, info = s.split(':')
+            except TypeError:
+                error("option --set-baudrate: need two parts separated by ':'", 
+                      ERR_WRONG_INPUT)
+            try:
+                baudrate_table.append(read_baudrate_info(info) + 
+                                      (int(baudrate), ))
+            except ValueError, err:
+                error("option --set-baudrate: %s" % str(err), 
+                      ERR_WRONG_INPUT)
+            
+        values['baudrate_table'] = baudrate_table
+    return values
+
+def find_device(patterns):
+    usb_patterns = []
+    for pattern in patterns:
+        if ':' in pattern:
+            try:
+                vidString, pidString = pattern.split(':')
+                vid = int(vidString, 16)
+                pid = int(pidString, 16)
+                
+            except (TypeError, ValueError):
+                error("Match be either 'ddd/ddd' or 'hhhh:hhhh'.",
+                      ERR_WRONG_INPUT)
+                
+            usb_patterns.append(dict(idVendor=vid, idProduct=pid))
+
+        elif '/' in pattern:
+            try:
+                busString, addressString = pattern.split('/')
+                bus = int(busString)
+                address = int(addressString)
+
+            except (TypeError, ValueError):
+                error("Match be either 'ddd/ddd' or 'hhhh:hhhh'.",
+                      ERR_WRONG_INPUT)
+
+            usb_patterns.append(dict(bus=bus, address=address))
+
+        else:
+            error("Match be either 'ddd/ddd' or 'hhhh:hhhh'.",
+                  ERR_WRONG_INPUT)
+                  
+    for dev in cp210x.Cp210xProgrammer.list_devices(usb_patterns):
+        return dev
+
+    error("No devices found", ERR_DEVICE_NOT_FOUND)
+    
+def read_cp210x(options):
+    usbdev = find_device(options.match)
+    dev = cp210x.Cp210xProgrammer(usbdev)
+
+    eeprom = EEPROM(dev)
+        
+    if options.hex_output:
+        eeprom.write_hex_file(output_file(options.hex_output))
+    if options.ini_output or not options.hex_output:
+        valuefile.write_file(output_file(options.ini_output), eeprom.get_values())
+
+def write_cp210x(options):
+    usbdev = find_device(options.match)
+    dev = cp210x.Cp210xProgrammer(usbdev)
+
+    if options.hex_input or options.force_eeprom:
+                
+            if options.hex_input:
+                eeprom = EEPROM(input_file(options.hex_input))
+            else:
+                eeprom = EEPROM(dev)
+                
+            values = eeprom.get_values()
+            if options.ini_input:
+                values = valuefile.read_file(input_file(options.ini_input))
+            update_values(values, options_to_values(options), eeprom)
+            
+            eeprom.set_values(values)
+            
+            eeprom.write_to_cp210x(dev)
+
+    else:
+            if options.ini_input:
+                values = valuefile.read_file(input_file(options.ini_input))
+            else:
+                values = {}
+            update_values(values, options_to_values(options), dev)
+            dev.set_values(values)
+            
+    if options.reset_device:
+        dev.reset()
+
+def change_hexfile(options):
+    eeprom = EEPROM(input_file(options.hex_input))
+    values =  {}
+    if options.ini_input:
+        update_values(values, 
+                      valuefile.read_file(input_file(options.ini_input)), 
+                      eeprom)
+    update_values(values, options_to_values(options), eeprom)
+    eeprom.set_values(values)
+    if options.ini_output:
+        valuefile.write_file(output_file(options.ini_output), 
+                             eeprom.get_values())
+    eeprom.write_hex_file(output_file(options.hex_output))
+    
+def parse_hexfile(options):
+    eeprom = EEPROM(input_file(options.hex_input))
+    valuefile.write_file(output_file(options.ini_output), eeprom.get_values())
+        
+parser = OptionParser(version=__version__, description=__doc__)
+parser.add_option("-r", "--read-cp210x", const=read_cp210x, 
+                  dest="action", action="store_const")
+parser.add_option("-w", "--write-cp210x", const=write_cp210x,
+                  dest="action", action="store_const")
+parser.add_option("-c", "--change-hexfile", const=change_hexfile,
+                  dest="action", action="store_const")
+parser.add_option("-p", "--parse-hexfile", const=parse_hexfile,
+                  dest="action", action="store_const")
+parser.add_option("-F", "--hex-input", metavar="FILE")
+parser.add_option("-f", "--hex-output", metavar="FILE")
+parser.add_option("-I", "--ini-input", metavar="FILE")
+parser.add_option("-i", "--ini-output", metavar="FILE")
+for name, type in cp210x.VALUES:
+    if name == 'baudrate_table':
+        continue
+    parser.add_option("--set-" + name.translate(TRANS_UNDERSCORE), 
+                      dest=name, metavar=name.upper(), type=type)
+parser.add_option("--set-baudrate", action="append", dest="baudrate_table")
+parser.add_option("-m", "--match", action="append", metavar="PATTERN")
+parser.add_option("--reset-device", action="store_true")
+parser.add_option("--force-eeprom", action="store_true")
+
+parser.set_defaults(
+    action=read_cp210x,
+    hex_input=None,
+    hex_output=None,
+    ini_input=None,
+    ini_output=None,
+    match=[],
+    baudrate_table=[],
+    reset_device=False,
+    force_eeprom=False,
+)
+
+def main():
+    (options, _) = parser.parse_args()
+    if not options.match:
+        options.match = ['10C4:EA60', '10C4:EA61']
+    options.action(options)
+
+if __name__ == '__main__':
+    try:
+        main()
+        
+    except cp210x.DeviceLocked:
+        error("Can not write data to device. Device is locked.", 
+              ERR_DEVICE_LOCKED)
+
+    except cp210x.Cp210xError, err:
+        error(str(err), ERR_DEVICE_ERROR)
+
+    except IOError, err:
+        error(str(err), ERR_OTHER)
+
+    except HexFileError, err:
+        error(str(err), ERR_OTHER)
+        
+    except ValuesFileError, err:
+        error(str(err), ERR_OTHER)
+
+    except SystemExit, err:
+        raise
+
+    except:
+        traceback.print_exc()
+        sys.exit(ERR_INTERNAL)
+        

+ 83 - 0
cp210x-program.doap

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Project
+  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+  xmlns="http://usefulinc.com/ns/doap#"
+  xmlns:foaf="http://xmlns.com/foaf/0.1/"
+  >
+
+	<name>CP210x Programmer</name>
+	<shortname>cp210x-program</shortname>
+	
+	<homepage rdf:resource="http://cp210x-program.sourceforge.net/" />
+	<created>2007-04-02</created>
+
+	<shortdesc xml:lang="en">
+	    Provides access to the EEPROM in an Silabs CP210x
+	</shortdesc>
+
+    <bug-database rdf:resource="http://sourceforge.net/tracker/?group_id=193093" />
+    <download-page rdf:resource="http://sourceforge.net/project/showfiles.php?group_id=193093" />
+
+	<description xml:lang="en">
+The goal of this library is to provide access to the EEPROM of an Silabs CP210x
+under Linux. 
+
+The CP210x is an USB-to-serial chip used in a lot of USB devices (similar to
+FTDIs and PL2303). The CP210x has a EEPROM on the chip which can be programmed
+via USB. Silabs provides already a library and gui programm to program this
+EEPROM, but only for windows. 
+
+For more information see:
+* http://www.silabs.com/tgwWebApp/public/web_content/products/Microcontrollers/Interface/en/interface.htm
+* http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/Interface/en/an144.pdf
+
+Requires:
+* libusb: http://libusb.sourceforge.net/
+* ctypes: http://starship.python.net/crew/theller/ctypes/
+	</description>
+
+<!--	<mailing-list rdf:resource="http://" /> -->
+
+	<maintainer>
+		<foaf:Person>
+			<foaf:name>Johannes Hölzl</foaf:name>
+			<foaf:homepage rdf:resource="http://hoelzl-bros.de/~johannes/" />
+		</foaf:Person>
+	</maintainer>
+
+    <repository>
+        <SVNRepository>
+            <location rdf:resource="http://cp210x-program.svn.sourceforge.net/" />
+        </SVNRepository>
+    </repository>
+
+	<license rdf:resource="http://usefulinc.com/doap/licenses/lgpl" />
+
+    <programming-language>
+        Python
+    </programming-language>
+    
+    <os>
+        Linux
+    </os>
+
+    <os>
+        FreeBSD
+    </os>
+
+    <os>
+        Mac OS X
+    </os>
+
+<!--    <bug-database rdf:resource="http://bugzilla.gnome.org/" /> -->
+
+	<release>
+		<Version>
+			<name>stable</name>
+			<created>2014-06-28</created>
+			<revision>1.0</revision>
+		</Version>
+	</release>
+	
+</Project>

+ 4 - 0
cp210x/__init__.py

@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+
+__author__ = "Johannes Hölzl <johannes.hoelzl@gmx.de>"
+__license__ = "GNU LGPL"

BIN
cp210x/__init__.pyc


+ 360 - 0
cp210x/cp210x.py

@@ -0,0 +1,360 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2007 Johannes Hölzl <johannes.hoelzl@gmx.de>
+#
+# This library is covered by the GNU LGPL, read LICENSE for details.
+"""Provides access to the EEPROM of Silabs CP210x devices
+
+The following class is available:
+
+class Cp210xProgrammer:
+    Provides direct access to the CP210x, can be used to write single data
+    directly or via an EEPROM image.
+"""
+
+import usb
+from usb.util import CTRL_IN, CTRL_OUT, CTRL_TYPE_VENDOR
+
+__all__ = ['Cp210xProgrammer', 'Cp210xError']
+
+CP210x_CONFIG       = 0xFF
+
+REG_VENDOR_ID       = 0x3701
+REG_PRODUCT_ID      = 0x3702
+REG_PRODUCT_STRING  = 0x3703
+REG_SERIAL_NUMBER   = 0x3704
+REG_CFG_ATTRIBUTES  = 0x3705
+REG_MAX_POWER       = 0x3706
+REG_VERSION         = 0x3707
+REG_UNKNOWN         = 0x3708
+REG_EEPROM          = 0x3709
+REG_LOCK_VALUE      = 0x370A
+REG_PART_NUMBER     = 0x370B
+
+SIZE_EEPROM         = 0x0400
+SIZE_PRODUCT_STRING = 255
+SIZE_SERIAL_NUMBER  = 128
+SIZE_BAUDRATES      = 32
+SIZE_BAUDRATE_CFG   = 10
+SIZE_BAUDRATE_TABLE = SIZE_BAUDRATES * SIZE_BAUDRATE_CFG
+SIZE_VENDOR_STRING  = 50
+
+# Buffer size limits
+# (see AN721: CP210x/CP211x Device Customization Guide)
+CP210x_MAX_PRODUCT_STRLEN = (SIZE_PRODUCT_STRING - 2) // 2
+CP210x_MAX_SERIAL_STRLEN  = (SIZE_SERIAL_NUMBER - 2) // 2
+
+LCK_LOCKED          = 0xF0
+LCK_UNLOCKED        = 0xFF
+
+VID_SILABS          = 0x10C4
+PID_CP210x          = 0xEA60
+
+VALUES = [
+    ('product_string', 'string'),
+    ('serial_number',  'string'),
+    ('vendor_id',      'id'),
+    ('product_id',     'id'),
+    ('version',        'version'),
+    ('bus_powered',    'boolean'),
+    ('max_power',      'int'),
+    ('locked',         'boolean'),
+    ('part_number',    'int'),
+    ('vendor_string',  'string'),
+    ('baudrate_table', 'list'),
+]
+
+def to_div2(p):
+    value = int(p / 2)
+    if (value * 2) < p:
+        value += 1
+    return value
+    
+def to_bcd(i):
+    assert i >= 0 and i <= 99
+    return (i // 10) << 4 | (i % 10)
+
+def to_bcd2( (i, j) ):
+    return to_bcd(i) << 8 | to_bcd(j)
+
+def from_bcd(num):
+    return num & 0x0F + (num >> 4) * 10
+
+def from_bcd2(data):
+    return (from_bcd(data >> 8), from_bcd(data & 0xFF))
+
+def from_binary(data, le=True):
+    value = 0
+    if le:
+        data = data[::-1]
+    for byte in data:
+        value = value << 8 | ord(byte)
+    return value
+
+def to_binary(value, size=2, le=True):
+    data = ''
+    for i in range(size):
+        data += chr(value & 0xFF)
+        value >>= 8
+    if le:
+        return data
+    else:
+        return data[::-1]
+    
+def parse_baudrate_cfg(data):
+    return (from_binary(data[0:2], le=False), 
+            from_binary(data[2:4], le=False), 
+            from_binary(data[4:5]),
+            from_binary(data[6:10]))
+
+def build_baudrate_cfg(baudgen, timer0reload, prescaler, baudrate):
+    return (to_binary(baudgen, le=False) + to_binary(timer0reload, le=False) + 
+            to_binary(prescaler, 1) + '\x00' + to_binary(baudrate, 4))
+
+class Cp210xError(IOError):
+    pass
+
+class DeviceLocked(Cp210xError):
+    pass
+
+class Cp210xMatch(object):
+    def __init__(self, patterns):
+        self.patterns = patterns
+
+    def __call__(self, dev):
+        for pattern in self.patterns:
+            for name, value in pattern.items():
+                if getattr(dev, name) != value:
+                    return False
+            return True
+        return False
+
+class Cp210xProgrammer(object):
+    """Program a Silabs CP2101, CP2102 or CP2103
+    
+    This module provides access to Silabs CP210x devices to set some USB
+    descriptor fields and some USB descriptor strings. 
+
+    The following fields can be set:
+
+     * Vendor ID
+     * Product ID
+     * Product String
+     * Serial Number
+     * Device Version
+     * Bus Powered
+     * max. Power consumption
+ 
+    Either use PyUSB to find a device, and pass the usb.Device object
+    to the constructor, or use Cp210xProgrammer.list_device() to list all
+    devices matching certain pattern.
+    """
+    
+    TIMEOUT = 300 #ms
+    
+    @classmethod
+    def list_devices(self, patterns=[{ 'idVendor': VID_SILABS, 
+                                       'idProduct': PID_CP210x }]):
+        """Yields a list of devices matching certain patterns.
+        
+        param patterns: This must be a list of dictionaries. Each device
+            in the usb tree is matched against all patterns in the list. 
+            
+            All fields of the descriptors are compared with the corresponding
+            values in the dictionary. A device matches the pattern only if all
+            values match.
+        
+        For example:
+
+        >> list(Cp210xProgrammer.list_device([{ 'idVendor': VID_SILABS, 
+                                           'idProduct': PID_CP210x }]))
+        [device(...)]
+        
+        """
+        
+        return usb.core.find(find_all=True,
+                             custom_match=Cp210xMatch(patterns))
+
+    def __init__(self, usbdev):
+        self.usbdev = usbdev
+        self._locked = None
+        try:
+            self.has_kernel_driver = usbdev.is_kernel_driver_active(0)
+        except NotImplementedError:
+            self.has_kernel_driver = False
+        if self.has_kernel_driver:
+            cfg = usbdev.get_active_configuration()
+            self.intf = cfg[(0,0)].bInterfaceNumber
+            usbdev.detach_kernel_driver(self.intf)
+        usbdev.set_configuration()
+        
+    def reset(self):
+        """Force the USB stack to reset the device.
+        
+        Resets the device through an hard reset over the port to which the
+        device is connected. After that happend the EEPROM content in the device
+        is reread and the device's descriptors are the one written to it.
+        """
+        self.usbdev.reset()
+    
+    def __del__(self):
+        if self.has_kernel_driver:
+            self.usbdev.attach_kernel_driver(self.intf)
+
+    def _set_config(self, value, index=0, data=None, request=CP210x_CONFIG):
+        if self.get_locked():
+            raise DeviceLocked()
+            
+        res = self.usbdev.ctrl_transfer(CTRL_OUT | CTRL_TYPE_VENDOR,
+                                        request, value, index, data)
+        if data is not None and res != len(data):
+            raise Cp210xError("Short write (%d of %d bytes)"
+                              % (res, len(data)))
+
+    def _set_config_string(self, value, content, max_desc_size):
+        assert isinstance(content, basestring)
+        encoded = content.encode('utf-16-le')
+        desc_size = len(encoded) + 2
+        assert desc_size <= max_desc_size
+        self._set_config(value, data=chr(desc_size) + "\x03" + encoded)
+
+    def _get_config(self, value, length, index=0, request=CP210x_CONFIG):
+        res = self.usbdev.ctrl_transfer(CTRL_IN | CTRL_TYPE_VENDOR,
+                                        request, value, index, length)
+        return res.tostring()
+
+    def _get_int8_config(self, value, index=0, request=CP210x_CONFIG):
+        return ord(self._get_config(value, 1, index=index, request=request))
+
+    def _get_int16_config(self, value, index=0, request=CP210x_CONFIG):
+        data = self._get_config(value, 2, index=index, request=request)
+        return ord(data[0]) << 8 | ord(data[1])
+    
+    def get_eeprom_content(self):
+        """Get the entire EEPROM content as one big 1024-byte blob.
+        """
+        return self._get_config(REG_EEPROM, SIZE_EEPROM)
+    
+    def get_baudrate_content(self):
+        """Get the baudrate table as binary data.
+        """
+        return self._get_config(REG_EEPROM, SIZE_BAUDRATE_TABLE)
+
+    def get_baudrate_table(self):
+        """Get the baudrate table.
+        
+        A list containing 4-tuples is returned.
+        Each tuple contains the following data:
+        
+         * BaudGen: Value used to generate the baudrate.
+         * Time0Reset: Value used to generate the usb timeout.
+         * Prescaler: Used to down-scale the baudrate.
+         * Baudrate: The baudrate which activates this entry.
+        """
+        data = self.get_baudrate_content()
+        return [parse_baudrate_cfg(data[pos:pos+SIZE_BAUDRATE_CFG])
+                for pos in range(0, SIZE_BAUDRATE_TABLE, SIZE_BAUDRATE_CFG)]
+        
+    def set_baudrate_table(self, baudrates):
+        """Write the baudrate table.
+        
+        See get_baudrate_table() for the structure of the table.
+        """
+        assert len(baudrates) == SIZE_BAUDRATES
+        self.set_baudrate_content(data=''.join(build_baudrate_cfg(*cfg) 
+                                               for cfg in baudrates))
+    baudrate_table = property(get_baudrate_table, set_baudrate_table)
+        
+    def get_part_number(self):
+        """Get the part number of the device.
+        
+        Returns: 1 for a CP2101
+                 2 for a CP2102
+                 3 for a CP2103
+        """
+        return self._get_int8_config(REG_PART_NUMBER)
+    
+    def get_locked(self):
+        """Read the lock value of the device.
+        
+        When True is returnes no data can be written to the device.
+        """
+        if self._locked is None:
+            self._locked = self._get_int8_config(REG_LOCK_VALUE) == LCK_LOCKED
+        return self._locked
+    
+    def set_eeprom_content(self, content):
+        """Write a 1024-byte blob to the EEPROM
+        """
+        assert len(content) == SIZE_EEPROM, ("EEPROM data must be %i bytes."
+                                             % SIZE_EEPROM)
+        assert isinstance(content, str), "EEPROM data must be string."
+        self._set_config(REG_EEPROM, data=content)
+    
+    def set_product_id(self, pid):
+        """Set the Product ID
+        """
+        assert pid > 0x0000 and pid < 0xFFFF
+        self._set_config(REG_PRODUCT_ID, pid)
+        
+    def set_vendor_id(self, vid):
+        """Set the Vendor ID
+        """
+        assert vid > 0x0000 and vid < 0xFFFF
+        self._set_config(REG_VENDOR_ID, vid)
+    
+    def set_product_string(self, product_string):
+        """Set the product string.
+        
+        The string will be encoded with UTF-16 and must not exceed
+        CP210x_MAX_PRODUCT_STRLEN.
+        For Unicode Plane 0 (BMP; code points 0-FFFF), this specifies
+        the maximum length of the string in characters.
+        """
+        self._set_config_string(REG_PRODUCT_STRING, product_string, 
+                                SIZE_PRODUCT_STRING)
+    
+    def set_serial_number(self, serial_number):
+        """Set the serial number string.
+        
+        The string will be encoded with UTF-16 and must not exceed
+        CP210x_MAX_SERIAL_STRLEN.
+        For Unicode Plane 0 (BMP; code points 0-FFFF), this specifies
+        the maximum length of the string in characters.
+        """
+        self._set_config_string(REG_SERIAL_NUMBER, serial_number, 
+                                SIZE_SERIAL_NUMBER)
+    
+    def set_max_power(self, max_power):
+        """Set maximum power consumption.
+        """
+        assert max_power >= 0 and max_power <= 500
+        self._set_config(REG_MAX_POWER, to_div2(max_power))
+    
+    def set_bus_powered(self, bus_powered):
+        """Set the bus-powered flag in the device descriptor.
+        """
+        if bus_powered:
+            self._set_config(REG_CFG_ATTRIBUTES, 0xC0)
+        else:
+            self._set_config(REG_CFG_ATTRIBUTES, 0x80)
+
+    def set_version(self, version):
+        """Set the device version .
+        """
+        self._set_config(REG_VERSION, to_bcd2(version))
+
+    def set_locked(self, locked):
+        """Set the lock value of the device.
+        
+        When True is returned no data can be written to the device.
+        """
+        if locked:
+            self._set_config(REG_LOCK_VALUE, LCK_LOCKED)
+        else:
+            self._set_config(REG_LOCK_VALUE, LCK_UNLOCKED)
+
+    def set_values(self, values):
+        for name, value in values.items():
+            if name not in ['part_number', 'vendor_string']:
+                getattr(self, "set_" + name) (value)
+            

BIN
cp210x/cp210x.pyc


+ 190 - 0
cp210x/eeprom.py

@@ -0,0 +1,190 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2007 Johannes Hölzl <johannes.hoelzl@gmx.de>
+#
+# This library is covered by the GNU LGPL, read LICENSE for details.
+"""Provides logical view of the EEPROM of Silabs CP210x devices
+
+The following class is available:
+
+class EEPROM:
+    Can be used to read or write a hex file containing the EEPROM content
+    of a CP210x. Also provides access to single fields in the EEPROM.
+"""
+
+import cp210x
+from cp210x import from_binary, to_binary, VALUES
+
+__all__ = ['EEPROM', 'HexFileError']
+
+POS_BAUDRATE_TABLE  = 0x0000
+POS_PART_NUMBER     = 0x01FF
+POS_STRING_DESC_0   = 0x0200
+POS_PRODUCT_STRING  = 0x0208
+POS_SERIAL_NUMBER   = 0x0307
+POS_VENDOR_ID       = 0x0390
+POS_PRODUCT_ID      = 0x0392
+POS_VERSION         = 0x0394
+POS_CFG_ATTRIBUTES  = 0x03A1
+POS_MAX_POWER       = 0x03A2
+POS_VENDOR_STRING   = 0x03C3
+POS_LOCK_VALUE      = 0x03FF
+
+class HexFileError(StandardError):
+    pass
+
+def checksum(line):
+    return sum(ord(c) for c in line) & 0xFF
+
+def _int_value(position, size, read=lambda x:x, write=lambda x:x):
+    def get(self):
+        return read(from_binary(self.get(position, size)))
+    def set(self, value):
+        self.set(position, to_binary(write(value), size))
+    return property(get, set)
+    
+def _str_value(position, max_desc_size):
+    def get(self):
+        desc_size = from_binary(self.get(position, 1))
+        assert desc_size <= max_desc_size and desc_size >= 2, "desc_size: %d, max: %d" % (desc_size, max_desc_size)
+        assert self.get(position + 1, 1) == '\x03', "Missing 0x03 at %04X" % (position + 1)
+        return self.get(position + 2, desc_size - 2).decode('utf-16-le')
+        
+    def set(self, value):
+        encoded = value.encode('utf-16-le')
+        desc_size = len(encoded) + 2
+        assert desc_size <= max_desc_size
+        self.set(position, chr(desc_size) + '\x03' + encoded)
+        
+    return property(get, set)
+
+class EEPROM(object):
+    START_ADDRESS = 0x3600
+    def __init__(self, content=None):
+        if isinstance(content, str) or content is None:
+            assert content is None or len(content) == cp210x.SIZE_EEPROM
+            self.content = content
+        elif isinstance(content, cp210x.Cp210xProgrammer):
+            self.content = content.get_eeprom_content()
+        else:
+            self.parse_hex_file(content.read())
+
+    def write_to_cp210x(self, cp210xDevice):
+        cp210xDevice.set_eeprom_content(self.content)
+            
+    def parse_hex_file(self, hex_content):
+        self.content = ''
+        address = self.START_ADDRESS
+        for tag in hex_content.split('\n'):
+            if not tag.startswith(':'):
+                raise HexFileError("Line doesn't start with ':'")
+            
+            try:
+                content = tag[1:].decode('hex')
+            except TypeError:
+                raise HexFileError("Hex data expected")
+            
+            if len(content) < 5:
+                raise HexFileError("Line too short")
+
+            if checksum(content) != 0:
+                raise HexFileError("Checksum error")
+        
+            size = from_binary(content[0])
+            tag_address = from_binary(content[1:3], le=False)
+            tag_type = from_binary(content[3:4])
+            line = content[4:-1]
+            
+            if tag_type == 0x00:
+                if tag_address != address:
+                    raise HexFileError("Expected address %04X but found %04X"
+                                       % (address, tag_address))
+                self.content += line
+                address += len(line)
+            elif tag_type == 0x01:
+                if size != 0 or len(line) != 0:
+                    raise HexFileError("Defect end tag")
+                break
+                
+            else:
+                raise HexFileError("Unknown tag type %02X" % tag_type)
+
+    def build_hex_file(self):
+        for tag_start in range(0, len(self.content), 0x10):
+            line = self.content[tag_start:tag_start+0x10]
+            address = self.START_ADDRESS + tag_start
+            tag = (to_binary(len(line), 1) + 
+                   to_binary(address, le=False) + 
+                   '\x00' + 
+                   line)
+            cs = checksum(tag)
+            if cs == 0:
+                tag += '\x00'
+            else:
+                tag += chr(0x100 - cs)
+            yield ":%s\n" % tag.encode('hex')
+        yield ":00000001FF\n"
+
+    def write_hex_file(self, f):
+        if isinstance(f, str):
+            f = file(f, 'wb')
+            do_close = True
+        else:
+            do_close = False
+        for line in self.build_hex_file():
+            f.write(line)
+        if do_close:
+            f.close()
+
+    def read_hex_file(self, f):
+        if isinstance(f, str):
+            f = file(f, 'rb')
+            do_close = True
+        else:
+            do_close = False
+        self.parse_hex_file(f.read())
+        if do_close:
+            f.close()
+
+    def get(self, pos, length):
+        return self.content[pos:pos+length]
+    
+    def set(self, pos, data):
+        self.content = (self.content[:pos] + 
+                        data + 
+                        self.content[pos + len(data):])
+   
+    def _get_baudrate_table(self):
+        dat = self.get(POS_BAUDRATE_TABLE, cp210x.SIZE_BAUDRATE_TABLE)
+        return [cp210x.parse_baudrate_cfg(dat[pos:pos+cp210x.SIZE_BAUDRATE_CFG])
+                for pos in range(0, cp210x.SIZE_BAUDRATE_TABLE, 
+                                 cp210x.SIZE_BAUDRATE_CFG)]
+    def _set_baudrate_table(self, baudrates):
+        assert len(baudrates) == cp210x.SIZE_BAUDRATES
+        self.set(POS_BAUDRATE_TABLE, 
+                 ''.join(cp210x.build_baudrate_cfg(*cfg) for cfg in baudrates))
+    baudrate_table = property(_get_baudrate_table, _set_baudrate_table)
+    product_string = _str_value(POS_PRODUCT_STRING, cp210x.SIZE_PRODUCT_STRING)
+    serial_number = _str_value(POS_SERIAL_NUMBER, cp210x.SIZE_SERIAL_NUMBER)
+    part_number = _int_value(POS_PART_NUMBER, 1)
+    vendor_id = _int_value(POS_VENDOR_ID, 2)
+    product_id = _int_value(POS_PRODUCT_ID, 2)
+    version = _int_value(POS_VERSION, 2, 
+                         cp210x.from_bcd2, cp210x.to_bcd2)
+    bus_powered = _int_value(POS_CFG_ATTRIBUTES, 1, 
+                             lambda a: bool(a & 0x40), 
+                             lambda a: 0xC0 if a else 0x80)
+    max_power = _int_value(POS_MAX_POWER, 1, lambda p: p*2, cp210x.to_div2)
+    vendor_string = _str_value(POS_VENDOR_STRING, cp210x.SIZE_VENDOR_STRING)
+    locked = _int_value(POS_LOCK_VALUE, 1, 
+                        lambda l: l == cp210x.LCK_LOCKED, 
+                        lambda b: cp210x.LCK_LOCKED if b
+                                  else cp210x.LCK_UNLOCKED)
+        
+    def get_values(self):
+        return dict((name, getattr(self, name)) for name, type in VALUES)
+
+    def set_values(self, values):
+        for name, value in values.items():
+            setattr(self, name, value)
+
+            

BIN
cp210x/eeprom.pyc


+ 234 - 0
cp210x/valuefile.py

@@ -0,0 +1,234 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2007 Johannes Hölzl <johannes.hoelzl@gmx.de>
+#
+# This library is covered by the GNU LGPL, read LICENSE for details.
+
+# For documentation of the baudrate table see:
+#
+# [AN205] Silicon Labs Application Note 205 Rev. 0.3
+# http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/Interface/en/an205.pdf
+
+import re
+from ConfigParser import ConfigParser
+
+import cp210x
+from cp210x import VALUES, SIZE_BAUDRATES
+
+__all__ = ['read_file', 'write_file', 'update_values', 'PrescalerIsZero',
+           'ValuesFileError']
+
+class ValuesError(StandardError):
+    pass
+
+class PrescalerIsZero(ValuesError):
+    pass
+
+class ValuesFileError(ValuesError):
+    pass
+
+version_pattern = re.compile(r'^\s*(\d\d?)\.(\d\d?)\s*$')
+def read_version(s):
+    match = version_pattern.match(s)
+    if match is None:
+        raise ValueError("Version does not match 'xx.yy'")
+    return (int(match.group(1)), int(match.group(2)))
+def write_version(v):
+    return "%d.%02d" % v
+
+def read_hex(s):
+    return int(s.strip(), 16)
+
+def write_hex(num):
+    return "%04X" % num
+
+def write_bool(b):
+    if b:
+        return 'yes'
+    else:
+        return 'no'
+
+def read_bool(s):
+    s = s.strip().lower()
+    if s not in ['true', 'yes', 'false', 'no']:
+        raise ValueError("Boolean must be either 'true', 'yes', 'false' or 'no'.")
+    return s in ['true', 'yes']
+
+def read_baudrate_info(s):
+    values = s.split(',')
+    if len(values) != 3:
+         raise ValueError("Baudrate info must be three comma-separated items")
+    try:
+        baudgen = read_hex(values[0])
+    except ValueError:
+        raise ValueError("The first baudrate info must be a hex-value")
+    try:
+        timer0 = read_hex(values[1])
+    except ValueError:
+        raise ValueError("The second baudrate info must be a hex-value")
+    try:
+        prescale = int(values[2])
+    except ValueError:
+        raise ValueError("The thirdbaudrate info must be a number")
+    return (baudgen, timer0, prescale)
+
+TYPES = {
+    'boolean':  (read_bool, write_bool),
+    'int':      (int, str),
+    'id':       (read_hex, write_hex),
+    'string':   (str, str),
+    'version':  (read_version, write_version),
+}
+
+def read_file(fp):
+    cp = ConfigParser()
+    if isinstance(fp, str):
+        cp.read([fp])
+    else:
+        cp.readfp(fp)
+    
+    values = {}
+    
+    for name, type in VALUES:
+        if name is 'baudrate_table':
+            continue
+        reader, _ = TYPES[type]
+        if cp.has_option('usb device', name):
+            try:
+                values[name] = reader(cp.get('usb device', name))
+            except ValueError, err:
+                raise ValuesFileError("Key '%s': %s" % (name, str(err)))
+    
+    if cp.has_section('baudrate table'):
+        baudrate_table = []
+        for name, value in cp.items('baudrate table'):
+            try:
+                baudrate = int(name)
+            except ValueError:
+                raise ValuesFileError("Key names in 'baudrate table' must be"
+                                      " baudrate numbers.")
+            try:
+                baudrate_table.append(read_baudrate_info(value) + (baudrate, ))
+            except ValueError, err:
+                raise ValuesFileError("Wrong baudrate info %i: %s"
+                                      % (baudrate, str(err)))
+        baudrate_table.sort(key=(lambda i: i[3]), reverse=True)
+        
+        values['baudrate_table'] = baudrate_table
+    return values
+
+def write_file(fp, values):
+    fp.write("[usb device]\n")
+    
+    for name, type in VALUES:
+        if name == 'baudrate_table':
+            continue
+        _, writer = TYPES[type]
+        if name in values:
+            fp.write("%s = %s\n" % (name, writer(values[name])))
+
+    if 'baudrate_table' in values:
+        fp.write("\n")
+        fp.write("[baudrate table]\n")
+        for (baudgen, timegen, prescaler, 
+             baudrate) in sorted(values['baudrate_table'], key=(lambda i: i[3]),
+                                 reverse=True):
+            fp.write("%7d = %04X, %04X, %d # %s\n"
+                     % (baudrate, baudgen, timegen, prescaler,
+                        show_baudrate(baudgen, timegen, prescaler)))
+
+def calc_baudrate(baudgen, timegen, prescaler):
+    # This formulas are from AN205 page 5.
+    if prescaler == 0:
+        raise PrescalerIsZero("Prescaler is 0")
+    baudrate = (24000000. / prescaler) / (0x10000 - baudgen)
+    return (baudrate, (0x10000 - timegen) * 2)
+
+def show_baudrate(baudgen, timegen, prescaler):
+    try:
+        baudrate, timeout = calc_baudrate(baudgen, timegen, prescaler)
+    except PrescalerIsZero:
+        return "Wrong data, Prescaler is 0."
+    if timeout >= 1000:
+        timeout = "%1.3f ms" % (float(timeout) / 1000)
+    else:
+        timeout = "%d us" % timeout
+    if baudrate is None:
+        return ", %s" % (baudrate, timeout)
+    else:
+        return "%7.0f Baud, %s" % (baudrate, timeout)
+
+def update_values(v, new, dev):
+    old_baudrate_table = v.get('baudrate_table')
+    new_baudrate_table = new.get('baudrate_table')
+    
+    v.update(new)
+
+    # update baudrate table
+    # it is needed, that the baudrate table has 32 entries when it is written
+    # to the eeprom or device.
+    if ((old_baudrate_table is not None or new_baudrate_table is not None) and
+        (new_baudrate_table is None or 
+         len(new_baudrate_table) < SIZE_BAUDRATES)):
+         
+        if old_baudrate_table is not None:
+            if len(old_baudrate_table) < SIZE_BAUDRATES:
+                baudrate_table = old_baudrate_table
+            else:
+                baudrate_table = list(merge_baudrate_table(dev.baudrate_table, 
+                                                           old_baudrate_table))
+        else:
+            baudrate_table = dev.baudrate_table
+                                                               
+        if new_baudrate_table:
+            baudrate_table = list(merge_baudrate_table(baudrate_table, 
+                                                       new_baudrate_table))        
+        v['baudrate_table'] = baudrate_table
+    
+            
+            
+def merge_baudrate_table(old, new):
+    for (old_info, (start, stop)) in zip(old, REQUEST_BAUDRATE_RANGES):
+        for baudgen, timer, prescaler, baudrate in new:
+            if ((start is None or baudrate <= start) and 
+                baudrate >= stop):
+                yield (baudgen, timer, prescaler, baudrate)
+                break
+        else:
+            yield old_info
+            
+REQUEST_BAUDRATE_RANGES = [
+# The table data is from AN205 Table 1 on page 1.
+#     Start     End       Default Baudrate
+    (None,    2457601), #  Undefined
+    (2457600, 1474561), #  Undefined
+    (1474560, 1053258), #  Undefined
+    (1053257,  670255), #  921600
+    ( 670254,  567139), #  576000
+    ( 567138,  491521), #  500000
+    ( 491520,  273067), #  460800
+    ( 273066,  254235), #  256000
+    ( 254234,  237833), #  250000
+    ( 237832,  156869), #  230400
+    ( 156868,  129348), #  153600
+    ( 129347,  117029), #  128000
+    ( 117028,   77609), #  115200
+    (  77608,   64112), #   76800
+    (  64111,   58054), #   64000
+    (  58053,   56281), #   57600
+    (  56280,   51559), #   56000
+    (  51558,   38602), #   51200
+    (  38601,   28913), #   38400
+    (  28912,   19251), #   28800
+    (  19250,   16063), #   19200
+    (  16062,   14429), #   16000
+    (  14428,    9613), #   14400
+    (   9612,    7208), #    9600
+    (   7207,    4804), #    7200
+    (   4803,    4001), #    4800
+    (   4000,    2401), #    4000
+    (   2400,    1801), #    2400
+    (   1800,    1201), #    1800
+    (   1200,     601), #    1200
+    (    600,     301), #     600
+    (    300,      57), #     300
+]

BIN
cp210x/valuefile.pyc


+ 9 - 0
doc/45-cp210x-programming.rules

@@ -0,0 +1,9 @@
+# udev rules file for CP210x device to be programmable py
+# cp210x-program
+
+SUBSYSTEM!="usb_device", GOTO="cp210x-programming_rules_end"
+
+SYSFS{idVendor}=="10C4", SYSFS{idProduct}=="EA60", MODE="0660", GROUP="plugdev"
+SYSFS{idVendor}=="10C4", SYSFS{idProduct}=="EA61", MODE="0660", GROUP="plugdev"
+
+LABEL="cp210x-programming_rules_end"

+ 110 - 0
doc/cp210x.txt

@@ -0,0 +1,110 @@
+
+
+COMMAND: 0xFF (ACCESS EEPROM)
+INDEX  SIZE            VALUE           
+0x3701 2               VENDOR ID       
+0x3702 2               PRODUCT ID      
+0x3703 -               PRODUCT STRING 
+0x3704 -               SERIAL NUMBER  
+0x3705                 ?               ? (bmAttribute?)
+0x3706 1               MAX POWER (2mA) -
+0x3707 2               BCD DEV VERSION -
+0x3708                 ?               ?
+0x3709 1024            EEPROM DUMP
+0x370A 1               LOCK VALUE          
+0x370B 1               PART NUMBER
+
+COMMAND: 0x0F UNKNOWN
+
+HEXFILE:
+
+0x3600: 320 Bytes BAUD CONFIG
+0x37FF: 1 Byte PART NUMBER
+0x3800: 4 Bytes String Descriptor Zero
+0x3808: 255 Bytes PRODUCT STRING (incl length and language)
+0x3907: 128 Bytes SERIAL NUMBER (incl length and language)
+0x3987: 1 Byte ???
+0x3988: 18 Byte DEVICE DESCRIPTOR
+0x399A: 32 Byte CONFIG DESCRIPTOR
+0x39C3: ? Byte VENDOR STRING
+0x39FF: 1 Byte LOCK VALUE
+
+1201100100000040ad139999020001020301
+
+02
+1201100100000040AD139999326401020301
+
+090220000101008096
+0904000002FF000002
+07058102400000
+07050102400000
+000000000000000000
+1A03530069006C00690063006F006E0020004C00610062007300000000
+00000000000000000000000000000000
+000000000000000000000000000000FF
+
+:10360000FFF0FFFA010060E31600FFF0FFFA01008F
+:1036100060E31600FFECFFF80100804F1200FFE4AA
+:10362000FF40010050F80C00FFD6FF40010000CA27
+:103630000800FFD0FFEE010020A10700FFCCFFEC47
+:10364000010000080700FFA2FFDC010000E8030002
+:10365000FFA0FFDC010090D00300FF98FFD901001C
+:1036600000840300FF64FFC5010000580200FF440E
+:10367000FFB9010000F40100FF2CFF40010000C26F
+:103680000100FEC8FF8B0100002C0100FE89FF73C2
+:10369000010000FA0000FE5FFF63010000E100008E
+:1036A000FE53FF5F0100C0DA0000FE2BFF50010057
+:1036B00000C80000FD8FFF15010000960000FCBF50
+:1036C000FEC7010080700000FB1EFE2B0100004BB6
+:1036D0000000FA24FE0C0100803E0000F97DFE0C83
+:1036E000010040380000F63CFE0C0100802500007F
+:1036F000F2FBFE0C0100201C0000EC78FE0C010027
+:10370000C0120000E890FE0C0100A00F0000D8F0ED
+:10371000FE0C010060090000CBEBFE0C0100080765
+:103720000000B1E0FE0C0100B004000063C0FE0C1C
+:10373000010058020000B1E0FE0C04002C01000062
+:103740000000000000000000000000000000000079
+:103750000000000000000000000000000000000069
+:103760000000000000000000000000000000000059
+:103770000000000000000000000000000000000049
+:103780000000000000000000000000000000000039
+:103790000000000000000000000000000000000029
+:1037A0000000000000000000000000000000000019
+:1037B0000000000000000000000000000000000009
+:1037C00000000000000000000000000000000000F9
+:1037D00000000000000000000000000000000000E9
+:1037E00000000000000000000000000000000000D9
+:1037F00000000000000000000000000000000002C7
+:1038000004030904000000002203500052004F008E
+:10381000440055004300540020005300540052005F
+:1038200049004E0047002100210065007200200081
+:1038300042007200690064006700650020004300D8
+:103840006F006E00740072006F006C006C00650009
+:1038500072000000000000000000000000000000F6
+:103860000000000000000000000000000000000058
+:103870000000000000000000000000000000000048
+:103880000000000000000000000000000000000038
+:103890000000000000000000000000000000000028
+:1038A0000000000000000000000000000000000018
+:1038B0000000000000000000000000000000000008
+:1038C00000000000000000000000000000000000F8
+:1038D00000000000000000000000000000000000E8
+:1038E00000000000000000000000000000000000D8
+:1038F00000000000000000000000000000000000C8
+:1039000000000000000000120331003100300030E0
+:1039100000300033003200380000000000000000DA
+:103920000000000000000000000000000000000097
+:103930000000000000000000000000000000000087
+:103940000000000000000000000000000000000077
+:103950000000000000000000000000000000000067
+:103960000000000000000000000000000000000057
+:103970000000000000000000000000000000000047
+:1039800000000000000000021201100100000040D1
+:10399000AD1399993264010203010902200001016B
+:1039A0000080960904000002FF0000020705810262
+:1039B0004000000705010240000000000000000078
+:1039C0000000001A03530069006C00690063006F77
+:1039D000006E0020004C00610062007300000000D7
+:1039E00000000000000000000000000000000000D7
+:1039F000000000000000000000000000000000FFC8
+:00000001FF

+ 28 - 0
instruction.md

@@ -0,0 +1,28 @@
+Install pyUSB library:
+cd pyusb
+sudo python2 setup.py install
+
+Okay, now to the real thing: create a backup of the EEPROM:
+sudo ./cp210x-program -f eeprom.hex
+
+The next step is to program the modified, non-standard baudrates:
+sudo ./cp210x-program -p -F eeprom.hex -w --set-baudrate 812500:FFE2,FFF4,1 --set-baudrate 406250:FFC5,FFE9,1 --set-baudrate 203125:FF8A,FFD3,1
+
+Check if the entries have been written successfully:
+sudo ./cp210x-program
+
+Show EEPROM content from device 002 on bus 001:
+cp210x-program --read-cp210x -m 001/002
+
+Write some data to device with vendor id 0x10C4 and product id 0xEA62:
+cp210x-program --write-cp210x -m 10C4:EA62 \
+                 --set-product-string="Product String" \
+                 --set-max-power=100 \
+                 --set-bus-powered=no
+
+From luke:
+./cp210x-program -w -F eeprom-content.Bitfountain.hex --set-product-string='Block Erupter Sapphire (Red)' --set-serial-number=ljr0001
+
+./cp210x-program -w -F eeprom-content.RBOX.hex --set-product-string='R-BOX miner' --set-serial-number=somethingunique
+
+

+ 16 - 0
pyusb/ACKNOWLEDGEMENTS

@@ -0,0 +1,16 @@
+This is a list of people who has contributed to PyUSB 1.0 development.
+If I forgot you, please email me.
+
+PyUSB 1.0.0 (alpha 0)
+---------------------
+
+- Thomas Reitmayr: thanks for your patches to get PyUSB running with libusb 1.0.
+- Carl Ritson: thanks for your patch to get minimal working of legacy layer.
+- Romain Aviolat: thanks for pointing out a mistake in the tutorial and to report a bug in ctrl_transfer.
+- Xiaofan Chen: thanks for your effort testing PyUSB with libusb 1.0 Windows backend and on FreeBSD.
+
+PyUSB 1.0.0 (alpha 1)
+---------------------
+
+- Xiaofan Chen: for support in mailing list.
+- Poul-Henning Kam: for the documentation patches.

+ 700 - 0
pyusb/ChangeLog

@@ -0,0 +1,700 @@
+2010-12-29 17:22  wander_lairson
+
+	* docs/tutorial.txt: Tutorial update.
+
+2010-12-29 17:11  wander_lairson
+
+	* usb/util.py: Documentation update.
+
+2010-12-24 22:08  wander_lairson
+
+	* usb/legacy.py: Finish implementation of 0.4 API emulation.
+
+2010-12-24 21:53  wander_lairson
+
+	* tests/test_control.py, usb/util.py: Implemented util.get_string
+	  function.
+
+2010-12-24 20:57  wander_lairson
+
+	* README, ReleaseNotes.txt, TODO: Documentation update.
+
+2010-12-24 20:29  wander_lairson
+
+	* tests/test_control.py, tests/test_integration.py, usb/control.py:
+	  Implemented standard control requests.
+
+2010-12-17 13:30  wander_lairson
+
+	* usb/core.py: Removed get_interface_altsetting function from
+	  Device interface.
+
+2010-12-15 18:18  wander_lairson
+
+	* usb/core.py, usb/legacy.py: Fixed some pychecker warnings.
+
+2010-12-15 17:43  wander_lairson
+
+	* tests/test_backend.py, tests/test_integration.py, tests/utils.py,
+	  usb/_debug.py, usb/backend/libusb01.py, usb/backend/libusb10.py,
+	  usb/backend/openusb.py, usb/core.py: Fixed pyflakes warnings.
+
+2010-12-14 21:55  wander_lairson
+
+	* tests/test_integration.py, usb/backend/__init__.py,
+	  usb/backend/libusb01.py, usb/backend/libusb10.py,
+	  usb/backend/openusb.py, usb/core.py: Implemented get_cofiguration
+	  on backends. Now Device issue a get_configuration request when a
+	  configuration is not set.
+
+2010-12-14 17:39  wander_lairson
+
+	* docs/tutorial.txt: Update documentation with minimum Python
+	  version info.
+
+2010-12-14 17:32  wander_lairson
+
+	* README, setup.py: Dropped Python 2.3 support.
+
+2010-12-14 17:26  wander_lairson
+
+	* LICENSE, setup.py, tests/devinfo.py, tests/test_backend.py,
+	  tests/test_find.py, tests/test_integration.py,
+	  tests/test_util.py, tests/testall.py, tests/utils.py,
+	  usb/__init__.py, usb/_debug.py, usb/_interop.py,
+	  usb/backend/__init__.py, usb/backend/libusb01.py,
+	  usb/backend/libusb10.py, usb/backend/openusb.py, usb/core.py,
+	  usb/legacy.py, usb/util.py: Update year copyright information.
+
+2010-12-14 17:12  wander_lairson
+
+	* tests/test_backend.py, tests/test_integration.py,
+	  tests/test_util.py, tests/utils.py: Fixed to not fail the tests
+	  when the test device is not connected.
+
+2010-12-12 04:27  wander_lairson
+
+	* tests/test_backend.py, tests/test_integration.py, tests/utils.py,
+	  usb/_interop.py, usb/backend/libusb01.py,
+	  usb/backend/libusb10.py, usb/core.py: Fixed python3 support.
+
+2010-12-09 18:30  wander_lairson
+
+	* usb/core.py: Minor code refactoring.
+
+2010-09-06 16:20  wander_lairson
+
+	* ACKNOWLEDGEMENTS, README, tests/test_util.py, usb/core.py: Fixed
+	  docs. Stronger checking of find_descriptor.
+
+2010-07-30 23:13  wander_lairson
+
+	* docs/tutorial.txt, usb/backend/libusb01.py,
+	  usb/backend/openusb.py, usb/util.py: Docs update. RequestType bit
+	  field now can optionally be ORed with constants in util module.
+	  Fixed libusb01 backend to find the library in Ubuntu. Fixed
+	  openusb backend (thanks to Cris Wolf)
+
+2010-07-30 22:41  wander_lairson
+
+	* tests/pic18f4550/Microchip Solutions/IMPORTANT README.txt,
+	  tests/pic18f4550/Microchip Solutions/Microchip,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/Benchmark.c,
+	  tests/test_backend.py, tests/test_integration.py: Removed reset
+	  call from regression tests because of portability reasons.
+	  Removed from sources the Microchip USB stack. Changed test
+	  firmware to reset control buffer upon a set_configuration.
+
+2010-07-16 02:43  wander_lairson
+
+	* tests/test_backend.py, tests/test_integration.py, tests/utils.py,
+	  usb/core.py: Fixed bug in the reset() method. Test hardware
+	  detection changed to use supplied backend.
+
+2010-07-10 22:27  wander_lairson
+
+	* tests/arm_str9, tests/pic18f4550, tests/pic18f4550/Microchip
+	  Solutions, tests/pic18f4550/Microchip Solutions/IMPORTANT
+	  README.txt, tests/pic18f4550/Microchip Solutions/Microchip,
+	  tests/pic18f4550/Microchip Solutions/Microchip/Include,
+	  tests/pic18f4550/Microchip
+	  Solutions/Microchip/Include/Compiler.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/Microchip/Include/GenericTypeDefs.h,
+	  tests/pic18f4550/Microchip Solutions/Microchip/Include/USB,
+	  tests/pic18f4550/Microchip Solutions/Microchip/Include/USB/usb.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/Microchip/Include/USB/usb_ch9.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/Microchip/Include/USB/usb_common.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/Microchip/Include/USB/usb_device.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/Microchip/Include/USB/usb_function_generic.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/Microchip/Include/USB/usb_hal.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/Microchip/Include/USB/usb_hal_pic18.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/Microchip/Include/USB/usb_hal_pic24.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/Microchip/Include/USB/usb_hal_pic32.h,
+	  tests/pic18f4550/Microchip Solutions/Microchip/USB,
+	  tests/pic18f4550/Microchip Solutions/Microchip/USB/Generic Device
+	  Driver, tests/pic18f4550/Microchip
+	  Solutions/Microchip/USB/Generic Device
+	  Driver/usb_function_generic.c, tests/pic18f4550/Microchip
+	  Solutions/Microchip/USB/usb_device.c, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/BDT_transfer.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/Benchmark.c,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/Benchmark.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/CleanUp.bat,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/HardwareProfile - Low Pin Count
+	  USB Development Kit.h, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/HardwareProfile - PIC18F46J50
+	  PIM.h, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/HardwareProfile - PIC18F87J50
+	  PIM.h, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/HardwareProfile - PIC24F Starter
+	  Kit.h, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/HardwareProfile - PIC24FJ256GB110
+	  PIM.h, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/HardwareProfile - PIC24FJ64GB002
+	  BreadBoard.h, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/HardwareProfile - PIC24FJ64GB004
+	  PIM.h, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/HardwareProfile - PIC32 USB
+	  Starter Kit.h, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/HardwareProfile - PIC32MX460F512L
+	  PIM.h, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/HardwareProfile - PICDEM FSUSB.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/HardwareProfile.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/Objects,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/Objects/USB Device - WinUSB -
+	  High Bandwidth - C32, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PIC24 HID Bootloader Remapping.s,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PicFWCommands.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C18_LowPinCountDevKit.mcp,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C18_LowPinCountDevKit.mcw,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C18_P18F46J50_PIM.mcp,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C18_P18F46J50_PIM.mcw,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C18_P18F87J50_PIM.mcp,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C18_P18F87J50_PIM.mcw,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C18_PICDEM_FSUSB.mcp,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C18_PICDEM_FSUSB.mcs,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C18_PICDEM_FSUSB.mcw,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C30.mcp,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C30.mcw,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C32_P32MX460F512L_PIM.mcp,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C32_P32MX460F512L_PIM.mcw,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C32_StarterKit.mcp,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C32_StarterKit.mcs,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/PyUSB_C32_StarterKit.mcw,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/main.c,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/p24FJ256GB110 - HID
+	  Bootloader.gld, tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/procdefs.ld.boot,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio/CompilerSettings.txt,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio/PyUSB.C18.FSUSB.lkr,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio/PyUSB.C18.FSUSB.sln,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio/PyUSB.C18.FSUSB.vcproj,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio/PyUSB.C30.sln,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio/PyUSB.C30.vcproj,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio/Utility,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio/Utility/MplabMake.exe,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio/Utility/RegexClean.exe,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio/_vcDummy.cpp,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio/clean.cmd,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/projects/VStudio/p24FJ64GB002.gld,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/rm18f14k50.lkr,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/rm18f4550 - HID Bootload.lkr,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/rm18f4550 - MCHPUSB Bootload.lkr,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/rm18f46j50_g.lkr,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/rm18f87j50.lkr,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/superClean.bat,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/usb_config.h,
+	  tests/pic18f4550/Microchip
+	  Solutions/TestFirmware/Firmware/usb_descriptors.c,
+	  tests/pic18f4550/README, tests/test_backend.py,
+	  tests/test_integration.py: New test firmware based on the
+	  libusbdotnet benchmark firmware. Thank you Travis for allow me
+	  use your code.
+
+2010-07-10 22:22  wander_lairson
+
+	* tests/pic18f4550: Removed old PIC test firmware.
+
+2010-04-16 14:52  wander_lairson
+
+	* ReleaseNotes.txt: * Minor fix in the ReleaseNotes file
+
+2010-04-16 14:47  wander_lairson
+
+	* ACKNOWLEDGEMENTS, MANIFEST.in, README, ReleaseNotes.txt, TODO,
+	  setup.py: * Minor docs changes
+
+2010-04-13 19:59  wander_lairson
+
+	* tests/test_backend.py, tests/test_find.py,
+	  tests/test_integration.py, tests/test_util.py, tests/testall.py,
+	  tests/utils.py, usb/__init__.py, usb/_debug.py, usb/_interop.py,
+	  usb/backend/libusb01.py, usb/backend/libusb10.py,
+	  usb/backend/openusb.py, usb/core.py: * Included trace of backend
+	  calls.
+	  * Test cases now can be runned individually.
+
+2010-04-12 14:28  wander_lairson
+
+	* usb/backend/libusb01.py, usb/backend/libusb10.py: * cygwin
+	  compatibility issues fixed
+
+2010-04-07 23:12  wander_lairson
+
+	* tests/testall.py: * Changed testall script to only add usb
+	  package to python path when we are at pyusb source tree
+
+2010-04-06 14:08  wander_lairson
+
+	* usb/backend/libusb01.py, usb/backend/libusb10.py: * Cygwin
+	  support
+
+2010-04-06 14:02  wander_lairson
+
+	* TODO, docs/tutorial.txt: * Docs update
+
+2010-04-05 21:45  wander_lairson
+
+	* tests/test_backend.py, tests/test_integration.py, tests/utils.py,
+	  usb/__init__.py, usb/_interop.py, usb/backend/libusb01.py,
+	  usb/backend/libusb10.py, usb/backend/openusb.py, usb/core.py: *
+	  Refactored _interop module
+	  * Added logging support facility
+
+2010-04-05 13:45  wander_lairson
+
+	* ACKNOWLEDGEMENTS, usb/backend/libusb01.py,
+	  usb/backend/libusb10.py: * Implemented support for FreeBSD in the
+	  libusb 1.0 backend. Thanks to Xiaofan Chen.
+	  * Implemented partial support for libusb 1.0 Windows backend.
+	  Thanks to Xiaofan Chen.
+
+2010-02-11 06:51  wander_lairson
+
+	* docs/tutorial.txt: Fixed spelling errors in the tutorial.
+
+2010-02-10 06:57  wander_lairson
+
+	* usb/core.py: Fixed some minor spelling errors.
+
+2010-02-10 05:46  wander_lairson
+
+	* usb/_interop.py, usb/legacy.py: Fixed several Python 2.3
+	  compatibility issues in the legacy module.
+
+2010-02-06 07:09  wander_lairson
+
+	* TODO, usb/core.py: * TODO list updated.
+	  * Fixed import in the find function.
+
+2010-02-06 05:38  wander_lairson
+
+	* LICENSE: License update
+
+2010-02-06 05:35  wander_lairson
+
+	* tests/devinfo.py, tests/test_backend.py, tests/test_find.py,
+	  tests/test_integration.py, tests/test_util.py, tests/testall.py,
+	  tests/utils.py, usb/_interop.py: Updated license information for
+	  test scripts.
+
+2010-02-06 04:41  wander_lairson
+
+	* docs/tutorial.txt: Fixed Python version information in the
+	  tutorial.
+
+2010-02-05 10:30  wander_lairson
+
+	* README, TODO, usb/__init__.py, usb/core.py, usb/legacy.py,
+	  usb/util.py: Damn it! 10 secs after commiting the code and
+	  dropping Python 2.3 and 2.4, I got an idea about how to solve the
+	  imports problem without the drop... Back with 2.3 and 2.4
+	  versions again...
+
+2010-02-05 10:08  wander_lairson
+
+	* LICENSE, README, TODO, docs/tutorial.txt, setup.py,
+	  tests/utils.py, usb/__init__.py, usb/_interop.py,
+	  usb/backend/__init__.py, usb/backend/libusb01.py,
+	  usb/backend/libusb10.py, usb/backend/openusb.py, usb/core.py,
+	  usb/legacy.py, usb/util.py: * [1.0] License update.
+	  * [1.0] Dropped support for Python version < 2.5.
+	  * [1.0] Fixed problems to work for Python 2 and Python 3.
+
+2010-02-04 00:29  wander_lairson
+
+	* ACKNOWLEDGEMENTS, LICENSE, MANIFEST.in, README, TODO, setup.py,
+	  usb/backend/libusb01.py: * [1.0] Added README, LICENSE, TODO and
+	  ACKNOWLEDGEMENTS files.
+	  * [1.0] Version update.
+	  * [0.1] Applied patch to make getString returning a Python string
+	  when langid != -1. By Tormod Volden.
+
+2010-02-03 08:14  wander_lairson
+
+	* usb/backend/libusb01.py: * Fixed issue #2945033.
+
+2010-02-02 00:18  wander_lairson
+
+	* docs/tutorial.txt, usb/core.py: * Fixed ctrl_transfer issue when
+	  we don't have a payload buffer.
+	  * Fixed tutorial example spelling...
+
+2009-12-22 17:05  wander_lairson
+
+	* usb/legacy.py: * Applied patch 2905610.
+
+2009-10-15 12:46  wander_lairson
+
+	* docs/tutorial.txt: * Tutorial update.
+
+2009-10-09 20:13  wander_lairson
+
+	* docs/tutorial.rst, docs/tutorial.txt: * Tutorial update.
+
+2009-09-24 19:48  wander_lairson
+
+	* docs/tutorial.rst, usb/backend/libusb10.py, usb/core.py: * Better
+	  error description for libusb 1.0 backend.
+	  * Implemented get_interface_altsetting method.
+	  * Tutorial update.
+
+2009-09-24 14:14  wander_lairson
+
+	* tests/utils.py, usb/_interop.py, usb/core.py: * Fixes for Python
+	  2.3 interoperability
+
+2009-09-24 13:08  wander_lairson
+
+	* tests/test_backend.py, tests/test_integration.py, tests/utils.py,
+	  usb/_interop.py, usb/backend/__init__.py,
+	  usb/backend/libusb01.py, usb/backend/libusb10.py,
+	  usb/backend/openusb.py, usb/core.py, usb/util.py: * Python 3
+	  compatibility fixes
+	  * Minor improvements
+	  * Code cleanup
+
+2009-09-23 18:37  wander_lairson
+
+	* docs/tutorial.rst: * Tutorial update.
+
+2009-09-21 19:38  wander_lairson
+
+	* docs/tutorial, docs/tutorial.rst: * Minor docs and messages
+	  improvements.
+	  * Tutorial update.
+
+2009-09-19 00:23  wander_lairson
+
+	* tests/test_integration.py, tests/testall.py,
+	  usb/backend/libusb01.py, usb/backend/libusb10.py,
+	  usb/backend/openusb.py, usb/core.py, usb/util.py: * Fixed issue
+	  #2860940. Thanks to Nicholas Wheeler.
+	  * Implementation of the get_active_configuration() method
+	  * Lots of other bug fixes
+
+2009-09-17 20:28  wander_lairson
+
+	* docs/tutorial, docs/tutorial/tutorial.rst: * PyUSB 1.0 tutorial
+	  (incomplete).
+
+2009-09-14 19:48  wander_lairson
+
+	* docs, setup.py, tests/test_util.py, usb/__init__.py, usb/core.py,
+	  usb/legacy.py, usb/util.py: * Update version for 0.x branch.
+	  * Included information for mailing in the 0.x branch.
+	  * Included tests for find_descriptor and build_request_type
+	  functions.
+	  * Bug fixes.
+	  * Update legacy module.
+
+2009-09-11 19:53  wander_lairson
+
+	* tests/backendtest.py, tests/fakebackend.py,
+	  tests/fakebackendtest.py, tests/inttest.py, tests/test.py,
+	  tests/test_backend.py, tests/test_find.py,
+	  tests/test_integration.py, tests/test_util.py, tests/testall.py,
+	  tests/utiltest.py, usb/core.py, usb/util.py: * Code refactoring
+
+2009-09-04 20:25  wander_lairson
+
+	* usb/util.py: * Changed name of the function from
+	  release_resources to dispose_resources
+
+2009-09-04 20:12  wander_lairson
+
+	* tests/backend_test.py, tests/backendtest.py, tests/core_test.py,
+	  tests/device_info.py, tests/devinfo.py, tests/fakebackend.py,
+	  tests/fakebackendtest.py, tests/inttest.py, tests/test.py,
+	  tests/util_test.py, tests/utils.py, tests/utiltest.py,
+	  usb/backend/__init__.py, usb/core.py, usb/util.py: * Refactoring
+	  of core module
+	  * Refactoring of tests
+	  * Initial implementation of a fake backend for tests
+	  * New functions in util module
+	  * IBackend exported in usb.backend
+
+2009-09-03 19:33  wander_lairson
+
+	* tests/backend_test.py, tests/core_test.py,
+	  usb/backend/__init__.py, usb/backend/libusb01.py,
+	  usb/backend/libusb10.py, usb/backend/openusb.py, usb/core.py: *
+	  Documentation improvement.
+	  * Automatic predefined backend selection in usb.core.find
+	  function.
+	  * Predefined backends return None in get_backend function when
+	  the underline library is not available.
+	  * Tests include backends testing only when they are available.
+
+2009-09-03 00:43  wander_lairson
+
+	* tests/backend_test.py, tests/core_test.py,
+	  usb/backend/libusb01.py, usb/backend/libusb10.py,
+	  usb/backend/openusb.py: * Fixes to work under Windows
+
+2009-09-02 14:41  wander_lairson
+
+	* usb/backend/__init__.py, usb/backend/libusb01.py,
+	  usb/backend/libusb10.py, usb/backend/openusb.py, usb/core.py,
+	  usb/legacy.py, usb/util.py: * Documentation improvement
+
+2009-09-02 01:15  wander_lairson
+
+	* tests/backend_test.py, tests/core_test.py, tests/utils.py,
+	  usb/backend/libusb01.py, usb/core.py: * Bug fixes
+
+2009-09-01 20:03  wander_lairson
+
+	* usb/backend/__init__.py: * Backend documentation improvement.
+
+2009-08-28 10:55  wander_lairson
+
+	* usb/backend/__init__.py: * Documentation improvement
+
+2009-08-25 19:56  wander_lairson
+
+	* tests/backend_test.py, tests/core_test.py, usb/core.py,
+	  usb/util.py: * Code refactoring
+	  * Documentation improved
+	  * Added default_timeout property to Device class
+	  * Changed policy to determine default configuration and interface
+	  values for
+	  the methods of the Device class (see Device documentation).
+	  * Included new function in the util module to build the
+	  bmRequetType field of the control requests.
+
+2009-08-25 11:40  wander_lairson
+
+	* tests/backend_test.py, tests/core_test.py, tests/utils.py: *
+	  Refactoring of tests
+	  * Write more tests for core
+
+2009-08-24 23:36  wander_lairson
+
+	* tests/core_test.py, usb/core.py: * Fix some issues in the core
+	  test module
+
+2009-08-24 19:50  wander_lairson
+
+	* tests/backend_test.py, tests/core_test.py, tests/test.py,
+	  tests/util_test.py: * Draft core test cases
+
+2009-08-24 14:06  wander_lairson
+
+	* tests/backend_test.py: * Some syntax tweaks in the backend_test
+	  module
+
+2009-08-24 12:29  wander_lairson
+
+	* tests/backend_test.py, tests/test.py, tests/util_test.py: *
+	  Included util test case
+
+2009-08-22 21:01  wander_lairson
+
+	* tests/backend_test.py, tests/device_info.py, tests/test.py,
+	  usb/backend/libusb01.py, usb/backend/libusb10.py,
+	  usb/backend/openusb.py, usb/core.py: * Included backend test case
+	  (v1.0)
+	  * Backend instance now is get through get_backend() function
+	  (v1.0)
+	  * Fixed some issues in libusb01 backend (v1.0)
+	  * Added support to compilation to macports (v0.4). Thanks to
+	  rossetti.
+
+2009-08-18 23:18  wander_lairson
+
+	* usb/backend/libusb01.py, usb/backend/libusb10.py,
+	  usb/backend/openusb.py: * Fix: buffer type convertions in the
+	  backends. Thanks to Thomas Reitmayr to point out this problem.
+
+2009-08-17 23:32  wander_lairson
+
+	* usb/backend/libusb10.py, usb/core.py, usb/util.py: * Patch
+	  '2837638' applied.
+	  * Patch '2837639' applied.
+	  * Patch '2837642' applied.
+	  * Patch '2837643' applied.
+	  * Patch '2837646' applied.
+	  * Patch '2837648' applied.
+	  * Patch '2837650' applied.
+	  * Patch '2837651' applied.
+	  * Patch '2837652' applied.
+	  * Patch '2837653' applied.
+	  * Patch '2837654' applied.
+
+2009-08-05 23:00  wander_lairson
+
+	* usb/backend/libusb10.py: * Fixed bug 2832279
+	  * Fixed bug 2832277
+	  * Fixed bug 2832276
+
+2009-07-27 12:58  wander_lairson
+
+	* usb/core.py: * Fixed some minor issues in usb.core.find()
+
+2009-07-27 11:15  wander_lairson
+
+	* usb/backend/libusb10.py, usb/core.py: * Applied patch 2827110
+	  * Applied patch 2827111
+
+2009-06-12 16:56  wander_lairson
+
+	* tests/pic18f4550, tests/pic18f4550/18f87j50.lkr,
+	  tests/pic18f4550/CleanUp.bat, tests/pic18f4550/MCHPUSB.mcp,
+	  tests/pic18f4550/MCHPUSB.mcs, tests/pic18f4550/MCHPUSB.mcw,
+	  tests/pic18f4550/MCHPUSB.mptags, tests/pic18f4550/MCHPUSB.tagsrc,
+	  tests/pic18f4550/_output, tests/pic18f4550/autofiles,
+	  tests/pic18f4550/autofiles/usbcfg.h,
+	  tests/pic18f4550/autofiles/usbdsc.c,
+	  tests/pic18f4550/autofiles/usbdsc.h, tests/pic18f4550/io_cfg.h,
+	  tests/pic18f4550/main.c, tests/pic18f4550/rm18f4550.lkr,
+	  tests/pic18f4550/system, tests/pic18f4550/system/interrupt,
+	  tests/pic18f4550/system/interrupt/interrupt.c,
+	  tests/pic18f4550/system/interrupt/interrupt.h,
+	  tests/pic18f4550/system/typedefs.h, tests/pic18f4550/system/usb,
+	  tests/pic18f4550/system/usb/_output,
+	  tests/pic18f4550/system/usb/class,
+	  tests/pic18f4550/system/usb/class/pyusb,
+	  tests/pic18f4550/system/usb/class/pyusb/pyusb.c,
+	  tests/pic18f4550/system/usb/class/pyusb/pyusb.h,
+	  tests/pic18f4550/system/usb/usb.h,
+	  tests/pic18f4550/system/usb/usb9,
+	  tests/pic18f4550/system/usb/usb9/usb9.c,
+	  tests/pic18f4550/system/usb/usb9/usb9.h,
+	  tests/pic18f4550/system/usb/usb_compile_time_validation.h,
+	  tests/pic18f4550/system/usb/usbctrltrf,
+	  tests/pic18f4550/system/usb/usbctrltrf/usbctrltrf.c,
+	  tests/pic18f4550/system/usb/usbctrltrf/usbctrltrf.h,
+	  tests/pic18f4550/system/usb/usbdefs,
+	  tests/pic18f4550/system/usb/usbdefs/usbdefs_ep0_buff.h,
+	  tests/pic18f4550/system/usb/usbdefs/usbdefs_std_dsc.h,
+	  tests/pic18f4550/system/usb/usbdrv,
+	  tests/pic18f4550/system/usb/usbdrv/usbdrv.c,
+	  tests/pic18f4550/system/usb/usbdrv/usbdrv.h,
+	  tests/pic18f4550/system/usb/usbmmap.c,
+	  tests/pic18f4550/system/usb/usbmmap.h: * PIC 184550 Test FW
+	  complete.
+	  * 0.x regression tests scripts complete.
+
+2009-05-08 10:35  wander_lairson
+
+	* usb/backend/__init__.py, usb/backend/libusb01.py,
+	  usb/backend/libusb10.py, usb/backend/openusb.py, usb/core.py,
+	  usb/legacy.py, usb/util.py: * Separated write and read endpoint
+	  methods
+	  * Transfer type in automatic inferred in the Device object
+	  * Documentation for util module
+	  * libusb backend modules refactored
+	  * Initial openusb implementation
+
+2009-05-05 11:50  wander_lairson
+
+	* usb/backend/libusb10.py: * Initial implementation of libusb 1.0
+	  backend
+
+2009-04-30 10:49  wander_lairson
+
+	* usb, usb/__init__.py, usb/backend, usb/backend/__init__.py,
+	  usb/backend/libusb01.py, usb/core.py, usb/legacy.py, usb/util.py:
+	  * Initial PyUSB 1.0 implementation
+
+2009-04-29 23:17  wander_lairson
+
+	* src, tests/arm_str9, tests/fw: * Moved 0.x version from cvs to
+	  svn
+	  * ARM Test FW folder renamed
+
+2008-04-16 22:50  wander_lairson
+
+	* ., src, tests, tests/fw, tests/fw/LST, tests/fw/OBJ,
+	  tests/fw/PyUSB_TestFw.Opt, tests/fw/PyUSB_TestFw.Uv2,
+	  tests/fw/src, tests/fw/src/91x_it.c, tests/fw/src/STR91x.s,
+	  tests/fw/src/main.c, tests/fw/src/ring_buffer.c,
+	  tests/fw/src/ring_buffer.h, tests/fw/src/startup_gcc.s,
+	  tests/fw/src/usb_conf.h, tests/fw/src/usb_desc.c,
+	  tests/fw/src/usb_desc.h, tests/fw/src/usb_endp.c,
+	  tests/fw/src/usb_istr.c, tests/fw/src/usb_prop.c,
+	  tests/fw/src/usb_prop.h, tests/fw/src/usb_pwr.c,
+	  tests/fw/src/usb_pwr.h, tests/fw/src/util.c, tests/fw/src/util.h:
+

+ 27 - 0
pyusb/LICENSE

@@ -0,0 +1,27 @@
+Copyright (C) 2009-2011 Wander Lairson Costa. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+

+ 15 - 0
pyusb/PKG-INFO

@@ -0,0 +1,15 @@
+Metadata-Version: 1.0
+Name: pyusb
+Version: 1.0.0-a1
+Summary: Python USB access module
+Home-page: http://pyusb.sourceforge.net
+Author: Wander Lairson Costa
+Author-email: wander.lairson@gmail.com
+License: BSD
+Description: 
+        PyUSB offers easy USB devices communication in Python.
+        It should work without additional code in any environment with
+        Python >= 2.4, ctypes and an pre-built usb backend library
+        (currently, libusb 0.1.x, libusb 1.x, and OpenUSB).
+        
+Platform: UNKNOWN

+ 78 - 0
pyusb/README

@@ -0,0 +1,78 @@
+=======================================
+PyUSB 1.0 - Easy USB access from Python
+=======================================
+
+Introduction
+============
+
+The PyUSB module provides Python with easy access to the host
+machine's Universal Serial Bus (USB) system.
+
+Until 0.4 version, PyUSB used to be a thin wrapper aroung libusb.
+With 1.0 version, things changed considerably. Now PyUSB is an
+API rich, backend neutral Python USB module easy to use.
+
+As with most Python modules, PyUSB's documentation is based on Python
+doc strings and can therefore be manipulated by tools such as pydoc.
+
+You can also find a tutorial at: http://pyusb.sourceforge.net/docs/1.0/tutorial.html.
+
+PyUSB is being developed and tested in Linux and Windows, but it should work
+fine in any platform running Python >= 2.4, ctypes and at least one of the
+builtin backends.
+
+PyUSB supports libusb 0.1, libusb 1.0 and OpenUSB, but the user does not need
+to worry about that, unless in some corner cases.
+
+If you have any question about PyUSB, you can use the PyUSB mailing list
+hosted in the SourceForge. In the PyUSB website (http://pyusb.sourceforge.net)
+you can find instructions on how to subscribe to the mailing list.
+
+Installing PyUSB on GNU/Linux Systems
+=====================================
+
+These instructions are for Debian-based systems.  Instructions for
+other flavors of GNU/Linux should be similar.  
+
+You will first need to install the following packages:
+
+1) python (PyUSB is useless without it), version >= 2.4
+2) At least one of the supported libraries (libusb 1.0, libusb 0.1 or OpenUSB)
+3) If your Python version is < 2.5, you have to install ctypes as a separate package,
+   because these versions of Python does not ship it.
+
+For example, the command
+
+sudo apt-get install python libusb
+
+should install all these packages on most Debian-based systems with
+access to the proper package repositories.
+
+Once the above packages are installed, you can install PyUSB
+with the command
+
+python setup.py install
+
+run as root from within the same directory as this README file.
+
+Installing PyUSB on Windows
+===========================
+
+Now that PyUSB is 100% written in Python, you install it on Windows
+in the same way you do on Linux:
+
+python setup.py install
+
+Remember that you need libusb (1.0 or 0.1) or OpenUSB running on your
+system. For Windows users, libusb 1.0 is still experimental, so it is
+recommended libusb-win32 package. Check the libusb website for updates
+(http://www.libusb.org).
+
+Reporting bugs/Submitting patches
+=================================
+
+Some people have been sending me patches and reporting bugs directly
+in my email. Please, do it through SourceForge tracker, I had
+a hardtime tracking their names to put them in the acknowledgments file. ;-)
+
+PS: this README file was based on the great Josh Lifton's one... ^_^

+ 20 - 0
pyusb/TODO

@@ -0,0 +1,20 @@
+1.0.0-a0:
+    * Implement standard control requests API.
+    * Finish implementation of legacy compatibility layer.
+    * Determine automatically current configuration when user hasn't set it.
+    * Validate it on platforms other than Windows and Linux.
+    * Finish implementation and test of OpenUSB backend.
+    * Validate it on Python 2.3 and Python 3.x.
+    * Samples.
+    * Improve documentation.
+    * Implement isochronous transfers.
+    * Upgrade PIC test firmware to use 2.6a version Microchip USB stack.
+    * Test, test and test.
+
+1.0.0-a1:
+    * Validate it on platforms other than Windows and Linux.
+    * Finish implementation and test OpenUSB backend.
+    * Samples.
+    * Improve documentation.
+    * Implement isochronous transfers.
+    * Test, test and test.

+ 85 - 0
pyusb/build/lib.linux-armv6l-2.7/usb/__init__.py

@@ -0,0 +1,85 @@
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+r"""PyUSB - Easy USB access in Python
+
+This package exports the following modules and subpackages:
+
+    core - the main USB implementation
+    legacy - the compatibility layer with 0.x version
+    backend - the support for backend implementations.
+
+Since version 1.0, main PyUSB implementation lives in the 'usb.core'
+module. New applications are encouraged to use it.
+"""
+
+import logging
+import os
+
+__author__ = 'Wander Lairson Costa'
+
+__all__ = ['legacy', 'core', 'backend', 'util']
+
+
+def _setup_log():
+    logger = logging.getLogger('usb')
+    debug_level = os.getenv('PYUSB_DEBUG_LEVEL')
+
+    if debug_level is not None:
+        filename = os.getenv('PYUSB_LOG_FILENAME')
+
+        LEVELS = {'debug': logging.DEBUG,
+                  'info': logging.INFO,
+                  'warning': logging.WARNING,
+                  'error': logging.ERROR,
+                  'critical': logging.CRITICAL}
+
+        level = LEVELS.get(debug_level, logging.CRITICAL + 10)
+        logger.setLevel(level = level)
+
+        try:
+            handler = logging.FileHandler(filename)
+        except:
+            handler = logging.StreamHandler()
+
+        fmt = logging.Formatter('%(asctime)s %(levelname)s:%(name)s:%(message)s')
+        handler.setFormatter(fmt)
+        logger.addHandler(handler)
+    else:
+        class NullHandler(logging.Handler):
+            def emit(self, record):
+                pass
+
+        logger.addHandler(NullHandler())
+
+
+_setup_log()
+
+# We import all 'legacy' module symbols to provide compatility
+# with applications that use 0.x versions.
+from usb.legacy import *

+ 67 - 0
pyusb/build/lib.linux-armv6l-2.7/usb/_debug.py

@@ -0,0 +1,67 @@
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+__author__ = 'Wander Lairson Costa'
+
+__all__ = ['methodtrace', 'functiontrace']
+
+import logging
+import usb._interop as _interop
+
+def _trace_function_call(logger, fname, *args, **named_args):
+    logger.debug(
+                # TODO: check if 'f' is a method or a free function
+                fname + '(' + \
+                ', '.join((str(val) for val in args)) + \
+                ', '.join((name + '=' + str(val) for name, val in named_args.items())) + ')'
+            )
+
+# decorator for methods calls tracing
+def methodtrace(logger):
+    def decorator_logging(f):
+        def do_trace(*args, **named_args):
+            # this if is just a optimization to avoid unecessary string formatting
+            if logging.DEBUG >= logger.getEffectiveLevel():
+                fn = type(args[0]).__name__ + '.' + f.__name__
+                _trace_function_call(logger, fn, *args[1:], **named_args)
+            return f(*args, **named_args)
+        _interop._update_wrapper(do_trace, f)
+        return do_trace
+    return decorator_logging
+
+# decorator for methods calls tracing
+def functiontrace(logger):
+    def decorator_logging(f):
+        def do_trace(*args, **named_args):
+            # this if is just a optimization to avoid unecessary string formatting
+            if logging.DEBUG >= logger.getEffectiveLevel():
+                _trace_function_call(logger, f.__name__, *args, **named_args)
+            return f(*args, **named_args)
+        _interop._update_wrapper(do_trace, f)
+        return do_trace
+    return decorator_logging

+ 135 - 0
pyusb/build/lib.linux-armv6l-2.7/usb/_interop.py

@@ -0,0 +1,135 @@
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+# All the hacks necessary to assure compatibility across all
+# supported versions come here.
+# Please, note that there is one version check for each
+# hack we need to do, this makes maintenance easier... ^^
+
+import sys
+import array
+
+__all__ = ['_reduce', '_set', '_next', '_groupby', '_sorted', '_update_wrapper']
+
+# we support Python >= 2.3
+assert sys.hexversion >= 0x020300f0
+
+# On Python 3, reduce became a functools module function
+try:
+    import functools
+    _reduce = functools.reduce
+except (ImportError, AttributeError):
+    _reduce = reduce
+
+# we only have the builtin set type since 2.5 version
+try:
+    _set = set
+except NameError:
+    import sets
+    _set = sets.Set
+
+# On Python >= 2.6, we have the builtin next() function
+# On Python 2.5 and before, we have to call the iterator method next()
+def _next(iter):
+    try:
+        return next(iter)
+    except NameError:
+        return iter.next()
+
+# groupby is available only since 2.4 version
+try:
+    import itertools
+    _groupby = itertools.groupby
+except (ImportError, AttributeError):
+    # stolen from Python docs
+    class _groupby(object):
+        # [k for k, g in groupby('AAAABBBCCDAABBB')] --> A B C D A B
+        # [list(g) for k, g in groupby('AAAABBBCCD')] --> AAAA BBB CC D
+        def __init__(self, iterable, key=None):
+            if key is None:
+                key = lambda x: x
+            self.keyfunc = key
+            self.it = iter(iterable)
+            self.tgtkey = self.currkey = self.currvalue = object()
+        def __iter__(self):
+            return self
+        def next(self):
+            while self.currkey == self.tgtkey:
+                self.currvalue = _next(self.it)    # Exit on StopIteration
+                self.currkey = self.keyfunc(self.currvalue)
+            self.tgtkey = self.currkey
+            return (self.currkey, self._grouper(self.tgtkey))
+        def _grouper(self, tgtkey):
+            while self.currkey == tgtkey:
+                yield self.currvalue
+                self.currvalue = _next(self.it)    # Exit on StopIteration
+                self.currkey = self.keyfunc(self.currvalue)
+
+# builtin sorted function is only availale since 2.4 version
+try:
+    _sorted = sorted
+except NameError:
+    def _sorted(l, key=None, reverse=False):
+        # sort function on Python 2.3 does not
+        # support 'key' parameter
+        class KeyToCmp(object):
+            def __init__(self, K):
+                self.key = K
+            def __call__(self, x, y):
+                kx = self.key(x)
+                ky = self.key(y)
+                if kx < ky:
+                    return reverse and 1 or -1
+                elif kx > ky:
+                    return reverse and -1 or 1
+                else:
+                    return 0
+        tmp = list(l)
+        tmp.sort(KeyToCmp(key))
+        return tmp
+
+try:
+    import functools
+    _update_wrapper = functools.update_wrapper
+except (ImportError, AttributeError):
+    def _update_wrapper(wrapper, wrapped):
+        wrapper.__name__ = wrapped.__name__
+        wrapper.__module__ = wrapped.__module__
+        wrapper.__doc__ = wrapped.__doc__
+        wrapper.__dict__ = wrapped.__dict__
+
+def as_array(data=None):
+    if data is None:
+        return array.array('B')
+    try:
+        return array.array('B', data)
+    except TypeError:
+        # When you pass a unicode string, you got a TypeError
+        # if first parameter is not 'u'
+        return array.array('u', data)
+

+ 368 - 0
pyusb/build/lib.linux-armv6l-2.7/usb/backend/__init__.py

@@ -0,0 +1,368 @@
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+r"""usb.backend - Backend interface.
+
+This module exports:
+
+IBackend - backend interface.
+
+Backends are Python objects which implement the IBackend interface.
+The easiest way to do so is inherinting from IBackend. 
+
+PyUSB already provides backends for libusb versions 0.1 and 1.0,
+and OpenUSB library. Backends modules included with PyUSB are required to
+export the get_backend() function, which returns an instance of a backend
+object. You can provide your own customized backend if you
+want to. Bellow you find a skeleton of a backend implementation module:
+
+import usb.backend
+
+class MyBackend(usb.backend.IBackend):
+    pass
+
+def get_backend():
+    return MyBackend()
+
+You can use your customized backend by passing it as the backend parameter of the
+usb.core.find() function. For example:
+
+import custom_backend
+import usb.core
+
+myidVendor = 0xfffe
+myidProduct = 0x0001
+
+mybackend = custom_backend.get_backend()
+
+dev = usb.core.find(backend = mybackend, idProduct=myidProduct,
+                    idVendor=myidVendor)
+
+For custom backends, you are not required to supply the get_backend() function,
+since the application code will instantiate the backend.
+
+If you do not provide a backend to the find() function, it will use one of the
+defaults backend according to its internal rules. For details, consult the
+find() function documentation.
+"""
+
+__author__ = 'Wander Lairson Costa'
+
+__all__ = ['IBackend', 'libusb01', 'libusb10', 'openusb']
+
+def _not_implemented(func):
+    raise NotImplementedError(func.__name__)
+
+class IBackend(object):
+    r"""Backend interface.
+
+    IBackend is the basic interface for backend implementations. By default,
+    the methods of the interface raise a NotImplementedError exception. A
+    backend implementation should replace the methods to provide the funcionality
+    necessary.
+
+    As Python is a dynamic typed language, you are not obligated to inherit from
+    IBackend: everything that bahaves like an IBackend is an IBackend. But you
+    are strongly recommended to do so, inheriting from IBackend provides consistent
+    default behavior.
+    """
+    def enumerate_devices(self):
+        r"""This function is required to return an iterable object which
+        yields an implementation defined device identification for each
+        USB device found in the system.
+
+        The device identification object is used as argument to other methods
+        of the interface.
+        """
+        _not_implemented(self.enumerate_devices)
+
+    def get_device_descriptor(self, dev):
+        r"""Return the device descriptor of the given device.
+
+        The object returned is required to have all the Device Descriptor
+        fields accessible as member variables. They must be convertible (but
+        not required to be equal) to the int type.
+
+        dev is an object yielded by the iterator returned by the enumerate_devices()
+        method.
+        """
+        _not_implemented(self.get_device_descriptor)
+
+    def get_configuration_descriptor(self, dev, config):
+        r"""Return a configuration descriptor of the given device.
+
+        The object returned is required to have all the Configuration Descriptor
+        fields acessible as member variables. They must be convertible (but
+        not required to be equal) to the int type.
+
+        The dev parameter is the already described device identification object.
+        config is the logical index of the configuration (not the bConfigurationValue
+        field).  By "logical index" we mean the relative order of the configurations
+        returned by the peripheral as a result of GET_DESCRIPTOR request.
+        """
+        _not_implemented(self.get_configuration_descriptor)
+
+    def get_interface_descriptor(self, dev, intf, alt, config):
+        r"""Return an interface descriptor of the given device.
+
+        The object returned is required to have all the Interface Descriptor
+        fields accessible as member variables. They must be convertible (but
+        not required to be equal) to the int type.
+
+        The dev parameter is the already described device identification object.
+        The intf parameter is the interface logical index (not the bInterfaceNumber field)
+        and alt is the alternate setting logical index (not the bAlternateSetting value).
+        Not every interface has more than one alternate setting.  In this case, the alt
+        parameter should be zero. config is the configuration logical index (not the
+        bConfigurationValue field).
+        """
+        _not_implemented(self.get_interface_descriptor)
+
+    def get_endpoint_descriptor(self, dev, ep, intf, alt, config):
+        r"""Return an endpoint descriptor of the given device.
+
+        The object returned is required to have all the Endpoint Descriptor
+        fields acessible as member variables. They must be convertible (but
+        not required to be equal) to the int type.
+
+        The ep parameter is the endpoint logical index (not the bEndpointAddress
+        field) of the endpoint descriptor desired. intf, alt and config are the same
+        values already described in the get_interface_descriptor() method.
+        """
+        _not_implemented(self.get_endpoint_descriptor)
+
+    def open_device(self, dev):
+        r"""Open the device for data exchange.
+
+        This method opens the device identified by the dev parameter for communication.
+        This method must be called before calling any communication related method, such
+        as transfer methods.
+        
+        It returns a handle identifying the communication instance. This handle must be
+        passed to the communication methods.
+        """
+        _not_implemented(self.open_device)
+
+    def close_device(self, dev_handle):
+        r"""Close the device handle.
+
+        This method closes the device communication channel and releases any
+        system resources related to it.
+        """
+        _not_implemented(self.close_device)
+
+    def set_configuration(self, dev_handle, config_value):
+        r"""Set the active device configuration.
+
+        This method should be called to set the active configuration
+        of the device. The dev_handle parameter is the value returned
+        by the open_device() method and the config_value parameter is the
+        bConfigurationValue field of the related configuration descriptor.
+        """
+        _not_implemented(self.set_configuration)
+
+    def get_configuration(self, dev_handle):
+        r"""Get the current active device configuration.
+
+        This method returns the bConfigurationValue of the currently
+        active configuration. Depending on the backend and the OS,
+        either a cached value may be returned or a control request may
+        be issued. The dev_handle parameter is the value returned by
+        the open_device method.
+        """
+        _not_implemented(self.get_configuration)
+
+    def set_interface_altsetting(self, dev_handle, intf, altsetting):
+        r"""Set the interface alternate setting.
+
+        This method should only be called when the interface has more than
+        one alternate setting. The dev_handle is the value returned by the
+        open_device() method. intf and altsetting are respectivelly the 
+        bInterfaceNumber and bAlternateSetting fields of the related interface.
+        """
+        _not_implemented(self.set_interface_altsetting)
+
+    def claim_interface(self, dev_handle, intf):
+        r"""Claim the given interface.
+
+        Interface claiming is not related to USB spec itself, but it is
+        generally an necessary call of the USB libraries. It requests exclusive
+        access to the interface on the system. This method must be called
+        before using one of the transfer methods.
+
+        dev_handle is the value returned by the open_device() method and
+        intf is the bInterfaceNumber field of the desired interface.
+        """
+        _not_implemented(self.claim_interface)
+
+    def release_interface(self, dev_handle, intf):
+        r"""Release the claimed interface.
+
+        dev_handle and intf are the same parameters of the claim_interface
+        method.
+        """
+        _not_implemented(self.release_interface)
+
+    def bulk_write(self, dev_handle, ep, intf, data, timeout):
+        r"""Perform a bulk write.
+
+        dev_handle is the value returned by the open_device() method.
+        The ep parameter is the bEndpointAddress field whose endpoint
+        the data will be sent to. intf is the bInterfaceNumber field
+        of the interface containing the endpoint. The data parameter
+        is the data to be sent. It must be an instance of the array.array
+        class. The timeout parameter specifies a time limit to the operation
+        in miliseconds.
+
+        The method returns the number of bytes written.
+        """
+        _not_implemented(self.bulk_write)
+
+    def bulk_read(self, dev_handle, ep, intf, size, timeout):
+        r"""Perform a bulk read.
+
+        dev_handle is the value returned by the open_device() method.
+        The ep parameter is the bEndpointAddress field whose endpoint
+        the data will be received from. intf is the bInterfaceNumber field
+        of the interface containing the endpoint. The size parameter
+        is the number of bytes to be read.  The timeout parameter specifies
+        a time limit to the operation in miliseconds.
+
+        The method returns an array.array object containing the data read.
+        """
+        _not_implemented(self.bulk_read)
+
+    def intr_write(self, dev_handle, ep, intf, data, timeout):
+        r"""Perform an interrupt write.
+
+        dev_handle is the value returned by the open_device() method.
+        The ep parameter is the bEndpointAddress field whose endpoint
+        the data will be sent to. intf is the bInterfaceNumber field
+        of the interface containing the endpoint. The data parameter
+        is the data to be sent. It must be an instance of the array.array
+        class. The timeout parameter specifies a time limit to the operation
+        in miliseconds.
+
+        The method returns the number of bytes written.
+        """
+        _not_implemented(self.intr_write)
+
+    def intr_read(self, dev_handle, ep, intf, size, timeout):
+        r"""Perform an interrut read.
+
+        dev_handle is the value returned by the open_device() method.
+        The ep parameter is the bEndpointAddress field whose endpoint
+        the data will be received from. intf is the bInterfaceNumber field
+        of the interface containing the endpoint. The size parameter
+        is the number of bytes to be read.  The timeout parameter specifies
+        a time limit to the operation in miliseconds.
+
+        The method returns an array.array object containing the data read.
+        """
+        _not_implemented(self.intr_read)
+
+    def iso_write(self, dev_handle, ep, intf, data, timeout):
+        r"""Perform an isochronous write.
+
+        dev_handle is the value returned by the open_device() method.
+        The ep parameter is the bEndpointAddress field whose endpoint
+        the data will be sent to. intf is the bInterfaceNumber field
+        of the interface containing the endpoint. The data parameter
+        is the data to be sent.It must be an instance of the array.array
+        class. The timeout parameter specifies a time limit to the operation
+        in miliseconds.
+
+        The method returns the number of bytes written.
+        """
+        _not_implemented(self.iso_write)
+
+    def iso_read(self, dev_handle, ep, intf, size, timeout):
+        r"""Perform an isochronous read.
+
+        dev_handle is the value returned by the open_device() method.
+        The ep parameter is the bEndpointAddress field whose endpoint
+        the data will be received from. intf is the bInterfaceNumber field
+        of the interface containing the endpoint. The size parameter
+        is the number of bytes to be read. The timeout parameter specifies
+        a time limit to the operation in miliseconds.
+
+        The method returns an array.array object containing the data read.
+        """
+        _not_implemented(self.iso_read)
+
+    def ctrl_transfer(self,
+                      dev_handle,
+                      bmRequestType,
+                      bRequest,
+                      wValue,
+                      wIndex,
+                      data_or_wLength,
+                      timeout):
+        r"""Perform a control transfer on the endpoint 0.
+
+        The direction of the transfer is inferred from the bmRequestType
+        field of the setup packet.
+
+        dev_handle is the value returned by the open_device() method.
+        bmRequestType, bRequest, wValue and wIndex are the same fields
+        of the setup packet. data_or_wLength is either the payload to be sent
+        to the device, if any, as an array.array object (None there is no
+        payload) for OUT requests in the data stage or the wLength field
+        specifying the number of bytes to read for IN requests in the data
+        stage. The timeout parameter specifies a time limit to the operation
+        in miliseconds.
+
+        Return the number of bytes written (for OUT transfers) or the data
+        read (for IN transfers), as an array.array object.
+        """
+        _not_implemented(self.ctrl_transfer)
+
+    def reset_device(self, dev_handle):
+        r"""Reset the device."""
+        _not_implemented(self.reset_device)
+
+    def is_kernel_driver_active(self, dev_handle, intf):
+        r"""Determine if a kernel driver is active on an interface.
+
+        If a kernel driver is active, you cannot claim the interface,
+        and the backend will be unable to perform I/O.
+        """
+        _not_implemented(self.is_kernel_driver_active)
+
+    def detach_kernel_driver(self, dev_handle, intf):
+        r"""Detach a kernel driver from an interface.
+        
+        If successful, you will then be able to claim the interface
+        and perform I/O.
+        """
+        _not_implemented(self.detach_kernel_driver)
+
+    def attach_kernel_driver(self, dev_handle, intf):
+        r"""Re-attach an interface's kernel driver, which was previously
+        detached using detach_kernel_driver()."""
+        _not_implemented(self.attach_kernel_driver)

+ 564 - 0
pyusb/build/lib.linux-armv6l-2.7/usb/backend/libusb01.py

@@ -0,0 +1,564 @@
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+from ctypes import *
+import ctypes.util
+import os
+import usb.backend
+import usb.util
+import sys
+from usb.core import USBError
+from usb._debug import methodtrace
+import usb._interop as _interop
+import logging
+
+__author__ = 'Wander Lairson Costa'
+
+__all__ = ['get_backend']
+
+_logger = logging.getLogger('usb.backend.libusb01')
+
+# usb.h
+
+_PC_PATH_MAX = 4
+
+if sys.platform != 'win32':
+    _PATH_MAX = os.pathconf('.', _PC_PATH_MAX)
+else:
+    _PATH_MAX = 511
+
+# libusb-win32 makes all structures packed, while
+# default libusb only does for some structures
+# _PackPolicy defines the structure packing according
+# to the platform.
+class _PackPolicy(object):
+    pass
+
+if sys.platform == 'win32':
+    _PackPolicy._pack_ = 1
+
+# Data structures
+
+class _usb_descriptor_header(Structure):
+    _pack_ = 1
+    _fields_ = [('blength', c_uint8),
+                ('bDescriptorType', c_uint8)]
+
+class _usb_string_descriptor(Structure):
+    _pack_ = 1
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('wData', c_uint16)]
+
+class _usb_endpoint_descriptor(Structure, _PackPolicy):
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('bEndpointAddress', c_uint8),
+                ('bmAttributes', c_uint8),
+                ('wMaxPacketSize', c_uint16),
+                ('bInterval', c_uint8),
+                ('bRefresh', c_uint8),
+                ('bSynchAddress', c_uint8),
+                ('extra', POINTER(c_uint8)),
+                ('extralen', c_int)]
+
+class _usb_interface_descriptor(Structure, _PackPolicy):
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('bInterfaceNumber', c_uint8),
+                ('bAlternateSetting', c_uint8),
+                ('bNumEndpoints', c_uint8),
+                ('bInterfaceClass', c_uint8),
+                ('bInterfaceSubClass', c_uint8),
+                ('bInterfaceProtocol', c_uint8),
+                ('iInterface', c_uint8),
+                ('endpoint', POINTER(_usb_endpoint_descriptor)),
+                ('extra', POINTER(c_uint8)),
+                ('extralen', c_int)]
+
+class _usb_interface(Structure, _PackPolicy):
+    _fields_ = [('altsetting', POINTER(_usb_interface_descriptor)),
+                ('num_altsetting', c_int)]
+
+class _usb_config_descriptor(Structure, _PackPolicy):
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('wTotalLength', c_uint16),
+                ('bNumInterfaces', c_uint8),
+                ('bConfigurationValue', c_uint8),
+                ('iConfiguration', c_uint8),
+                ('bmAttributes', c_uint8),
+                ('bMaxPower', c_uint8),
+                ('interface', POINTER(_usb_interface)),
+                ('extra', POINTER(c_uint8)),
+                ('extralen', c_int)]
+
+class _usb_device_descriptor(Structure, _PackPolicy):
+    _pack_ = 1
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('bcdUSB', c_uint16),
+                ('bDeviceClass', c_uint8),
+                ('bDeviceSubClass', c_uint8),
+                ('bDeviceProtocol', c_uint8),
+                ('bMaxPacketSize0', c_uint8),
+                ('idVendor', c_uint16),
+                ('idProduct', c_uint16),
+                ('bcdDevice', c_uint16),
+                ('iManufacturer', c_uint8),
+                ('iProduct', c_uint8),
+                ('iSerialNumber', c_uint8),
+                ('bNumConfigurations', c_uint8)]
+
+class _usb_device(Structure, _PackPolicy):
+    pass
+
+class _usb_bus(Structure, _PackPolicy):
+    pass
+
+_usb_device._fields_ = [('next', POINTER(_usb_device)),
+                        ('prev', POINTER(_usb_device)),
+                        ('filename', c_int8 * (_PATH_MAX + 1)),
+                        ('bus', POINTER(_usb_bus)),
+                        ('descriptor', _usb_device_descriptor),
+                        ('config', POINTER(_usb_config_descriptor)),
+                        ('dev', c_void_p),
+                        ('devnum', c_uint8),
+                        ('num_children', c_ubyte),
+                        ('children', POINTER(POINTER(_usb_device)))]
+
+_usb_bus._fields_ = [('next', POINTER(_usb_bus)),
+                    ('prev', POINTER(_usb_bus)),
+                    ('dirname', c_char * (_PATH_MAX + 1)),
+                    ('devices', POINTER(_usb_device)),
+                    ('location', c_uint32),
+                    ('root_dev', POINTER(_usb_device))]
+
+_usb_dev_handle = c_void_p
+
+_lib = None
+
+def _load_library():
+    candidates = ('usb-0.1', 'usb', 'libusb0')
+    for candidate in candidates:
+        libname = ctypes.util.find_library(candidate)
+        if libname is not None: break
+    else:
+        # corner cases
+        # cygwin predefines library names with 'cyg' instead of 'lib'
+        if sys.platform == 'cygwin':
+            try:
+                return CDLL('cygusb0.dll')
+            except:
+                _logger.error('Libusb 0 could not be loaded in cygwin', exc_info=True)
+
+        raise OSError('USB library could not be found')
+    return CDLL(libname)
+
+def _setup_prototypes(lib):
+    # usb_dev_handle *usb_open(struct usb_device *dev);
+    lib.usb_open.argtypes = [POINTER(_usb_device)]
+    lib.usb_open.restype = _usb_dev_handle
+
+    # int usb_close(usb_dev_handle *dev);
+    lib.usb_close.argtypes = [_usb_dev_handle]
+
+    # int usb_get_string(usb_dev_handle *dev,
+    #                    int index,
+    #                    int langid,
+    #                    char *buf,
+    #                    size_t buflen);
+    lib.usb_get_string.argtypes = [
+            _usb_dev_handle,
+            c_int,
+            c_int,
+            c_char_p,
+            c_size_t
+        ]
+
+    # int usb_get_string_simple(usb_dev_handle *dev,
+    #                           int index,
+    #                           char *buf,
+    #                           size_t buflen);
+    lib.usb_get_string_simple.argtypes = [
+            _usb_dev_handle,
+            c_int,
+            c_char_p,
+            c_size_t
+        ]
+
+    # int usb_get_descriptor_by_endpoint(usb_dev_handle *udev,
+    #                                    int ep,
+    #	                                 unsigned char type,
+    #                                    unsigned char index,
+    #                                    void *buf,
+    #                                    int size);
+    lib.usb_get_descriptor_by_endpoint.argtypes = [
+                                _usb_dev_handle,
+                                c_int,
+                                c_ubyte,
+                                c_ubyte,
+                                c_void_p,
+                                c_int
+                            ]
+
+    # int usb_get_descriptor(usb_dev_handle *udev,
+    #                        unsigned char type,
+    #	                     unsigned char index,
+    #                        void *buf,
+    #                        int size);
+    lib.usb_get_descriptor.argtypes = [
+                    _usb_dev_handle,
+                    c_ubyte,
+                    c_ubyte,
+                    c_void_p,
+                    c_int
+                ]
+
+    # int usb_bulk_write(usb_dev_handle *dev,
+    #                    int ep,
+    #                    const char *bytes,
+    #                    int size,
+    #                    int timeout);
+    lib.usb_bulk_write.argtypes = [
+            _usb_dev_handle,
+            c_int,
+            c_char_p,
+            c_int,
+            c_int
+        ]
+
+    # int usb_bulk_read(usb_dev_handle *dev,
+    #                   int ep,
+    #                   char *bytes,
+    #                   int size,
+    #                   int timeout);
+    lib.usb_bulk_read.argtypes = [
+            _usb_dev_handle,
+            c_int,
+            c_char_p,
+            c_int,
+            c_int
+        ]
+
+    # int usb_interrupt_write(usb_dev_handle *dev,
+    #                         int ep,
+    #                         const char *bytes,
+    #                         int size,
+    #                         int timeout);
+    lib.usb_interrupt_write.argtypes = [
+            _usb_dev_handle,
+            c_int,
+            c_char_p,
+            c_int,
+            c_int
+        ]
+
+    # int usb_interrupt_read(usb_dev_handle *dev,
+    #                        int ep,
+    #                        char *bytes,
+    #                        int size,
+    #                        int timeout);
+    lib.usb_interrupt_read.argtypes = [
+            _usb_dev_handle,
+            c_int,
+            c_char_p,
+            c_int,
+            c_int
+        ]
+
+    # int usb_control_msg(usb_dev_handle *dev,
+    #                     int requesttype,
+    #                     int request,
+    # 	                  int value,
+    #                     int index,
+    #                     char *bytes,
+    #                     int size,
+    #                     int timeout);
+    lib.usb_control_msg.argtypes = [
+            _usb_dev_handle,
+            c_int,
+            c_int,
+            c_int,
+            c_int,
+            c_char_p,
+            c_int,
+            c_int
+        ]
+
+    # int usb_set_configuration(usb_dev_handle *dev, int configuration);
+    lib.usb_set_configuration.argtypes = [_usb_dev_handle, c_int]
+
+    # int usb_claim_interface(usb_dev_handle *dev, int interface);
+    lib.usb_claim_interface.argtypes = [_usb_dev_handle, c_int]
+
+    # int usb_release_interface(usb_dev_handle *dev, int interface);
+    lib.usb_release_interface.argtypes = [_usb_dev_handle, c_int]
+
+    # int usb_set_altinterface(usb_dev_handle *dev, int alternate);
+    lib.usb_set_altinterface.argtypes = [_usb_dev_handle, c_int]
+
+    # int usb_resetep(usb_dev_handle *dev, unsigned int ep);
+    lib.usb_resetep.argtypes = [_usb_dev_handle, c_int]
+
+    # int usb_clear_halt(usb_dev_handle *dev, unsigned int ep);
+    lib.usb_clear_halt.argtypes = [_usb_dev_handle, c_int]
+
+    # int usb_reset(usb_dev_handle *dev);
+    lib.usb_reset.argtypes = [_usb_dev_handle]
+
+    # char *usb_strerror(void);
+    lib.usb_strerror.argtypes = []
+    lib.usb_strerror.restype = c_char_p
+
+    # void usb_set_debug(int level);
+    lib.usb_set_debug.argtypes = [c_int]
+
+    # struct usb_device *usb_device(usb_dev_handle *dev);
+    lib.usb_device.argtypes = [_usb_dev_handle]
+    lib.usb_device.restype = POINTER(_usb_device)
+
+    # struct usb_bus *usb_get_busses(void);
+    lib.usb_get_busses.restype = POINTER(_usb_bus)
+
+def _check(retval):
+    if retval is None:
+        errmsg = _lib.usb_strerror()
+    else:
+        ret = int(retval)
+        if ret < 0:
+            errmsg = _lib.usb_strerror()
+            # No error means that we need to get the error
+            # message from the return code
+            # Thanks to Nicholas Wheeler to point out the problem...
+            # Also see issue #2860940
+            if errmsg.lower() == 'no error':
+                errmsg = os.strerror(-ret)
+        else:
+            return ret
+    raise USBError(errmsg)
+
+# implementation of libusb 0.1.x backend
+class _LibUSB(usb.backend.IBackend):
+    @methodtrace(_logger)
+    def enumerate_devices(self):
+        _check(_lib.usb_find_busses())
+        _check(_lib.usb_find_devices())
+
+        bus = _lib.usb_get_busses()
+
+        while bool(bus):
+            dev = bus[0].devices
+            while bool(dev):
+                yield dev[0]
+                dev = dev[0].next
+            bus = bus[0].next
+
+    @methodtrace(_logger)
+    def get_device_descriptor(self, dev):
+        return dev.descriptor
+
+    @methodtrace(_logger)
+    def get_configuration_descriptor(self, dev, config):
+        if config >= dev.descriptor.bNumConfigurations:
+            raise IndexError('Invalid configuration index ' + str(config))
+        return dev.config[config]
+
+    @methodtrace(_logger)
+    def get_interface_descriptor(self, dev, intf, alt, config):
+        cfgdesc = self.get_configuration_descriptor(dev, config)
+        if intf >= cfgdesc.bNumInterfaces:
+            raise IndexError('Invalid interface index ' + str(interface))
+        interface = cfgdesc.interface[intf]
+        if alt >= interface.num_altsetting:
+            raise IndexError('Invalid alternate setting index ' + str(alt))
+        return interface.altsetting[alt]
+
+    @methodtrace(_logger)
+    def get_endpoint_descriptor(self, dev, ep, intf, alt, config):
+        interface = self.get_interface_descriptor(dev, intf, alt, config)
+        if ep >= interface.bNumEndpoints:
+            raise IndexError('Invalid endpoint index ' + str(ep))
+        return interface.endpoint[ep]
+
+    @methodtrace(_logger)
+    def open_device(self, dev):
+        return _check(_lib.usb_open(dev))
+
+    @methodtrace(_logger)
+    def close_device(self, dev_handle):
+        _check(_lib.usb_close(dev_handle))
+
+    @methodtrace(_logger)
+    def set_configuration(self, dev_handle, config_value):
+        _check(_lib.usb_set_configuration(dev_handle, config_value))
+
+    @methodtrace(_logger)
+    def set_interface_altsetting(self, dev_handle, intf, altsetting):
+        _check(_lib.usb_set_altinterface(dev_handle, altsetting))
+
+    @methodtrace(_logger)
+    def get_configuration(self, dev_handle):
+        bmRequestType = usb.util.build_request_type(
+                                usb.util.CTRL_IN,
+                                usb.util.CTRL_TYPE_STANDARD,
+                                usb.util.CTRL_RECIPIENT_DEVICE
+                            )
+        return self.ctrl_transfer(dev_handle,
+                                  bmRequestType,
+                                  0x08,
+                                  0,
+                                  0,
+                                  1,
+                                  100
+                            )[0]
+                                  
+
+    @methodtrace(_logger)
+    def claim_interface(self, dev_handle, intf):
+        _check(_lib.usb_claim_interface(dev_handle, intf))
+
+    @methodtrace(_logger)
+    def release_interface(self, dev_handle, intf):
+        _check(_lib.usb_release_interface(dev_handle, intf))
+
+    @methodtrace(_logger)
+    def bulk_write(self, dev_handle, ep, intf, data, timeout):
+        return self.__write(_lib.usb_bulk_write,
+                            dev_handle,
+                            ep,
+                            intf,
+                            data, timeout)
+
+    @methodtrace(_logger)
+    def bulk_read(self, dev_handle, ep, intf, size, timeout):
+        return self.__read(_lib.usb_bulk_read,
+                           dev_handle,
+                           ep,
+                           intf,
+                           size,
+                           timeout)
+
+    @methodtrace(_logger)
+    def intr_write(self, dev_handle, ep, intf, data, timeout):
+        return self.__write(_lib.usb_interrupt_write,
+                            dev_handle,
+                            ep,
+                            intf,
+                            data,
+                            timeout)
+
+    @methodtrace(_logger)
+    def intr_read(self, dev_handle, ep, intf, size, timeout):
+        return self.__read(_lib.usb_interrupt_read,
+                           dev_handle,
+                           ep,
+                           intf,
+                           size,
+                           timeout)
+
+    @methodtrace(_logger)
+    def ctrl_transfer(self,
+                      dev_handle,
+                      bmRequestType,
+                      bRequest,
+                      wValue,
+                      wIndex,
+                      data_or_wLength,
+                      timeout):
+        if usb.util.ctrl_direction(bmRequestType) == usb.util.CTRL_OUT:
+            address, length = data_or_wLength.buffer_info()
+            length *= data_or_wLength.itemsize
+            return _check(_lib.usb_control_msg(
+                                dev_handle,
+                                bmRequestType,
+                                bRequest,
+                                wValue,
+                                wIndex,
+                                cast(address, c_char_p),
+                                length,
+                                timeout
+                            ))
+        else:
+            data = _interop.as_array((0,) * data_or_wLength)
+            read = int(_check(_lib.usb_control_msg(
+                                dev_handle,
+                                bmRequestType,
+                                bRequest,
+                                wValue,
+                                wIndex,
+                                cast(data.buffer_info()[0],
+                                     c_char_p),
+                                data_or_wLength,
+                                timeout
+                            )))
+            return data[:read]
+
+    @methodtrace(_logger)
+    def reset_device(self, dev_handle):
+        _check(_lib.usb_reset(dev_handle))
+
+    @methodtrace(_logger)
+    def detach_kernel_driver(self, dev_handle, intf):
+        _check(_lib.usb_detach_kernel_driver_np(dev_handle, intf))
+
+    def __write(self, fn, dev_handle, ep, intf, data, timeout):
+        address, length = data.buffer_info()
+        length *= data.itemsize
+        return int(_check(fn(
+                        dev_handle,
+                        ep,
+                        cast(address, c_char_p),
+                        length,
+                        timeout
+                    )))
+
+    def __read(self, fn, dev_handle, ep, intf, size, timeout):
+        data = _interop.as_array((0,) * size)
+        address, length = data.buffer_info()
+        length *= data.itemsize
+        ret = int(_check(fn(
+                    dev_handle,
+                    ep,
+                    cast(address, c_char_p),
+                    length,
+                    timeout
+                )))
+        return data[:ret]
+
+def get_backend():
+    global _lib
+    try:
+        if _lib is None:
+            _lib = _load_library()
+            _setup_prototypes(_lib)
+            _lib.usb_init()
+        return _LibUSB()
+    except Exception:
+        _logger.error('Error loading libusb 0.1 backend', exc_info=True)
+        return None

+ 606 - 0
pyusb/build/lib.linux-armv6l-2.7/usb/backend/libusb10.py

@@ -0,0 +1,606 @@
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+from ctypes import *
+import ctypes.util
+import usb.util
+import sys
+import logging
+from usb._debug import methodtrace
+import usb._interop as _interop
+
+__author__ = 'Wander Lairson Costa'
+
+__all__ = ['get_backend']
+
+_logger = logging.getLogger('usb.backend.libusb10')
+
+# libusb.h
+
+# return codes
+
+_LIBUSB_SUCCESS = 0
+_LIBUSB_ERROR_IO = -1
+_LIBUSB_ERROR_INVALID_PARAM = -2
+_LIBUSB_ERROR_ACCESS = -3
+_LIBUSB_ERROR_NO_DEVICE = -4
+_LIBUSB_ERROR_NOT_FOUND = -5
+_LIBUSB_ERROR_BUSY = -6
+_LIBUSB_ERROR_TIMEOUT = -7
+_LIBUSB_ERROR_OVERFLOW = -8
+_LIBUSB_ERROR_PIPE = -9
+_LIBUSB_ERROR_INTERRUPTED = -10
+_LIBUSB_ERROR_NO_MEM = -11
+_LIBUSB_ERROR_NOT_SUPPORTED = -12
+_LIBUSB_ERROR_OTHER = -99
+
+# map return codes to strings
+_str_error = {
+    _LIBUSB_SUCCESS:'Success (no error)',
+    _LIBUSB_ERROR_IO:'Input/output error',
+    _LIBUSB_ERROR_INVALID_PARAM:'Invalid parameter',
+    _LIBUSB_ERROR_ACCESS:'Access denied (insufficient permissions)',
+    _LIBUSB_ERROR_NO_DEVICE:'No such device (it may have been disconnected)',
+    _LIBUSB_ERROR_NOT_FOUND:'Entity not found',
+    _LIBUSB_ERROR_BUSY:'Resource busy',
+    _LIBUSB_ERROR_TIMEOUT:'Operation timed out',
+    _LIBUSB_ERROR_OVERFLOW:'Overflow',
+    _LIBUSB_ERROR_PIPE:'Pipe error',
+    _LIBUSB_ERROR_INTERRUPTED:'System call interrupted (perhaps due to signal)',
+    _LIBUSB_ERROR_NO_MEM:'Insufficient memory',
+    _LIBUSB_ERROR_NOT_SUPPORTED:'Operation not supported or unimplemented on this platform',
+    _LIBUSB_ERROR_OTHER:'Unknown error'
+}
+
+# Data structures
+
+class _libusb_endpoint_descriptor(Structure):
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('bEndpointAddress', c_uint8),
+                ('bmAttributes', c_uint8),
+                ('wMaxPacketSize', c_uint16),
+                ('bInterval', c_uint8),
+                ('bRefresh', c_uint8),
+                ('bSynchAddress', c_uint8),
+                ('extra', POINTER(c_ubyte)),
+                ('extra_length', c_int)]
+
+class _libusb_interface_descriptor(Structure):
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('bInterfaceNumber', c_uint8),
+                ('bAlternateSetting', c_uint8),
+                ('bNumEndpoints', c_uint8),
+                ('bInterfaceClass', c_uint8),
+                ('bInterfaceSubClass', c_uint8),
+                ('bInterfaceProtocol', c_uint8),
+                ('iInterface', c_uint8),
+                ('endpoint', POINTER(_libusb_endpoint_descriptor)),
+                ('extra', POINTER(c_ubyte)),
+                ('extra_length', c_int)]
+
+class _libusb_interface(Structure):
+    _fields_ = [('altsetting', POINTER(_libusb_interface_descriptor)),
+                ('num_altsetting', c_int)]
+
+class _libusb_config_descriptor(Structure):
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('wTotalLength', c_uint16),
+                ('bNumInterfaces', c_uint8),
+                ('bConfigurationValue', c_uint8),
+                ('iConfiguration', c_uint8),
+                ('bmAttributes', c_uint8),
+                ('bMaxPower', c_uint8),
+                ('interface', POINTER(_libusb_interface)),
+                ('extra', POINTER(c_ubyte)),
+                ('extra_length', c_int)]
+
+class _libusb_device_descriptor(Structure):
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('bcdUSB', c_uint16),
+                ('bDeviceClass', c_uint8),
+                ('bDeviceSubClass', c_uint8),
+                ('bDeviceProtocol', c_uint8),
+                ('bMaxPacketSize0', c_uint8),
+                ('idVendor', c_uint16),
+                ('idProduct', c_uint16),
+                ('bcdDevice', c_uint16),
+                ('iManufacturer', c_uint8),
+                ('iProduct', c_uint8),
+                ('iSerialNumber', c_uint8),
+                ('bNumConfigurations', c_uint8)]
+
+_lib = None
+_init = None
+
+_libusb_device_handle = c_void_p
+
+def _load_library():
+    candidates = ('usb-1.0', 'libusb-1.0', 'usb')
+    for candidate in candidates:
+        libname = ctypes.util.find_library(candidate)
+        if libname is not None: break
+    else:
+        # corner cases
+        # cygwin predefines library names with 'cyg' instead of 'lib'
+        if sys.platform == 'cygwin':
+            try:
+                return CDLL('cygusb-1.0-0.dll')
+            except Exception:
+                _logger.error('Libusb 1.0 could not be loaded in cygwin', exc_info=True)
+
+        raise OSError('USB library could not be found')
+    # Windows backend uses stdcall calling convention
+    if sys.platform == 'win32':
+        l = WinDLL(libname)
+    else:
+        l = CDLL(libname)
+    # On FreeBSD 8/9, libusb 1.0 and libusb 0.1 are in the same shared
+    # object libusb.so, so if we found libusb library name, we must assure
+    # it is 1.0 version. We just try to get some symbol from 1.0 version
+    if not hasattr(l, 'libusb_init'):
+        raise OSError('USB library could not be found')
+    return l
+
+def _setup_prototypes(lib):
+    # void libusb_set_debug (libusb_context *ctx, int level)
+    lib.libusb_set_debug.argtypes = [c_void_p, c_int]
+
+    # int libusb_init (libusb_context **context)
+    lib.libusb_init.argtypes = [POINTER(c_void_p)]
+
+    # void libusb_exit (struct libusb_context *ctx)
+    lib.libusb_exit.argtypes = [c_void_p]
+
+    # ssize_t libusb_get_device_list (libusb_context *ctx,
+    #                                 libusb_device ***list)
+    lib.libusb_get_device_list.argtypes = [
+            c_void_p,
+            POINTER(POINTER(c_void_p))
+        ]
+
+    # void libusb_free_device_list (libusb_device **list,
+    #                               int unref_devices)
+    lib.libusb_free_device_list.argtypes = [
+            POINTER(c_void_p),
+            c_int
+        ]
+
+    # libusb_device *libusb_ref_device (libusb_device *dev)
+    lib.libusb_ref_device.argtypes = [c_void_p]
+    lib.libusb_ref_device.restype = c_void_p
+
+    # void libusb_unref_device(libusb_device *dev)
+    lib.libusb_unref_device.argtypes = [c_void_p]
+
+    # int libusb_open(libusb_device *dev, libusb_device_handle **handle)
+    lib.libusb_open.argtypes = [c_void_p, POINTER(_libusb_device_handle)]
+
+    # void libusb_close(libusb_device_handle *dev_handle)
+    lib.libusb_close.argtypes = [_libusb_device_handle]
+
+    # int libusb_set_configuration(libusb_device_handle *dev,
+    #                              int configuration)
+    lib.libusb_set_configuration.argtypes = [_libusb_device_handle, c_int]
+
+    # int libusb_get_configuration(libusb_device_handle *dev,
+    #                              int *config)   
+    lib.libusb_get_configuration.argtypes = [_libusb_device_handle, POINTER(c_int)]
+
+    # int libusb_claim_interface(libusb_device_handle *dev,
+    #                               int interface_number)
+    lib.libusb_claim_interface.argtypes = [_libusb_device_handle, c_int]
+
+    # int libusb_release_interface(libusb_device_handle *dev,
+    #                              int interface_number)
+    lib.libusb_release_interface.argtypes = [_libusb_device_handle, c_int]
+
+    # int libusb_set_interface_alt_setting(libusb_device_handle *dev,
+    #                                      int interface_number,
+    #                                      int alternate_setting)
+    lib.libusb_set_interface_alt_setting.argtypes = [
+            _libusb_device_handle,
+            c_int,
+            c_int
+        ]
+
+    # int libusb_reset_device (libusb_device_handle *dev)
+    lib.libusb_reset_device.argtypes = [_libusb_device_handle]
+
+    # int libusb_kernel_driver_active(libusb_device_handle *dev,
+    #                                 int interface)
+    lib.libusb_kernel_driver_active.argtypes = [
+            _libusb_device_handle,
+            c_int
+        ]
+
+    # int libusb_detach_kernel_driver(libusb_device_handle *dev,
+    #                                 int interface)
+    lib.libusb_detach_kernel_driver.argtypes = [
+            _libusb_device_handle,
+            c_int
+        ]
+
+    # int libusb_attach_kernel_driver(libusb_device_handle *dev,
+    #                                 int interface)
+    lib.libusb_attach_kernel_driver.argtypes = [
+            _libusb_device_handle,
+            c_int
+        ]
+
+    # int libusb_get_device_descriptor(
+    #                   libusb_device *dev,
+    #                   struct libusb_device_descriptor *desc
+    #               )
+    lib.libusb_get_device_descriptor.argtypes = [
+            c_void_p,
+            POINTER(_libusb_device_descriptor)
+        ]
+
+    # int libusb_get_config_descriptor(
+    #           libusb_device *dev,
+    #           uint8_t config_index,
+    #           struct libusb_config_descriptor **config
+    #       )
+    lib.libusb_get_config_descriptor.argtypes = [
+            c_void_p,
+            c_uint8,
+            POINTER(POINTER(_libusb_config_descriptor))
+        ]
+
+    # void  libusb_free_config_descriptor(
+    #           struct libusb_config_descriptor *config
+    #   )
+    lib.libusb_free_config_descriptor.argtypes = [
+            POINTER(_libusb_config_descriptor)
+        ]
+
+    # int libusb_get_string_descriptor_ascii(libusb_device_handle *dev,
+    #                                         uint8_t desc_index,
+    #                                         unsigned char *data,
+    #                                         int length)
+    lib.libusb_get_string_descriptor_ascii.argtypes = [
+            _libusb_device_handle,
+            c_uint8,
+            POINTER(c_ubyte),
+            c_int
+        ]
+
+    # int libusb_control_transfer(libusb_device_handle *dev_handle,
+    #                             uint8_t bmRequestType,
+    #                             uint8_t bRequest,
+    #                             uint16_t wValue,
+    #                             uint16_t wIndex,
+    #                             unsigned char *data,
+    #                             uint16_t wLength,
+    #                             unsigned int timeout)
+    lib.libusb_control_transfer.argtypes = [
+            _libusb_device_handle,
+            c_uint8,
+            c_uint8, 
+            c_uint16,
+            c_uint16,
+            POINTER(c_ubyte),
+            c_uint16,
+            c_uint
+        ]
+
+    #int libusb_bulk_transfer(
+    #           struct libusb_device_handle *dev_handle,
+    #           unsigned char endpoint,
+    #           unsigned char *data,
+    #           int length,
+    #           int *transferred,
+    #           unsigned int timeout
+    #       )
+    lib.libusb_bulk_transfer.argtypes = [
+                _libusb_device_handle,
+                c_ubyte,
+                POINTER(c_ubyte),
+                c_int,
+                POINTER(c_int),
+                c_uint
+            ]
+
+    # int libusb_interrupt_transfer(
+    #               libusb_device_handle *dev_handle,
+    #	            unsigned char endpoint,
+    #               unsigned char *data,
+    #               int length,
+    #	            int *actual_length,
+    #               unsigned int timeout
+    #           );
+    lib.libusb_interrupt_transfer.argtypes = [
+                    _libusb_device_handle,
+                    c_ubyte,
+                    POINTER(c_ubyte),
+                    c_int,
+                    POINTER(c_int),
+                    c_uint
+                ]
+
+# check a libusb function call
+def _check(retval):
+    if isinstance(retval, int):
+        retval = c_int(retval)
+    if isinstance(retval, c_int):
+        if retval.value < 0:
+           from usb.core import USBError
+           raise USBError(_str_error[retval.value])
+    return retval
+
+# wrap a device
+class _Device(object):
+    def __init__(self, devid):
+        self.devid = _lib.libusb_ref_device(devid)
+    def __del__(self):
+        _lib.libusb_unref_device(self.devid)
+
+# wrap a descriptor and keep a reference to another object
+# Thanks to Thomas Reitmayr.
+class _WrapDescriptor(object):
+    def __init__(self, desc, obj = None):
+        self.obj = obj
+        self.desc = desc
+    def __getattr__(self, name):
+        return getattr(self.desc, name)
+
+# wrap a configuration descriptor
+class _ConfigDescriptor(object):
+    def __init__(self, desc):
+        self.desc = desc
+    def __del__(self):
+        _lib.libusb_free_config_descriptor(self.desc)
+    def __getattr__(self, name):
+        return getattr(self.desc.contents, name)
+
+# initialize and finalize the library
+class _Initializer(object):
+    def __init__(self):
+        _check(_lib.libusb_init(None))
+    def __del__(self):
+        _lib.libusb_exit(None)
+
+
+# iterator for libusb devices
+class _DevIterator(object):
+    def __init__(self):
+        self.dev_list = POINTER(c_void_p)()
+        self.num_devs = _check(_lib.libusb_get_device_list(
+                                    None,
+                                    byref(self.dev_list))
+                                ).value
+    def __iter__(self):
+        for i in range(self.num_devs):
+            yield _Device(self.dev_list[i])
+    def __del__(self):
+        _lib.libusb_free_device_list(self.dev_list, 1)
+
+# implementation of libusb 1.0 backend
+class _LibUSB(usb.backend.IBackend):
+    @methodtrace(_logger)
+    def enumerate_devices(self):
+        return _DevIterator()
+
+    @methodtrace(_logger)
+    def get_device_descriptor(self, dev):
+        dev_desc = _libusb_device_descriptor()
+        _check(_lib.libusb_get_device_descriptor(dev.devid, byref(dev_desc)))
+        return dev_desc
+
+    @methodtrace(_logger)
+    def get_configuration_descriptor(self, dev, config):
+        cfg = POINTER(_libusb_config_descriptor)()
+        _check(_lib.libusb_get_config_descriptor(dev.devid,
+                                                 config, byref(cfg)))
+        return _ConfigDescriptor(cfg)
+
+    @methodtrace(_logger)
+    def get_interface_descriptor(self, dev, intf, alt, config):
+        cfg = self.get_configuration_descriptor(dev, config)
+        if intf >= cfg.bNumInterfaces:
+            raise IndexError('Invalid interface index ' + str(intf))
+        i = cfg.interface[intf]
+        if alt >= i.num_altsetting:
+            raise IndexError('Invalid alternate setting index ' + str(alt))
+        return _WrapDescriptor(i.altsetting[alt], cfg)
+
+    @methodtrace(_logger)
+    def get_endpoint_descriptor(self, dev, ep, intf, alt, config):
+        i = self.get_interface_descriptor(dev, intf, alt, config)
+        if ep > i.bNumEndpoints:
+            raise IndexError('Invalid endpoint index ' + str(ep))
+        return _WrapDescriptor(i.endpoint[ep], i)
+
+    @methodtrace(_logger)
+    def open_device(self, dev):
+        handle = _libusb_device_handle()
+        _check(_lib.libusb_open(dev.devid, byref(handle)))
+        return handle
+
+    @methodtrace(_logger)
+    def close_device(self, dev_handle):
+        _lib.libusb_close(dev_handle)
+
+    @methodtrace(_logger)
+    def set_configuration(self, dev_handle, config_value):
+        _check(_lib.libusb_set_configuration(dev_handle, config_value))
+
+    @methodtrace(_logger)
+    def get_configuration(self, dev_handle):
+        config = c_int()
+        _check(_lib.libusb_get_configuration(dev_handle, byref(config)))
+        return config.value
+
+    @methodtrace(_logger)
+    def set_interface_altsetting(self, dev_handle, intf, altsetting):
+        _check(_lib.libusb_set_interface_alt_setting(dev_handle,
+                                                     intf,
+                                                     altsetting))
+
+    @methodtrace(_logger)
+    def claim_interface(self, dev_handle, intf):
+        _check(_lib.libusb_claim_interface(dev_handle, intf))
+
+    @methodtrace(_logger)
+    def release_interface(self, dev_handle, intf):
+        _check(_lib.libusb_release_interface(dev_handle, intf))
+
+    @methodtrace(_logger)
+    def bulk_write(self, dev_handle, ep, intf, data, timeout):
+        return self.__write(_lib.libusb_bulk_transfer,
+                            dev_handle,
+                            ep,
+                            intf,
+                            data,
+                            timeout)
+
+    @methodtrace(_logger)
+    def bulk_read(self, dev_handle, ep, intf, size, timeout):
+        return self.__read(_lib.libusb_bulk_transfer,
+                           dev_handle,
+                           ep,
+                           intf,
+                           size,
+                           timeout)
+
+    @methodtrace(_logger)
+    def intr_write(self, dev_handle, ep, intf, data, timeout):
+        return self.__write(_lib.libusb_interrupt_transfer,
+                            dev_handle,
+                            ep,
+                            intf,
+                            data,
+                            timeout)
+
+    @methodtrace(_logger)
+    def intr_read(self, dev_handle, ep, intf, size, timeout):
+        return self.__read(_lib.libusb_interrupt_transfer,
+                           dev_handle,
+                           ep,
+                           intf,
+                           size,
+                           timeout)
+
+# TODO: implement isochronous
+#    @methodtrace(_logger)
+#    def iso_write(self, dev_handle, ep, intf, data, timeout):
+#       pass
+
+
+#    @methodtrace(_logger)
+#    def iso_read(self, dev_handle, ep, intf, size, timeout):
+#        pass
+
+    @methodtrace(_logger)
+    def ctrl_transfer(self,
+                      dev_handle,
+                      bmRequestType,
+                      bRequest,
+                      wValue,
+                      wIndex,
+                      data_or_wLength,
+                      timeout):
+        if usb.util.ctrl_direction(bmRequestType) == usb.util.CTRL_OUT:
+            buff = data_or_wLength
+        else:
+            buff = _interop.as_array((0,) * data_or_wLength)
+
+        addr, length = buff.buffer_info()
+        length *= buff.itemsize
+
+        ret = _check(_lib.libusb_control_transfer(dev_handle,
+                                                  bmRequestType,
+                                                  bRequest,
+                                                  wValue,
+                                                  wIndex,
+                                                  cast(addr,
+                                                       POINTER(c_ubyte)),
+                                                  length,
+                                                  timeout))
+
+        if usb.util.ctrl_direction(bmRequestType) == usb.util.CTRL_OUT:
+            return ret.value
+        else:
+            return buff[:ret.value]
+
+    @methodtrace(_logger)
+    def reset_device(self, dev_handle):
+        _check(_lib.libusb_reset_device(dev_handle))
+
+    @methodtrace(_logger)
+    def is_kernel_driver_active(self, dev_handle, intf):
+        return bool(_check(_lib.libusb_kernel_driver_active(dev_handle, intf)))
+
+    @methodtrace(_logger)
+    def detach_kernel_driver(self, dev_handle, intf):
+        _check(_lib.libusb_detach_kernel_driver(dev_handle, intf))
+
+    @methodtrace(_logger)
+    def attach_kernel_driver(self, dev_handle, intf):
+        _check(_lib.libusb_attach_kernel_driver(dev_handle, intf))
+
+    def __write(self, fn, dev_handle, ep, intf, data, timeout):
+        address, length = data.buffer_info()
+        length *= data.itemsize
+        transferred = c_int()
+        _check(fn(dev_handle,
+                  ep,
+                  cast(address, POINTER(c_ubyte)),
+                  length,
+                  byref(transferred),
+                  timeout))
+        return transferred.value
+
+    def __read(self, fn, dev_handle, ep, intf, size, timeout):
+        data = _interop.as_array((0,) * size)
+        address, length = data.buffer_info()
+        length *= data.itemsize
+        transferred = c_int()
+        _check(fn(dev_handle,
+                  ep,
+                  cast(address, POINTER(c_ubyte)),
+                  length,
+                  byref(transferred),
+                  timeout))
+        return data[:transferred.value]
+
+def get_backend():
+    global _lib, _init
+    try:
+        if _lib is None:
+            _lib = _load_library()
+            _setup_prototypes(_lib)
+            _init = _Initializer()
+        return _LibUSB()
+    except Exception:
+        _logger.error('Error loading libusb 1.0 backend', exc_info=True)
+        return None

+ 604 - 0
pyusb/build/lib.linux-armv6l-2.7/usb/backend/openusb.py

@@ -0,0 +1,604 @@
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+from ctypes import *
+import ctypes.util
+import usb.util
+from usb._debug import methodtrace
+import logging
+
+__author__ = 'Wander Lairson Costa'
+
+__all__ = ['get_backend']
+
+_logger = logging.getLogger('usb.backend.openusb')
+
+class _usb_endpoint_desc(Structure):
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('bEndpointAddress', c_uint8),
+                ('bmAttributes', c_uint8),
+                ('wMaxPacketSize', c_uint16),
+                ('bInterval', c_uint8),
+                ('bRefresh', c_uint8),
+                ('bSynchAddress', c_uint8)]
+
+class _usb_interface_desc(Structure):
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('bInterfaceNumber', c_uint8),
+                ('bAlternateSetting', c_uint8),
+                ('bNumEndpoints', c_uint8),
+                ('bInterfaceClass', c_uint8),
+                ('bInterfaceSubClass', c_uint8),
+                ('bInterfaceProtocol', c_uint8),
+                ('iInterface', c_uint8)]
+
+class _usb_config_desc(Structure):
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('wTotalLength', c_uint16),
+                ('bNumInterfaces', c_uint8),
+                ('bConfigurationValue', c_uint8),
+                ('iConfiguration', c_uint8),
+                ('bmAttributes', c_uint8),
+                ('bMaxPower', c_uint8)]
+
+class _usb_device_desc(Structure):
+    _fields_ = [('bLength', c_uint8),
+                ('bDescriptorType', c_uint8),
+                ('bcdUSB', c_uint16),
+                ('bDeviceClass', c_uint8),
+                ('bDeviceSubClass', c_uint8),
+                ('bDeviceProtocol', c_uint8),
+                ('bMaxPacketSize0', c_uint8),
+                ('idVendor', c_uint16),
+                ('idProduct', c_uint16),
+                ('bcdDevice', c_uint16),
+                ('iManufacturer', c_uint8),
+                ('iProduct', c_uint8),
+                ('iSerialNumber', c_uint8),
+                ('bNumConfigurations', c_uint8)]
+
+class _openusb_request_result(Structure):
+    _fields_ = [('status', c_int32),
+                ('transfered_bytes', c_uint32)]
+
+class _openusb_ctrl_request(Structure):
+    class _openusb_ctrl_setup(Structure):
+        _fields_ = [('bmRequestType', c_uint8),
+                    ('bRequest', c_uint8),
+                    ('wValue', c_uint16),
+                    ('wIndex', c_uint16)]
+    _fields_ = [('payload', POINTER(c_uint8)),
+                ('length', c_uint32),
+                ('timeout', c_uint32),
+                ('flags', c_uint32),
+                ('result', _openusb_request_result),
+                ('next', c_void_p)]
+
+class _openusb_intr_request(Structure):
+    _fields_ = [('interval', c_uint16),
+                ('payload', POINTER(c_uint8)),
+                ('length', c_uint32),
+                ('timeout', c_uint32),
+                ('flags', c_uint32),
+                ('result', _openusb_request_result),
+                ('next', c_void_p)]
+
+class _openusb_bulk_request(Structure):
+    _fields_ = [('payload', POINTER(c_uint8)),
+                ('length', c_uint32),
+                ('timeout', c_uint32),
+                ('flags', c_uint32),
+                ('result', _openusb_request_result),
+                ('next', c_void_p)]
+
+class _openusb_isoc_pkts(Structure):
+    class _openusb_isoc_packet(Structure):
+        _fields_ = [('payload', POINTER(c_uint8)),
+                    ('length', c_uint32)]
+    _fields_ = [('num_packets', c_uint32),
+                ('packets', POINTER(_openusb_isoc_packet))]
+
+class _openusb_isoc_request(Structure):
+    _fields_ = [('start_frame', c_uint32),
+                ('flags', c_uint32),
+                ('pkts', _openusb_isoc_pkts),
+                ('isoc_results', POINTER(_openusb_request_result)),
+                ('isoc_status', c_int32),
+                ('next', c_void_p)]
+
+_openusb_devid = c_uint64
+_openusb_busid = c_uint64
+_openusb_handle = c_uint64
+_openusb_dev_handle = c_uint64
+
+_lib = None
+_ctx = None
+
+def _load_library():
+    libname = ctypes.util.find_library('openusb')
+    if libname is None:
+        raise OSError('USB library could not be found')
+    return CDLL(libname)
+
+def _setup_prototypes(lib):
+    # int32_t openusb_init(uint32_t flags , openusb_handle_t *handle);
+    lib.openusb_init.argtypes = [c_uint32, POINTER(_openusb_handle)]
+    lib.openusb_init.restype = c_int32
+
+    # void openusb_fini(openusb_handle_t handle );
+    lib.openusb_fini.argtypes = [_openusb_handle]
+
+    # uint32_t openusb_get_busid_list(openusb_handle_t handle,
+    #                                 openusb_busid_t **busids,
+    #                                 uint32_t *num_busids);
+    lib.openusb_get_busid_list.argtypes = [
+            _openusb_handle,
+            POINTER(POINTER(_openusb_busid)),
+            POINTER(c_uint32)
+        ]
+
+    # void openusb_free_busid_list(openusb_busid_t * busids);
+    lib.openusb_free_busid_list.argtypes = [POINTER(_openusb_busid)]
+
+    # uint32_t openusb_get_devids_by_bus(openusb_handle_t handle,
+    #                                    openusb_busid_t busid,
+    #                                    openusb_devid_t **devids,
+    #                                    uint32_t *num_devids);
+    lib.openusb_get_devids_by_bus.argtypes = [
+                _openusb_handle,
+                _openusb_busid,
+                POINTER(POINTER(_openusb_devid)),
+                POINTER(c_uint32)
+            ]
+
+    lib.openusb_get_devids_by_bus.restype = c_int32
+
+    # void openusb_free_devid_list(openusb_devid_t * devids);
+    lib.openusb_free_devid_list.argtypes = [POINTER(_openusb_devid)]
+
+    # int32_t openusb_open_device(openusb_handle_t handle,
+    #                             openusb_devid_t devid ,
+    #                             uint32_t flags,
+    #                             openusb_dev_handle_t *dev);
+    lib.openusb_open_device.argtypes = [
+                _openusb_handle,
+                _openusb_devid,
+                c_uint32,
+                POINTER(_openusb_dev_handle)
+            ]
+
+    lib.openusb_open_device.restype = c_int32
+
+    # int32_t openusb_close_device(openusb_dev_handle_t dev);
+    lib.openusb_close_device.argtypes = [_openusb_dev_handle]
+    lib.openusb_close_device.restype = c_int32
+
+    # int32_t openusb_set_configuration(openusb_dev_handle_t dev,
+    #                                   uint8_t cfg);
+    lib.openusb_set_configuration.argtypes = [_openusb_dev_handle, c_uint8]
+    lib.openusb_set_configuration.restype = c_int32
+
+    # int32_t openusb_get_configuration(openusb_dev_handle_t dev,
+    #                                   uint8_t *cfg);
+    lib.openusb_get_configuration.argtypes = [_openusb_dev_handle, POINTER(c_uint8)]
+    lib.openusb_get_configuration.restype = c_int32
+
+    # int32_t openusb_claim_interface(openusb_dev_handle_t dev,
+    #                                 uint8_t ifc,
+    #                                 openusb_init_flag_t flags);
+    lib.openusb_claim_interface.argtypes = [
+            _openusb_dev_handle,
+            c_uint8,
+            c_int
+        ]
+
+    lib.openusb_claim_interface.restype = c_int32
+
+    # int32_t openusb_release_interface(openusb_dev_handle_t dev,
+    #                                   uint8_t ifc);
+    lib.openusb_release_interface.argtypes = [
+            _openusb_dev_handle,
+            c_uint8
+        ]
+
+    lib.openusb_release_interface.restype = c_int32
+
+    # int32_topenusb_set_altsetting(openusb_dev_handle_t dev,
+    #                               uint8_t ifc,
+    #                               uint8_t alt);
+    lib.openusb_set_altsetting.argtypes = [
+            _openusb_dev_handle,
+            c_uint8,
+            c_uint8
+        ]
+    lib.openusb_set_altsetting.restype = c_int32
+
+    # int32_t openusb_reset(openusb_dev_handle_t dev);
+    lib.openusb_reset.argtypes = [_openusb_dev_handle]
+    lib.openusb_reset.restype = c_int32
+
+    # int32_t openusb_parse_device_desc(openusb_handle_t handle,
+    #                                   openusb_devid_t devid,
+    #                                   uint8_t *buffer,
+    #                                   uint16_t buflen,
+    #                                   usb_device_desc_t *devdesc);
+    lib.openusb_parse_device_desc.argtypes = [
+            _openusb_handle,
+            _openusb_devid,
+            POINTER(c_uint8),
+            c_uint16,
+            POINTER(_usb_device_desc)
+        ]
+
+    lib.openusb_parse_device_desc.restype = c_int32
+
+    # int32_t openusb_parse_config_desc(openusb_handle_t handle,
+    #                                   openusb_devid_t devid,
+    #                                   uint8_t *buffer,
+    #                                   uint16_t buflen,
+    #                                   uint8_t cfgidx,
+    #                                   usb_config_desc_t *cfgdesc);
+    lib.openusb_parse_config_desc.argtypes = [
+                _openusb_handle,
+                _openusb_devid,
+                POINTER(c_uint8),
+                c_uint16,
+                c_uint8,
+                POINTER(_usb_config_desc)
+            ]
+    lib.openusb_parse_config_desc.restype = c_int32
+
+    # int32_t openusb_parse_interface_desc(openusb_handle_t handle,
+    #                                      openusb_devid_t devid,
+    #                                      uint8_t *buffer,
+    #                                      uint16_t buflen,
+    #                                      uint8_t cfgidx,
+    #                                      uint8_t ifcidx,
+    #                                      uint8_t alt,
+    #                                      usb_interface_desc_t *ifcdesc);
+    lib.openusb_parse_interface_desc.argtypes = [
+                    _openusb_handle,
+                    _openusb_devid,
+                    POINTER(c_uint8),
+                    c_uint16,
+                    c_uint8,
+                    c_uint8,
+                    c_uint8,
+                    POINTER(_usb_interface_desc)
+                ]
+
+    lib.openusb_parse_interface_desc.restype = c_int32
+     
+    # int32_t openusb_parse_endpoint_desc(openusb_handle_t handle,
+    #                                     openusb_devid_t devid,
+    #                                     uint8_t *buffer,
+    #                                     uint16_t buflen,
+    #                                     uint8_t cfgidx,
+    #                                     uint8_t ifcidx,
+    #                                     uint8_t alt,
+    #                                     uint8_t eptidx,
+    #                                     usb_endpoint_desc_t *eptdesc);
+    lib.openusb_parse_endpoint_desc.argtypes = [
+                    _openusb_handle,
+                    _openusb_devid,
+                    POINTER(c_uint8),
+                    c_uint16,
+                    c_uint8,
+                    c_uint8,
+                    c_uint8,
+                    c_uint8,
+                    POINTER(_usb_endpoint_desc)
+                ]
+
+    lib.openusb_parse_interface_desc.restype = c_int32
+
+    # const char *openusb_strerror(int32_t error );
+    lib.openusb_strerror.argtypes = [c_int32]
+    lib.openusb_strerror.restype = c_char_p
+
+    # int32_t openusb_ctrl_xfer(openusb_dev_handle_t dev,
+    #                           uint8_t ifc,
+    #                           uint8_t ept,
+    #                           openusb_ctrl_request_t *ctrl);
+    lib.openusb_ctrl_xfer.argtypes = [
+            _openusb_dev_handle,
+            c_uint8,
+            c_uint8,
+            POINTER(_openusb_ctrl_request)
+        ]
+
+    lib.openusb_ctrl_xfer.restype = c_int32
+
+    # int32_t openusb_intr_xfer(openusb_dev_handle_t dev,
+    #                           uint8_t ifc,
+    #                           uint8_t ept,
+    #                           openusb_intr_request_t *intr);
+    lib.openusb_intr_xfer.argtypes = [
+                _openusb_dev_handle,
+                c_uint8,
+                c_uint8,
+                POINTER(_openusb_intr_request)
+            ]
+
+    lib.openusb_bulk_xfer.restype = c_int32
+
+    # int32_t openusb_bulk_xfer(openusb_dev_handle_t dev,
+    #                           uint8_t ifc,
+    #                           uint8_t ept,
+    #                           openusb_bulk_request_t *bulk);
+    lib.openusb_bulk_xfer.argtypes = [
+            _openusb_dev_handle,
+            c_uint8,
+            c_uint8,
+            POINTER(_openusb_bulk_request)
+        ]
+
+    lib.openusb_bulk_xfer.restype = c_int32
+
+    # int32_t openusb_isoc_xfer(openusb_dev_handle_t dev,
+    #                           uint8_t ifc,
+    #                           uint8_t ept,
+    #                           openusb_isoc_request_t *isoc);
+    lib.openusb_isoc_xfer.argtypes = [
+            _openusb_dev_handle,
+            c_uint8,
+            c_uint8,
+            POINTER(_openusb_isoc_request)
+        ]
+
+    lib.openusb_isoc_xfer.restype = c_int32
+
+def _check(retval):
+    if retval.value != 0:
+        from usb.core import USBError
+        raise USBError(_lib.openusb_strerror(retval).value)
+    return retval
+
+class _Context(object):
+    def __init__(self):
+        self.handle = _openusb_handle()
+        _check(_lib.openusb_init(0, byref(self.handle)))
+    def __del__(self):
+        _lib.openusb_fini(self.handle)
+
+class _BusIterator(object):
+    def __init__(self):
+        self.buslist = POINTER(openusb_busid)()
+        num_busids = c_uint32()
+        _check(_lib.openusb_get_busid_list(_ctx.handle,
+                                           byref(self.buslist),
+                                           byref(num_busids)))
+        self.num_busids = num_busids.value
+    def __iter__(self):
+        for i in range(self.num_busids):
+            yield self.buslist[i]
+    def __del__(self):
+        _lib.openusb_free_busid_list(self.buslist)
+
+class _DevIterator(object):
+    def __init__(self, busid):
+        self.devlist = POINTER(_openusb_devid)()
+        num_devids = c_uint32()
+        _check(_lib.openusb_get_devids_by_bus(_ctx.handle,
+                                              busid,
+                                              byref(self.devlist),
+                                              byref(num_devids)))
+        self.num_devids = num_devids.value
+    def __iter__(self):
+        for i in range(self.num_devids):
+            yield self.devlist[i]
+    def __del__(self):
+        _lib.openusb_free_devid_list(self.devlist)
+
+class _OpenUSB(usb.backend.IBackend):
+    @methodtrace(_logger)
+    def enumerate_devices(self):
+        for bus in _BusIterator():
+            for devid in _DevIterator(bus):
+                yield devid
+
+    @methodtrace(_logger)
+    def get_device_descriptor(self, dev):
+        desc = _usb_device_desc()
+        _check(_lib.openusb_parse_device_desc(_ctx.handle,
+                                              dev,
+                                              None,
+                                              0,
+                                              byref(desc)))
+        return desc
+
+    @methodtrace(_logger)
+    def get_configuration_descriptor(self, dev, config):
+        desc = _usb_config_desc()
+        _check(_lib.openusb_parse_config_desc(_ctx.handle,
+                                              dev,
+                                              None,
+                                              0,
+                                              config,
+                                              byref(desc)))
+        return desc
+
+    @methodtrace(_logger)
+    def get_interface_descriptor(self, dev, intf, alt, config):
+        desc = _usb_interface_desc()
+        _check(_lib.openusb_parse_interface_desc(_ctx.handle,
+                                                 dev,
+                                                 None,
+                                                 0,
+                                                 config,
+                                                 intf,
+                                                 alt,
+                                                 byref(desc)))
+        return desc
+
+    @methodtrace(_logger)
+    def get_endpoint_descriptor(self, dev, ep, intf, alt, config):
+        desc = _usb_endpoint_desc()
+        _check(_lib.openusb_parse_endpoint_desc(_ctx.handle,
+                                                dev,
+                                                None,
+                                                0,
+                                                config,
+                                                intf,
+                                                alt,
+                                                ep,
+                                                byref(desc)))
+        return desc
+
+    @methodtrace(_logger)
+    def open_device(self, dev):
+        handle = _openusb_dev_handle()
+        _check(_lib.openusb_open_device(_ctx.handle, dev, 0, byref(handle)))
+        return handle
+
+    @methodtrace(_logger)
+    def close_device(self, dev_handle):
+        _lib.openusb_close_device(dev_handle)
+
+    @methodtrace(_logger)
+    def set_configuration(self, dev_handle, config_value):
+        _check(_lib.openusb_set_configuration(dev_handle, config_value))
+
+    @methodtrace(_logger)
+    def get_configuration(self, dev_handle):
+        config = c_uint8()
+        _check(_lib.openusb_get_configuration(dev_handle, byref(config)))
+        return config.value
+
+    @methodtrace(_logger)
+    def set_interface_altsetting(self, dev_handle, intf, altsetting):
+        _check(_lib.set_altsetting(dev_handle, intf, altsetting))
+
+    @methodtrace(_logger)
+    def claim_interface(self, dev_handle, intf):
+        _check(_lib.openusb_claim_interface(dev_handle, intf, 0))
+
+    @methodtrace(_logger)
+    def release_interface(self, dev_handle, intf):
+        _lib.openusb_release_interface(dev_handle, intf)
+
+    @methodtrace(_logger)
+    def bulk_write(self, dev_handle, ep, intf, data, timeout):
+        request = _openusb_bulk_request()
+        memset(byref(request), 0, sizeof(request))
+        request.payload, request.length = data.buffer_info()
+        request.timeout = timeout
+        _check(_lib.openusb_bulk_xfer(dev_handle, intf, ep, byref(request)))
+        return request.transfered_bytes.value
+
+    @methodtrace(_logger)
+    def bulk_read(self, dev_handle, ep, intf, size, timeout):
+        request = _openusb_bulk_request()
+        buffer = array.array('B', '\x00' * size)
+        memset(byref(request), 0, sizeof(request))
+        request.payload, request.length = buffer.buffer_info()
+        request.timeout = timeout
+        _check(_lib.openusb_bulk_xfer(dev_handle, intf, ep, byref(request)))
+        return buffer[:request.transfered_bytes.value]
+
+    @methodtrace(_logger)
+    def intr_write(self, dev_handle, ep, intf, data, timeout):
+        request = _openusb_intr_request()
+        memset(byref(request), 0, sizeof(request))
+        payload, request.length = data.buffer_info()
+        request.payload = cast(payload, POINTER(c_uint8))
+        request.timeout = timeout
+        _check(_lib.openusb_intr_xfer(dev_handle, intf, ep, byref(request)))
+        return request.transfered_bytes.value
+
+    @methodtrace(_logger)
+    def intr_read(self, dev_handle, ep, intf, size, timeout):
+        request = _openusb_intr_request()
+        buffer = array.array('B', '\x00' * size)
+        memset(byref(request), 0, sizeof(request))
+        payload, request.length = buffer.buffer_info()
+        request.payload = cast(payload, POINTER(c_uint8))
+        request.timeout = timeout
+        _check(_lib.openusb_intr_xfer(dev_handle, intf, ep, byref(request)))
+        return buffer[:request.transfered_bytes.value]
+
+# TODO: implement isochronous
+#    @methodtrace(_logger)
+#    def iso_write(self, dev_handle, ep, intf, data, timeout):
+#       pass
+
+#    @methodtrace(_logger)
+#    def iso_read(self, dev_handle, ep, intf, size, timeout):
+#        pass
+
+    @methodtrace(_logger)
+    def ctrl_transfer(self,
+                      dev_handle,
+                      bmRequestType,
+                      bRequest,
+                      wValue,
+                      wIndex,
+                      data_or_wLength,
+                      timeout):
+        request = _openusb_ctrl_request()
+        request.setup.bmRequestType = bmRequestType
+        request.setup.bRequest = bRequest
+        request.setup.wValue
+        request.setup.wIndex
+        request.timeout = timeout
+
+        direction = usb.util.ctrl_direction(bmRequestType)
+
+        if direction == ENDPOINT_OUT:
+            buffer = data_or_wLength
+        else:
+            buffer = array.array('B', '\x00' * data_or_wLength)
+
+        payload, request.length = buffer.buffer_info()
+        request.payload = cast(payload, POINTER(c_uint8))
+
+        ret = _check(_lib.openusb_ctrl_xfer(dev_handle, 0, 0, byref(request)))
+
+        if direction == ENDPOINT_OUT:
+            ret
+        else:
+            buffer[:ret]
+
+    @methodtrace(_logger)
+    def reset_device(self, dev_handle):
+        _check(_lib.openusb_reset(dev_handle))
+
+def get_backend():
+    try:
+        global _lib, _ctx
+        if _lib is None:
+            _lib = _load_library()
+            _setup_prototypes(_lib)
+            _ctx = _Context()
+        return _OpenUSB()
+    except Exception:
+        _logger.error('Error loading OpenUSB backend', exc_info=True)
+        return None

+ 252 - 0
pyusb/build/lib.linux-armv6l-2.7/usb/control.py

@@ -0,0 +1,252 @@
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+r"""usb.control - USB standard control requests
+
+This module exports:
+
+get_status - get recipeint status
+clear_feature - clear a recipient feature
+set_feature - set a recipient feature
+get_descriptor - get a device descriptor
+set_descriptor - set a device descriptor
+get_configuration - get a device configuration
+set_configuration - set a device configuration
+get_interface - get a device interface
+set_interface - set a device interface
+"""
+
+__author__ = 'Wander Lairson Costa'
+
+__all__ = ['get_status',
+           'clear_feature',
+           'set_feature',
+           'get_descriptor',
+           'set_descriptor',
+           'get_configuration',
+           'set_configuration',
+           'get_interface',
+           'set_interface',
+           'ENDPOINT_HALT',
+           'FUNCTION_SUSPEND',
+           'DEVICE_REMOTE_WAKEUP',
+           'U1_ENABLE',
+           'U2_ENABLE',
+           'LTM_ENABLE']
+
+import usb.util as util
+import usb.core as core
+
+def _parse_recipient(recipient, direction):
+    if recipient is None:
+        r = util.CTRL_RECIPIENT_DEVICE
+        wIndex = 0
+    elif isinstance(recipient, core.Interface):
+        r = util.CTRL_RECIPIENT_INTERFACE
+        wIndex = recipient.bInterfaceNumber
+    elif isinstance(recipient, core.Endpoint):
+        r = util.CTRL_RECIPIENT_ENDPOINT
+        wIndex = recipient.bEndpointAddress
+    else:
+        raise ValueError('Invalid recipient.')
+    bmRequestType = util.build_request_type(
+                            direction,
+                            util.CTRL_TYPE_STANDARD,
+                            r
+                        )
+    return (bmRequestType, wIndex)
+
+# standard feature selectors from USB 2.0/3.0
+ENDPOINT_HALT = 0
+FUNCTION_SUSPEND = 0
+DEVICE_REMOTE_WAKEUP = 1
+U1_ENABLE = 48
+U2_ENABLE = 49
+LTM_ENABLE = 50
+
+def get_status(dev, recipient = None):
+    r"""Return the status for the specified recipient.
+
+    dev is the Device object to which the request will be
+    sent to.
+
+    The recipient can be None (on which the status will be queried
+    on the device), an Interface or Endpoint descriptors.
+
+    The status value is returned as an integer with the lower
+    word being the two bytes status value.
+    """
+    bmRequestType, wIndex = _parse_recipient(recipient, util.CTRL_IN)
+    ret = dev.ctrl_transfer(bmRequestType = bmRequestType,
+                            bRequest = 0x00,
+                            wIndex = wIndex,
+                            data_or_wLength = 2)
+    return ret[0] | (ret[1] << 8)
+
+def clear_feature(dev, feature, recipient = None):
+    r"""Clear/disable a specific feature.
+
+    dev is the Device object to which the request will be
+    sent to.
+
+    feature is the feature you want to disable.
+
+    The recipient can be None (on which the status will be queried
+    on the device), an Interface or Endpoint descriptors.
+    """
+    bmRequestType, wIndex = _parse_recipient(recipient, util.CTRL_OUT)
+    dev.ctrl_transfer(bmRequestType = bmRequestType,
+                      bRequest = 0x01,
+                      wIndex = wIndex,
+                      wValue = feature)
+
+def set_feature(dev, feature, recipient = None):
+    r"""Set/enable a specific feature.
+
+    dev is the Device object to which the request will be
+    sent to.
+
+    feature is the feature you want to enable.
+
+    The recipient can be None (on which the status will be queried
+    on the device), an Interface or Endpoint descriptors.
+    """
+    bmRequestType, wIndex = _parse_recipient(recipient, util.CTRL_OUT)
+    dev.ctrl_transfer(bmRequestType = bmRequestType,
+                      bRequest = 0x03,
+                      wIndex = wIndex,
+                      wValue = feature)
+
+def get_descriptor(dev, desc_size, desc_type, desc_index, wIndex = 0):
+    r"""Return the specified descriptor.
+
+    dev is the Device object to which the request will be
+    sent to.
+
+    desc_size is the descriptor size.
+
+    desc_type and desc_index are the descriptor type and index,
+    respectively. wIndex index is used for string descriptors
+    and represents the Language ID. For other types of descriptors,
+    it is zero.
+    """
+    wValue = desc_index | (desc_type << 8)
+    bmRequestType = util.build_request_type(
+                        util.CTRL_IN,
+                        util.CTRL_TYPE_STANDARD,
+                        util.CTRL_RECIPIENT_DEVICE
+                    )
+    return dev.ctrl_transfer(
+            bmRequestType = bmRequestType,
+            bRequest = 0x06,
+            wValue = wValue,
+            wIndex = wIndex,
+            data_or_wLength = desc_size
+        )
+
+def set_descriptor(dev, desc, desc_type, desc_index, wIndex = None):
+    r"""Update an existing descriptor or add a new one.
+
+    dev is the Device object to which the request will be
+    sent to.
+
+    The desc parameter is the descriptor to be sent to the device.
+    desc_type and desc_index are the descriptor type and index,
+    respectively. wIndex index is used for string descriptors
+    and represents the Language ID. For other types of descriptors,
+    it is zero.
+    """
+    wValue = desc_index | (desc_type << 8)
+    bmRequestType = util.build_request_type(
+                        util.CTRL_OUT,
+                        util.CTRL_TYPE_STANDARD,
+                        util.CTRL_RECIPIENT_DEVICE
+                    )
+    dev.ctrl_transfer(
+        bmRequestType = bmRequestType,
+        bRequest = 0x07,
+        wValue = wValue,
+        wIndex = wIndex,
+        data_or_wLength = desc
+    )
+
+def get_configuration(dev):
+    r"""Get the current active configuration of the device.
+
+    dev is the Device object to which the request will be
+    sent to.
+
+    This function differs from the Device.get_active_configuration
+    method because the later may use cached data, while this
+    function always does a device request.
+    """
+    bmRequestType = util.build_request_type(
+                            util.CTRL_IN,
+                            util.CTRL_TYPE_STANDARD,
+                            util.CTRL_RECIPIENT_DEVICE
+                        )
+    return dev.ctrl_transfer(
+                bmRequestType,
+                bRequest = 0x08,
+                data_or_wLength = 1
+            )[0]
+
+def set_configuration(dev, bConfigurationNumber):
+    r"""Set the current device configuration.
+
+    dev is the Device object to which the request will be
+    sent to.
+    """
+    dev.set_configuration(bConfigurationNumber)
+
+def get_interface(dev, bInterfaceNumber):
+    r"""Get the current alternate setting of the interface.
+
+    dev is the Device object to which the request will be
+    sent to.
+    """
+    bmRequestType = util.build_request_type(
+                            util.CTRL_IN,
+                            util.CTRL_TYPE_STANDARD,
+                            util.CTRL_RECIPIENT_INTERFACE
+                        )
+    return dev.ctrl_transfer(
+                bmRequestType = bmRequestType,
+                bRequest = 0x0a,
+                wIndex = bInterfaceNumber,
+                data_or_wLength = 1
+            )[0]
+
+def set_interface(dev, bInterfaceNumber, bAlternateSetting):
+    r"""Set the alternate setting of the interface.
+
+    dev is the Device object to which the request will be
+    sent to.
+    """
+    dev.set_interface_altsetting(bInterfaceNumber, bAlternateSetting)
+

+ 839 - 0
pyusb/build/lib.linux-armv6l-2.7/usb/core.py

@@ -0,0 +1,839 @@
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+r"""usb.core - Core USB features.
+
+This module exports:
+
+Device - a class representing a USB device.
+Configuration - a class representing a configuration descriptor.
+Interface - a class representing an interface descriptor.
+Endpoint - a class representing an endpoint descriptor.
+find() - a function to find USB devices.
+"""
+
+__author__ = 'Wander Lairson Costa'
+
+__all__ = ['Device', 'Configuration', 'Interface', 'Endpoint', 'find']
+
+import usb.util as util
+import copy
+import operator
+import usb._interop as _interop
+import logging
+
+_logger = logging.getLogger('usb.core')
+
+_DEFAULT_TIMEOUT = 1000
+
+def _set_attr(input, output, fields):
+    for f in fields:
+        setattr(output, f, int(getattr(input, f)))
+
+class _ResourceManager(object):
+    def __init__(self, dev, backend):
+        self.backend = backend
+        self._active_cfg_index = None
+        self.dev = dev
+        self.handle = None
+        self._claimed_intf = _interop._set()
+        self._alt_set = {}
+        self._ep_type_map = {}
+
+    def managed_open(self):
+        if self.handle is None:
+            self.handle = self.backend.open_device(self.dev)
+        return self.handle
+
+    def managed_close(self):
+        if self.handle is not None:
+            self.backend.close_device(self.handle)
+            self.handle = None
+
+    def managed_set_configuration(self, device, config):
+        if config is None:
+            cfg = device[0]
+        elif isinstance(config, Configuration):
+            cfg = config
+        elif config == 0: # unconfigured state
+            class FakeConfiguration(object):
+                def __init__(self):
+                    self.index = None
+                    self.bConfigurationValue = 0
+            cfg = FakeConfiguration()
+        else:
+            cfg = util.find_descriptor(device, bConfigurationValue=config)
+        self.managed_open()
+        self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
+        # cache the index instead of the object to avoid cyclic references
+        # of the device and Configuration (Device tracks the _ResourceManager,
+        # which tracks the Configuration, which tracks the Device)
+        self._active_cfg_index = cfg.index
+        # after changing configuration, our alternate setting and endpoint type caches
+        # are not valid anymore
+        self._ep_type_map.clear()
+        self._alt_set.clear()
+
+    def managed_claim_interface(self, device, intf):
+        self.managed_open()
+        if intf is None:
+            cfg = self.get_active_configuration(device)
+            i = cfg[(0,0)].bInterfaceNumber
+        elif isinstance(intf, Interface):
+            i = intf.bInterfaceNumber
+        else:
+            i = intf
+        if i not in self._claimed_intf:
+            self.backend.claim_interface(self.handle, i)
+            self._claimed_intf.add(i)
+
+    def managed_release_interface(self, device, intf):
+        if intf is None:
+            cfg = self.get_active_configuration(device)
+            i = cfg[(0,0)].bInterfaceNumber
+        elif isinstance(intf, Interface):
+            i = intf.bInterfaceNumber
+        else:
+            i = intf
+        if i in self._claimed_intf:
+            self.backend.release_interface(self.handle, i)
+            self._claimed_intf.remove(i)
+
+    def managed_set_interface(self, device, intf, alt):
+        if intf is None:
+            i = self.get_interface(device, intf)
+        elif isinstance(intf, Interface):
+            i = intf
+        else:
+            cfg = self.get_active_configuration(device)
+            if alt is not None:
+                i = util.find_descriptor(cfg, bInterfaceNumber=intf, bAlternateSetting=alt)
+            else:
+                i = util.find_descriptor(cfg, bInterfaceNumber=intf)
+        self.managed_claim_interface(device, i)
+        if alt is None:
+            alt = i.bAlternateSetting
+        self.backend.set_interface_altsetting(self.handle, i.bInterfaceNumber, alt)
+        self._alt_set[i.bInterfaceNumber] = alt
+
+    def get_interface(self, device, intf):
+        # TODO: check the viability of issuing a GET_INTERFACE
+        # request when we don't have a alternate setting cached
+        if intf is None:
+            cfg = self.get_active_configuration(device)
+            return cfg[(0,0)]
+        elif isinstance(intf, Interface):
+            return intf
+        else:
+            cfg = self.get_active_configuration(device)
+            if intf in self._alt_set:
+                return util.find_descriptor(cfg,
+                                            bInterfaceNumber=intf,
+                                            bAlternateSetting=self._alt_set[intf])
+            else:
+                return util.find_descriptor(cfg, bInterfaceNumber=intf)
+
+    def get_active_configuration(self, device):
+        if self._active_cfg_index is None:
+            cfg = util.find_descriptor(
+                    device,
+                    bConfigurationValue=self.backend.get_configuration(self.handle)
+                )
+            if cfg is None:
+                raise USBError('Configuration not set')
+            self._active_cfg_index = cfg.index
+            return cfg
+        return device[self._active_cfg_index]
+
+    def get_endpoint_type(self, device, address, intf):
+        intf = self.get_interface(device, intf)
+        key = (address, intf.bInterfaceNumber, intf.bAlternateSetting)
+        try:
+            return self._ep_type_map[key]
+        except KeyError:
+            e = util.find_descriptor(intf, bEndpointAddress=address)
+            etype = util.endpoint_type(e.bmAttributes)
+            self._ep_type_map[key] = etype
+            return etype
+
+    def release_all_interfaces(self, device):
+        claimed = copy.copy(self._claimed_intf)
+        for i in claimed:
+            self.managed_release_interface(device, i)
+
+    def dispose(self, device, close_handle = True):
+        self.release_all_interfaces(device)
+        if close_handle:
+            self.managed_close()
+        self._ep_type_map.clear()
+        self._alt_set.clear()
+        self._active_cfg_index = None
+
+class USBError(IOError):
+    r"""Exception class for USB errors.
+    
+    Backends must raise this exception when USB related errors occur.
+    """
+    pass
+
+class Endpoint(object):
+    r"""Represent an endpoint object.
+
+    This class contains all fields of the Endpoint Descriptor
+    according to the USB Specification. You may access them as class
+    properties.  For example, to access the field bEndpointAddress
+    of the endpoint descriptor:
+
+    >>> import usb.core
+    >>> dev = usb.core.find()
+    >>> for cfg in dev:
+    >>>     for i in cfg:
+    >>>         for e in i:
+    >>>             print e.bEndpointAddress
+    """
+
+    def __init__(self, device, endpoint, interface = 0,
+                    alternate_setting = 0, configuration = 0):
+        r"""Initialize the Endpoint object.
+
+        The device parameter is the device object returned by the find()
+        function. endpoint is the endpoint logical index (not the endpoint address).
+        The configuration parameter is the logical index of the
+        configuration (not the bConfigurationValue field). The interface
+        parameter is the interface logical index (not the bInterfaceNumber field)
+        and alternate_setting is the alternate setting logical index (not the
+        bAlternateSetting value).  Not every interface has more than one alternate
+        setting.  In this case, the alternate_setting parameter should be zero.
+        By "logical index" we mean the relative order of the configurations returned by the
+        peripheral as a result of GET_DESCRIPTOR request.
+        """
+        self.device = device
+        intf = Interface(device, interface, alternate_setting, configuration)
+        self.interface = intf.bInterfaceNumber
+        self.index = endpoint
+
+        backend = device._ctx.backend
+
+        desc = backend.get_endpoint_descriptor(
+                    device._ctx.dev,
+                    endpoint,
+                    interface,
+                    alternate_setting,
+                    configuration
+                )
+
+        _set_attr(
+                desc,
+                self,
+                (
+                    'bLength',
+                    'bDescriptorType',
+                    'bEndpointAddress',
+                    'bmAttributes',
+                    'wMaxPacketSize',
+                    'bInterval',
+                    'bRefresh',
+                    'bSynchAddress'
+                )
+            )
+
+    def write(self, data, timeout = None):
+        r"""Write data to the endpoint.
+        
+        The parameter data contains the data to be sent to the endpoint and
+        timeout is the time limit of the operation. The transfer type and
+        endpoint address are automatically inferred.
+
+        The method returns the number of bytes written.
+
+        For details, see the Device.write() method.
+        """
+        return self.device.write(self.bEndpointAddress, data, self.interface, timeout)
+
+    def read(self, size, timeout = None):
+        r"""Read data from the endpoint.
+        
+        The parameter size is the number of bytes to read and timeout is the
+        time limit of the operation.The transfer type and endpoint address
+        are automatically inferred.
+
+        The method returns an array.array object with the data read.
+
+        For details, see the Device.read() method.
+        """
+        return self.device.read(self.bEndpointAddress, size, self.interface, timeout)
+
+class Interface(object):
+    r"""Represent an interface object.
+
+    This class contains all fields of the Interface Descriptor
+    according to the USB Specification. You may access them as class
+    properties.  For example, to access the field bInterfaceNumber
+    of the interface descriptor:
+
+    >>> import usb.core
+    >>> dev = usb.core.find()
+    >>> for cfg in dev:
+    >>>     for i in cfg:
+    >>>         print i.bInterfaceNumber
+    """
+
+    def __init__(self, device, interface = 0,
+            alternate_setting = 0, configuration = 0):
+        r"""Initialize the interface object.
+
+        The device parameter is the device object returned by the find()
+        function. The configuration parameter is the logical index of the
+        configuration (not the bConfigurationValue field). The interface
+        parameter is the interface logical index (not the bInterfaceNumber field)
+        and alternate_setting is the alternate setting logical index (not the
+        bAlternateSetting value).  Not every interface has more than one alternate
+        setting.  In this case, the alternate_setting parameter should be zero.
+        By "logical index" we mean the relative order of the configurations returned by the
+        peripheral as a result of GET_DESCRIPTOR request.
+        """
+        self.device = device
+        self.alternate_index = alternate_setting
+        self.index = interface
+        self.configuration = configuration
+
+        backend = device._ctx.backend
+
+        desc = backend.get_interface_descriptor(
+                    self.device._ctx.dev,
+                    interface,
+                    alternate_setting,
+                    configuration
+                )
+
+        _set_attr(
+                desc,
+                self,
+                (
+                    'bLength',
+                    'bDescriptorType',
+                    'bInterfaceNumber',
+                    'bAlternateSetting',
+                    'bNumEndpoints',
+                    'bInterfaceClass',
+                    'bInterfaceSubClass',
+                    'bInterfaceProtocol',
+                    'iInterface'
+                )
+            )
+
+    def set_altsetting(self):
+        r"""Set the interface alternate setting."""
+        self.device.set_interface_altsetting(
+            self.bInterfaceNumber,
+            self.bAlternateSetting
+        )
+
+    def __iter__(self):
+        r"""Iterate over all endpoints of the interface."""
+        for i in range(self.bNumEndpoints):
+            yield Endpoint(
+                    self.device,
+                    i,
+                    self.index,
+                    self.alternate_index,
+                    self.configuration
+                )
+    def __getitem__(self, index):
+        r"""Return the Endpoint object in the given position."""
+        return Endpoint(
+                self.device,
+                index,
+                self.index,
+                self.alternate_index,
+                self.configuration
+            )
+
+class Configuration(object):
+    r"""Represent a configuration object.
+ 
+    This class contains all fields of the Configuration Descriptor
+    according to the USB Specification. You may access them as class
+    properties.  For example, to access the field bConfigurationValue
+    of the configuration descriptor:
+
+    >>> import usb.core
+    >>> dev = usb.core.find()
+    >>> for cfg in dev:
+    >>>     print cfg.bConfigurationValue
+    """
+
+    def __init__(self, device, configuration = 0):
+        r"""Initialize the configuration object.
+
+        The device parameter is the device object returned by the find()
+        function. The configuration parameter is the logical index of the
+        configuration (not the bConfigurationValue field). By "logical index"
+        we mean the relative order of the configurations returned by the
+        peripheral as a result of GET_DESCRIPTOR request.
+        """
+        self.device = device
+        self.index = configuration
+
+        backend = device._ctx.backend
+
+        desc = backend.get_configuration_descriptor(
+                self.device._ctx.dev,
+                configuration
+            )
+
+        _set_attr(
+                desc,
+                self,
+                (
+                    'bLength',
+                    'bDescriptorType',
+                    'wTotalLength',
+                    'bNumInterfaces',
+                    'bConfigurationValue',
+                    'iConfiguration',
+                    'bmAttributes',
+                    'bMaxPower'
+                )
+            )
+
+    def set(self):
+        r"""Set this configuration as the active one."""
+        self.device.set_configuration(self.bConfigurationValue)
+
+    def __iter__(self):
+        r"""Iterate over all interfaces of the configuration."""
+        for i in range(self.bNumInterfaces):
+            alt = 0
+            try:
+                while True:
+                    yield Interface(self.device, i, alt, self.index)
+                    alt += 1
+            except (USBError, IndexError):
+                pass
+    def __getitem__(self, index):
+        r"""Return the Interface object in the given position.
+
+        index is a tuple of two values with interface index and
+        alternate setting index, respectivally. Example:
+
+        >>> interface = config[(0, 0)]
+        """
+        return Interface(self.device, index[0], index[1], self.index)
+
+
+class Device(object):
+    r"""Device object.
+    
+    This class contains all fields of the Device Descriptor according
+    to the USB Specification. You may access them as class properties.
+    For example, to access the field bDescriptorType of the device
+    descriptor:
+
+    >>> import usb.core
+    >>> dev = usb.core.find()
+    >>> dev.bDescriptorType
+
+    Additionally, the class provides methods to communicate with
+    the hardware. Typically, an application will first call the
+    set_configuration() method to put the device in a known configured
+    state, optionally call the set_interface_altsetting() to select the
+    alternate setting (if there is more than one) of the interface used,
+    and call the write() and read() method to send and receive data.
+
+    When working in a new hardware, one first try would be like this:
+
+    >>> import usb.core
+    >>> dev = usb.core.find(idVendor=myVendorId, idProduct=myProductId)
+    >>> dev.set_configuration()
+    >>> dev.write(1, 'test')
+
+    This sample finds the device of interest (myVendorId and myProductId should be
+    replaced by the corresponding values of your device), then configures the device
+    (by default, the configuration value is 1, which is a typical value for most
+    devices) and then writes some data to the endpoint 0x01.
+
+    Timeout values for the write, read and ctrl_transfer methods are specified in
+    miliseconds. If the parameter is omitted, Device.default_timeout value will
+    be used instead. This property can be set by the user at anytime.
+    """
+
+    def __init__(self, dev, backend):
+        r"""Initialize the Device object.
+
+        Library users should normally get a Device instance through
+        the find function. The dev parameter is the identification
+        of a device to the backend and its meaning is opaque outside
+        of it. The backend parameter is a instance of a backend
+        object.
+        """
+        self._ctx = _ResourceManager(dev, backend)
+        self.__default_timeout = _DEFAULT_TIMEOUT
+
+        desc = backend.get_device_descriptor(dev)
+
+        _set_attr(
+                desc,
+                self,
+                (
+                    'bLength',
+                    'bDescriptorType',
+                    'bcdUSB',
+                    'bDeviceClass',
+                    'bDeviceSubClass',
+                    'bDeviceProtocol',
+                    'bMaxPacketSize0',
+                    'idVendor',
+                    'idProduct',
+                    'bcdDevice',
+                    'iManufacturer',
+                    'iProduct',
+                    'iSerialNumber',
+                    'bNumConfigurations'
+                )
+            )
+
+    def set_configuration(self, configuration = None):
+        r"""Set the active configuration.
+        
+        The configuration parameter is the bConfigurationValue field of the
+        configuration you want to set as active. If you call this method
+        without parameter, it will use the first configuration found.
+        As a device hardly ever has more than one configuration, calling
+        the method without parameter is enough to get the device ready.
+        """
+        self._ctx.managed_set_configuration(self, configuration)
+
+    def get_active_configuration(self):
+        r"""Return a Configuration object representing the current configuration set."""
+        return self._ctx.get_active_configuration(self)
+
+    def set_interface_altsetting(self, interface = None, alternate_setting = None):
+        r"""Set the alternate setting for an interface.
+ 
+        When you want to use an interface and it has more than one alternate setting,
+        you should call this method to select the alternate setting you would like
+        to use. If you call the method without one or the two parameters, it will
+        be selected the first one found in the Device in the same way of set_configuration
+        method.
+
+        Commonly, an interface has only one alternate setting and this call is
+        not necessary. For most of the devices, either it has more than one alternate
+        setting or not, it is not harmful to make a call to this method with no arguments,
+        as devices will silently ignore the request when there is only one alternate
+        setting, though the USB Spec allows devices with no additional alternate setting
+        return an error to the Host in response to a SET_INTERFACE request.
+
+        If you are in doubt, you may want to call it with no arguments wrapped by
+        a try/except clause:
+
+        >>> try:
+        >>>     dev.set_interface_altsetting()
+        >>> except usb.core.USBError:
+        >>>     pass
+        """
+        self._ctx.managed_set_interface(self, interface, alternate_setting)
+
+    def reset(self):
+        r"""Reset the device."""
+        self._ctx.dispose(self, False)
+        self._ctx.backend.reset_device(self._ctx.handle)
+        self._ctx.dispose(self, True)
+
+    def write(self, endpoint, data, interface = None, timeout = None):
+        r"""Write data to the endpoint.
+
+        This method is used to send data to the device. The endpoint parameter
+        corresponds to the bEndpointAddress member whose endpoint you want to
+        communicate with. The interface parameter is the bInterfaceNumber field
+        of the interface descriptor which contains the endpoint. If you do not
+        provide one, the first one found will be used, as explained in the
+        set_interface_altsetting() method.
+
+        The data parameter should be a sequence like type convertible to
+        array type (see array module).
+
+        The timeout is specified in miliseconds.
+
+        The method returns the number of bytes written.
+        """
+        backend = self._ctx.backend
+
+        fn_map = {
+                    util.ENDPOINT_TYPE_BULK:backend.bulk_write,
+                    util.ENDPOINT_TYPE_INTR:backend.intr_write,
+                    util.ENDPOINT_TYPE_ISO:backend.iso_write
+                }
+
+        intf = self._ctx.get_interface(self, interface)
+        fn = fn_map[self._ctx.get_endpoint_type(self, endpoint, intf)]
+        self._ctx.managed_claim_interface(self, intf)
+
+        return fn(
+                self._ctx.handle,
+                endpoint,
+                intf.bInterfaceNumber,
+                _interop.as_array(data),
+                self.__get_timeout(timeout)
+            )
+
+    def read(self, endpoint, size, interface = None, timeout = None):
+        r"""Read data from the endpoint.
+
+        This method is used to receive data from the device. The endpoint parameter
+        corresponds to the bEndpointAddress member whose endpoint you want to
+        communicate with. The interface parameter is the bInterfaceNumber field
+        of the interface descriptor which contains the endpoint. If you do not
+        provide one, the first one found will be used, as explained in the
+        set_interface_altsetting() method. The size parameters tells how many
+        bytes you want to read.
+
+        The timeout is specified in miliseconds.
+
+        The method returns an array object with the data read.
+        """
+        backend = self._ctx.backend
+
+        fn_map = {
+                    util.ENDPOINT_TYPE_BULK:backend.bulk_read,
+                    util.ENDPOINT_TYPE_INTR:backend.intr_read,
+                    util.ENDPOINT_TYPE_ISO:backend.iso_read
+                }
+
+        intf = self._ctx.get_interface(self, interface)
+        fn = fn_map[self._ctx.get_endpoint_type(self, endpoint, intf)]
+        self._ctx.managed_claim_interface(self, intf)
+
+        return fn(
+                self._ctx.handle,
+                endpoint,
+                intf.bInterfaceNumber,
+                size,
+                self.__get_timeout(timeout)
+            )
+
+
+    def ctrl_transfer(self, bmRequestType, bRequest, wValue=0, wIndex=0,
+            data_or_wLength = None, timeout = None):
+        r"""Do a control transfer on the endpoint 0.
+
+        This method is used to issue a control transfer over the
+        endpoint 0(endpoint 0 is required to always be a control endpoint).
+
+        The parameters bmRequestType, bRequest, wValue and wIndex are the
+        same of the USB Standard Control Request format.
+
+        Control requests may or may not have a data payload to write/read.
+        In cases which it has, the direction bit of the bmRequestType
+        field is used to infere the desired request direction. For
+        host to device requests (OUT), data_or_wLength parameter is
+        the data payload to send, and it must be a sequence type convertible
+        to an array object. In this case, the return value is the number of data
+        payload written. For device to host requests (IN), data_or_wLength
+        is the wLength parameter of the control request specifying the
+        number of bytes to read in data payload. In this case, the return
+        value is the data payload read, as an array object.
+        """
+        if util.ctrl_direction(bmRequestType) == util.CTRL_OUT:
+            a = _interop.as_array(data_or_wLength)
+        elif data_or_wLength is None:
+            a = 0
+        else:
+            a = data_or_wLength
+
+        self._ctx.managed_open()
+
+        return self._ctx.backend.ctrl_transfer(
+                                    self._ctx.handle,
+                                    bmRequestType,
+                                    bRequest,
+                                    wValue,
+                                    wIndex,
+                                    a,
+                                    self.__get_timeout(timeout)
+                                )
+
+    def is_kernel_driver_active(self, interface):
+        r"""Determine if there is kernel driver associated with the interface.
+
+        If a kernel driver is active, and the object will be unable to perform I/O.
+        """
+        self._ctx.managed_open()
+        return self._ctx.backend.is_kernel_driver_active(self._ctx.handle, interface)
+
+    def detach_kernel_driver(self, interface):
+        r"""Detach a kernel driver.
+
+        If successful, you will then be able to perform I/O.
+        """
+        self._ctx.managed_open()
+        self._ctx.backend.detach_kernel_driver(self._ctx.handle, interface)
+
+    def attach_kernel_driver(self, interface):
+        r"""Re-attach an interface's kernel driver, which was previously
+        detached using detach_kernel_driver()."""
+        self._ctx.managed_open()
+        self._ctx.backend.attach_kernel_driver(self._ctx.handle, interface)
+
+    def __iter__(self):
+        r"""Iterate over all configurations of the device."""
+        for i in range(self.bNumConfigurations):
+            yield Configuration(self, i)
+
+    def __getitem__(self, index):
+        r"""Return the Configuration object in the given position."""
+        return Configuration(self, index)
+
+    def __del__(self):
+        self._ctx.dispose(self)
+
+    def __get_timeout(self, timeout):
+        if timeout is not None:
+            return timeout
+        return self.__default_timeout
+
+    def __set_def_tmo(self, tmo):
+        if tmo < 0:
+            raise ValueError('Timeout cannot be a negative value')
+        self.__default_timeout = tmo
+
+    def __get_def_tmo(self):
+        return self.__default_timeout
+
+    default_timeout = property(
+                        __get_def_tmo,
+                        __set_def_tmo,
+                        doc = 'Default timeout for transfer I/O functions'
+                    )
+
+def find(find_all=False, backend = None, custom_match = None, **args):
+    r"""Find an USB device and return it.
+
+    find() is the function used to discover USB devices.
+    You can pass as arguments any combination of the
+    USB Device Descriptor fields to match a device. For example:
+
+    find(idVendor=0x3f4, idProduct=0x2009)
+
+    will return the Device object for the device with
+    idVendor Device descriptor field equals to 0x3f4 and
+    idProduct equals to 0x2009.
+
+    If there is more than one device which matchs the criteria,
+    the first one found will be returned. If a matching device cannot
+    be found the function returns None. If you want to get all
+    devices, you can set the parameter find_all to True, then find
+    will return an list with all matched devices. If no matching device
+    is found, it will return an empty list. Example:
+
+    printers = find(find_all=True, bDeviceClass=7)
+
+    This call will get all the USB printers connected to the system.
+    (actually may be not, because some devices put their class
+     information in the Interface Descriptor).
+
+    You can also use a customized match criteria:
+
+    dev = find(custom_match = lambda d: d.idProduct=0x3f4 and d.idvendor=0x2009)
+
+    A more accurate printer finder using a customized match would be like
+    so:
+
+    def is_printer(dev):
+        import usb.util
+        if dev.bDeviceClass == 7:
+            return True
+        for cfg in dev:
+            if usb.util.find_descriptor(cfg, bInterfaceClass=7) is not None:
+                return True
+
+    printers = find(find_all=True, custom_match = is_printer)
+
+    Now even if the device class code is in the interface descriptor the
+    printer will be found.
+
+    You can combine a customized match with device descriptor fields. In this
+    case, the fields must match and the custom_match must return True. In the our
+    previous example, if we would like to get all printers belonging to the
+    manufacturer 0x3f4, the code would be like so:
+
+    printers = find(find_all=True, idVendor=0x3f4, custom_match=is_printer)
+
+    If you want to use find as a 'list all devices' function, just call
+    it with find_all = True:
+
+    devices = find(find_all=True)
+
+    Finally, you may pass a custom backend to the find function:
+
+    find(backend = MyBackend())
+
+    PyUSB has builtin backends for libusb 0.1, libusb 1.0 and OpenUSB.
+    If you do not supply a backend explicitly, find() function will select
+    one of the predefineds backends according to system availability.
+
+    Backends are explained in the usb.backend module.
+    """
+
+    def device_iter(k, v):
+        for dev in backend.enumerate_devices():
+            d = Device(dev, backend)
+            if (custom_match is None or custom_match(d)) and \
+                _interop._reduce(
+                        lambda a, b: a and b,
+                        map(
+                            operator.eq,
+                            v,
+                            map(lambda i: getattr(d, i), k)
+                        ),
+                        True
+                    ):
+                yield d
+
+    if backend is None:
+        import usb.backend.libusb10 as libusb10
+        import usb.backend.libusb01 as libusb01
+        import usb.backend.openusb as openusb
+
+        for m in (libusb10, openusb, libusb01):
+            backend = m.get_backend()
+            if backend is not None:
+                _logger.info('find(): using backend "%s"', m.__name__)
+                break
+        else:
+            raise ValueError('No backend available')
+
+    k, v = args.keys(), args.values()
+    
+    if find_all:
+        return [d for d in device_iter(k, v)]
+    else:
+        try:
+            return _interop._next(device_iter(k, v))
+        except StopIteration:
+            return None

+ 331 - 0
pyusb/build/lib.linux-armv6l-2.7/usb/legacy.py

@@ -0,0 +1,331 @@
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+import usb.core as core
+import usb.util as util
+import usb._interop as _interop
+import usb.control as control
+
+__author__ = 'Wander Lairson Costa'
+
+USBError = core.USBError
+
+CLASS_AUDIO = 1
+CLASS_COMM = 2
+CLASS_DATA = 10
+CLASS_HID = 3
+CLASS_HUB = 9
+CLASS_MASS_STORAGE = 8
+CLASS_PER_INTERFACE = 0
+CLASS_PRINTER = 7
+CLASS_VENDOR_SPEC = 255
+DT_CONFIG = 2
+DT_CONFIG_SIZE = 9
+DT_DEVICE = 1
+DT_DEVICE_SIZE = 18
+DT_ENDPOINT = 5
+DT_ENDPOINT_AUDIO_SIZE = 9
+DT_ENDPOINT_SIZE = 7
+DT_HID = 33
+DT_HUB = 41
+DT_HUB_NONVAR_SIZE = 7
+DT_INTERFACE = 4
+DT_INTERFACE_SIZE = 9
+DT_PHYSICAL = 35
+DT_REPORT = 34
+DT_STRING = 3
+ENDPOINT_ADDRESS_MASK = 15
+ENDPOINT_DIR_MASK = 128
+ENDPOINT_IN = 128
+ENDPOINT_OUT = 0
+ENDPOINT_TYPE_BULK = 2
+ENDPOINT_TYPE_CONTROL = 0
+ENDPOINT_TYPE_INTERRUPT = 3
+ENDPOINT_TYPE_ISOCHRONOUS = 1
+ENDPOINT_TYPE_MASK = 3
+ERROR_BEGIN = 500000
+MAXALTSETTING = 128
+MAXCONFIG = 8
+MAXENDPOINTS = 32
+MAXINTERFACES = 32
+RECIP_DEVICE = 0
+RECIP_ENDPOINT = 2
+RECIP_INTERFACE = 1
+RECIP_OTHER = 3
+REQ_CLEAR_FEATURE = 1
+REQ_GET_CONFIGURATION = 8
+REQ_GET_DESCRIPTOR = 6
+REQ_GET_INTERFACE = 10
+REQ_GET_STATUS = 0
+REQ_SET_ADDRESS = 5
+REQ_SET_CONFIGURATION = 9
+REQ_SET_DESCRIPTOR = 7
+REQ_SET_FEATURE = 3
+REQ_SET_INTERFACE = 11
+REQ_SYNCH_FRAME = 12
+TYPE_CLASS = 32
+TYPE_RESERVED = 96
+TYPE_STANDARD = 0
+TYPE_VENDOR = 64
+
+class Endpoint(object):
+    r"""Endpoint descriptor object."""
+    def __init__(self, ep):
+        self.address = ep.bEndpointAddress
+        self.interval = ep.bInterval
+        self.maxPacketSize = ep.wMaxPacketSize
+        self.type = util.endpoint_type(ep.bmAttributes)
+
+class Interface(object):
+    r"""Interface descriptor object."""
+    def __init__(self, intf):
+        self.alternateSetting = intf.bAlternateSetting
+        self.interfaceNumber = intf.bInterfaceNumber
+        self.iInterface = intf.iInterface
+        self.interfaceClass = intf.bInterfaceClass
+        self.interfaceSubClass = intf.bInterfaceSubClass
+        self.interfaceProtocol = intf.bInterfaceProtocol
+        self.endpoints = [Endpoint(e) for e in intf]
+
+class Configuration(object):
+    r"""Configuration descriptor object."""
+    def __init__(self, cfg):
+        self.iConfiguration = cfg.iConfiguration
+        self.maxPower = cfg.bMaxPower << 2
+        self.remoteWakeup = (cfg.bmAttributes >> 5) & 1
+        self.selfPowered = (cfg.bmAttributes >> 6) & 1
+        self.totalLength = cfg.wTotalLength
+        self.value = cfg.bConfigurationValue
+        self.interfaces = [
+                            list(g) for k, g in _interop._groupby(
+                                    _interop._sorted(
+                                        [Interface(i) for i in cfg],
+                                        key=lambda i: i.interfaceNumber
+                                    ),
+                                    lambda i: i.alternateSetting)
+                        ]
+
+class DeviceHandle(object):
+    def __init__(self, dev):
+        self.dev = dev
+        self.__claimed_interface = -1
+
+    def bulkWrite(self, endpoint, buffer, timeout = 100):
+        r"""Perform a bulk write request to the endpoint specified.
+
+            Arguments:
+                endpoint: endpoint number.
+                buffer: sequence data buffer to write.
+                        This parameter can be any sequence type.
+                timeout: operation timeout in miliseconds. (default: 100)
+                         Returns the number of bytes written.
+        """
+        return self.dev.write(endpoint, buffer, self.__claimed_interface, timeout)
+
+    def bulkRead(self, endpoint, size, timeout = 100):
+        r"""Performs a bulk read request to the endpoint specified.
+
+            Arguments:
+                endpoint: endpoint number.
+                size: number of bytes to read.
+                timeout: operation timeout in miliseconds. (default: 100)
+            Return a tuple with the data read.
+        """
+        return self.dev.read(endpoint, size, self.__claimed_interface, timeout)
+
+    def interruptWrite(self, endpoint, buffer, timeout = 100):
+        r"""Perform a interrupt write request to the endpoint specified.
+
+            Arguments:
+                endpoint: endpoint number.
+                buffer: sequence data buffer to write.
+                        This parameter can be any sequence type.
+                timeout: operation timeout in miliseconds. (default: 100)
+                         Returns the number of bytes written.
+        """
+        return self.dev.write(endpoint, buffer, self.__claimed_interface, timeout)
+
+    def interruptRead(self, endpoint, size, timeout = 100):
+        r"""Performs a interrupt read request to the endpoint specified.
+
+            Arguments:
+                endpoint: endpoint number.
+                size: number of bytes to read.
+                timeout: operation timeout in miliseconds. (default: 100)
+            Return a tuple with the data read.
+        """
+        return self.dev.read(endpoint, size, self.__claimed_interface, timeout)
+
+    def controlMsg(self, requestType, request, buffer, value = 0, index = 0, timeout = 100):
+        r"""Perform a control request to the default control pipe on a device.
+
+        Arguments:
+            requestType: specifies the direction of data flow, the type
+                         of request, and the recipient.
+            request: specifies the request.
+            buffer: if the transfer is a write transfer, buffer is a sequence 
+                    with the transfer data, otherwise, buffer is the number of
+                    bytes to read.
+            value: specific information to pass to the device. (default: 0)
+                   index: specific information to pass to the device. (default: 0)
+            timeout: operation timeout in miliseconds. (default: 100)
+        Return the number of bytes written.
+        """
+        return self.dev.ctrl_transfer(
+                    requestType,
+                    request,
+                    wValue = value,
+                    wIndex = index,
+                    data_or_wLength = buffer,
+                    timeout = timeout
+                )
+
+    def clearHalt(self, endpoint):
+        r"""Clears any halt status on the specified endpoint.
+
+        Arguments:
+            endpoint: endpoint number.
+        """
+        cfg = self.dev.get_active_configuration()
+        intf = util.find_descriptor(cfg, bInterfaceNumber = self.__claimed_interface)
+        e = util.find_descriptor(intf, bEndpointAddress = endpoint)
+        control.clear_feature(self.dev, control.ENDPOINT_HALT, e)
+
+    def claimInterface(self, interface):
+        r"""Claims the interface with the Operating System.
+
+        Arguments:
+            interface: interface number or an Interface object.
+        """
+        util.claim_interface(self.dev, interface)
+        self.__claimed_interface = interface
+
+    def releaseInterface(self):
+        r"""Release an interface previously claimed with claimInterface."""
+        util.release_interface(self.dev, self.__claimed_interface)
+        self.__claimed_interface = -1
+
+    def reset(self):
+        r"""Reset the specified device by sending a RESET
+            down the port it is connected to."""
+        self.dev.reset()
+
+    def resetEndpoint(self, endpoint):
+        r"""Reset all states for the specified endpoint.
+
+        Arguments:
+            endpoint: endpoint number.
+        """
+        self.clearHalt(endpoint)
+
+    def setConfiguration(self, configuration):
+        r"""Set the active configuration of a device.
+
+        Arguments:
+            configuration: a configuration value or a Configuration object.
+        """
+        self.dev.set_configuration(configuration)
+
+    def setAltInterface(self, alternate):
+        r"""Sets the active alternate setting of the current interface.
+
+        Arguments:
+            alternate: an alternate setting number or an Interface object.
+        """
+        self.dev.set_interface_altsetting(self.__claimed_interface, alternate)
+
+    def getString(self, index, length, langid = None):
+        r"""Retrieve the string descriptor specified by index
+            and langid from a device.
+
+        Arguments:
+            index: index of descriptor in the device.
+            length: number of bytes of the string
+            langid: Language ID. If it is omittedi, will be
+                    used the first language.
+        """
+        return util.get_string(self.dev, length, index, langid).encode('ascii')
+
+    def getDescriptor(self, desc_type, desc_index, length, endpoint = -1):
+        r"""Retrieves a descriptor from the device identified by the type
+        and index of the descriptor.
+
+        Arguments:
+            desc_type: descriptor type.
+            desc_index: index of the descriptor.
+            len: descriptor length.
+            endpoint: ignored.
+        """
+        return control.get_descriptor(self.dev, length, desc_type, desc_index)
+
+    def detachKernelDriver(self, interface):
+        r"""Detach a kernel driver from the interface (if one is attached,
+            we have permission and the operation is supported by the OS)
+
+        Arguments:
+            interface: interface number or an Interface object.
+        """
+        self.dev.detach_kernel_driver(interface)
+
+class Device(object):
+    r"""Device descriptor object"""
+    def __init__(self, dev):
+        self.deviceClass = dev.bDeviceClass
+        self.deviceSubClass = dev.bDeviceSubClass
+        self.deviceProtocol = dev.bDeviceProtocol
+        self.deviceVersion = dev.bcdDevice
+        self.devnum = None
+        self.filename = ''
+        self.iManufacturer = dev.iManufacturer
+        self.iProduct = dev.iProduct
+        self.iSerialNumber = dev.iSerialNumber
+        self.idProduct = dev.idProduct
+        self.idVendor = dev.idVendor
+        self.maxPacketSize = dev.bMaxPacketSize0
+        self.usbVersion = dev.bcdUSB
+        self.configurations = [Configuration(c) for c in dev]
+        self.dev = dev
+
+    def open(self):
+        r"""Open the device for use.
+
+        Return a DeviceHandle object
+        """
+        return DeviceHandle(self.dev)
+
+class Bus(object):
+    r"""Bus object."""
+    def __init__(self):
+        self.dirname = ''
+        self.localtion = 0
+        self.devices = [Device(d) for d in core.find(find_all=True)]
+
+def busses():
+    r"""Return a tuple with the usb busses."""
+    return (Bus(),)
+

+ 260 - 0
pyusb/build/lib.linux-armv6l-2.7/usb/util.py

@@ -0,0 +1,260 @@
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+r"""usb.util - Utility functions.
+
+This module exports:
+
+endpoint_address - return the endpoint absolute address.
+endpoint_direction - return the endpoint transfer direction.
+endpoint_type - return the endpoint type
+ctrl_direction - return the direction of a control transfer
+build_request_type - build a bmRequestType field of a control transfer.
+find_descriptor - find an inner descriptor.
+claim_interface - explicitly claim an interface.
+release_interface - explicitly release an interface.
+dispose_resources - release internal resources allocated by the object.
+get_string - retrieve a string descriptor from the device.
+"""
+
+__author__ = 'Wander Lairson Costa'
+
+import operator
+import usb._interop as _interop
+
+# descriptor type
+DESC_TYPE_DEVICE = 0x01
+DESC_TYPE_CONFIG = 0x02
+DESC_TYPE_STRING = 0x03
+DESC_TYPE_INTERFACE = 0x04
+DESC_TYPE_ENDPOINT = 0x05
+
+# endpoint direction
+ENDPOINT_IN = 0x80
+ENDPOINT_OUT = 0x00
+
+# endpoint type
+ENDPOINT_TYPE_CTRL = 0x00
+ENDPOINT_TYPE_ISO = 0x01
+ENDPOINT_TYPE_BULK = 0x02
+ENDPOINT_TYPE_INTR = 0x03
+
+# control request type
+CTRL_TYPE_STANDARD = (0 << 5)
+CTRL_TYPE_CLASS = (1 << 5)
+CTRL_TYPE_VENDOR = (2 << 5)
+CTRL_TYPE_RESERVED = (3 << 5)
+
+# control request recipient
+CTRL_RECIPIENT_DEVICE = 0
+CTRL_RECIPIENT_INTERFACE = 1
+CTRL_RECIPIENT_ENDPOINT = 2
+CTRL_RECIPIENT_OTHER = 3
+
+# control request direction
+CTRL_OUT = 0x00
+CTRL_IN = 0x80
+
+_ENDPOINT_ADDR_MASK = 0x0f
+_ENDPOINT_DIR_MASK = 0x80
+_ENDPOINT_TRANSFER_TYPE_MASK = 0x03
+_CTRL_DIR_MASK = 0x80
+
+def endpoint_address(address):
+    r"""Return the endpoint absolute address.
+    
+    The address parameter is the bEndpointAddress field
+    of the endpoint descriptor.
+    """
+    return address & _ENDPOINT_ADDR_MASK
+
+def endpoint_direction(address):
+    r"""Return the endpoint direction.
+
+    The address parameter is the bEndpointAddress field
+    of the endpoint descriptor.
+    The possible return values are ENDPOINT_OUT or ENDPOINT_IN.
+    """
+    return address & _ENDPOINT_DIR_MASK
+
+def endpoint_type(bmAttributes):
+    r"""Return the transfer type of the endpoint.
+    
+    The bmAttributes parameter is the bmAttributes field
+    of the endpoint descriptor.
+    The possible return values are: ENDPOINT_TYPE_CTRL,
+    ENDPOINT_TYPE_ISO, ENDPOINT_TYPE_BULK or ENDPOINT_TYPE_INTR.
+    """
+    return bmAttributes & _ENDPOINT_TRANSFER_TYPE_MASK
+
+def ctrl_direction(bmRequestType):
+    r"""Return the direction of a control request.
+    
+    The bmRequestType parameter is the value of the
+    bmRequestType field of a control transfer.
+    The possible return values are CTRL_OUT or CTRL_IN.
+    """
+    return bmRequestType & _CTRL_DIR_MASK
+
+def build_request_type(direction, type, recipient):
+    r"""Build a bmRequestType field for control requests.
+
+    These is a conventional function to build a bmRequestType
+    for a control request.
+
+    The direction parameter can be CTRL_OUT or CTRL_IN.
+    The type parameter can be CTRL_TYPE_STANDARD, CTRL_TYPE_CLASS,
+    CTRL_TYPE_VENDOR or CTRL_TYPE_RESERVED values.
+    The recipient can be CTRL_RECIPIENT_DEVICE, CTRL_RECIPIENT_INTERFACE,
+    CTRL_RECIPIENT_ENDPOINT or CTRL_RECIPIENT_OTHER.
+
+    Return the bmRequestType value.
+    """
+    return recipient | type | direction
+
+def find_descriptor(desc, find_all=False, custom_match=None, **args):
+    r"""Find an inner descriptor.
+
+    find_descriptor works in the same way the core.find() function does,
+    but it acts on general descriptor objects. For example, suppose you
+    have a Device object called dev and want a Configuration of this
+    object with its bConfigurationValue equals to 1, the code would
+    be like so:
+
+    >>> cfg = util.find_descriptor(dev, bConfigurationValue=1)
+
+    You can use any field of the Descriptor as a match criteria, and you
+    can supply a customized match just like core.find() does. The
+    find_descriptor function also accepts the find_all parameter to get
+    a list of descriptor instead of just one.
+    """
+    def desc_iter(k, v):
+        for d in desc:
+            if (custom_match is None or custom_match(d)) and \
+                _interop._reduce(
+                        lambda a, b: a and b,
+                        map(
+                            operator.eq,
+                            v,
+                            map(lambda i: getattr(d, i), k)
+                        ),
+                        True
+                    ):
+                yield d
+
+    k, v = args.keys(), args.values()
+
+    if find_all:
+        return [d for d in desc_iter(k, v)]
+    else:
+        try:
+            return _interop._next(desc_iter(k, v))
+        except StopIteration:
+            return None
+
+def claim_interface(device, interface):
+    r"""Explicitly claim an interface.
+
+    PyUSB users normally do not have to worry about interface claiming,
+    as the library takes care of it automatically. But there are situations
+    where you need deterministic interface claiming. For these uncommon
+    cases, you can use claim_interface.
+
+    If the interface is already claimed, either through a previously call
+    to claim_interface or internally by the device object, nothing happens.
+    """
+    device._ctx.managed_claim_interface(device, interface)
+
+def release_interface(device, interface):
+    r"""Explicitly release an interface.
+
+    This function is used to release an interface previously claimed,
+    either through a call to claim_interface or internally by the
+    device object.
+
+    Normally, you do not need to worry about claiming policies, as
+    the device object takes care of it automatically.
+    """
+    device._ctx.managed_release_interface(device, interface)
+
+def dispose_resources(device):
+    r"""Release internal resources allocated by the object.
+
+    Sometimes you need to provide deterministic resources
+    freeing, for example to allow another application to
+    talk to the device. As Python does not provide deterministic
+    destruction, this function releases all internal resources
+    allocated by the device, like device handle and interface
+    policy.
+
+    After calling this function, you can continue using the device
+    object normally. If the resources will be necessary again, it
+    will allocate them automatically.
+    """
+    device._ctx.dispose(device)
+
+def get_string(dev, length, index, langid = None):
+    r"""Retrieve a string descriptor from the device.
+
+    dev is the Device object to which the request will be
+    sent to.
+
+    length is the length of string in number of characters.
+
+    index is the string descriptor index and langid is the Language
+    ID of the descriptor. If langid is omitted, the string descriptor
+    of the first Language ID will be returned.
+
+    The return value is the unicode string present in the descriptor.
+    """
+    from usb.control import get_descriptor
+    if langid is None:
+	# Asking for the zero'th index is special - it returns a string
+	# descriptor that contains all the language IDs supported by the device.
+	# Typically there aren't many - often only one. The language IDs are 16
+	# bit numbers, and they start at the third byte in the descriptor. See
+	# USB 2.0 specification section 9.6.7 for more information.
+        #
+        # Note from libusb 1.0 sources (descriptor.c)
+        buf = get_descriptor(
+                    dev,
+                    1024,
+                    DESC_TYPE_STRING,
+                    0
+                )
+        assert len(buf) >= 4
+        langid = buf[2] | (buf[3] << 8)
+
+    buf = get_descriptor(
+                dev,
+                length * 2 + 2, # string is utf16 + 2 bytes of the descriptor
+                DESC_TYPE_STRING,
+                index,
+                langid
+            )
+    return buf[2:].tostring().decode('utf-16-le')

+ 533 - 0
pyusb/docs/tutorial.txt

@@ -0,0 +1,533 @@
+==========================
+Programming with PyUSB 1.0
+==========================
+
+Let me introduce myself
+=======================
+
+PyUSB 1.0 is a Python_ library allowing easy USB_ access. It has the following features:
+
+100% written in Python:
+    Unlike the 0.x version, which is written in C, 1.0 version is written in Python.
+    This allows Python programmers with no background in C to understand better how PyUSB
+    works.
+Platform neutrality:
+    1.0 version implements a frontend-backend scheme. This isolates the API from system
+    specific implementation details. The glue between the two layers is the ``IBackend``
+    interface. PyUSB comes with builtin backends for libusb 0.1, libusb 1.0 and OpenUSB.
+    You can write your own backend if you desire to.
+Portability:
+    PyUSB should run on any platform with Python >= 2.4, ctypes_ and at least one of the
+    supported builtin backends.
+Easiness:
+    Communicating with an USB_ device has never been so easy! USB is a complex protocol,
+    but PyUSB has good defaults for most common configurations.
+Support for isochronous transfers:
+    PyUSB supports isochronous transfers if the underline backend supports it.
+
+Although PyUSB makes USB programming less painful, it is assumed in this tutorial that
+you have a minimal USB protocol background. If you don't know anything about USB, I
+recommend you the excellent Jan Axelson's book **USB Complete**.
+
+Enough talk, let's code!
+========================
+
+Who's who
+---------
+
+First of all, let's give an overview on the PyUSB modules. PyUSB modules are under
+the ``usb`` package. This package has the following modules:
+
+======= ===========
+Content Description
+------- -----------
+core    The main USB module.
+util    Utility functions.
+control Standard control requests.
+legacy  The 0.x compatibility layer.
+backend A subpackage containing the builtin backends.
+======= ===========
+
+For example, to import the ``core`` module, you do as so::
+
+    >>> import usb.core
+    >>> dev = usb.core.find()
+
+Let's get it started
+--------------------
+
+Following is a simplistic program that sends the 'test' string to the first OUT endpoint
+found::
+
+    import usb.core
+    import usb.util
+
+    # find our device
+    dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)
+
+    # was it found?
+    if dev is None:
+        raise ValueError('Device not found')
+
+    # set the active configuration. With no arguments, the first
+    # configuration will be the active one
+    dev.set_configuration()
+
+    # get an endpoint instance
+    ep = usb.util.find_descriptor(
+            dev.get_interface_altsetting(),   # first interface
+            # match the first OUT endpoint
+            custom_match = \
+                lambda e: \
+                    usb.util.endpoint_direction(e.bEndpointAddress) == \
+                    usb.util.ENDPOINT_OUT
+        )
+
+    assert ep is not None
+
+    # write the data
+    ep.write('test')
+
+The first two lines import PyUSB package modules. ``usb.core`` is the main module, and
+``usb.util`` contains utility functions. The next command searches our device
+and returns an instance object if it is found. If not, ``None`` is returned.
+After, we set the configuration to use. Note that no argument indicating what
+configuration we want was supplied. As you will see, many PyUSB functions
+have defaults for most common devices. In this case, the configuration set is
+the first one found.
+
+Then, we look for the endpoint we are interested. We search it inside the first
+interface we have. After finding the endpoint, we send data to it.
+
+If we know the endpoint address in advance, we could just call the ``write`` function
+from the device object::
+
+    dev.write(1, 'test', 0)
+
+Here we write the string 'test' at endpoint address *1* of the interface number *0*.
+All these functions will be detailed in the next sections.
+
+What's wrong?
+-------------
+
+Every function in PyUSB raises an exception in case of an error. Besides the `Python
+standard exceptions <http://docs.python.org/library/exceptions.html>`_, PyUSB defines
+the ``usb.core.USBError`` for USB related errors.
+
+You can also use the PyUSB log funcionality. It uses the `logging 
+<http://docs.python.org/library/logging.html>`_ module. To enable it, define
+the environment variable ``PYUSB_DEBUG_LEVEL`` with one of the following level
+names: ``critical``, ``error``, ``warning``, ``info`` or ``debug``.
+
+By default the messages are sent to `sys.stderr <http://docs.python.org/library/sys.html>`_.
+If you want to, you can redirect log messages to a file by defining the ``PYUSB_LOG_FILENAME``
+environment variable. If its value is a valid file path, messages will be written to it,
+otherwise it will be sent to ``sys.stderr``.
+
+Where are you?
+--------------
+
+The ``find()`` function in the ``core`` module is used to
+find and enumerate devices connected to the system. For example, let's
+say that our device has a vendor id equals to 0xfffe and product id
+equals to 0x0001. If we would like to find it, we would do so::
+
+    import usb.core
+
+    dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)
+    if dev is None:
+        raise ValueError('Our device is not connected')
+
+Just it, the function will return an ``usb.core.Device`` object representing
+our device. If the device is not found, it returns ``None``. Actually, you
+can use any field of the Device Descriptor_ you desire. For example, what
+if we would like to discover if there is an USB printer connected to the system?
+This is far easy::
+
+    # actually this is not the whole history, keep reading
+    if usb.core.find(bDeviceClass=7) is None:
+        raise ValueError('No printer found')
+
+The 7 is the code for the printer class according to the USB standard.
+Hey, wait, what if I want to enumerate all printers present? No problem::
+
+    # this is not the whole history yet...
+    printers = usb.core.find(find_all=True, bDeviceClass=7)
+
+    # Python 2, Python 3, to be or not to be
+    import sys
+    sys.stdout.write('There are ' + len(printers) + ' in the system\n.')
+
+What happened? Well, it is time for a little explanation... ``find``
+has a parameter called ``find_all`` that defaults to False. When it is
+false [#]_, ``find`` will return the first device found that matches the
+specified criteria (more on it soon). If you give it a true value,
+``find`` instead will return a list with all devices matching the criteria.
+That's it! Simple, doesn't it?
+
+Finished? No! I have not told you the whole history: many devices actually
+put their class information in the Interface Descriptor_ instead of the
+Device Descriptor_. So, to really find all printers connected to the
+system, we would need to transverse all configurations, and then
+all interfaces and check if one of the interfaces has its bInterfaceClass
+field equals to 7. If you are a  
+`programmer <http://en.wikipedia.org/wiki/Laziness>`_" like me, you might be wondering
+if there is an easier way to do that. The answer is yes, it does. Firstly, let's
+give a look on the final code to find all printers connected::
+
+    import usb.core
+    import usb.util
+    import sys
+
+    class find_class(object):
+        def __init__(self, class_):
+            self._class = class_
+        def __call__(self, device):
+            # first, let's check the device
+            if device.bDeviceClass == self._class:
+                return True
+            # ok, transverse all devices to find an
+            # interface that matches our class
+            for cfg in device:
+                # find_descriptor: what's it?
+                intf = usb.util.find_descriptor(
+                                            cfg,
+                                            bInterfaceClass=self._class
+                                    )
+                if intf is not None:
+                    return True
+
+            return False
+
+    printers = usb.core.find(find_all=1, custom_match=find_all(7))
+
+The ``custom_match`` parameter accepts any callable object that receives the device
+object. It must return true for a matching device, and false for a non-matching
+device. You can also combine ``custom_match`` with device fields if you want::
+
+    # find all printers that belongs to our vendor:
+    printers = usb.core.find(find_all=1, custom_match=find_class(7), idVendor=0xfffe)
+
+Here we are only interested in the printers of the 0xfffe vendor.
+
+Describe yourself
+-----------------
+
+Ok, we've found our device, but before talking to it, we would like
+to know more about it, you know, configurations, interfaces, endpoints,
+transfer types...
+
+If you have a device, you can access any device descriptor fields as object
+properties::
+
+    >>> dev.bLength
+    >>> dev.bNumConfigurations
+    >>> dev.bDeviceClass
+    >>> # ...
+
+To access the configurations available in the device, you can iterate over the
+device::
+
+    for cfg in dev:
+        sys.stdout.write(str(cfg.bConfigurationValue) + '\n')
+
+In the same way, you can iterate over a configuration to access the interfaces,
+and iterate over the interfaces to access their endpoints. Each kind of object has
+as attributes the fields of the respective descriptor. Let's see an example::
+
+    for cfg in dev:
+        sys.stdout.write(str(cfg.bConfigurationValue) + '\n')
+        for intf in cfg:
+            sys.stdout.write('\t' + \
+                             str(intf.bInterfaceNumber) + \
+                             ',' + \
+                             str(intf.bAlternateSetting) + \
+                             '\n')
+            for ep in intf:
+                sys.stdout.write('\t\t' + \
+                                 str(ep.bEndpointAddress) + \
+                                 '\n')
+
+You can also use the subscript operator to access the descriptors randomly, like that::
+
+    >>> # access the second configuration
+    >>> cfg = dev[1]
+    >>> # access the first interface
+    >>> intf = cfg[(0,0)]
+    >>> # third endpoint
+    >>> ep = intf[2]
+
+As you can see, the index is zero based. But wait! There is something weird in the way
+I access an interface... Yes, you are right, the subscript operator in the Configuration
+accepts a sequence of two items, with the first one being the index of the Interface and
+the second one, the alternate setting. So, to access the first interface, but its second
+alternate setting, we write ``cfg[(0,1)]``.
+
+Now it's time to we learn a powerfull way to find descriptors, the ``find_descriptor``
+utility function. We have already seem it in the printer finding example.
+``find_descriptor`` works in almost the same way as ``find``, with two exceptions:
+
+* ``find_descriptor`` receives as its first parameter the parent descriptor that you
+  will search on.
+* There is no ``backend`` [#]_ parameter.
+
+For example, if we have a configuration descriptor ``cfg`` and want to find all
+alternate setttings of the interface 1, we do so::
+
+    import usb.util
+    alt = usb.util.find_descriptor(cfg, find_all=True, bInterfaceNumber=1)
+
+Note that ``find_descriptor`` is in the ``usb.util`` module. It also
+accepts the early described ``custom_match`` parameter.
+
+How am I supposed to work?
+--------------------------
+
+USB devices after connected must be configured through a few standard requests.
+When I got started to study USB_ spec, I found myself confused with descriptors,
+configurations, interfaces, alternate settings, transfer types and all this
+stuff... And worst, you cannot simply ignore them, a device does not work
+without setting a configuration, even if it has just one! PyUSB tries to
+make your life as easy as possible. For example, after getting your device
+object, one of the first things you need to do before communicating with it
+is issueing a ``set_configuration`` request. The parameter for this request
+is the ``bConfigurationValue`` of the configuration you are interested in.
+Most devices has no more than one configuration, and tracking the configuration
+value to use is annoying (although most code I have seem simply hardcode it).
+Therefore, in PyUSB, you can just issue a ``set_configuration`` call with no
+parameters. In this case, it will set the first configuration found (if your
+device has just one, you don't need to worry about the configuration value
+at all). For example, let's imagine you have a device with one configuration descriptor
+with its bConfigurationValue field equals to 5 [#]_, the following ways bellow will
+work equally::
+
+    >>> dev.set_configuration(5)
+    >>> dev.set_configuration() # we assume the configuration 5 is the first one
+    >>> cfg = util.find_descriptor(dev, bConfiguration=5)
+    >>> cfg.set()
+    >>> dev.set_configuration(cfg)
+
+Wow! You can use a ``Configuration`` object as a parameter to ``set_configuration``!
+Yes, and also it has a ``set`` method to configure itself as the current configuration.
+
+The other setting you might or might not have to configure is the interface alternate
+setting. Each device can have only one activated configuration at a time, and each
+configuration may have more than one interface, and you can use all interfaces at the
+same time. You better understand this concept if you think of an interface as a logical
+device. For example, let's imagine a multifunction printer, which is at the same time a
+printer and a scanner. To keep things simple (or at least as simple as we can), let's
+consider it has just one configuration. As we have a printer and a scanner, the configuration
+has two interfaces, one for the printer and one for the scanner. A device with more than
+one interface is called a composite device. When you connect your multifunction printer
+to your computer, the Operating System would load two different drivers: one for each 
+"logical" peripheral you have [#]_.
+
+And about the alternate setting? Good you have asked. An interface has one or
+more alternate settings. An interface with just one alternate setting is considered
+to not having an alternate settting [#]_. Alternate settings are for interfaces which
+configurations are for devices, i.e, for each interface, you can have only one alternate
+setting active. For example, USB spec says that a device cannot
+have a isochronous endpoint in its primary alternate setting [#]_, so a streaming device
+must have at least two alternate setttings, with the second one having the isochronous
+endpoint(s). But as opposed to configurations, interfaces with just one alternate
+setting don't need to be set [#]_. You select an interface alternate setting
+through the ``set_interface_altsetting`` function::
+
+    >>> dev.set_interface_altsetting(interface = 0, alternate_setting = 0)
+
+.. warning::
+    The USB spec says that a device is allowed to return an error in case it
+    receives a SET_INTERFACE request for an interface that has no additional
+    alternate settings. So, if you are not sure if the interface has more
+    than one alternate setting or it accepts a SET_INTERFACE request,
+    the safesty way is to call ``set_interface_altsetting`` inside an
+    try-except block, like so::
+
+        try:
+            dev.set_interface_altsetting(...)
+        except USBError:
+            pass
+
+You can also use an ``Interface`` object as parameter to the function, the
+``interface`` and ``alternate_setting`` parameters are automatically inferred
+from ``bInterfaceNumber`` and ``bAlternateSetting`` fields. Example::
+
+    >>> intf = find_descriptor(...)
+    >>> dev.set_interface_altsetting(intf)
+    >>> intf.set_altsetting() # wow! Interface also has a method for it
+
+.. warning::
+    The ``Interface`` object must belong to the active configuration descriptor.
+
+Talk to me, honey
+-----------------
+
+Now it's time to we learn how to communicate with USB devices. USB has four
+flavors of transfers: bulk, interrupt, isochronous and control. I don't intend
+to explain the purpose of each transfer and the differences among them. Therefore,
+I assume you know at least the basics of the USB transfers.
+
+Control transfer is the unique transfer that has structured data described in the
+spec, the others just send and receive raw data from USB point of view. Because of it,
+you have a different function to deal with control transfers,
+all the other transfers are managed by the same functions.
+
+You issue a control transfer through the ``ctrl_transfer`` method. It is used both for
+OUT and IN transfers. The transfer direction is determined from the ``bmRequestType``
+parameter.
+
+The ``ctrl_transfer`` parameters are almost equal to the control request
+structure. Following is a example of how to do a control transfer [#]_::
+
+    >>> msg = 'test'
+    >>> assert dev.ctrl_transfer(0x40, CTRL_LOOPBACK_WRITE, 0, 0, msg) == len(msg)
+    >>> ret = dev.ctrl_transfer(0x40, CTRL_LOOPBACK_READ, 0, 0, len(msg))
+    >>> sret = ''.join([chr(x) for x in ret])
+    >>> assert sret == msg
+
+In this example, it is assumed that our device implements two custom control requests that act
+as a loopback pipe. What you write with the ``CTRL_LOOPBACK_WRITE`` message, you can read with the
+``CTRL_LOOPBACK_READ`` message.
+
+The first four parameters are the ``bmRequestType``, ``bmRequest``, ``wValue`` and
+``wIndex`` fields of the standard control transfer structure. The fifth parameter is either
+the data payload for an OUT transfer or the number of bytes to read in an IN transfer.
+The data payload can be any sequence type that can be used as a parameter for the array_
+``__init__`` method.  If there is no data payload, the parameter should be ``None`` (or 0 in case
+of an IN transfer).  There is one last optional parameter specifying the timeout of the operation.
+If you don't supply it, a default timeout will be used (more on that later). In an OUT transfer,
+the return value is the number of bytes really sent to the device. In an IN transfer, the return
+value is an array_ object with the data read. 
+
+For the other transfers, you use the methods ``write`` and ``read``, respectivelly, to
+write and read data. You don't need to worry about the transfer type, it is automatically
+determined from the endpoint address. Here is our loopback example assuming the we have
+a loopback pipe in the endpoint 1::
+
+    >>> msg = 'test'
+    >>> assert len(dev.write(1, msg, 0, 100)) == len(msg)
+    >>> ret = dev.read(0x81, len(msg), 0, 100)
+    >>> sret = ''.join([chr(x) for x in ret])
+    >>> assert sret == msg
+
+The first, third and fourth parameters are equal for both methods, they are the endpoint
+address, interface number and timeout, respectivelly. The second parameter is the data
+payload (write) or the number of bytes to read (read). The return of the ``read``
+function is an instance of the array_ object or the number of bytes written
+for the ``write`` method.
+
+As in ``ctrl_transfer``, the ``timeout`` parameter is optional. When the ``timeout``
+is omitted, it is used the ``Device.default_timeout`` property as the operation timeout.
+
+Control yourself
+----------------
+
+Besides the transfers functions, the module ``usb.control`` offers functions which
+implement the standard USB control requests and the ``usb.util`` module has the
+convenience function ``get_string`` specifically to return string descriptors.
+
+Additional Topics
+=================
+
+Behind every great abstraction, there's a great implementation
+--------------------------------------------------------------
+
+On early days, there was only libusb_. Then came libusb 1.0, and now we had libusb 0.1 and 1.0.
+After, they created OpenUSB_, and now we live at the
+`Tower of Babel <http://en.wikipedia.org/wiki/Tower_of_Babel>`_ of the USB libraries [#]_.
+How does PyUSB deal with it? Well, PyUSB is a democratic library, you may choose whatever
+library you want. Actually, you can write your own USB library from scratch and tell
+PyUSB to use it.
+
+The ``find`` function has one more parameter that I haven't told you. It is the ``backend``
+parameter. If you don't supply it, it will be used one of the builtin backends. A backend
+is a object derived from ``usb.backend.IBackend``, responsible to implement the operating
+system specific USB stuff. As you might guess, the builtins are libusb 0.1, libusb 1.0 and
+OpenUSB backends. 
+
+You can create you own backend and use it. Just inherit from ``IBackend`` and implement
+the methods necessary. You might want to give a look at ``backend`` package documentation
+to learn how to do that.
+
+Don't be selfish
+----------------
+
+Python has what we say *automatic memory management*. This means that the virtual machine
+will take care about when to release objects from the memory. Under the hoods, PyUSB manages
+all low level resource management it needs to work (interface claiming, device handles, etc.)
+internally and most of users don't need to worry about that. But, because of the nonderterminisc
+nature of automatic object destruction of Python, users cannot predict when the resources
+allocated will be released. Some applications need to allocate and free the resources deterministically.
+For these kind of applications, the ``usb.util`` module has a set of functions to deal with resource
+management.
+
+If you want to claim and release interfaces manually, you may use the ``claim_interface``
+and ``release_interface`` functions. ``claim_interface`` will claim the specified interface
+if the device has not done it yet. If the device already claimed the interface, it does nothing.
+In a similar way, ``release_interface`` will release the specified interface if it is claimed.
+If the interface is not claimed, it does nothing. You can use manual interface claim to solve
+the `configuration selection problem <http://libusb.sourceforge.net/api-1.0/caveats.html>`_
+described in the libusb_ documentation.
+
+If you want to free all resources allocated by the device object (including interfaces claimed),
+you can use the ``dispose_resources`` function. It releases all resources allocated and put the
+device object (but not the device hardware itself) in the state it was at the time when the ``find`` 
+function returned.
+
+Oldschool rules
+---------------
+
+If you wrote an application using the old PyUSB API (0.whatever), you may be asking yourself
+if you need to update your code to use the new API. Well, you should, but you don't need to. PyUSB
+1.0 comes with the ``usb.legacy`` compatibility module. It implements the older API above the
+new API. "So, do I have just to replace my ``import usb`` statement with ``import usb.legacy as
+usb`` to get my application working?", you ask. The answer is yes, it will, but you don't have
+to. If you run your application untouched it will just work, because the ``import usb`` statement
+will import all public symbols from ``usb.legacy``. If you face a problem, probably you found a bug.
+
+Help me, please
+---------------
+
+If you need help, **do not email me**, the mailing list is there for this. Subscribe instructions
+can be found at the PyUSB_ website.
+
+What do you think about it?
+---------------------------
+
+At alpha stage, users of PyUSB are invited to give their opinion about the PyUSB API.
+If you think a feature is hard to use and you have a better idea, open a new thread
+in the mailing list so we can discuss about that.
+
+.. [#] When I say True or False (capitalized), I mean the respectivelly values of the
+       Python language. And when I say true and false, I mean any expression in Python
+       which evals to true or false.
+
+.. [#] See backend specific documentation.
+
+.. [#] USB spec does not impose any sequential value to the configuration value. The same
+       is true for interface and alternate setting numbers.
+
+.. [#] Actually things are a little more complex, but this simple explanation is enough
+       for us.
+
+.. [#] I know it sounds weird.
+
+.. [#] This is because if there is no bandwidth for isochronous transfer at the device
+       configuration time, the device can be successfully enumerated.
+
+.. [#] This does not happen for configurations because a device is allowed to be in an
+       unconfigured state.
+
+.. [#] In PyUSB, control transfers are only issued in the endpoint 0. It's very very very
+       rare a device having an alternate control endpoint (I've never seem such device).
+
+.. [#] It's just a joke, don't take it serious. Many choices is better than no choice.
+
+.. _libusb: http://www.libusb.org
+.. _OpenUSB: http://openusb.wiki.sourceforge.net
+.. _USB: http://www.usb.org
+.. _PyUSB: http://pyusb.wiki.sourceforge.net
+.. _Python: http://www.python.org
+.. _ctypes: http://docs.python.org/library/ctypes.html
+.. _Descriptor: http://www.beyondlogic.org/usbnutshell/usb5.htm
+.. _array: http://docs.python.org/library/array.html

+ 50 - 0
pyusb/setup.py

@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+from distutils.core import setup
+
+setup(
+    name='pyusb',
+    version='1.0.0-a1',
+    description='Python USB access module',
+    author='Wander Lairson Costa',
+    author_email='wander.lairson@gmail.com',
+    license = 'BSD',
+    url='http://pyusb.sourceforge.net',
+    packages=['usb', 'usb.backend'],
+    long_description =
+"""
+PyUSB offers easy USB devices communication in Python.
+It should work without additional code in any environment with
+Python >= 2.4, ctypes and an pre-built usb backend library
+(currently, libusb 0.1.x, libusb 1.x, and OpenUSB).
+"""
+)
+

+ 42 - 0
pyusb/tests/devinfo.py

@@ -0,0 +1,42 @@
+# Copyright (C) 2009-2011 Wander Lairson Costa 
+# 
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+# 
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+# 
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+# 
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+ID_VENDOR = 0xFFFE
+ID_PRODUCT = 0x0001
+
+# endpoint addresses
+EP_BULK_OUT = 0x01
+EP_BULK_IN = 0x81
+EP_INTR_OUT = 0x02
+EP_INTR_IN = 0x82
+EP_ISO_OUT = 0x03
+EP_ISO_IN = 0x83
+
+# For control transfer test
+CTRL_LOOPBACK_WRITE = 0
+CTRL_LOOPBACK_READ = 1

+ 17 - 0
pyusb/tests/pic18f4550/Microchip Solutions/IMPORTANT README.txt

@@ -0,0 +1,17 @@
+PIC USB Benchmark Firmware
+
+DIRECTORY TREE:
+ Device_Benchmark  - PIC USB Benchmark Firmware
+ Microchip         - Original MCP USB Stack 2.6a files used by the benchmark
+                     firmware. 
+
+REQUIRED:
+ * MCP USB Stack 2.6a
+ * Microchip PIC USB Demo/Test Board
+
+GETTING STARTED:
+ * Move the "TestFirmware" folder to your 
+   'Microchip Application Libraries' installation directory. This is normally 
+   "C:\Microchip Solutions".
+ 
+ * This firmware can use either libusb or winusb for a device driver.

+ 170 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/BDT_transfer.h

@@ -0,0 +1,170 @@
+#ifndef _BBT_TRANSFER_H
+#define _BBT_TRANSFER_H
+
+#include "USB/usb.h"
+#include "USB/usb_function_generic.h"
+#include "HardwareProfile.h"
+
+// Externs from usb_device.c
+extern volatile BDT_ENTRY* pBDTEntryOut[USB_MAX_EP_NUMBER+1];
+extern volatile BDT_ENTRY* pBDTEntryIn[USB_MAX_EP_NUMBER+1];
+
+/////////////////////////
+// BDT transfer macros //
+/////////////////////////
+//Toggle the DTS bit if required
+#if ((USB_PING_PONG_MODE==USB_PING_PONG__FULL_PING_PONG) || (USB_PING_PONG_MODE==USB_PING_PONG__ALL_BUT_EP0))
+	#define PP_COUNT (2)
+
+	// Copied from usb_device.h ///////////////
+	#if defined (__18CXX) || defined(__C30__)
+		#define USB_NEXT_PING_PONG 0x0004
+	#elif defined(__C32__)
+		#define USB_NEXT_PING_PONG 0x0008
+	#else
+		#error "Not defined for this compiler"
+	#endif
+	///////////////////////////////////////////
+
+	#define mBDT_MaskAndToggleDTS(BdtPtr)  (BdtPtr->STAT.Val & _DTSMASK)
+	#define mBDT_IsOdd(BdtPtr)             ((((BYTE_VAL*)&BdtPtr)->Val & USB_NEXT_PING_PONG)?1:0)
+	#define mBDT_TogglePP(BdtPtr)          ((BYTE_VAL*)&BdtPtr)->Val ^= USB_NEXT_PING_PONG
+
+#else
+	#define PP_COUNT (1)
+
+	#define mBDT_MaskAndToggleDTS(BdtPtr)  ((BdtPtr->STAT.Val & _DTSMASK) ^ _DTSMASK)
+	#define mBDT_IsOdd(BdtPtr)             (0)
+	#define mBDT_TogglePP(BdtPtr)
+#endif
+
+#if defined(__C32__)
+	#define mBDT_FillTransfer(BdtPtr, BufferPtr, BufferLength)	\
+	{															\
+	    BdtPtr->ADR = ConvertToPhysicalAddress(BufferPtr);		\
+	    BdtPtr->CNT = BufferLength;								\
+	}
+	
+	#define mBDT_GetLength(BdtPtr) (BdtPtr->CNT)
+
+#else
+	#define mBDT_FillTransfer(BdtPtr, BufferPtr, BufferLength)	\
+	{															\
+	    BdtPtr->ADR = ConvertToPhysicalAddress(BufferPtr);		\
+	    BdtPtr->CNT = (BYTE)BufferLength;						\
+	}
+
+	#define mBDT_GetLength(BdtPtr) (BdtPtr->CNT + ((BdtPtr->STAT.Val << 8) & 0x300))
+
+#endif
+
+// Masks STAT with DTS, Set _USIE, _DTSEN
+#define mBDT_SubmitTransfer(BdtPtr) BdtPtr->STAT.Val = (mBDT_MaskAndToggleDTS(BdtPtr)) | _USIE | _DTSEN
+
+#if defined (__18CXX) || defined(__C30__)
+	// Sets BC8 & BC9 with high transfer length bits, _USIE
+	#define mBDT_SubmitIsoTransfer(BdtPtr, BufferLength) BdtPtr->STAT.Val = (((BufferLength >> 8) & 0x3) | _USIE)
+#elif defined(__C32__)
+	// Sets _USIE (CNT is 16bit for PIC32)
+	#define mBDT_SubmitIsoTransfer(BdtPtr, BufferLength) BdtPtr->STAT.Val = _USIE
+#else
+    #error "Not defined for this compiler"
+#endif
+
+#if USB_MAX_EP_NUMBER > 0
+	#define pBdtRxEp1	pBDTEntryOut[1]
+	#define pBdtOutEp1	pBDTEntryOut[1]
+	#define pBdtTxEp1	pBDTEntryIn[1]
+	#define pBdtInEp1	pBDTEntryIn[1]
+#endif
+
+#if USB_MAX_EP_NUMBER > 1
+	#define pBdtRxEp2	pBDTEntryOut[2]
+	#define pBdtOutEp2	pBDTEntryOut[2]
+	#define pBdtTxEp2	pBDTEntryIn[2]
+	#define pBdtInEp2	pBDTEntryIn[2]
+#endif
+
+#if USB_MAX_EP_NUMBER > 2
+	#define pBdtRxEp3	pBDTEntryOut[3]
+	#define pBdtOutEp3	pBDTEntryOut[3]
+	#define pBdtTxEp3	pBDTEntryIn[3]
+	#define pBdtInEp3	pBDTEntryIn[3]
+#endif
+
+#if USB_MAX_EP_NUMBER > 3
+	#define pBdtRxEp4	pBDTEntryOut[4]
+	#define pBdtOutEp4	pBDTEntryOut[4]
+	#define pBdtTxEp4	pBDTEntryIn[4]
+	#define pBdtInEp4	pBDTEntryIn[4]
+#endif
+
+#if USB_MAX_EP_NUMBER > 4
+	#define pBdtRxEp5	pBDTEntryOut[5]
+	#define pBdtOutEp5	pBDTEntryOut[5]
+	#define pBdtTxEp5	pBDTEntryIn[5]
+	#define pBdtInEp5	pBDTEntryIn[5]
+#endif
+
+#if USB_MAX_EP_NUMBER > 5
+	#define pBdtRxEp6	pBDTEntryOut[6]
+	#define pBdtOutEp6	pBDTEntryOut[6]
+	#define pBdtTxEp6	pBDTEntryIn[6]
+	#define pBdtInEp6	pBDTEntryIn[6]
+#endif
+#if USB_MAX_EP_NUMBER > 6
+	#define pBdtRxEp7	pBDTEntryOut[7]
+	#define pBdtOutEp7	pBDTEntryOut[7]
+	#define pBdtTxEp7	pBDTEntryIn[7]
+	#define pBdtInEp7	pBDTEntryIn[7]
+#endif
+#if USB_MAX_EP_NUMBER > 7
+	#define pBdtRxEp8	pBDTEntryOut[8]
+	#define pBdtOutEp8	pBDTEntryOut[8]
+	#define pBdtTxEp8	pBDTEntryIn[8]
+	#define pBdtInEp8	pBDTEntryIn[8]
+#endif
+#if USB_MAX_EP_NUMBER > 8
+	#define pBdtRxEp9	pBDTEntryOut[9]
+	#define pBdtOutEp9	pBDTEntryOut[9]
+	#define pBdtTxEp9	pBDTEntryIn[9]
+	#define pBdtInEp9	pBDTEntryIn[9]
+#endif
+#if USB_MAX_EP_NUMBER > 9
+	#define pBdtRxEp10	pBDTEntryOut[10]
+	#define pBdtOutEp10	pBDTEntryOut[10]
+	#define pBdtTxEp10	pBDTEntryIn[10]
+	#define pBdtInEp10	pBDTEntryIn[10]
+#endif
+#if USB_MAX_EP_NUMBER > 10
+	#define pBdtRxEp11	pBDTEntryOut[11]
+	#define pBdtOutEp11	pBDTEntryOut[11]
+	#define pBdtTxEp11	pBDTEntryIn[11]
+	#define pBdtInEp11	pBDTEntryIn[11]
+#endif
+#if USB_MAX_EP_NUMBER > 11
+	#define pBdtRxEp12	pBDTEntryOut[12]
+	#define pBdtOutEp12	pBDTEntryOut[12]
+	#define pBdtTxEp12	pBDTEntryIn[12]
+	#define pBdtInEp12	pBDTEntryIn[12]
+#endif
+#if USB_MAX_EP_NUMBER > 12
+	#define pBdtRxEp13	pBDTEntryOut[13]
+	#define pBdtOutEp13	pBDTEntryOut[13]
+	#define pBdtTxEp13	pBDTEntryIn[13]
+	#define pBdtInEp13	pBDTEntryIn[13]
+#endif
+#if USB_MAX_EP_NUMBER > 13
+	#define pBdtRxEp14	pBDTEntryOut[14]
+	#define pBdtOutEp14	pBDTEntryOut[14]
+	#define pBdtTxEp14	pBDTEntryIn[14]
+	#define pBdtInEp14	pBDTEntryIn[14]
+#endif
+#if USB_MAX_EP_NUMBER > 14
+	#define pBdtRxEp15	pBDTEntryOut[15]
+	#define pBdtOutEp15	pBDTEntryOut[15]
+	#define pBdtTxEp15	pBDTEntryIn[15]
+	#define pBdtInEp15	pBDTEntryIn[15]
+#endif
+
+#endif

+ 530 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/Benchmark.c

@@ -0,0 +1,530 @@
+/// Benchmark.c 
+/// Single interface ping-pong buffering enabled.
+
+/* USB Benchmark for libusb-win32
+
+    Copyright © 2010 Travis Robinson. <libusbdotnet@gmail.com>
+    website: http://sourceforge.net/projects/libusb-win32
+ 
+    Software License Agreement:
+    
+    The software supplied herewith is intended for use solely and
+    exclusively on Microchip PIC Microcontroller products. This 
+    software is owned by Travis Robinson, and is protected under
+	applicable copyright laws. All rights are reserved. Any use in 
+	violation of the foregoing restrictions may subject the user to 
+	criminal sanctions under applicable laws, as well as to civil 
+	liability for the breach of the terms and conditions of this
+    license.
+
+	You may redistribute and/or modify this file under the terms
+	described above.
+    
+    THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+    WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+    TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+    PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE OWNER SHALL NOT,
+    IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+    CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.	
+*/
+
+/** INCLUDES *******************************************************/
+#include "USB/usb.h"
+#include "USB/usb_function_generic.h"
+#include "HardwareProfile.h"
+#include "Benchmark.h"
+#include "PicFWCommands.h"
+#include "BDT_transfer.h"
+
+/** VARIABLES ******************************************************/
+//NOTE:  The below endpoint buffers need to be located in a section of
+//system SRAM that is accessible by the USB module.  The USB module on all
+//currently existing Microchip USB microcontrollers use a dedicated DMA
+//interface for reading/writing USB data into/out of main system SRAM.
+
+//On some USB PIC microcontrollers, all of the microcontroller SRAM is dual
+//access, and therefore all of it can be accessed by either the USB 
+//module or the microcontroller core.  On other devices, only a certain 
+//portion of the SRAM is accessible by the USB module. Therefore, on some 
+//devices, it is important to place USB data buffers in certain sections of
+//SRAM, while on other devices, the buffers can be placed anywhere.
+
+
+
+//For all PIC18F87J50 family and PIC18F46J50 family devices: all SRAM is USB accessible.
+//For PIC18F1xK50 devices: 0x200-0x2FF is USB accessible.
+//For PIC18F4450/2450 devices: 0x400-0x4FF is USB accessible.
+//For PIC18F4550/4553/4455/4458/2550/2553/2455/2458: 0x400-0x7FF is USB accessible.
+#if defined(__18F14K50) || defined(__18F13K50) || defined(__18LF14K50) || defined(__18LF13K50) 
+	#pragma udata USB_VARIABLES=0x240
+#elif defined(__18F2455) || defined(__18F2550) || defined(__18F4455) || defined(__18F4550) || defined(__18F2458) || defined(__18F2453) || defined(__18F4558) || defined(__18F4553)
+	#pragma udata USB_VARIABLES=0x450
+#elif defined(__18F4450) || defined(__18F2450)
+	#pragma udata USB_VARIABLES=0x450
+#else
+	#pragma udata
+#endif
+
+// Data buffers
+BYTE BenchmarkBuffers_INTF0_1[2][PP_COUNT][USBGEN_EP_SIZE_INTF0];
+BYTE BenchmarkBuffers_INTF0_2[2][PP_COUNT][USBGEN_EP_SIZE_INTF0];
+
+BYTE BenchmarkBuffer_CTRL[USB_EP0_BUFF_SIZE];
+
+#ifdef DUAL_INTERFACE
+BYTE BenchmarkBuffers_INTF1[2][PP_COUNT][USBGEN_EP_SIZE_INTF1];
+#endif
+
+// The below variables are only accessed by the CPU and can be placed anywhere in RAM.
+#pragma udata
+
+WORD Ctrl_BufferCount = 0;
+
+// Temporary variables 
+WORD counter;
+
+// Internal test variables
+volatile BYTE TestType_INTF0;
+volatile BYTE PrevTestType_INTF0;
+
+volatile BYTE FillCount_INTF0_1;
+volatile BYTE NextPacketKey_INTF0_1;
+
+volatile BYTE FillCount_INTF0_2;
+volatile BYTE NextPacketKey_INTF0_2;
+
+#ifdef DUAL_INTERFACE
+	volatile BYTE TestType_INTF1;
+	volatile BYTE PrevTestType_INTF1;
+
+	volatile BYTE FillCount_INTF1;
+	volatile BYTE NextPacketKey_INTF1;
+#endif
+
+/** EXTERNS ********************************************************/
+extern void BlinkUSBStatus(void);
+
+/** BMARK FUNCTIONS ************************************************/
+void doBenchmarkLoop_INTF0(void);
+void doBenchmarkWrite_INTF0(void);
+void doBenchmarkRead_INTF0(void);
+
+#ifdef DUAL_INTERFACE
+	void doBenchmarkLoop_INTF1(void);
+	void doBenchmarkWrite_INTF1(void);
+	void doBenchmarkRead_INTF1(void);
+#endif
+
+void fillBuffer(BYTE* pBuffer, WORD size);
+
+/** BMARK MACROS ****************************************************/
+#define	mBenchMarkInit_INTF0()			\
+{										\
+	TestType_INTF0=TEST_LOOP;			\
+	PrevTestType_INTF0=TEST_LOOP;		\
+	FillCount_INTF0_1=0;				\
+	NextPacketKey_INTF0_1=0;			\
+	FillCount_INTF0_2=0;				\
+	NextPacketKey_INTF0_2=0;			\
+}
+
+#define	mBenchMarkInit_INTF1()			\
+{										\
+	TestType_INTF1=TEST_LOOP;			\
+	PrevTestType_INTF1=TEST_LOOP;		\
+	FillCount_INTF1_1=0;				\
+	NextPacketKey_INTF1_1=0;			\
+	FillCount_INTF1_2=0;				\
+	NextPacketKey_INTF1_2=0;			\
+}
+
+
+#define mSetWritePacketID(BufferPtr, BufferSize, FillCount, NextPacketKey)	\
+{																			\
+	if (FillCount < 3)														\
+	{																		\
+		FillCount++;														\
+		fillBuffer((BYTE*)BufferPtr,BufferSize);							\
+	}																		\
+	BufferPtr[1]=NextPacketKey++;											\
+}
+
+// If interface #0 is iso, use an iso specific submit macro
+#if (INTF0==EP_ISO)
+	#define mSubmitTransfer_INTF0(BdtPtr, BufferLength) mBDT_SubmitIsoTransfer(BdtPtr, BufferLength)
+#else
+	#define mSubmitTransfer_INTF0(BdtPtr, BufferLength) mBDT_SubmitTransfer(BdtPtr)
+#endif
+
+// If interface #1 is iso, use an iso specific submit macro
+#if (INTF1==EP_ISO)
+	#define mSubmitTransfer_INTF1(BdtPtr, BufferLength) mBDT_SubmitIsoTransfer(BdtPtr, BufferLength)
+#else
+	#define mSubmitTransfer_INTF1(BdtPtr, BufferLength) mBDT_SubmitTransfer(BdtPtr)
+#endif
+
+#define GetBenchmarkBuffer(IntfSuffix, Direction, IsOdd) BenchmarkBuffers_##IntfSuffix[Direction][IsOdd]
+
+// Swaps byte pointers
+#define Swap(r1,r2) { pSwapBufferTemp = r1; r1 = r2; r2 = pSwapBufferTemp; }
+
+/** BMARK DECLARATIONS *********************************************/
+#pragma code
+
+// The Benchmark firmware "overrides" the USBCBInitEP to initialize
+// the OUT (MCU Rx) endpoint with the first BenchmarkBuffer.
+void USBCBInitEP(void)
+{
+    USBEnableEndpoint(USBGEN_EP_NUM_INTF0_1,USB_OUT_ENABLED|USB_IN_ENABLED|USBGEN_EP_HANDSHAKE_INTF0_1|USB_DISALLOW_SETUP);
+	USBEnableEndpoint(USBGEN_EP_NUM_INTF0_2,USB_OUT_ENABLED|USB_IN_ENABLED|USBGEN_EP_HANDSHAKE_INTF0_1|USB_DISALLOW_SETUP);
+
+	//Prepare the OUT endpoints to receive the first packets from the host.
+	pBdtRxEp1->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF0_1, OUT_FROM_HOST, mBDT_IsOdd(pBdtRxEp1)));
+	#if (PP_COUNT==(2))
+		mBDT_TogglePP(pBdtRxEp1);
+		pBdtRxEp1->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF0_1, OUT_FROM_HOST, mBDT_IsOdd(pBdtRxEp1)));
+		mBDT_TogglePP(pBdtRxEp1);
+	#endif
+
+	pBdtRxEp2->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF0_2, OUT_FROM_HOST, mBDT_IsOdd(pBdtRxEp2)));
+	#if (PP_COUNT==(2))
+		mBDT_TogglePP(pBdtRxEp2);
+		pBdtRxEp2->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF0_2, OUT_FROM_HOST, mBDT_IsOdd(pBdtRxEp2)));
+		mBDT_TogglePP(pBdtRxEp2);
+	#endif
+
+	doBenchmarkRead_INTF0();
+	doBenchmarkRead_INTF0();
+	
+	pBdtTxEp1->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF0_1, IN_TO_HOST, mBDT_IsOdd(pBdtTxEp1)));
+	#if (PP_COUNT==(2))
+		mBDT_TogglePP(pBdtTxEp1);
+		pBdtTxEp1->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF0_1, IN_TO_HOST, mBDT_IsOdd(pBdtTxEp1)));
+		mBDT_TogglePP(pBdtTxEp1);
+	#endif
+
+	pBdtTxEp2->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF0_2, IN_TO_HOST, mBDT_IsOdd(pBdtTxEp2)));
+	#if (PP_COUNT==(2))
+		mBDT_TogglePP(pBdtTxEp2);
+		pBdtTxEp2->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF0_2, IN_TO_HOST, mBDT_IsOdd(pBdtTxEp2)));
+		mBDT_TogglePP(pBdtTxEp2);
+	#endif
+
+    Ctrl_BufferCount = 0;
+
+	#ifdef DUAL_INTERFACE
+		USBEnableEndpoint(USBGEN_EP_NUM_INTF1,USB_OUT_ENABLED|USB_IN_ENABLED|USBGEN_EP_HANDSHAKE_INTF1|USB_DISALLOW_SETUP);
+
+		//Prepare the OUT endpoints to receive the first packets from the host.
+		pBdtRxEp2->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF1, OUT_FROM_HOST, mBDT_IsOdd(pBdtRxEp2)));
+		#if (PP_COUNT==(2))
+			mBDT_TogglePP(pBdtRxEp2);
+			pBdtRxEp2->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF1, OUT_FROM_HOST, mBDT_IsOdd(pBdtRxEp2)));
+			mBDT_TogglePP(pBdtRxEp2);
+		#endif
+
+		doBenchmarkRead_INTF1();
+		doBenchmarkRead_INTF1();
+		
+		pBdtTxEp2->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF1, IN_TO_HOST, mBDT_IsOdd(pBdtTxEp2)));
+		#if (PP_COUNT==(2))
+			mBDT_TogglePP(pBdtTxEp2);
+			pBdtTxEp2->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF1, IN_TO_HOST, mBDT_IsOdd(pBdtTxEp2)));
+			mBDT_TogglePP(pBdtTxEp2);
+		#endif
+	#endif
+
+}
+void USBCBCheckOtherReq(void)
+{
+	if (SetupPkt.RequestType != USB_SETUP_TYPE_VENDOR_BITFIELD) return;
+
+	switch (SetupPkt.bRequest)
+	{
+	case PICFW_SET_TEST:
+#ifdef DUAL_INTERFACE
+		if ((SetupPkt.wIndex & 0xff) == 1)
+		{
+			TestType_INTF1=SetupPkt.wValue & 0xff;
+			inPipes[0].pSrc.bRam = (BYTE*)&TestType_INTF1;  // Set Source
+			inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM;		// Set memory type
+			inPipes[0].wCount.v[0] = 1;						// Set data count
+			inPipes[0].info.bits.busy = 1;
+		}
+		else
+#endif
+		{
+			TestType_INTF0=SetupPkt.wValue & 0xff;
+			inPipes[0].pSrc.bRam = (BYTE*)&TestType_INTF0;  // Set Source
+			inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM;		// Set memory type
+			inPipes[0].wCount.v[0] = 1;						// Set data count
+			inPipes[0].info.bits.busy = 1;
+		}
+		break;
+	case PICFW_GET_TEST:
+#ifdef DUAL_INTERFACE
+		if ((SetupPkt.wIndex & 0xff) == 1)
+		{
+			inPipes[0].pSrc.bRam = (BYTE*)&TestType_INTF1;  // Set Source
+			inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM;		// Set memory type
+			inPipes[0].wCount.v[0] = 1;						// Set data count
+			inPipes[0].info.bits.busy = 1;
+		}
+		else
+#endif
+		{
+			inPipes[0].pSrc.bRam = (BYTE*)&TestType_INTF0;  // Set Source
+			inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM;		// Set memory type
+			inPipes[0].wCount.v[0] = 1;						// Set data count
+			inPipes[0].info.bits.busy = 1;
+		}
+		break;
+	case PICFW_GET_EEDATA:
+		break;
+	case PICFW_SET_EEDATA:
+		break;
+	case CTRL_LOOPBACK_WRITE:
+		Ctrl_BufferCount = SetupPkt.wLength;
+		outPipes[0].pDst.bRam = BenchmarkBuffer_CTRL;
+		outPipes[0].info.bits.busy = 1;
+		outPipes[0].wCount.Val = Ctrl_BufferCount;
+		break;
+	case CTRL_LOOPBACK_READ:
+		inPipes[0].pSrc.bRam = BenchmarkBuffer_CTRL;  // Set Source
+		inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM;		// Set memory type
+		inPipes[0].wCount.Val = SetupPkt.wLength > Ctrl_BufferCount ? Ctrl_BufferCount : SetupPkt.wLength;	// Set data count
+		inPipes[0].info.bits.busy = 1;
+		break;
+	default:
+		break;
+	}//end switch
+
+}//end
+
+void Benchmark_Init(void)
+{
+		mBenchMarkInit_INTF0();
+#ifdef DUAL_INTERFACE
+		mBenchMarkInit(INTF1);
+#endif
+
+}//end UserInit
+
+void fillBuffer(BYTE* pBuffer, WORD size)
+{
+	BYTE dataByte = 0;
+	for (counter=0; counter < size; counter++)
+	{
+		pBuffer[counter] = dataByte++;
+		if (dataByte == 0) dataByte++;
+	}
+}
+
+void Benchmark_ProcessIO(void)
+{
+	//Blink the LEDs according to the USB device status, but only do so if the PC application isn't connected and controlling the LEDs.
+	BlinkUSBStatus();
+
+	//Don't attempt to read/write over the USB until after the device has been fully enumerated.
+	if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1))
+	{
+		Benchmark_Init();
+		return;
+	}
+
+	if (TestType_INTF0!=PrevTestType_INTF0)
+	{
+		FillCount_INTF0_1=0;
+		NextPacketKey_INTF0_1=0;
+		FillCount_INTF0_2=0;
+		NextPacketKey_INTF0_2=0;
+		PrevTestType_INTF0=TestType_INTF0;
+	}
+
+	switch(TestType_INTF0)
+	{
+	case TEST_PCREAD:
+		doBenchmarkWrite_INTF0();
+		break;
+	case TEST_PCWRITE:
+		doBenchmarkRead_INTF0();
+		break;
+	case TEST_LOOP:
+		doBenchmarkLoop_INTF0();
+		break;
+	default:
+		doBenchmarkRead_INTF0();
+		break;
+	}
+
+#ifdef DUAL_INTERFACE
+	if (TestType_INTF1!=PrevTestType_INTF1)
+	{
+		FillCount_INTF1=0;
+		NextPacketKey_INTF1=0;
+		PrevTestType_INTF1=TestType_INTF1;
+	}
+
+	switch(TestType_INTF1)
+	{
+	case TEST_PCREAD:
+		doBenchmarkWrite_INTF1();
+		break;
+	case TEST_PCWRITE:
+		doBenchmarkRead_INTF1();
+		break;
+	case TEST_LOOP:
+		doBenchmarkLoop_INTF1();
+		break;
+	default:
+		doBenchmarkRead_INTF1();
+		break;
+	}
+#endif
+
+}//end Benchmark_ProcessIO
+
+void doBenchmarkWrite_INTF0(void)
+{
+	BYTE* pBufferTx;
+	if (!USBHandleBusy(pBdtTxEp1))
+	{
+		pBufferTx = USBHandleGetAddr(pBdtTxEp1);
+		mSetWritePacketID(pBufferTx, USBGEN_EP_SIZE_INTF0, FillCount_INTF0_1, NextPacketKey_INTF0_1);
+		mBDT_FillTransfer(pBdtTxEp1, pBufferTx, USBGEN_EP_SIZE_INTF0);
+		mSubmitTransfer_INTF0(pBdtTxEp1, USBGEN_EP_SIZE_INTF0);
+
+		mBDT_TogglePP(pBdtTxEp1);
+	}
+
+	if (!USBHandleBusy(pBdtTxEp2))
+	{
+		pBufferTx = USBHandleGetAddr(pBdtTxEp2);
+		mSetWritePacketID(pBufferTx, USBGEN_EP_SIZE_INTF0, FillCount_INTF0_2, NextPacketKey_INTF0_2);
+		mBDT_FillTransfer(pBdtTxEp2, pBufferTx, USBGEN_EP_SIZE_INTF0);
+		mSubmitTransfer_INTF0(pBdtTxEp2, USBGEN_EP_SIZE_INTF0);
+
+		mBDT_TogglePP(pBdtTxEp2);
+	}
+}
+
+void doBenchmarkLoop_INTF0(void)
+{
+	WORD Length;
+	BYTE* pBufferRx;
+	BYTE* pBufferTx;
+
+	if (!USBHandleBusy(pBdtRxEp1) && !USBHandleBusy(pBdtTxEp1))
+	{
+		pBufferTx = USBHandleGetAddr(pBdtRxEp1);
+		pBufferRx = USBHandleGetAddr(pBdtTxEp1);
+#if INTF0_1==EP_ISO
+		Length = USBGEN_EP_SIZE_INTF0;
+#else
+		Length = mBDT_GetLength(pBdtRxEp1);
+#endif
+		mBDT_FillTransfer(pBdtTxEp1, pBufferTx, Length);
+		mSubmitTransfer_INTF0(pBdtTxEp1, Length);
+		mBDT_TogglePP(pBdtTxEp1);
+
+		mBDT_FillTransfer(pBdtRxEp1, pBufferRx, USBGEN_EP_SIZE_INTF0);
+		mSubmitTransfer_INTF0(pBdtRxEp1, USBGEN_EP_SIZE_INTF0);
+		mBDT_TogglePP(pBdtRxEp1);
+	
+	}
+
+	if (!USBHandleBusy(pBdtRxEp2) && !USBHandleBusy(pBdtTxEp2))
+	{
+		pBufferTx = USBHandleGetAddr(pBdtRxEp2);
+		pBufferRx = USBHandleGetAddr(pBdtTxEp2);
+#if INTF0_2==EP_ISO
+		Length = USBGEN_EP_SIZE_INTF0;
+#else
+		Length = mBDT_GetLength(pBdtRxEp2);
+#endif
+		mBDT_FillTransfer(pBdtTxEp2, pBufferTx, Length);
+		mSubmitTransfer_INTF0(pBdtTxEp2, Length);
+		mBDT_TogglePP(pBdtTxEp2);
+
+		mBDT_FillTransfer(pBdtRxEp2, pBufferRx, USBGEN_EP_SIZE_INTF0);
+		mSubmitTransfer_INTF0(pBdtRxEp2, USBGEN_EP_SIZE_INTF0);
+		mBDT_TogglePP(pBdtRxEp2);
+	}
+}
+
+void doBenchmarkRead_INTF0(void)
+{
+	BYTE* pBufferRx;
+
+	if (!USBHandleBusy(pBdtRxEp1))
+	{
+		pBufferRx = USBHandleGetAddr(pBdtRxEp1);
+		mBDT_FillTransfer(pBdtRxEp1, pBufferRx, USBGEN_EP_SIZE_INTF0);
+		mSubmitTransfer_INTF0(pBdtRxEp1, USBGEN_EP_SIZE_INTF0);
+		mBDT_TogglePP(pBdtRxEp1);
+	}
+
+	if (!USBHandleBusy(pBdtRxEp2))
+	{
+		pBufferRx = USBHandleGetAddr(pBdtRxEp2);
+		mBDT_FillTransfer(pBdtRxEp2, pBufferRx, USBGEN_EP_SIZE_INTF0);
+		mSubmitTransfer_INTF0(pBdtRxEp2, USBGEN_EP_SIZE_INTF0);
+		mBDT_TogglePP(pBdtRxEp2);
+	}
+}
+
+#ifdef DUAL_INTERFACE
+void doBenchmarkWrite_INTF1(void)
+{
+	BYTE* pBufferTx;
+	if (!USBHandleBusy(pBdtTxEp2))
+	{
+		pBufferTx = USBHandleGetAddr(pBdtTxEp2);
+		mSetWritePacketID(pBufferTx, USBGEN_EP_SIZE_INTF1, FillCount_INTF1, NextPacketKey_INTF1);
+		mBDT_FillTransfer(pBdtTxEp2, pBufferTx, USBGEN_EP_SIZE_INTF1);
+		mSubmitTransfer_INTF1(pBdtTxEp2, USBGEN_EP_SIZE_INTF1);
+
+		mBDT_TogglePP(pBdtTxEp2);
+	}
+}
+
+void doBenchmarkLoop_INTF1(void)
+{
+	WORD Length;
+	BYTE* pBufferRx;
+	BYTE* pBufferTx;
+
+	if (!USBHandleBusy(pBdtRxEp2) && !USBHandleBusy(pBdtTxEp2))
+	{
+		pBufferTx = USBHandleGetAddr(pBdtRxEp2);
+		pBufferRx = USBHandleGetAddr(pBdtTxEp2);
+#if INTF1==EP_ISO
+		Length = USBGEN_EP_SIZE_INTF1;
+#else
+		Length = mBDT_GetLength(pBdtRxEp2);
+#endif
+		mBDT_FillTransfer(pBdtTxEp2, pBufferTx, Length);
+		mSubmitTransfer_INTF1(pBdtTxEp2, Length);
+		mBDT_TogglePP(pBdtTxEp2);
+
+		mBDT_FillTransfer(pBdtRxEp2, pBufferRx, USBGEN_EP_SIZE_INTF1);
+		mSubmitTransfer_INTF1(pBdtRxEp2, USBGEN_EP_SIZE_INTF1);
+		mBDT_TogglePP(pBdtRxEp2);
+	
+	}
+}
+
+void doBenchmarkRead_INTF1(void)
+{
+	BYTE* pBufferRx;
+
+	if (!USBHandleBusy(pBdtRxEp2))
+	{
+		pBufferRx = USBHandleGetAddr(pBdtRxEp2);
+		mBDT_FillTransfer(pBdtRxEp2, pBufferRx, USBGEN_EP_SIZE_INTF1);
+		mSubmitTransfer_INTF1(pBdtRxEp2, USBGEN_EP_SIZE_INTF1);
+		mBDT_TogglePP(pBdtRxEp2);
+	}
+}
+
+#endif

+ 62 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/Benchmark.h

@@ -0,0 +1,62 @@
+/// Benchmark.h
+/// Common header file.
+
+/* USB Benchmark for libusb-win32
+
+    Copyright © 2010 Travis Robinson. <libusbdotnet@gmail.com>
+    website: http://sourceforge.net/projects/libusb-win32
+ 
+    Software License Agreement:
+    
+    The software supplied herewith is intended for use solely and
+    exclusively on Microchip PIC Microcontroller products. This 
+    software is owned by Travis Robinson, and is protected under
+	applicable copyright laws. All rights are reserved. Any use in 
+	violation of the foregoing restrictions may subject the user to 
+	criminal sanctions under applicable laws, as well as to civil 
+	liability for the breach of the terms and conditions of this
+    license.
+
+	You may redistribute and/or modify this file under the terms
+	described above.
+    
+    THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+    WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+    TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+    PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE OWNER SHALL NOT,
+    IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+    CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.	
+*/
+
+#ifndef _BENCHMARK_H
+#define _BENCHMARK_H
+
+/** INCLUDES *******************************************************/
+#include "USB/usb.h"
+#include "USB/usb_function_generic.h"
+#include "HardwareProfile.h"
+
+// These are vendor specific commands
+// See the PICFW_COMMANDS for details
+// on how this is implemented.
+enum TestType
+{
+    TEST_NONE,
+    TEST_PCREAD,
+    TEST_PCWRITE,
+    TEST_LOOP
+};
+
+/** BMARK CALLBACKS ************************************************/
+void USBCBCheckOtherReq(void);
+void USBCBInitEP(void);
+
+/** USB FW EXTERNS DEFINES *****************************************/
+extern volatile CTRL_TRF_SETUP SetupPkt;
+
+/** BMARK DEFINES **************************************************/
+void Benchmark_ProcessIO(void);
+void Benchmark_Init(void);
+
+#endif
+

+ 91 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/CleanUp.bat

@@ -0,0 +1,91 @@
+@echo off
+REM Remove files generated by compiler in this directory
+REM and all subdirectories.
+
+echo Removing *.$$$ files...
+del *.$$$ /f /q /s
+echo.
+
+echo Removing *.bkx files...
+del *.bkx /f /q /s
+echo.
+
+echo Removing *.cce files...
+del *.cce /f /q /s
+echo.
+
+echo Removing *.cod files...
+del *.cod /f /q /s
+echo.
+
+echo Removing *.cof files...
+del *.cof /f /q /s
+echo.
+
+echo Removing *.err files...
+del *.err /f /q /s
+echo.
+
+echo Removing *.hex files...
+del *.hex /f /q /s
+echo.
+
+echo Removing *.i files...
+del *.i /f /q /s
+echo.
+
+echo Removing *.lde files...
+del *.lde /f /q /s
+echo.
+
+echo Removing *.lst files...
+del *.lst /f /q /s
+echo.
+
+echo Removing *.obj files...
+del *.obj /f /q /s
+echo.
+
+echo Removing *.o files...
+del *.o /f /q /s
+echo.
+
+echo Removing *.rlf files...
+del *.rlf /f /q /s
+echo.
+
+echo Removing *.sym files...
+del *.sym /f /q /s
+echo.
+
+echo Removing *.sdb files...
+del *.sdb /f /q /s
+echo.
+
+echo Removing *.wat files...
+del *.wat /f /q /s
+echo.
+
+echo Removing *.mcs files...
+del *.mcs /f /q /s
+echo.
+
+echo Removing *.mptags files...
+del *.mptags /f /q /s
+echo.
+
+echo Removing *.tagsrc files...
+del *.tagsrc /f /q /s
+echo.
+
+echo Removing *.map files...
+del *.map /f /q /s
+echo.
+
+echo Removing *.elf files...
+del *.elf /f /q /s
+echo.
+
+rd Objects /S /Q
+
+echo Done.

+ 136 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - Low Pin Count USB Development Kit.h

@@ -0,0 +1,136 @@
+/********************************************************************
+ FileName:      HardwareProfile - Low Pin Count USB Development Kit.h
+ Dependencies:  See INCLUDES section
+ Processor:     PIC18 or PIC24 USB Microcontrollers
+ Hardware:      Low Pin Count USB Development Kit
+ Compiler:      Microchip C18
+ Company:       Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+  Rev   Date         Description
+  1.0   11/19/2004   Initial release
+  2.1   02/26/2007   Updated for simplicity and to use common
+                     coding style
+  2.3   09/15/2008   Broke out each hardware platform into its own
+                     "HardwareProfile - xxx.h" file
+********************************************************************/
+
+#ifndef HARDWARE_PROFILE_LOW_PIN_COUNT_USB_DEVELOPMENT_KIT_H
+#define HARDWARE_PROFILE_LOW_PIN_COUNT_USB_DEVELOPMENT_KIT_H
+
+    /*******************************************************************/
+    /******** USB stack hardware selection options *********************/
+    /*******************************************************************/
+    //This section is the set of definitions required by the MCHPFSUSB
+    //  framework.  These definitions tell the firmware what mode it is
+    //  running in, and where it can find the results to some information
+    //  that the stack needs.
+    //These definitions are required by every application developed with
+    //  this revision of the MCHPFSUSB framework.  Please review each
+    //  option carefully and determine which options are desired/required
+    //  for your application.
+
+    //#define USE_SELF_POWER_SENSE_IO	
+    #define tris_self_power     TRISAbits.TRISA2    // Input
+    #if defined(USE_SELF_POWER_SENSE_IO)
+    #define self_power          PORTAbits.RA2
+    #else
+    #define self_power          1
+    #endif
+
+    //#define USE_USB_BUS_SENSE_IO
+    #define tris_usb_bus_sense  TRISAbits.TRISA1    // Input
+    #if defined(USE_USB_BUS_SENSE_IO)
+    #define USB_BUS_SENSE       PORTAbits.RA1
+    #else
+    #define USB_BUS_SENSE       1
+    #endif
+
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /******** Application specific definitions *************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+
+    //Uncomment the following line to make the output HEX of this 
+    //  project work with the HID Bootloader
+    #define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER	
+
+    /** Board definition ***********************************************/
+    //These defintions will tell the main() function which board is
+    //  currently selected.  This will allow the application to add
+    //  the correct configuration bits as wells use the correct
+    //  initialization functions for the board.  These defitions are only
+    //  required in the stack provided demos.  They are not required in
+    //  final application design.
+    
+    #define DEMO_BOARD LOW_PIN_COUNT_USB_DEVELOPMENT_KIT
+    #define LOW_PIN_COUNT_USB_DEVELOPMENT_KIT
+    #define CLOCK_FREQ 48000000
+    
+    /** LED ************************************************************/
+    #define mInitAllLEDs()      LATC &= 0xF0; TRISC &= 0xF0;
+    
+    #define mLED_1              LATCbits.LATC0
+    #define mLED_2              LATCbits.LATC1
+    #define mLED_3              LATCbits.LATC2
+    #define mLED_4              LATCbits.LATC3
+    
+    #define mGetLED_1()         mLED_1
+    #define mGetLED_2()         mLED_2
+    #define mGetLED_3()         mLED_3
+    #define mGetLED_4()         mLED_4
+
+    #define mLED_1_On()         mLED_1 = 1;
+    #define mLED_2_On()         mLED_2 = 1;
+    #define mLED_3_On()         mLED_3 = 1;
+    #define mLED_4_On()         mLED_4 = 1;
+    
+    #define mLED_1_Off()        mLED_1 = 0;
+    #define mLED_2_Off()        mLED_2 = 0;
+    #define mLED_3_Off()        mLED_3 = 0;
+    #define mLED_4_Off()        mLED_4 = 0;
+    
+    #define mLED_1_Toggle()     mLED_1 = !mLED_1;
+    #define mLED_2_Toggle()     mLED_2 = !mLED_2;
+    #define mLED_3_Toggle()     mLED_3 = !mLED_3;
+    #define mLED_4_Toggle()     mLED_4 = !mLED_4;
+    
+    /** SWITCH *********************************************************/
+    #define mInitSwitch2()      //TRISAbits.TRISA3=1
+        //only one switch available so double duty
+    #define mInitSwitch3()      //TRISAbits.TRISA3=1
+    #define sw2                 PORTAbits.RA3
+    #define sw3                 PORTAbits.RA3
+    #define mInitAllSwitches()  mInitSwitch2();
+
+    /** I/O pin definitions ********************************************/
+    #define INPUT_PIN 1
+    #define OUTPUT_PIN 0
+
+#endif  //HARDWARE_PROFILE_LOW_PIN_COUNT_USB_DEVELOPMENT_KIT_H

+ 127 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC18F46J50 PIM.h

@@ -0,0 +1,127 @@
+/********************************************************************
+ FileName:     	HardwareProfile - PIC18F46J50 PIM.h
+ Dependencies:	See INCLUDES section
+ Processor:	PIC18 USB Microcontrollers
+ Hardware:	PIC18F46J50 PIM
+ Compiler:  	Microchip C18
+ Company:	Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+  Rev   Date         Description
+  1.0   11/19/2004   Initial release
+  2.1   02/26/2007   Updated for simplicity and to use common
+                     coding style
+  2.3   09/15/2008   Broke out each hardware platform into its own
+                     "HardwareProfile - xxx.h" file
+********************************************************************/
+
+#ifndef HARDWARE_PROFILE_PIC18F46J50_PIM_H
+#define HARDWARE_PROFILE_PIC18F46J50_PIM_H
+
+    /*******************************************************************/
+    /******** USB stack hardware selection options *********************/
+    /*******************************************************************/
+    //This section is the set of definitions required by the MCHPFSUSB
+    //  framework.  These definitions tell the firmware what mode it is
+    //  running in, and where it can find the results to some information
+    //  that the stack needs.
+    //These definitions are required by every application developed with
+    //  this revision of the MCHPFSUSB framework.  Please review each
+    //  option carefully and determine which options are desired/required
+    //  for your application.
+
+    //#define USE_SELF_POWER_SENSE_IO
+    #define tris_self_power     TRISCbits.TRISC2    // Input
+    #define self_power          1
+
+    //#define USE_USB_BUS_SENSE_IO
+    #define tris_usb_bus_sense  TRISCbits.TRISC2    // Input
+    #define USB_BUS_SENSE       1 
+ 
+    //Uncomment this to make the output HEX of this project 
+    //   to be able to be bootloaded using the HID bootloader
+	#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER		
+
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /******** Application specific definitions *************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+
+    /** Board definition ***********************************************/
+    //These defintions will tell the main() function which board is
+    //  currently selected.  This will allow the application to add
+    //  the correct configuration bits as wells use the correct
+    //  initialization functions for the board.  These defitions are only
+    //  required in the stack provided demos.  They are not required in
+    //  final application design.
+    #define DEMO_BOARD PIC18F46J50_PIM
+    #define PIC18F46J50_PIM
+    #define CLOCK_FREQ 48000000
+    #define GetSystemClock() CLOCK_FREQ   
+    #define GetInstructionClock() GetSystemClock()
+
+    /** LED ************************************************************/
+    #define mInitAllLEDs()      LATE &= 0xFC; TRISE &= 0xFC;
+    
+    #define mLED_1              LATEbits.LATE0
+    #define mLED_2              LATEbits.LATE1
+    #define mLED_3              
+    #define mLED_4              
+    
+    #define mGetLED_1()         mLED_1
+    #define mGetLED_2()         mLED_2
+    #define mGetLED_3()         1
+    #define mGetLED_4()         1
+
+    #define mLED_1_On()         mLED_1 = 1;
+    #define mLED_2_On()         mLED_2 = 1;
+    #define mLED_3_On()         
+    #define mLED_4_On()        
+    
+    #define mLED_1_Off()        mLED_1 = 0;
+    #define mLED_2_Off()        mLED_2 = 0;
+    #define mLED_3_Off()        
+    #define mLED_4_Off()        
+    
+    #define mLED_1_Toggle()     mLED_1 = !mLED_1;
+    #define mLED_2_Toggle()     mLED_2 = !mLED_2;
+    #define mLED_3_Toggle()     
+    #define mLED_4_Toggle() 
+    
+    /** SWITCH *********************************************************/
+    #define mInitSwitch2()      TRISBbits.TRISB2=1;
+    #define mInitSwitch3()      mInitSwitch2();
+    #define mInitAllSwitches()  mInitSwitch2();
+    #define sw2                 PORTBbits.RB2
+    #define sw3                 PORTBbits.RB2
+
+    /** I/O pin definitions ********************************************/
+    #define INPUT_PIN 1
+    #define OUTPUT_PIN 0
+#endif  //HARDWARE_PROFILE_PIC18F46J50_PIM_H

+ 153 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC18F87J50 PIM.h

@@ -0,0 +1,153 @@
+/********************************************************************
+ FileName:     	HardwareProfile - PIC18F87J50 PIM.h
+ Dependencies:	See INCLUDES section
+ Processor:	PIC18 USB Microcontrollers
+ Hardware:	PIC18F87J50 PIM
+ Compiler:  	Microchip C18
+ Company:		Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+  Rev   Date         Description
+  1.0   11/19/2004   Initial release
+  2.1   02/26/2007   Updated for simplicity and to use common
+                     coding style
+  2.3   09/15/2008   Broke out each hardware platform into its own
+                     "HardwareProfile - xxx.h" file
+********************************************************************/
+
+#ifndef HARDWARE_PROFILE_PIC18F87J50_PIM_H
+#define HARDWARE_PROFILE_PIC18F87J50_PIM_H
+
+    /*******************************************************************/
+    /******** USB stack hardware selection options *********************/
+    /*******************************************************************/
+    //This section is the set of definitions required by the MCHPFSUSB
+    //  framework.  These definitions tell the firmware what mode it is
+    //  running in, and where it can find the results to some information
+    //  that the stack needs.
+    //These definitions are required by every application developed with
+    //  this revision of the MCHPFSUSB framework.  Please review each
+    //  option carefully and determine which options are desired/required
+    //  for your application.
+
+    /** USB ************************************************************/
+    //The PIC18F87J50 FS USB Plug-In Module supports the USE_USB_BUS_SENSE_IO
+    //feature.  The USE_SELF_POWER_SENSE_IO feature is not implemented on the
+    //circuit board, so the USE_SELF_POWER_SENSE_IO define should always be
+    //commented for this hardware platform.
+
+    //#define USE_SELF_POWER_SENSE_IO
+    #define tris_self_power     TRISAbits.TRISA2    // Input
+    #if defined(USE_SELF_POWER_SENSE_IO)
+    #define self_power          PORTAbits.RA2
+    #else
+    #define self_power          1
+    #endif
+
+    //#define USE_USB_BUS_SENSE_IO		//JP1 must be in R-U position to use this feature on this board	
+    #define tris_usb_bus_sense  TRISBbits.TRISB5    // Input
+    #if defined(USE_USB_BUS_SENSE_IO)
+    #define USB_BUS_SENSE       PORTBbits.RB5
+    #else
+    #define USB_BUS_SENSE       1
+    #endif
+ 
+    //Uncomment this to make the output HEX of this project 
+    //   to be able to be bootloaded using the HID bootloader
+	#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER		
+
+
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /******** Application specific definitions *************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+
+    /** Board definition ***********************************************/
+    //These defintions will tell the main() function which board is
+    //  currently selected.  This will allow the application to add
+    //  the correct configuration bits as wells use the correct
+    //  initialization functions for the board.  These defitions are only
+    //  required in the stack provided demos.  They are not required in
+    //  final application design.
+    #define DEMO_BOARD PIC18F87J50_PIM
+    #define PIC18F87J50_PIM
+    #define CLOCK_FREQ 48000000
+    #define GetSystemClock()  CLOCK_FREQ   
+    #define GetInstructionClock() CLOCK_FREQ   
+    
+    /** LED ************************************************************/
+    #define mInitAllLEDs()      {LATE &= 0xFC; TRISE &= 0xFC; LATD &= 0xF3; TRISD &= 0xF3;}
+    
+    #define mLED_1              LATEbits.LATE0
+    #define mLED_2              LATEbits.LATE1
+    #define mLED_3              LATDbits.LATD2
+    #define mLED_4              LATDbits.LATD3
+    
+    #define mGetLED_1()         mLED_1
+    #define mGetLED_2()         mLED_2
+    #define mGetLED_3()         mLED_3
+    #define mGetLED_4()         mLED_4
+
+    #define mLED_1_On()         mLED_1 = 1;
+    #define mLED_2_On()         mLED_2 = 1;
+    #define mLED_3_On()         mLED_3 = 1;
+    #define mLED_4_On()         mLED_4 = 1;
+    
+    #define mLED_1_Off()        mLED_1 = 0;
+    #define mLED_2_Off()        mLED_2 = 0;
+    #define mLED_3_Off()        mLED_3 = 0;
+    #define mLED_4_Off()        mLED_4 = 0;
+    
+    #define mLED_1_Toggle()     mLED_1 = !mLED_1;
+    #define mLED_2_Toggle()     mLED_2 = !mLED_2;
+    #define mLED_3_Toggle()     mLED_3 = !mLED_3;
+    #define mLED_4_Toggle()     mLED_4 = !mLED_4;
+    
+    /** SWITCH *********************************************************/
+    #define mInitAllSwitches()  TRISBbits.TRISB4=1;
+    #define mInitSwitch2()      TRISBbits.TRISB4=1;
+    #define mInitSwitch3()      TRISBbits.TRISB4=1;
+    #define sw2                 PORTBbits.RB4
+    #define sw3                 PORTBbits.RB4
+    
+    /** POT ************************************************************/
+    #define mInitPOT()          {TRISAbits.TRISA0=1;			\
+    							 WDTCONbits.ADSHR = 1;			\
+    							 ANCON0bits.PCFG0 = 1;			\
+    							 WDTCONbits.ADSHR = 0;			\
+    							 ADCON0=0x01;					\
+    							 ADCON1=0xBE;}		// POT on HPC Explorer				
+    
+    /** I 2 C   T E M P   S E N S E *************************************/
+    #define	mInitI2CPins()		TRISC |= 0x18;		// RC3 and RC4 are I2C
+    
+    /** I/O pin definitions ********************************************/
+    #define INPUT_PIN 1
+    #define OUTPUT_PIN 0
+#endif  //HARDWARE_PROFILE_PIC18F87J50_PIM_H

+ 130 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC24F Starter Kit.h

@@ -0,0 +1,130 @@
+/********************************************************************
+ FileName:      HardwareProfile - PIC24F Starter Kit.h
+ Dependencies:  See INCLUDES section
+ Processor:     PIC24FJ256GB106
+ Hardware:      PIC24F Starter Kit
+ Compiler:      Microchip C30
+ Company:       Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+  Rev   Date         Description
+  1.0   11/19/2004   Initial release
+  2.1   02/26/2007   Updated for simplicity and to use common
+                     coding style
+  2.3   09/15/2008   Broke out each hardware platform into its own
+                     "HardwareProfile - xxx.h" file
+********************************************************************/
+
+#ifndef HARDWARE_PROFILE_PIC24F_STARTER_KIT_H
+#define HARDWARE_PROFILE_PIC24F_STARTER_KIT_H
+
+    /*******************************************************************/
+    /******** USB stack hardware selection options *********************/
+    /*******************************************************************/
+    //This section is the set of definitions required by the MCHPFSUSB
+    //  framework.  These definitions tell the firmware what mode it is
+    //  running in, and where it can find the results to some information
+    //  that the stack needs.
+    //These definitions are required by every application developed with
+    //  this revision of the MCHPFSUSB framework.  Please review each
+    //  option carefully and determine which options are desired/required
+    //  for your application.
+
+    //#define USE_SELF_POWER_SENSE_IO
+    #define tris_self_power     TRISAbits.TRISA2    // Input
+    #define self_power          1
+
+    //#define USE_USB_BUS_SENSE_IO
+    #define tris_usb_bus_sense  U1OTGSTATbits.SESVD  //TRISBbits.TRISB5    // Input
+    #define USB_BUS_SENSE       U1OTGSTATbits.SESVD
+   
+    //Uncomment this to make the output HEX of this project 
+    //   to be able to be bootloaded using the HID bootloader
+    #define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER	
+
+    //If the application is going to be used with the HID bootloader
+    //  then this will provide a function for the application to 
+    //  enter the bootloader from the application (optional)
+    #if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)
+        #define EnterBootloader() __asm__("goto 0x400")
+    #endif   
+
+
+
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /******** Application specific definitions *************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+
+    /** Board definition ***********************************************/
+    //These defintions will tell the main() function which board is
+    //  currently selected.  This will allow the application to add
+    //  the correct configuration bits as wells use the correct
+    //  initialization functions for the board.  These defitions are only
+    //  required in the stack provided demos.  They are not required in
+    //  final application design.
+    #define DEMO_BOARD PIC24F_STARTER_KIT
+    #define PIC24F_STARTER_KIT
+    #define CLOCK_FREQ 32000000
+   
+    /** LED ************************************************************/
+    #define mInitAllLEDs()      LATG &= 0xFE1F; TRISG &= 0xFE1F; LATF &= 0xFFCF; TRISF &= 0xFFCF; //G6,7,8,9 and F4,5
+    
+    #define mGetLED_1()         (TRISG & ~0x0180?1:0)
+    #define mGetLED_2()         (TRISG & ~0x0060?1:0)
+    #define mGetLED_3()         (TRISF & ~0x0030?1:0)
+    #define mGetLED_4()              
+
+    #define mLED_1_On()         TRISG |= 0x0180; 
+    #define mLED_2_On()         TRISG |= 0x0060; 
+    #define mLED_3_On()         TRISF |= 0x0030; 
+    #define mLED_4_On()          
+    
+    #define mLED_1_Off()        TRISG &= ~0x0180; 
+    #define mLED_2_Off()        TRISG &= ~0x0060;  
+    #define mLED_3_Off()        TRISF &= ~0x0030;  
+    #define mLED_4_Off()         
+    
+    #define mLED_1_Toggle()     TRISG ^= 0x0180; 
+    #define mLED_2_Toggle()     TRISG ^= 0x0060;  
+    #define mLED_3_Toggle()     TRISF ^= 0x0030; 
+    #define mLED_4_Toggle()      
+    
+    /** SWITCH *********************************************************/
+    #define mInitSwitch2()      TRISDbits.TRISD6=1;
+    #define mInitSwitch3()      TRISDbits.TRISD7=1;
+    #define mInitAllSwitches()  mInitSwitch2();mInitSwitch3();
+    #define sw2                 PORTDbits.RD6
+    #define sw3                 PORTDbits.RD7
+
+    /** I/O pin definitions ********************************************/
+    #define INPUT_PIN 1
+    #define OUTPUT_PIN 0
+    
+#endif  //HARDWARE_PROFILE_PIC24F_STARTER_KIT_H

+ 137 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC24FJ256GB110 PIM.h

@@ -0,0 +1,137 @@
+/********************************************************************
+ FileName:     	HardwareProfile - PIC24FJ256GB110 PIM.h
+ Dependencies:  See INCLUDES section
+ Processor:     PIC24FJ256GB110
+ Hardware:      PIC24FJ256GB110 PIM
+ Compiler:      Microchip C30
+ Company:       Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+  Rev   Date         Description
+  1.0   11/19/2004   Initial release
+  2.1   02/26/2007   Updated for simplicity and to use common
+                     coding style
+  2.3   09/15/2008   Broke out each hardware platform into its own
+                     "HardwareProfile - xxx.h" file
+********************************************************************/
+
+#ifndef HARDWARE_PROFILE_PIC24FJ256GB110_PIM_H
+#define HARDWARE_PROFILE_PIC24FJ256GB110_PIM_H
+
+    /*******************************************************************/
+    /******** USB stack hardware selection options *********************/
+    /*******************************************************************/
+    //This section is the set of definitions required by the MCHPFSUSB
+    //  framework.  These definitions tell the firmware what mode it is
+    //  running in, and where it can find the results to some information
+    //  that the stack needs.
+    //These definitions are required by every application developed with
+    //  this revision of the MCHPFSUSB framework.  Please review each
+    //  option carefully and determine which options are desired/required
+    //  for your application.
+
+    //#define USE_SELF_POWER_SENSE_IO
+    #define tris_self_power     TRISAbits.TRISA2    // Input
+    #define self_power          1
+
+    //#define USE_USB_BUS_SENSE_IO
+    #define tris_usb_bus_sense  TRISBbits.TRISB5    // Input
+    #define USB_BUS_SENSE       1 
+   
+    //Uncomment this to make the output HEX of this project 
+    //   to be able to be bootloaded using the HID bootloader
+    #define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER	
+
+    //If the application is going to be used with the HID bootloader
+    //  then this will provide a function for the application to 
+    //  enter the bootloader from the application (optional)
+    #if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)
+        #define EnterBootloader() __asm__("goto 0x400")
+    #endif   
+
+
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /******** Application specific definitions *************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+
+    /** Board definition ***********************************************/
+    //These defintions will tell the main() function which board is
+    //  currently selected.  This will allow the application to add
+    //  the correct configuration bits as wells use the correct
+    //  initialization functions for the board.  These defitions are only
+    //  required in the stack provided demos.  They are not required in
+    //  final application design.
+    #define DEMO_BOARD PIC24FJ256GB110_PIM
+    #define EXPLORER_16
+    #define PIC24FJ256GB110_PIM
+    #define CLOCK_FREQ 32000000
+    #define GetSystemClock() CLOCK_FREQ
+    #define GetInstructionClock() GetSystemClock()
+    
+    /** LED ************************************************************/
+    #define mInitAllLEDs()      LATA &= 0xF0; TRISA &= 0xF0;
+    
+    #define mLED_1              LATAbits.LATA0
+    #define mLED_2              LATAbits.LATA1
+    #define mLED_3              LATAbits.LATA2
+    #define mLED_4              LATAbits.LATA3
+
+    #define mGetLED_1()         mLED_1
+    #define mGetLED_2()         mLED_2
+    #define mGetLED_3()         mLED_3
+    #define mGetLED_4()         mLED_4     
+    
+    #define mLED_1_On()         mLED_1 = 1;
+    #define mLED_2_On()         mLED_2 = 1;
+    #define mLED_3_On()         mLED_3 = 1;
+    #define mLED_4_On()         mLED_4 = 1;
+    
+    #define mLED_1_Off()        mLED_1 = 0;
+    #define mLED_2_Off()        mLED_2 = 0;
+    #define mLED_3_Off()        mLED_3 = 0;
+    #define mLED_4_Off()        mLED_4 = 0;
+    
+    #define mLED_1_Toggle()     mLED_1 = !mLED_1;
+    #define mLED_2_Toggle()     mLED_2 = !mLED_2;
+    #define mLED_3_Toggle()     mLED_3 = !mLED_3;
+    #define mLED_4_Toggle()     mLED_4 = !mLED_4;
+    
+    /** SWITCH *********************************************************/
+    #define mInitSwitch2()      TRISDbits.TRISD6=1;
+    #define mInitSwitch3()      TRISDbits.TRISD7=1;
+    #define mInitAllSwitches()  mInitSwitch2();mInitSwitch3();
+    #define sw2                 PORTDbits.RD6
+    #define sw3                 PORTDbits.RD7
+
+    /** I/O pin definitions ********************************************/
+    #define INPUT_PIN 1
+    #define OUTPUT_PIN 0
+
+#endif  //HARDWARE_PROFILE_PIC24FJ256GB110_PIM_H

+ 128 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC24FJ64GB002 BreadBoard.h

@@ -0,0 +1,128 @@
+/********************************************************************
+ FileName:     	HardwareProfile - PIC24FJ64GB004 PIM.h
+ Dependencies:  See INCLUDES section
+ Processor:     PIC24FJ64GB004
+ Hardware:      PIC24FJ64GB004 PIM
+ Compiler:      Microchip C30
+ Company:       Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+  Rev   Date         Description
+  1.0   11/19/2004   Initial release
+  2.1   02/26/2007   Updated for simplicity and to use common
+                     coding style
+  2.3   09/15/2008   Broke out each hardware platform into its own
+                     "HardwareProfile - xxx.h" file
+  2.4b  04/08/2009   Initial support for PIC24FJ64GB004 family
+********************************************************************/
+
+#ifndef HARDWARE_PROFILE_PIC24FJ64GB002_BREADBOARD_H
+#define HARDWARE_PROFILE_PIC24FJ64GB002_BREADBOARD_H
+
+    /*******************************************************************/
+    /******** USB stack hardware selection options *********************/
+    /*******************************************************************/
+    //This section is the set of definitions required by the MCHPFSUSB
+    //  framework.  These definitions tell the firmware what mode it is
+    //  running in, and where it can find the results to some information
+    //  that the stack needs.
+    //These definitions are required by every application developed with
+    //  this revision of the MCHPFSUSB framework.  Please review each
+    //  option carefully and determine which options are desired/required
+    //  for your application.
+
+    //#define USE_SELF_POWER_SENSE_IO
+    #define tris_self_power     TRISAbits.TRISA2    // Input
+    #define self_power          1
+
+    //#define USE_USB_BUS_SENSE_IO
+    #define tris_usb_bus_sense  TRISBbits.TRISB5    // Input
+    #define USB_BUS_SENSE       1 
+   
+    //Uncomment this to make the output HEX of this project 
+    //   to be able to be bootloaded using the HID bootloader
+    #define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER	
+
+    //If the application is going to be used with the HID bootloader
+    //  then this will provide a function for the application to 
+    //  enter the bootloader from the application (optional)
+    #if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)
+        #define EnterBootloader() __asm__("goto 0x400")
+    #endif   
+
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /******** Application specific definitions *************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+
+    /** Board definition ***********************************************/
+    //These defintions will tell the main() function which board is
+    //  currently selected.  This will allow the application to add
+    //  the correct configuration bits as wells use the correct
+    //  initialization functions for the board.  These defitions are only
+    //  required in the stack provided demos.  They are not required in
+    //  final application design.
+    #define DEMO_BOARD PIC24FJ64GB002
+    #define BREADBOARD
+    #define PIC24FJ64GB002_BREADBOARD
+    #define CLOCK_FREQ 32000000
+    #define GetSystemClock() CLOCK_FREQ
+    #define GetInstructionClock() GetSystemClock()
+    
+    /** LED ************************************************************/
+    #define mInitAllLEDs()      LATB &= 0xFF5F; TRISB &= 0xFF5F; ODCB|=0x00A0;
+    
+    #define mLED_1              LATBbits.LATB7
+    #define mLED_2              LATBbits.LATB5
+
+    #define mGetLED_1()         (!mLED_1)
+    #define mGetLED_2()         (!mLED_2)
+   
+    
+    #define mLED_1_On()         mLED_1 = 0;
+    #define mLED_2_On()         mLED_2 = 0;
+    
+    #define mLED_1_Off()        mLED_1 = 1;
+    #define mLED_2_Off()        mLED_2 = 1;
+    
+    #define mLED_1_Toggle()     mLED_1 = !mLED_1;
+    #define mLED_2_Toggle()     mLED_2 = !mLED_2;
+    
+    /** SWITCH *********************************************************/
+    #define mInitSwitch2()      TRISAbits.TRISA10=1;
+    #define mInitSwitch3()      TRISAbits.TRISA9=1;
+    #define mInitAllSwitches()  
+    #define sw2                 PORTAbits.RA10
+    #define sw3                 PORTAbits.RA9
+
+    /** I/O pin definitions ********************************************/
+    #define INPUT_PIN 1
+    #define OUTPUT_PIN 0
+
+#endif  //HARDWARE_PROFILE_PIC24FJ64GB002_BREADBOARD_H

+ 137 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC24FJ64GB004 PIM.h

@@ -0,0 +1,137 @@
+/********************************************************************
+ FileName:     	HardwareProfile - PIC24FJ64GB004 PIM.h
+ Dependencies:  See INCLUDES section
+ Processor:     PIC24FJ64GB004
+ Hardware:      PIC24FJ64GB004 PIM
+ Compiler:      Microchip C30
+ Company:       Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+  Rev   Date         Description
+  1.0   11/19/2004   Initial release
+  2.1   02/26/2007   Updated for simplicity and to use common
+                     coding style
+  2.3   09/15/2008   Broke out each hardware platform into its own
+                     "HardwareProfile - xxx.h" file
+  2.4b  04/08/2009   Initial support for PIC24FJ64GB004 family
+********************************************************************/
+
+#ifndef HARDWARE_PROFILE_PIC24FJ64GB004_PIM_H
+#define HARDWARE_PROFILE_PIC24FJ64GB004_PIM_H
+
+    /*******************************************************************/
+    /******** USB stack hardware selection options *********************/
+    /*******************************************************************/
+    //This section is the set of definitions required by the MCHPFSUSB
+    //  framework.  These definitions tell the firmware what mode it is
+    //  running in, and where it can find the results to some information
+    //  that the stack needs.
+    //These definitions are required by every application developed with
+    //  this revision of the MCHPFSUSB framework.  Please review each
+    //  option carefully and determine which options are desired/required
+    //  for your application.
+
+    //#define USE_SELF_POWER_SENSE_IO
+    #define tris_self_power     TRISAbits.TRISA2    // Input
+    #define self_power          1
+
+    //#define USE_USB_BUS_SENSE_IO
+    #define tris_usb_bus_sense  TRISBbits.TRISB5    // Input
+    #define USB_BUS_SENSE       1 
+   
+    //Uncomment this to make the output HEX of this project 
+    //   to be able to be bootloaded using the HID bootloader
+    #define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER	
+
+    //If the application is going to be used with the HID bootloader
+    //  then this will provide a function for the application to 
+    //  enter the bootloader from the application (optional)
+    #if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)
+        #define EnterBootloader() __asm__("goto 0x400")
+    #endif   
+
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /******** Application specific definitions *************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+
+    /** Board definition ***********************************************/
+    //These defintions will tell the main() function which board is
+    //  currently selected.  This will allow the application to add
+    //  the correct configuration bits as wells use the correct
+    //  initialization functions for the board.  These defitions are only
+    //  required in the stack provided demos.  They are not required in
+    //  final application design.
+    #define DEMO_BOARD PIC24FJ64GB004_PIM
+    #define EXPLORER_16
+    #define PIC24FJ64GB004_PIM
+    #define CLOCK_FREQ 32000000
+    #define GetSystemClock() CLOCK_FREQ
+    #define GetInstructionClock() GetSystemClock()
+    
+    /** LED ************************************************************/
+    #define mInitAllLEDs()      LATA &= 0xFD7F; TRISA &= 0xFD7F; LATB &= 0xFFF3; TRISB &= 0xFFF3;
+    
+    #define mLED_1              LATAbits.LATA7
+    #define mLED_2              LATBbits.LATB3
+    #define mLED_3              LATBbits.LATB2
+    #define mLED_4              LATAbits.LATA9
+
+    #define mGetLED_1()         mLED_1
+    #define mGetLED_2()         mLED_2
+    #define mGetLED_3()         mLED_3
+    #define mGetLED_4()         mLED_4     
+    
+    #define mLED_1_On()         mLED_1 = 1;
+    #define mLED_2_On()         mLED_2 = 1;
+    #define mLED_3_On()         mLED_3 = 1;
+    #define mLED_4_On()         mLED_4 = 1;
+    
+    #define mLED_1_Off()        mLED_1 = 0;
+    #define mLED_2_Off()        mLED_2 = 0;
+    #define mLED_3_Off()        mLED_3 = 0;
+    #define mLED_4_Off()        mLED_4 = 0;
+    
+    #define mLED_1_Toggle()     mLED_1 = !mLED_1;
+    #define mLED_2_Toggle()     mLED_2 = !mLED_2;
+    #define mLED_3_Toggle()     mLED_3 = !mLED_3;
+    #define mLED_4_Toggle()     mLED_4 = !mLED_4;
+    
+    /** SWITCH *********************************************************/
+    #define mInitSwitch2()      TRISAbits.TRISA10=1;
+    #define mInitSwitch3()      TRISAbits.TRISA9=1;
+    #define mInitAllSwitches()  mInitSwitch2();mInitSwitch3();
+    #define sw2                 PORTAbits.RA10
+    #define sw3                 PORTAbits.RA9
+
+    /** I/O pin definitions ********************************************/
+    #define INPUT_PIN 1
+    #define OUTPUT_PIN 0
+
+#endif  //HARDWARE_PROFILE_PIC24FJ64GB004_PIM_H

+ 120 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC32 USB Starter Kit.h

@@ -0,0 +1,120 @@
+/********************************************************************
+ FileName:      HardwareProfile - PIC32MX460F512L PIM.h
+ Dependencies:  See INCLUDES section
+ Processor:     PIC32 USB Microcontrollers
+ Hardware:      PIC32MX460F512L PIM
+ Compiler:      Microchip C32 (for PIC32)
+ Company:       Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+  Rev   Date         Description
+  1.0   11/19/2004   Initial release
+  2.1   02/26/2007   Updated for simplicity and to use common
+                     coding style
+  2.3   09/15/2008   Broke out each hardware platform into its own
+                     "HardwareProfile - xxx.h" file
+********************************************************************/
+
+#ifndef HARDWARE_PROFILE_PIC32MX460F512L_PIM_H
+#define HARDWARE_PROFILE_PIC32MX460F512L_PIM_H
+
+    /*******************************************************************/
+    /******** USB stack hardware selection options *********************/
+    /*******************************************************************/
+    //This section is the set of definitions required by the MCHPFSUSB
+    //  framework.  These definitions tell the firmware what mode it is
+    //  running in, and where it can find the results to some information
+    //  that the stack needs.
+    //These definitions are required by every application developed with
+    //  this revision of the MCHPFSUSB framework.  Please review each
+    //  option carefully and determine which options are desired/required
+    //  for your application.
+
+    //#define USE_SELF_POWER_SENSE_IO
+    #define tris_self_power     TRISAbits.TRISA2    // Input
+    #define self_power          1
+
+    //#define USE_USB_BUS_SENSE_IO
+    #define tris_usb_bus_sense  TRISBbits.TRISB5    // Input
+    #define USB_BUS_SENSE       1 
+
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /******** Application specific definitions *************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+
+    /** Board definition ***********************************************/
+    //These defintions will tell the main() function which board is
+    //  currently selected.  This will allow the application to add
+    //  the correct configuration bits as wells use the correct
+    //  initialization functions for the board.  These defitions are only
+    //  required in the stack provided demos.  They are not required in
+    //  final application design.
+    #define DEMO_BOARD PIC32_USB_STARTER_KIT
+
+    /** LED ************************************************************/
+    #define mInitAllLEDs()      LATD &= 0xFFF8; TRISD &= 0xFFF8;
+    
+    #define mLED_1              LATDbits.LATD0
+    #define mLED_2              LATDbits.LATD1
+    #define mLED_3              LATDbits.LATD2
+    #define mLED_4              
+    
+    #define mGetLED_1()         mLED_1
+    #define mGetLED_2()         mLED_2
+    #define mGetLED_3()         mLED_3
+    #define mGetLED_4()         1
+
+    #define mLED_1_On()         mLED_1 = 1;
+    #define mLED_2_On()         mLED_2 = 1;
+    #define mLED_3_On()         mLED_3 = 1;
+    #define mLED_4_On()         
+    
+    #define mLED_1_Off()        mLED_1 = 0;
+    #define mLED_2_Off()        mLED_2 = 0;
+    #define mLED_3_Off()        mLED_3 = 0;
+    #define mLED_4_Off()        
+    
+    #define mLED_1_Toggle()     mLED_1 = !mLED_1;
+    #define mLED_2_Toggle()     mLED_2 = !mLED_2;
+    #define mLED_3_Toggle()     mLED_3 = !mLED_3;
+    #define mLED_4_Toggle()     
+    
+    /** SWITCH *********************************************************/
+    #define mInitSwitch2()      TRISDbits.TRISD6=1;
+    #define mInitSwitch3()      TRISDbits.TRISD7=1;
+    #define mInitAllSwitches()  mInitSwitch2();mInitSwitch3();
+    #define sw2                 PORTDbits.RD6
+    #define sw3                 PORTDbits.RD7
+
+    /** I/O pin definitions ********************************************/
+    #define INPUT_PIN 1
+    #define OUTPUT_PIN 0
+
+#endif  //HARDWARE_PROFILE_PIC32MX460F512L_PIM_H

+ 121 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PIC32MX460F512L PIM.h

@@ -0,0 +1,121 @@
+/********************************************************************
+ FileName:      HardwareProfile - PIC32MX460F512L PIM.h
+ Dependencies:  See INCLUDES section
+ Processor:     PIC32 USB Microcontrollers
+ Hardware:      PIC32MX460F512L PIM
+ Compiler:      Microchip C32 (for PIC32)
+ Company:       Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+  Rev   Date         Description
+  1.0   11/19/2004   Initial release
+  2.1   02/26/2007   Updated for simplicity and to use common
+                     coding style
+  2.3   09/15/2008   Broke out each hardware platform into its own
+                     "HardwareProfile - xxx.h" file
+********************************************************************/
+
+#ifndef HARDWARE_PROFILE_PIC32MX460F512L_PIM_H
+#define HARDWARE_PROFILE_PIC32MX460F512L_PIM_H
+
+    /*******************************************************************/
+    /******** USB stack hardware selection options *********************/
+    /*******************************************************************/
+    //This section is the set of definitions required by the MCHPFSUSB
+    //  framework.  These definitions tell the firmware what mode it is
+    //  running in, and where it can find the results to some information
+    //  that the stack needs.
+    //These definitions are required by every application developed with
+    //  this revision of the MCHPFSUSB framework.  Please review each
+    //  option carefully and determine which options are desired/required
+    //  for your application.
+
+    //#define USE_SELF_POWER_SENSE_IO
+    #define tris_self_power     TRISAbits.TRISA2    // Input
+    #define self_power          1
+
+    //#define USE_USB_BUS_SENSE_IO
+    #define tris_usb_bus_sense  TRISBbits.TRISB5    // Input
+    #define USB_BUS_SENSE       1 
+
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /******** Application specific definitions *************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+
+    /** Board definition ***********************************************/
+    //These defintions will tell the main() function which board is
+    //  currently selected.  This will allow the application to add
+    //  the correct configuration bits as wells use the correct
+    //  initialization functions for the board.  These defitions are only
+    //  required in the stack provided demos.  They are not required in
+    //  final application design.
+    #define DEMO_BOARD PIC32MX460F512L_PIM
+    #define EXPLORER_16
+
+    /** LED ************************************************************/
+    #define mInitAllLEDs()      LATA &= 0xFFC3; TRISA &= 0xFFC3;
+    
+    #define mLED_1              LATAbits.LATA2
+    #define mLED_2              LATAbits.LATA3
+    #define mLED_3              LATAbits.LATA4
+    #define mLED_4              LATAbits.LATA5
+    
+    #define mGetLED_1()         mLED_1
+    #define mGetLED_2()         mLED_2
+    #define mGetLED_3()         mLED_3
+    #define mGetLED_4()         mLED_4
+
+    #define mLED_1_On()         mLED_1 = 1;
+    #define mLED_2_On()         mLED_2 = 1;
+    #define mLED_3_On()         mLED_3 = 1;
+    #define mLED_4_On()         mLED_4 = 1;
+    
+    #define mLED_1_Off()        mLED_1 = 0;
+    #define mLED_2_Off()        mLED_2 = 0;
+    #define mLED_3_Off()        mLED_3 = 0;
+    #define mLED_4_Off()        mLED_4 = 0;
+    
+    #define mLED_1_Toggle()     mLED_1 = !mLED_1;
+    #define mLED_2_Toggle()     mLED_2 = !mLED_2;
+    #define mLED_3_Toggle()     mLED_3 = !mLED_3;
+    #define mLED_4_Toggle()     mLED_4 = !mLED_4;
+    
+    /** SWITCH *********************************************************/
+    #define mInitSwitch2()      TRISDbits.TRISD6=1;
+    #define mInitSwitch3()      TRISDbits.TRISD7=1;
+    #define mInitAllSwitches()  mInitSwitch2();mInitSwitch3();
+    #define sw2                 PORTDbits.RD6
+    #define sw3                 PORTDbits.RD7
+
+    /** I/O pin definitions ********************************************/
+    #define INPUT_PIN 1
+    #define OUTPUT_PIN 0
+
+#endif  //HARDWARE_PROFILE_PIC32MX460F512L_PIM_H

+ 165 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile - PICDEM FSUSB.h

@@ -0,0 +1,165 @@
+/********************************************************************
+ FileName:     	HardwareProfile - PICDEM FSUSB.h
+ Dependencies:  See INCLUDES section
+ Processor:     PIC18 USB Microcontrollers
+ Hardware:      PICDEM FSUSB
+ Compiler:      Microchip C18
+ Company:       Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+  Rev   Date         Description
+  1.0   11/19/2004   Initial release
+  2.1   02/26/2007   Updated for simplicity and to use common
+                     coding style
+  2.3   09/15/2008   Broke out each hardware platform into its own
+                     "HardwareProfile - xxx.h" file
+********************************************************************/
+
+#ifndef HARDWARE_PROFILE_PICDEM_FSUSB_H
+#define HARDWARE_PROFILE_PICDEM_FSUSB_H
+
+    /*******************************************************************/
+    /******** USB stack hardware selection options *********************/
+    /*******************************************************************/
+    //This section is the set of definitions required by the MCHPFSUSB
+    //  framework.  These definitions tell the firmware what mode it is
+    //  running in, and where it can find the results to some information
+    //  that the stack needs.
+    //These definitions are required by every application developed with
+    //  this revision of the MCHPFSUSB framework.  Please review each
+    //  option carefully and determine which options are desired/required
+    //  for your application.
+
+    //The PICDEM FS USB Demo Board platform supports the USE_SELF_POWER_SENSE_IO
+    //and USE_USB_BUS_SENSE_IO features.  Uncomment the below line(s) if
+    //it is desireable to use one or both of the features.
+    #define USE_SELF_POWER_SENSE_IO
+    #define tris_self_power     TRISAbits.TRISA2    // Input
+    #if defined(USE_SELF_POWER_SENSE_IO)
+    #define self_power          PORTAbits.RA2
+    #else
+    #define self_power          1
+    #endif
+
+    #define USE_USB_BUS_SENSE_IO
+    #define tris_usb_bus_sense  TRISAbits.TRISA1    // Input
+    #if defined(USE_USB_BUS_SENSE_IO)
+    #define USB_BUS_SENSE       PORTAbits.RA1
+    #else
+    #define USB_BUS_SENSE       1
+    #endif
+
+    //Uncomment the following line to make the output HEX of this  
+    //  project work with the MCHPUSB Bootloader    
+    #define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER
+	
+    //Uncomment the following line to make the output HEX of this 
+    //  project work with the HID Bootloader
+    //#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER		
+
+    /*******************************************************************/
+    /******** MDD File System selection options ************************/
+    /*******************************************************************/
+    #define USE_PIC18
+
+    #define ERASE_BLOCK_SIZE        64
+    #define WRITE_BLOCK_SIZE        32
+
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /******** Application specific definitions *************************/
+    /*******************************************************************/
+    /*******************************************************************/
+    /*******************************************************************/
+
+    /** Board definition ***********************************************/
+    //These defintions will tell the main() function which board is
+    //  currently selected.  This will allow the application to add
+    //  the correct configuration bits as wells use the correct
+    //  initialization functions for the board.  These defitions are only
+    //  required in the stack provided demos.  They are not required in
+    //  final application design.
+    #define DEMO_BOARD PICDEM_FS_USB
+    #define PICDEM_FS_USB
+    #define CLOCK_FREQ 48000000
+
+    /** LED ************************************************************/
+    #define mInitAllLEDs()      LATD &= 0xF0; TRISD &= 0xF0;
+    
+    #define mLED_1              LATDbits.LATD0
+    #define mLED_2              LATDbits.LATD1
+    #define mLED_3              LATDbits.LATD2
+    #define mLED_4              LATDbits.LATD3
+    
+    #define mGetLED_1()         mLED_1
+    #define mGetLED_2()         mLED_2
+    #define mGetLED_3()         mLED_3
+    #define mGetLED_4()         mLED_4
+
+    #define mLED_1_On()         mLED_1 = 1;
+    #define mLED_2_On()         mLED_2 = 1;
+    #define mLED_3_On()         mLED_3 = 1;
+    #define mLED_4_On()         mLED_4 = 1;
+    
+    #define mLED_1_Off()        mLED_1 = 0;
+    #define mLED_2_Off()        mLED_2 = 0;
+    #define mLED_3_Off()        mLED_3 = 0;
+    #define mLED_4_Off()        mLED_4 = 0;
+    
+    #define mLED_1_Toggle()     mLED_1 = !mLED_1;
+    #define mLED_2_Toggle()     mLED_2 = !mLED_2;
+    #define mLED_3_Toggle()     mLED_3 = !mLED_3;
+    #define mLED_4_Toggle()     mLED_4 = !mLED_4;
+    
+    /** SWITCH *********************************************************/
+    #define mInitAllSwitches()  TRISBbits.TRISB4=1;TRISBbits.TRISB5=1;
+    #define mInitSwitch2()      TRISBbits.TRISB4=1;
+    #define mInitSwitch3()      TRISBbits.TRISB5=1;
+    #define sw2                 PORTBbits.RB4
+    #define sw3                 PORTBbits.RB5
+    
+    /** POT ************************************************************/
+    #define mInitPOT()          {TRISAbits.TRISA0=1;ADCON0=0x01;ADCON2=0x3C;ADCON2bits.ADFM = 1;}
+    
+    /** SPI : Chip Select Lines ****************************************/
+    #define tris_cs_temp_sensor TRISBbits.TRISB2    // Output
+    #define cs_temp_sensor      LATBbits.LATB2
+    /** USB external transceiver interface (optional) ******************/
+    #define tris_usb_vpo        TRISBbits.TRISB3    // Output
+    #define tris_usb_vmo        TRISBbits.TRISB2    // Output
+    #define tris_usb_rcv        TRISAbits.TRISA4    // Input
+    #define tris_usb_vp         TRISCbits.TRISC5    // Input
+    #define tris_usb_vm         TRISCbits.TRISC4    // Input
+    #define tris_usb_oe         TRISCbits.TRISC1    // Output
+    
+    #define tris_usb_suspnd     TRISAbits.TRISA3    // Output
+    
+    /** TRIS ***********************************************************/
+    #define INPUT_PIN           1
+    #define OUTPUT_PIN          0
+
+#endif  //HARDWARE_PROFILE_PICDEM_FSUSB_H

+ 96 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/HardwareProfile.h

@@ -0,0 +1,96 @@
+/********************************************************************
+ FileName:      HardwareProfile.h
+ Dependencies:  See INCLUDES section
+ Processor:     PIC18, PIC24, or PIC32 USB Microcontrollers
+ Hardware:      The code is natively intended to be used on the 
+                  following hardware platforms: 
+                    PICDEM™ FS USB Demo Board
+                    PIC18F46J50 FS USB Plug-In Module
+                    PIC18F87J50 FS USB Plug-In Module
+                    Explorer 16 + PIC24 or PIC32 USB PIMs
+                    PIC24F Starter Kit
+                    Low Pin Count USB Development Kit
+                  The firmware may be modified for use on other USB 
+                    platforms by editing this file (HardwareProfile.h)
+ Compiler:  	Microchip C18 (for PIC18), C30 (for PIC24), 
+                  or C32 (for PIC32)
+ Company:       Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+  Rev   Date         Description
+  1.0   11/19/2004   Initial release
+  2.1   02/26/2007   Updated for simplicity and to use common
+                     coding style
+  2.3   09/15/2008   Broke out each hardware platform into its own
+                     "HardwareProfile - xxx.h" file
+********************************************************************/
+
+#ifndef HARDWARE_PROFILE_H
+#define HARDWARE_PROFILE_H
+
+//#define DEMO_BOARD USER_DEFINED_BOARD
+
+#if !defined(DEMO_BOARD)
+    #if defined(__C32__)
+        #if defined(__32MX460F512L__)
+            #if defined(PIC32MX460F512L_PIM)
+                #include "HardwareProfile - PIC32MX460F512L PIM.h"
+            #elif defined(PIC32_USB_STARTER_KIT)
+                #include "HardwareProfile - PIC32 USB Starter Kit.h"
+            #endif
+        #endif
+    #endif
+
+    #if defined(__C30__)
+        #if defined(__PIC24FJ256GB110__)
+            #include "HardwareProfile - PIC24FJ256GB110 PIM.h"
+        #elif defined(__PIC24FJ256GB106__)
+            #include "HardwareProfile - PIC24F Starter Kit.h"
+        #elif defined(__PIC24FJ64GB004__)
+            #include "HardwareProfile - PIC24FJ64GB004 PIM.h"
+        #elif defined(__PIC24FJ64GB002__)
+            #include "HardwareProfile - PIC24FJ64GB002 BreadBoard.h"
+        #endif
+    #endif
+
+    #if defined(__18CXX)
+        #if defined(__18F4550)
+            #include "HardwareProfile - PICDEM FSUSB.h"
+        #elif defined(__18F87J50)
+            #include "HardwareProfile - PIC18F87J50 PIM.h"
+        #elif defined(__18F14K50)
+            #include "HardwareProfile - Low Pin Count USB Development Kit.h"
+        #elif defined(__18F46J50)
+            #include "HardwareProfile - PIC18F46J50 PIM.h"
+        #endif
+    #endif
+#endif
+
+#if !defined(DEMO_BOARD)
+    #error "Demo board not defined.  Either define DEMO_BOARD for a custom board or select the correct processor for the demo board."
+#endif
+
+#endif  //HARDWARE_PROFILE_H

+ 318 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PIC24 HID Bootloader Remapping.s

@@ -0,0 +1,318 @@
+
+.section .init,code
+BootloaderEntry:
+
+;**************************************************************************************
+; allocate 0x00s from 0x200 to 0x400 page of filler
+;**************************************************************************************
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+;**************************************************************************************
+
+
+;**************************************************************************************
+; 1 page of filler
+;**************************************************************************************
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+;**************************************************************************************
+
+;**************************************************************************************
+; 1 page of filler
+;**************************************************************************************
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+;**************************************************************************************
+
+;**************************************************************************************
+; 1 page of filler
+;**************************************************************************************
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+;**************************************************************************************
+
+;**************************************************************************************
+; 1 page of filler
+;**************************************************************************************
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+;**************************************************************************************
+.pword  0xFFFFFF,0xFFFFFF

+ 15 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PicFWCommands.h

@@ -0,0 +1,15 @@
+#ifndef _PICFWCOMMANDS_H
+#define _PICFWCOMMANDS_H
+
+// PicFW Vendor-Specific Requests
+enum PICFW_COMMANDS
+{
+	CTRL_LOOPBACK_WRITE	= 0x00,
+	CTRL_LOOPBACK_READ	= 0x01,
+    PICFW_SET_TEST		= 0x0E,
+    PICFW_GET_TEST		= 0x0F,
+    PICFW_SET_EEDATA	= 0x10,
+    PICFW_GET_EEDATA	= 0x11
+};
+
+#endif

+ 126 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_LowPinCountDevKit.mcp

@@ -0,0 +1,126 @@
+[HEADER]
+magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
+file_version=1.0
+device=PIC18F14K50
+[PATH_INFO]
+BuildDirPolicy=BuildDirIsProjectDir
+dir_src=
+dir_bin=
+dir_tmp=.\Objects\USB Device - Benchmark - C18 - LPC Dev Kit
+dir_sin=
+dir_inc=c:\mcc18\h;..\..\Microchip\Include
+dir_lib=C:\mcc18\lib
+dir_lkr=
+[CAT_FILTERS]
+filter_src=*.asm;*.c
+filter_inc=*.h;*.inc
+filter_obj=*.o
+filter_lib=*.lib
+filter_lkr=*.lkr
+[CAT_SUBFOLDERS]
+subfolder_src=USB Stack
+subfolder_inc=Common;USB Stack
+subfolder_obj=
+subfolder_lib=
+subfolder_lkr=
+[FILE_SUBFOLDERS]
+file_000=.
+file_001=USB Stack
+file_002=USB Stack
+file_003=.
+file_004=.
+file_005=.
+file_006=.
+file_007=Common
+file_008=Common
+file_009=USB Stack
+file_010=USB Stack
+file_011=USB Stack
+file_012=USB Stack
+file_013=USB Stack
+file_014=USB Stack
+file_015=USB Stack
+file_016=.
+file_017=.
+file_018=.
+file_019=.
+[GENERATED_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+[OTHER_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+[FILE_INFO]
+file_000=usb_descriptors.c
+file_001=..\..\Microchip\USB\usb_device.c
+file_002=..\..\Microchip\USB\Generic Device Driver\usb_function_generic.c
+file_003=Benchmark.c
+file_004=main.c
+file_005=HardwareProfile.h
+file_006=usb_config.h
+file_007=..\..\Microchip\Include\GenericTypeDefs.h
+file_008=..\..\Microchip\Include\Compiler.h
+file_009=..\..\Microchip\Include\USB\usb_hal_pic18.h
+file_010=..\..\Microchip\Include\USB\usb.h
+file_011=..\..\Microchip\Include\USB\usb_ch9.h
+file_012=..\..\Microchip\Include\USB\usb_common.h
+file_013=..\..\Microchip\Include\USB\usb_device.h
+file_014=..\..\Microchip\Include\USB\usb_function_generic.h
+file_015=..\..\Microchip\Include\USB\usb_hal.h
+file_016=HardwareProfile - Low Pin Count USB Development Kit.h
+file_017=Benchmark.h
+file_018=BDT_transfer.h
+file_019=rm18f14k50.lkr
+[SUITE_INFO]
+suite_guid={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
+suite_state=
+[TOOL_SETTINGS]
+TS{DD2213A8-6310-47B1-8376-9430CDFC013F}=
+TS{BFD27FBA-4A02-4C0E-A5E5-B812F3E7707C}=/m"$(BINDIR_)$(TARGETBASE).map" /w /o"$(TARGETBASE).cof"
+TS{C2AF05E7-1416-4625-923D-E114DB6E2B96}=
+TS{ADE93A55-C7C7-4D4D-A4BA-59305F7D0391}=
+[INSTRUMENTED_TRACE]
+enable=0
+transport=0
+format=0
+[CUSTOM_BUILD]
+Pre-Build=
+Pre-BuildEnabled=1
+Post-Build=
+Post-BuildEnabled=1

BIN
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_LowPinCountDevKit.mcw


+ 126 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_P18F46J50_PIM.mcp

@@ -0,0 +1,126 @@
+[HEADER]
+magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
+file_version=1.0
+device=PIC18F46J50
+[PATH_INFO]
+BuildDirPolicy=BuildDirIsProjectDir
+dir_src=
+dir_bin=
+dir_tmp=.\Objects\USB Device - Benchmark - C18 - PIC18F46J50 PIM
+dir_sin=
+dir_inc=c:\mcc18\h;..\..\Microchip\Include
+dir_lib=C:\mcc18\lib
+dir_lkr=
+[CAT_FILTERS]
+filter_src=*.asm;*.c
+filter_inc=*.h;*.inc
+filter_obj=*.o
+filter_lib=*.lib
+filter_lkr=*.lkr
+[CAT_SUBFOLDERS]
+subfolder_src=USB Stack
+subfolder_inc=Common;USB Stack
+subfolder_obj=
+subfolder_lib=
+subfolder_lkr=
+[FILE_SUBFOLDERS]
+file_000=.
+file_001=.
+file_002=USB Stack
+file_003=USB Stack
+file_004=.
+file_005=.
+file_006=.
+file_007=Common
+file_008=Common
+file_009=USB Stack
+file_010=USB Stack
+file_011=USB Stack
+file_012=USB Stack
+file_013=USB Stack
+file_014=USB Stack
+file_015=USB Stack
+file_016=.
+file_017=.
+file_018=.
+file_019=.
+[GENERATED_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+[OTHER_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+[FILE_INFO]
+file_000=main.c
+file_001=usb_descriptors.c
+file_002=..\..\Microchip\USB\usb_device.c
+file_003=..\..\Microchip\USB\Generic Device Driver\usb_function_generic.c
+file_004=Benchmark.c
+file_005=HardwareProfile.h
+file_006=usb_config.h
+file_007=..\..\Microchip\Include\GenericTypeDefs.h
+file_008=..\..\Microchip\Include\Compiler.h
+file_009=..\..\Microchip\Include\USB\usb_hal_pic18.h
+file_010=..\..\Microchip\Include\USB\usb.h
+file_011=..\..\Microchip\Include\USB\usb_ch9.h
+file_012=..\..\Microchip\Include\USB\usb_common.h
+file_013=..\..\Microchip\Include\USB\usb_device.h
+file_014=..\..\Microchip\Include\USB\usb_function_generic.h
+file_015=..\..\Microchip\Include\USB\usb_hal.h
+file_016=HardwareProfile - PIC18F46J50 PIM.h
+file_017=Benchmark.h
+file_018=BDT_transfer.h
+file_019=rm18f46j50_g.lkr
+[SUITE_INFO]
+suite_guid={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
+suite_state=
+[TOOL_SETTINGS]
+TS{DD2213A8-6310-47B1-8376-9430CDFC013F}=
+TS{BFD27FBA-4A02-4C0E-A5E5-B812F3E7707C}=/m"$(BINDIR_)$(TARGETBASE).map" /w /o"$(BINDIR_)$(TARGETBASE).cof"
+TS{C2AF05E7-1416-4625-923D-E114DB6E2B96}=-Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
+TS{ADE93A55-C7C7-4D4D-A4BA-59305F7D0391}=
+[INSTRUMENTED_TRACE]
+enable=0
+transport=0
+format=0
+[CUSTOM_BUILD]
+Pre-Build=
+Pre-BuildEnabled=1
+Post-Build=
+Post-BuildEnabled=1

BIN
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_P18F46J50_PIM.mcw


+ 126 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_P18F87J50_PIM.mcp

@@ -0,0 +1,126 @@
+[HEADER]
+magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
+file_version=1.0
+device=PIC18F87J50
+[PATH_INFO]
+BuildDirPolicy=BuildDirIsProjectDir
+dir_src=
+dir_bin=
+dir_tmp=.\Objects\USB Device - Benchmark - C18 - PIC18F87J50 PIM
+dir_sin=
+dir_inc=c:\mcc18\h;..\..\Microchip\Include
+dir_lib=C:\mcc18\lib
+dir_lkr=
+[CAT_FILTERS]
+filter_src=*.asm;*.c
+filter_inc=*.h;*.inc
+filter_obj=*.o
+filter_lib=*.lib
+filter_lkr=*.lkr
+[CAT_SUBFOLDERS]
+subfolder_src=USB Stack
+subfolder_inc=Common;USB Stack
+subfolder_obj=
+subfolder_lib=
+subfolder_lkr=
+[FILE_SUBFOLDERS]
+file_000=.
+file_001=.
+file_002=USB Stack
+file_003=USB Stack
+file_004=.
+file_005=.
+file_006=.
+file_007=Common
+file_008=Common
+file_009=USB Stack
+file_010=USB Stack
+file_011=USB Stack
+file_012=USB Stack
+file_013=USB Stack
+file_014=USB Stack
+file_015=USB Stack
+file_016=.
+file_017=.
+file_018=.
+file_019=.
+[GENERATED_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+[OTHER_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+[FILE_INFO]
+file_000=main.c
+file_001=usb_descriptors.c
+file_002=..\..\Microchip\USB\usb_device.c
+file_003=..\..\Microchip\USB\Generic Device Driver\usb_function_generic.c
+file_004=Benchmark.c
+file_005=HardwareProfile.h
+file_006=usb_config.h
+file_007=..\..\Microchip\Include\GenericTypeDefs.h
+file_008=..\..\Microchip\Include\Compiler.h
+file_009=..\..\Microchip\Include\USB\usb_hal_pic18.h
+file_010=..\..\Microchip\Include\USB\usb.h
+file_011=..\..\Microchip\Include\USB\usb_ch9.h
+file_012=..\..\Microchip\Include\USB\usb_common.h
+file_013=..\..\Microchip\Include\USB\usb_device.h
+file_014=..\..\Microchip\Include\USB\usb_function_generic.h
+file_015=..\..\Microchip\Include\USB\usb_hal.h
+file_016=HardwareProfile - PIC18F87J50 PIM.h
+file_017=Benchmark.h
+file_018=BDT_transfer.h
+file_019=rm18f87j50.lkr
+[SUITE_INFO]
+suite_guid={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
+suite_state=
+[TOOL_SETTINGS]
+TS{DD2213A8-6310-47B1-8376-9430CDFC013F}=
+TS{BFD27FBA-4A02-4C0E-A5E5-B812F3E7707C}=/m"$(BINDIR_)$(TARGETBASE).map" /w /o"$(BINDIR_)$(TARGETBASE).cof"
+TS{C2AF05E7-1416-4625-923D-E114DB6E2B96}=-Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
+TS{ADE93A55-C7C7-4D4D-A4BA-59305F7D0391}=
+[INSTRUMENTED_TRACE]
+enable=0
+transport=0
+format=0
+[CUSTOM_BUILD]
+Pre-Build=
+Pre-BuildEnabled=1
+Post-Build=
+Post-BuildEnabled=1

BIN
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_P18F87J50_PIM.mcw


+ 130 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_PICDEM_FSUSB.mcp

@@ -0,0 +1,130 @@
+[HEADER]
+magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
+file_version=1.0
+device=PIC18F4550
+[PATH_INFO]
+BuildDirPolicy=BuildDirIsProjectDir
+dir_src=
+dir_bin=
+dir_tmp=.\Objects\USB Device - Benchmark - C18 - PICDEM FSUSB
+dir_sin=
+dir_inc=c:\mcc18\h;..\..\Microchip\Include
+dir_lib=C:\mcc18\lib
+dir_lkr=
+[CAT_FILTERS]
+filter_src=*.asm;*.c
+filter_inc=*.h;*.inc
+filter_obj=*.o
+filter_lib=*.lib
+filter_lkr=*.lkr
+[CAT_SUBFOLDERS]
+subfolder_src=USB Stack
+subfolder_inc=Common;USB Stack
+subfolder_obj=
+subfolder_lib=
+subfolder_lkr=
+[FILE_SUBFOLDERS]
+file_000=.
+file_001=.
+file_002=USB Stack
+file_003=USB Stack
+file_004=.
+file_005=.
+file_006=.
+file_007=Common
+file_008=Common
+file_009=USB Stack
+file_010=USB Stack
+file_011=USB Stack
+file_012=USB Stack
+file_013=USB Stack
+file_014=USB Stack
+file_015=USB Stack
+file_016=.
+file_017=.
+file_018=.
+file_019=.
+file_020=.
+[GENERATED_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+file_020=no
+[OTHER_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+file_020=no
+[FILE_INFO]
+file_000=main.c
+file_001=usb_descriptors.c
+file_002=..\..\Microchip\USB\usb_device.c
+file_003=..\..\Microchip\USB\Generic Device Driver\usb_function_generic.c
+file_004=Benchmark.c
+file_005=HardwareProfile.h
+file_006=usb_config.h
+file_007=..\..\Microchip\Include\GenericTypeDefs.h
+file_008=..\..\Microchip\Include\Compiler.h
+file_009=..\..\Microchip\Include\USB\usb_hal_pic18.h
+file_010=..\..\Microchip\Include\USB\usb.h
+file_011=..\..\Microchip\Include\USB\usb_ch9.h
+file_012=..\..\Microchip\Include\USB\usb_common.h
+file_013=..\..\Microchip\Include\USB\usb_device.h
+file_014=..\..\Microchip\Include\USB\usb_function_generic.h
+file_015=..\..\Microchip\Include\USB\usb_hal.h
+file_016=HardwareProfile - PICDEM FSUSB.h
+file_017=Benchmark.h
+file_018=PicFWCommands.h
+file_019=BDT_transfer.h
+file_020=rm18f4550 - HID Bootload.lkr
+[SUITE_INFO]
+suite_guid={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
+suite_state=
+[TOOL_SETTINGS]
+TS{DD2213A8-6310-47B1-8376-9430CDFC013F}=
+TS{BFD27FBA-4A02-4C0E-A5E5-B812F3E7707C}=/m"$(BINDIR_)$(TARGETBASE).map" /w /o"$(BINDIR_)$(TARGETBASE).cof"
+TS{C2AF05E7-1416-4625-923D-E114DB6E2B96}=
+TS{ADE93A55-C7C7-4D4D-A4BA-59305F7D0391}=
+[INSTRUMENTED_TRACE]
+enable=0
+transport=0
+format=0
+[CUSTOM_BUILD]
+Pre-Build=
+Pre-BuildEnabled=1
+Post-Build=
+Post-BuildEnabled=1

+ 3 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_PICDEM_FSUSB.mcs

@@ -0,0 +1,3 @@
+[Header]
+MagicCookie={0b13fe8c-dfe0-40eb-8900-6712719559a7}
+Version=1.0

BIN
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C18_PICDEM_FSUSB.mcw


+ 138 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C30.mcp

@@ -0,0 +1,138 @@
+[HEADER]
+magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
+file_version=1.0
+device=PIC24FJ64GB002
+[PATH_INFO]
+BuildDirPolicy=BuildDirIsProjectDir
+dir_src=
+dir_bin=
+dir_tmp=./Objects\USB Device - Benchmark - C30
+dir_sin=
+dir_inc=.;..;..\..\Microchip\Include
+dir_lib=C:\Program Files\Microchip\MPLAB C30\lib
+dir_lkr=
+[CAT_FILTERS]
+filter_src=*.s;*.c
+filter_inc=*.h;*.inc
+filter_obj=*.o
+filter_lib=*.a
+filter_lkr=*.gld
+[CAT_SUBFOLDERS]
+subfolder_src=USB Stack
+subfolder_inc=Common;Hardware Profiles;USB Stack
+subfolder_obj=
+subfolder_lib=
+subfolder_lkr=
+[FILE_SUBFOLDERS]
+file_000=.
+file_001=.
+file_002=USB Stack
+file_003=USB Stack
+file_004=.
+file_005=.
+file_006=.
+file_007=.
+file_008=Common
+file_009=Common
+file_010=USB Stack
+file_011=USB Stack
+file_012=USB Stack
+file_013=USB Stack
+file_014=USB Stack
+file_015=USB Stack
+file_016=USB Stack
+file_017=Hardware Profiles
+file_018=Hardware Profiles
+file_019=Hardware Profiles
+file_020=.
+file_021=Hardware Profiles
+file_022=.
+[GENERATED_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+file_020=no
+file_021=no
+file_022=no
+[OTHER_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+file_020=no
+file_021=no
+file_022=no
+[FILE_INFO]
+file_000=main.c
+file_001=usb_descriptors.c
+file_002=..\..\Microchip\USB\usb_device.c
+file_003=..\..\Microchip\USB\Generic Device Driver\usb_function_generic.c
+file_004=PIC24 HID Bootloader Remapping.s
+file_005=Benchmark.c
+file_006=HardwareProfile.h
+file_007=usb_config.h
+file_008=..\..\Microchip\Include\GenericTypeDefs.h
+file_009=..\..\Microchip\Include\Compiler.h
+file_010=..\..\Microchip\Include\USB\usb_hal_pic24.h
+file_011=..\..\Microchip\Include\USB\usb.h
+file_012=..\..\Microchip\Include\USB\usb_ch9.h
+file_013=..\..\Microchip\Include\USB\usb_common.h
+file_014=..\..\Microchip\Include\USB\usb_device.h
+file_015=..\..\Microchip\Include\USB\usb_function_generic.h
+file_016=..\..\Microchip\Include\USB\usb_hal.h
+file_017=HardwareProfile - PIC24F Starter Kit.h
+file_018=HardwareProfile - PIC24FJ256GB110 PIM.h
+file_019=HardwareProfile - PIC24FJ64GB004 PIM.h
+file_020=Benchmark.h
+file_021=HardwareProfile - PIC24FJ64GB002 BreadBoard.h
+file_022=BDT_transfer.h
+[SUITE_INFO]
+suite_guid={479DDE59-4D56-455E-855E-FFF59A3DB57E}
+suite_state=
+[TOOL_SETTINGS]
+TS{7D9C6ECE-785D-44CB-BA22-17BF2E119622}=-g
+TS{25AC22BD-2378-4FDB-BFB6-7345A15512D3}=-g -Wall -Os
+TS{7DAC9A1D-4C45-45D6-B25A-D117C74E8F5A}=--heap=800 -Map="$(BINDIR_)$(TARGETBASE).map" --report-mem -o"$(BINDIR_)$(TARGETBASE).$(TARGETSUFFIX)"
+TS{509E5861-1E2A-483B-8B6B-CA8DB7F2DD78}=
+[INSTRUMENTED_TRACE]
+enable=0
+transport=0
+format=0
+[CUSTOM_BUILD]
+Pre-Build=
+Pre-BuildEnabled=1
+Post-Build=
+Post-BuildEnabled=1

BIN
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C30.mcw


+ 126 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C32_P32MX460F512L_PIM.mcp

@@ -0,0 +1,126 @@
+[HEADER]
+magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
+file_version=1.0
+device=PIC32MX460F512L
+[PATH_INFO]
+BuildDirPolicy=BuildDirIsProjectDir
+dir_src=
+dir_bin=
+dir_tmp=./Objects\USB Device - Benchmark - C32
+dir_sin=
+dir_inc=.;..;..\..\Microchip\Include
+dir_lib=C:\Program Files\Microchip\MPLAB C30\lib
+dir_lkr=
+[CAT_FILTERS]
+filter_src=*.s;*.c
+filter_inc=*.h;*.inc
+filter_obj=*.o
+filter_lib=*.a
+filter_lkr=*.gld
+[CAT_SUBFOLDERS]
+subfolder_src=USB Stack
+subfolder_inc=Common;Hardware Profile;USB Stack
+subfolder_obj=
+subfolder_lib=
+subfolder_lkr=
+[FILE_SUBFOLDERS]
+file_000=.
+file_001=.
+file_002=USB Stack
+file_003=USB Stack
+file_004=.
+file_005=.
+file_006=.
+file_007=Common
+file_008=Common
+file_009=USB Stack
+file_010=USB Stack
+file_011=USB Stack
+file_012=USB Stack
+file_013=USB Stack
+file_014=USB Stack
+file_015=USB Stack
+file_016=Hardware Profile
+file_017=Hardware Profile
+file_018=.
+file_019=.
+[GENERATED_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+[OTHER_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+[FILE_INFO]
+file_000=main.c
+file_001=usb_descriptors.c
+file_002=..\..\Microchip\USB\usb_device.c
+file_003=..\..\Microchip\USB\Generic Device Driver\usb_function_generic.c
+file_004=Benchmark.c
+file_005=HardwareProfile.h
+file_006=usb_config.h
+file_007=..\..\Microchip\Include\GenericTypeDefs.h
+file_008=..\..\Microchip\Include\Compiler.h
+file_009=..\..\Microchip\Include\USB\usb.h
+file_010=..\..\Microchip\Include\USB\usb_ch9.h
+file_011=..\..\Microchip\Include\USB\usb_common.h
+file_012=..\..\Microchip\Include\USB\usb_device.h
+file_013=..\..\Microchip\Include\USB\usb_function_generic.h
+file_014=..\..\Microchip\Include\USB\usb_hal.h
+file_015=..\..\Microchip\Include\USB\usb_hal_pic32.h
+file_016=HardwareProfile - PIC32MX460F512L PIM.h
+file_017=HardwareProfile - PIC32 USB Starter Kit.h
+file_018=Benchmark.h
+file_019=BDT_transfer.h
+[SUITE_INFO]
+suite_guid={14495C23-81F8-43F3-8A44-859C583D7760}
+suite_state=
+[TOOL_SETTINGS]
+TS{CB0AF4B8-4022-429D-8F99-8A56782B2C6D}=-gdwarf-2
+TS{9C698E0A-CBC9-4EFF-AE7D-B569F93E7322}=-g -DPIC32MX460F512L_PIM -Os
+TS{77F59DA1-3C53-4677-AC5F-A03EB0125170}=-o"$(BINDIR_)$(TARGETBASE).$(TARGETSUFFIX)" -Map="$(BINDIR_)$(TARGETBASE).map"
+TS{0396C0A1-9052-4E4F-8B84-EF0162B1B4E9}=
+[INSTRUMENTED_TRACE]
+enable=0
+transport=0
+format=0
+[CUSTOM_BUILD]
+Pre-Build=
+Pre-BuildEnabled=1
+Post-Build=
+Post-BuildEnabled=1

BIN
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C32_P32MX460F512L_PIM.mcw


+ 126 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C32_StarterKit.mcp

@@ -0,0 +1,126 @@
+[HEADER]
+magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
+file_version=1.0
+device=PIC32MX460F512L
+[PATH_INFO]
+BuildDirPolicy=BuildDirIsProjectDir
+dir_src=
+dir_bin=
+dir_tmp=./Objects\USB Device - Benchmark - C32
+dir_sin=
+dir_inc=.;..;..\..\Microchip\Include
+dir_lib=C:\Program Files\Microchip\MPLAB C30\lib
+dir_lkr=
+[CAT_FILTERS]
+filter_src=*.s;*.c
+filter_inc=*.h;*.inc
+filter_obj=*.o
+filter_lib=*.a
+filter_lkr=*.gld
+[CAT_SUBFOLDERS]
+subfolder_src=USB Stack
+subfolder_inc=Common;Hardware Profile;USB Stack
+subfolder_obj=
+subfolder_lib=
+subfolder_lkr=
+[FILE_SUBFOLDERS]
+file_000=.
+file_001=.
+file_002=USB Stack
+file_003=USB Stack
+file_004=.
+file_005=.
+file_006=.
+file_007=Common
+file_008=Common
+file_009=USB Stack
+file_010=USB Stack
+file_011=USB Stack
+file_012=USB Stack
+file_013=USB Stack
+file_014=USB Stack
+file_015=USB Stack
+file_016=Hardware Profile
+file_017=Hardware Profile
+file_018=.
+file_019=.
+[GENERATED_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+[OTHER_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+file_007=no
+file_008=no
+file_009=no
+file_010=no
+file_011=no
+file_012=no
+file_013=no
+file_014=no
+file_015=no
+file_016=no
+file_017=no
+file_018=no
+file_019=no
+[FILE_INFO]
+file_000=main.c
+file_001=usb_descriptors.c
+file_002=..\..\Microchip\USB\usb_device.c
+file_003=..\..\Microchip\USB\Generic Device Driver\usb_function_generic.c
+file_004=Benchmark.c
+file_005=HardwareProfile.h
+file_006=usb_config.h
+file_007=..\..\Microchip\Include\GenericTypeDefs.h
+file_008=..\..\Microchip\Include\Compiler.h
+file_009=..\..\Microchip\Include\USB\usb.h
+file_010=..\..\Microchip\Include\USB\usb_ch9.h
+file_011=..\..\Microchip\Include\USB\usb_common.h
+file_012=..\..\Microchip\Include\USB\usb_device.h
+file_013=..\..\Microchip\Include\USB\usb_function_generic.h
+file_014=..\..\Microchip\Include\USB\usb_hal.h
+file_015=..\..\Microchip\Include\USB\usb_hal_pic32.h
+file_016=HardwareProfile - PIC32MX460F512L PIM.h
+file_017=HardwareProfile - PIC32 USB Starter Kit.h
+file_018=Benchmark.h
+file_019=BDT_transfer.h
+[SUITE_INFO]
+suite_guid={14495C23-81F8-43F3-8A44-859C583D7760}
+suite_state=
+[TOOL_SETTINGS]
+TS{CB0AF4B8-4022-429D-8F99-8A56782B2C6D}=-gdwarf-2
+TS{9C698E0A-CBC9-4EFF-AE7D-B569F93E7322}=-g -DPIC32_USB_STARTER_KIT -Os
+TS{77F59DA1-3C53-4677-AC5F-A03EB0125170}=-o"$(BINDIR_)$(TARGETBASE).$(TARGETSUFFIX)" -Map="$(BINDIR_)$(TARGETBASE).map"
+TS{0396C0A1-9052-4E4F-8B84-EF0162B1B4E9}=
+[INSTRUMENTED_TRACE]
+enable=0
+transport=0
+format=0
+[CUSTOM_BUILD]
+Pre-Build=
+Pre-BuildEnabled=1
+Post-Build=
+Post-BuildEnabled=1

+ 3 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C32_StarterKit.mcs

@@ -0,0 +1,3 @@
+[Header]
+MagicCookie={0b13fe8c-dfe0-40eb-8900-6712719559a7}
+Version=1.0

BIN
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/PyUSB_C32_StarterKit.mcw


+ 1215 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/main.c

@@ -0,0 +1,1215 @@
+/********************************************************************
+ FileName:		main.c
+ Dependencies:	See INCLUDES section
+ Processor:		PIC18 or PIC24 USB Microcontrollers
+ Hardware:		The code is natively intended to be used on the following
+ 				hardware platforms: PICDEM™ FS USB Demo Board, 
+ 				PIC18F87J50 FS USB Plug-In Module, or
+ 				Explorer 16 + PIC24 USB PIM.  The firmware may be
+ 				modified for use on other USB platforms by editing the
+ 				HardwareProfile.h file.
+ Complier:  	Microchip C18 (for PIC18) or C30 (for PIC24)
+ Company:		Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+  Rev   Date         Description
+  1.0   11/19/2004   Initial release
+  2.1   02/26/2007   Updated for simplicity and to use common
+                     coding style
+********************************************************************/
+
+/** INCLUDES *******************************************************/
+#include "USB/usb.h"
+#include "USB/usb_function_generic.h"
+#include "HardwareProfile.h"
+//#include "Compiler.h"
+//#include "GenericTypeDefs.h"
+//#include "USB/usb_device.h"
+//#include "USB/usb.h"
+//#include "usb_config.h"
+#include "Benchmark.h"
+
+/** CONFIGURATION **************************************************/
+#if defined(PICDEM_FS_USB)      // Configuration bits for PICDEM FS USB Demo Board (based on PIC18F4550)
+        #pragma config PLLDIV   = 5         // (20 MHz crystal on PICDEM FS USB board)
+        #pragma config CPUDIV   = OSC1_PLL2   
+        #pragma config USBDIV   = 2         // Clock source from 96MHz PLL/2
+        #pragma config FOSC     = HSPLL_HS
+        #pragma config FCMEN    = OFF
+        #pragma config IESO     = OFF
+        #pragma config PWRT     = OFF
+        #pragma config BOR      = ON
+        #pragma config BORV     = 3
+        #pragma config VREGEN   = ON      //USB Voltage Regulator
+        #pragma config WDT      = OFF
+        #pragma config WDTPS    = 32768
+        #pragma config MCLRE    = ON
+        #pragma config LPT1OSC  = OFF
+        #pragma config PBADEN   = OFF
+//      #pragma config CCP2MX   = ON
+        #pragma config STVREN   = ON
+        #pragma config LVP      = OFF
+//      #pragma config ICPRT    = OFF       // Dedicated In-Circuit Debug/Programming
+        #pragma config XINST    = OFF       // Extended Instruction Set
+        #pragma config CP0      = OFF
+        #pragma config CP1      = OFF
+//      #pragma config CP2      = OFF
+//      #pragma config CP3      = OFF
+        #pragma config CPB      = OFF
+//      #pragma config CPD      = OFF
+        #pragma config WRT0     = OFF
+        #pragma config WRT1     = OFF
+//      #pragma config WRT2     = OFF
+//      #pragma config WRT3     = OFF
+        #pragma config WRTB     = OFF       // Boot Block Write Protection
+        #pragma config WRTC     = OFF
+//      #pragma config WRTD     = OFF
+        #pragma config EBTR0    = OFF
+        #pragma config EBTR1    = OFF
+//      #pragma config EBTR2    = OFF
+//      #pragma config EBTR3    = OFF
+        #pragma config EBTRB    = OFF
+
+
+#elif defined(PIC18F87J50_PIM)				// Configuration bits for PIC18F87J50 FS USB Plug-In Module board
+        #pragma config XINST    = OFF   	// Extended instruction set
+        #pragma config STVREN   = ON      	// Stack overflow reset
+        #pragma config PLLDIV   = 3         // (12 MHz crystal used on this board)
+        #pragma config WDTEN    = OFF      	// Watch Dog Timer (WDT)
+        #pragma config CP0      = OFF      	// Code protect
+        #pragma config CPUDIV   = OSC1      // OSC1 = divide by 1 mode
+        #pragma config IESO     = OFF      	// Internal External (clock) Switchover
+        #pragma config FCMEN    = OFF      	// Fail Safe Clock Monitor
+        #pragma config FOSC     = HSPLL     // Firmware must also set OSCTUNE<PLLEN> to start PLL!
+        #pragma config WDTPS    = 32768
+//      #pragma config WAIT     = OFF      	// Commented choices are
+//      #pragma config BW       = 16      	// only available on the
+//      #pragma config MODE     = MM      	// 80 pin devices in the 
+//      #pragma config EASHFT   = OFF      	// family.
+        #pragma config MSSPMSK  = MSK5
+//      #pragma config PMPMX    = DEFAULT
+//      #pragma config ECCPMX   = DEFAULT
+        #pragma config CCP2MX   = DEFAULT   
+
+#elif defined(PIC18F46J50_PIM)
+     #pragma config WDTEN = OFF          //WDT disabled (enabled by SWDTEN bit)
+     #pragma config PLLDIV = 3           //Divide by 3 (12 MHz oscillator input)
+     #pragma config STVREN = ON            //stack overflow/underflow reset enabled
+     #pragma config XINST = OFF          //Extended instruction set disabled
+     #pragma config CPUDIV = OSC1        //No CPU system clock divide
+     #pragma config CP0 = OFF            //Program memory is not code-protected
+     #pragma config OSC = HSPLL          //HS oscillator, PLL enabled, HSPLL used by USB
+     #pragma config T1DIG = ON           //Sec Osc clock source may be selected
+     #pragma config LPT1OSC = OFF        //high power Timer1 mode
+     #pragma config FCMEN = OFF          //Fail-Safe Clock Monitor disabled
+     #pragma config IESO = OFF           //Two-Speed Start-up disabled
+     #pragma config WDTPS = 32768        //1:32768
+     #pragma config DSWDTOSC = INTOSCREF //DSWDT uses INTOSC/INTRC as clock
+     #pragma config RTCOSC = T1OSCREF    //RTCC uses T1OSC/T1CKI as clock
+     #pragma config DSBOREN = OFF        //Zero-Power BOR disabled in Deep Sleep
+     #pragma config DSWDTEN = OFF        //Disabled
+     #pragma config DSWDTPS = 8192       //1:8,192 (8.5 seconds)
+     #pragma config IOL1WAY = OFF        //IOLOCK bit can be set and cleared
+     #pragma config MSSP7B_EN = MSK7     //7 Bit address masking
+     #pragma config WPFP = PAGE_1        //Write Protect Program Flash Page 0
+     #pragma config WPEND = PAGE_0       //Start protection at page 0
+     #pragma config WPCFG = OFF          //Write/Erase last page protect Disabled
+     #pragma config WPDIS = OFF          //WPFP[5:0], WPEND, and WPCFG bits ignored 
+#elif defined(LOW_PIN_COUNT_USB_DEVELOPMENT_KIT)
+	// PIC18F14K50
+        #pragma config CPUDIV = NOCLKDIV
+        #pragma config USBDIV = OFF
+        #pragma config FOSC   = HS
+        #pragma config PLLEN  = ON
+        #pragma config FCMEN  = OFF
+        #pragma config IESO   = OFF
+        #pragma config PWRTEN = OFF
+        #pragma config BOREN  = OFF
+        #pragma config BORV   = 30
+        #pragma config WDTEN  = OFF
+        #pragma config WDTPS  = 32768
+        #pragma config MCLRE  = OFF
+        #pragma config HFOFST = OFF
+        #pragma config STVREN = ON
+        #pragma config LVP    = OFF
+        #pragma config XINST  = OFF
+        #pragma config BBSIZ  = OFF
+        #pragma config CP0    = OFF
+        #pragma config CP1    = OFF
+        #pragma config CPB    = OFF
+        #pragma config WRT0   = OFF
+        #pragma config WRT1   = OFF
+        #pragma config WRTB   = OFF
+        #pragma config WRTC   = OFF
+        #pragma config EBTR0  = OFF
+        #pragma config EBTR1  = OFF
+        #pragma config EBTRB  = OFF        
+
+#elif defined(EXPLORER_16)
+    #ifdef __PIC24FJ256GB110__ //Defined by MPLAB when using 24FJ256GB110 device
+        _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) 
+        _CONFIG2( 0xF7FF & IESO_OFF & FCKSM_CSDCMD & OSCIOFNC_ON & POSCMOD_HS & FNOSC_PRIPLL & PLLDIV_DIV2 & IOL1WAY_ON)
+    #elif defined(__PIC24FJ64GB004__)
+        _CONFIG1(WDTPS_PS1 & FWPSA_PR32 & WINDIS_OFF & FWDTEN_OFF & ICS_PGx1 & GWRP_OFF & GCP_OFF & JTAGEN_OFF)
+        _CONFIG2(POSCMOD_HS & I2C1SEL_PRI & IOL1WAY_OFF & OSCIOFNC_ON & FCKSM_CSDCMD & FNOSC_PRIPLL & PLL96MHZ_ON & PLLDIV_DIV2 & IESO_ON)
+        _CONFIG3(WPFP_WPFP0 & SOSCSEL_SOSC & WUTSEL_LEG & WPDIS_WPDIS & WPCFG_WPCFGDIS & WPEND_WPENDMEM)
+        _CONFIG4(DSWDTPS_DSWDTPS3 & DSWDTOSC_LPRC & RTCOSC_SOSC & DSBOREN_OFF & DSWDTEN_OFF)
+    #elif defined(__32MX460F512L__)
+        #pragma config UPLLEN   = ON        // USB PLL Enabled
+        #pragma config FPLLMUL  = MUL_15        // PLL Multiplier
+        #pragma config UPLLIDIV = DIV_2         // USB PLL Input Divider
+        #pragma config FPLLIDIV = DIV_2         // PLL Input Divider
+        #pragma config FPLLODIV = DIV_1         // PLL Output Divider
+        #pragma config FPBDIV   = DIV_1         // Peripheral Clock divisor
+        #pragma config FWDTEN   = OFF           // Watchdog Timer
+        #pragma config WDTPS    = PS1           // Watchdog Timer Postscale
+        #pragma config FCKSM    = CSDCMD        // Clock Switching & Fail Safe Clock Monitor
+        #pragma config OSCIOFNC = OFF           // CLKO Enable
+        #pragma config POSCMOD  = HS            // Primary Oscillator
+        #pragma config IESO     = OFF           // Internal/External Switch-over
+        #pragma config FSOSCEN  = OFF           // Secondary Oscillator Enable (KLO was off)
+        #pragma config FNOSC    = PRIPLL        // Oscillator Selection
+        #pragma config CP       = OFF           // Code Protect
+        #pragma config BWP      = OFF           // Boot Flash Write Protect
+        #pragma config PWP      = OFF           // Program Flash Write Protect
+        #pragma config ICESEL   = ICS_PGx2      // ICE/ICD Comm Channel Select
+        #pragma config DEBUG    = ON            // Background Debugger Enable
+    #else
+        #error No hardware board defined, see "HardwareProfile.h" and __FILE__
+    #endif
+#elif defined(PIC24F_STARTER_KIT)
+    _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) 
+    _CONFIG2( 0xF7FF & IESO_OFF & FCKSM_CSDCMD & OSCIOFNC_ON & POSCMOD_HS & FNOSC_PRIPLL & PLLDIV_DIV3 & IOL1WAY_ON)
+#elif defined(PIC32_USB_STARTER_KIT)
+    #pragma config UPLLEN   = ON        // USB PLL Enabled
+    #pragma config FPLLMUL  = MUL_15        // PLL Multiplier
+    #pragma config UPLLIDIV = DIV_2         // USB PLL Input Divider
+    #pragma config FPLLIDIV = DIV_2         // PLL Input Divider
+    #pragma config FPLLODIV = DIV_1         // PLL Output Divider
+    #pragma config FPBDIV   = DIV_1         // Peripheral Clock divisor
+    #pragma config FWDTEN   = OFF           // Watchdog Timer
+    #pragma config WDTPS    = PS1           // Watchdog Timer Postscale
+    #pragma config FCKSM    = CSDCMD        // Clock Switching & Fail Safe Clock Monitor
+    #pragma config OSCIOFNC = OFF           // CLKO Enable
+    #pragma config POSCMOD  = HS            // Primary Oscillator
+    #pragma config IESO     = OFF           // Internal/External Switch-over
+    #pragma config FSOSCEN  = OFF           // Secondary Oscillator Enable (KLO was off)
+    #pragma config FNOSC    = PRIPLL        // Oscillator Selection
+    #pragma config CP       = OFF           // Code Protect
+    #pragma config BWP      = OFF           // Boot Flash Write Protect
+    #pragma config PWP      = OFF           // Program Flash Write Protect
+    #pragma config ICESEL   = ICS_PGx2      // ICE/ICD Comm Channel Select
+    #pragma config DEBUG    = ON            // Background Debugger Enable
+#elif defined(BREADBOARD)
+	#if defined(__PIC24FJ64GB002__)
+        _CONFIG1(WDTPS_PS1 & FWPSA_PR32 & WINDIS_OFF & FWDTEN_OFF & ICS_PGx3 & GWRP_OFF & GCP_OFF & JTAGEN_OFF)
+        _CONFIG2(POSCMOD_HS & I2C1SEL_PRI & IOL1WAY_OFF & OSCIOFNC_OFF & FCKSM_CSDCMD & FNOSC_PRIPLL & PLL96MHZ_ON & PLLDIV_DIV3 & IESO_ON)
+        _CONFIG3(WPFP_WPFP0 & SOSCSEL_SOSC & WUTSEL_LEG & WPDIS_WPDIS & WPCFG_WPCFGDIS & WPEND_WPENDMEM)
+        _CONFIG4(DSWDTPS_DSWDTPS3 & DSWDTOSC_LPRC & RTCOSC_LPRC & DSBOREN_OFF & DSWDTEN_OFF)
+        //_CONFIG1(WDTPS_PS1 & FWPSA_PR32 & WINDIS_OFF & FWDTEN_OFF & ICS_PGx3 & GWRP_OFF & GCP_OFF & JTAGEN_OFF)
+        //_CONFIG2(POSCMOD_NONE & I2C1SEL_PRI & IOL1WAY_OFF & OSCIOFNC_OFF & FCKSM_CSDCMD & FNOSC_FRCPLL & PLL96MHZ_ON & PLLDIV_NODIV & IESO_ON)
+        //_CONFIG3(WPFP_WPFP0 & SOSCSEL_SOSC & WUTSEL_LEG & WPDIS_WPDIS & WPCFG_WPCFGDIS & WPEND_WPENDMEM)
+        //_CONFIG4(DSWDTPS_DSWDTPS3 & DSWDTOSC_LPRC & RTCOSC_SOSC & DSBOREN_OFF & DSWDTEN_OFF)
+    #else
+        #error No breadboard device defined, see "HardwareProfile.h" and __FILE__
+    #endif
+#else
+    #error No hardware board defined, see "HardwareProfile.h"
+#endif
+
+
+
+/** VARIABLES *****************************************************
+#if defined(__18F14K50) || defined(__18F13K50) || defined(__18LF14K50) || defined(__18LF13K50) 
+    #pragma udata usbram2
+#elif defined(__18F2455) || defined(__18F2550) || defined(__18F4455) || defined(__18F4550)\
+    || defined(__18F2458) || defined(__18F2453) || defined(__18F4558) || defined(__18F4553)
+    #pragma udata USB_VARIABLES=0x500
+#elif defined(__18F4450) || defined(__18F2450)
+    #pragma udata USB_VARIABLES=0x480
+#else
+    #pragma udata
+#endif
+
+unsigned char OUTPacket[64];	//User application buffer for receiving and holding OUT packets sent from the host
+unsigned char INPacket[64];		//User application buffer for sending IN packets to the host
+*/
+#pragma udata
+BOOL blinkStatusValid;
+/*
+USB_HANDLE USBGenericOutHandle;
+USB_HANDLE USBGenericInHandle;
+#pragma udata
+*/
+/** PRIVATE PROTOTYPES *********************************************/
+static void InitializeSystem(void);
+void USBDeviceTasks(void);
+void YourHighPriorityISRCode(void);
+void YourLowPriorityISRCode(void);
+void UserInit(void);
+void ProcessIO(void);
+void BlinkUSBStatus(void);
+
+/** VECTOR REMAPPING ***********************************************/
+#if defined(__18CXX)
+	//On PIC18 devices, addresses 0x00, 0x08, and 0x18 are used for
+	//the reset, high priority interrupt, and low priority interrupt
+	//vectors.  However, the current Microchip USB bootloader 
+	//examples are intended to occupy addresses 0x00-0x7FF or
+	//0x00-0xFFF depending on which bootloader is used.  Therefore,
+	//the bootloader code remaps these vectors to new locations
+	//as indicated below.  This remapping is only necessary if you
+	//wish to program the hex file generated from this project with
+	//the USB bootloader.  If no bootloader is used, edit the
+	//usb_config.h file and comment out the following defines:
+	//#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER
+	//#define PROGRAMMABLE_WITH_USB_LEGACY_CUSTOM_CLASS_BOOTLOADER
+	
+	#if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)
+		#define REMAPPED_RESET_VECTOR_ADDRESS			0x1000
+		#define REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS	0x1008
+		#define REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS	0x1018
+	#elif defined(PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER)	
+		#define REMAPPED_RESET_VECTOR_ADDRESS			0x800
+		#define REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS	0x808
+		#define REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS	0x818
+	#else	
+		#define REMAPPED_RESET_VECTOR_ADDRESS			0x00
+		#define REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS	0x08
+		#define REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS	0x18
+	#endif
+	
+	#if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)||defined(PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER)
+	extern void _startup (void);        // See c018i.c in your C18 compiler dir
+	#pragma code REMAPPED_RESET_VECTOR = REMAPPED_RESET_VECTOR_ADDRESS
+	void _reset (void)
+	{
+	    _asm goto _startup _endasm
+	}
+	#endif
+	#pragma code REMAPPED_HIGH_INTERRUPT_VECTOR = REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS
+	void Remapped_High_ISR (void)
+	{
+	     _asm goto YourHighPriorityISRCode _endasm
+	}
+	#pragma code REMAPPED_LOW_INTERRUPT_VECTOR = REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS
+	void Remapped_Low_ISR (void)
+	{
+	     _asm goto YourLowPriorityISRCode _endasm
+	}
+	
+	#if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)||defined(PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER)
+	//Note: If this project is built while one of the bootloaders has
+	//been defined, but then the output hex file is not programmed with
+	//the bootloader, addresses 0x08 and 0x18 would end up programmed with 0xFFFF.
+	//As a result, if an actual interrupt was enabled and occured, the PC would jump
+	//to 0x08 (or 0x18) and would begin executing "0xFFFF" (unprogrammed space).  This
+	//executes as nop instructions, but the PC would eventually reach the REMAPPED_RESET_VECTOR_ADDRESS
+	//(0x1000 or 0x800, depending upon bootloader), and would execute the "goto _startup".  This
+	//would effective reset the application.
+	
+	//To fix this situation, we should always deliberately place a 
+	//"goto REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS" at address 0x08, and a
+	//"goto REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS" at address 0x18.  When the output
+	//hex file of this project is programmed with the bootloader, these sections do not
+	//get bootloaded (as they overlap the bootloader space).  If the output hex file is not
+	//programmed using the bootloader, then the below goto instructions do get programmed,
+	//and the hex file still works like normal.  The below section is only required to fix this
+	//scenario.
+	#pragma code HIGH_INTERRUPT_VECTOR = 0x08
+	void High_ISR (void)
+	{
+	     _asm goto REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS _endasm
+	}
+	#pragma code LOW_INTERRUPT_VECTOR = 0x18
+	void Low_ISR (void)
+	{
+	     _asm goto REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS _endasm
+	}
+	#endif	//end of "#if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)||defined(PROGRAMMABLE_WITH_USB_LEGACY_CUSTOM_CLASS_BOOTLOADER)"
+
+	#pragma code
+	
+	
+	//These are your actual interrupt handling routines.
+	#pragma interrupt YourHighPriorityISRCode
+	void YourHighPriorityISRCode()
+	{
+		//Check which interrupt flag caused the interrupt.
+		//Service the interrupt
+		//Clear the interrupt flag
+		//Etc.
+        #if defined(USB_INTERRUPT)
+	        USBDeviceTasks();
+        #endif
+	
+	}	//This return will be a "retfie fast", since this is in a #pragma interrupt section 
+	#pragma interruptlow YourLowPriorityISRCode
+	void YourLowPriorityISRCode()
+	{
+		//Check which interrupt flag caused the interrupt.
+		//Service the interrupt
+		//Clear the interrupt flag
+		//Etc.
+	
+	}	//This return will be a "retfie", since this is in a #pragma interruptlow section 
+
+#elif defined(__C30__)
+    #if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)
+        /*
+         *	ISR JUMP TABLE
+         *
+         *	It is necessary to define jump table as a function because C30 will
+         *	not store 24-bit wide values in program memory as variables.
+         *
+         *	This function should be stored at an address where the goto instructions 
+         *	line up with the remapped vectors from the bootloader's linker script.
+         *  
+         *  For more information about how to remap the interrupt vectors,
+         *  please refer to AN1157.  An example is provided below for the T2
+         *  interrupt with a bootloader ending at address 0x1400
+         */
+//        void __attribute__ ((address(0x1404))) ISRTable(){
+//        
+//        	asm("reset"); //reset instruction to prevent runaway code
+//        	asm("goto %0"::"i"(&_T2Interrupt));  //T2Interrupt's address
+//        }
+    #endif
+#endif
+
+
+
+
+/** DECLARATIONS ***************************************************/
+#pragma code
+
+/******************************************************************************
+ * Function:        void main(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        Main program entry point.
+ *
+ * Note:            None
+ *******************************************************************/
+
+#if defined(__18CXX)
+void main(void)
+#else
+int main(void)
+#endif
+{   
+    InitializeSystem();
+
+    #if defined(USB_INTERRUPT)
+        USBDeviceAttach();
+    #endif
+
+    while(1)
+    {
+        #if defined(USB_POLLING)
+		// Check bus status and service USB interrupts.
+        USBDeviceTasks(); // Interrupt or polling method.  If using polling, must call
+        				  // this function periodically.  This function will take care
+        				  // of processing and responding to SETUP transactions 
+        				  // (such as during the enumeration process when you first
+        				  // plug in).  USB hosts require that USB devices should accept
+        				  // and process SETUP packets in a timely fashion.  Therefore,
+        				  // when using polling, this function should be called 
+        				  // frequently (such as once about every 100 microseconds) at any
+        				  // time that a SETUP packet might reasonably be expected to
+        				  // be sent by the host to your device.  In most cases, the
+        				  // USBDeviceTasks() function does not take very long to
+        				  // execute (~50 instruction cycles) before it returns.
+        #endif
+    				  
+
+		// Application-specific tasks.
+		// Application related code may be added here, or in the ProcessIO() function.
+        Benchmark_ProcessIO();        
+    }//end while
+}//end main
+
+
+/********************************************************************
+ * Function:        static void InitializeSystem(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        InitializeSystem is a centralize initialization
+ *                  routine. All required USB initialization routines
+ *                  are called from here.
+ *
+ *                  User application initialization routine should
+ *                  also be called from here.                  
+ *
+ * Note:            None
+ *******************************************************************/
+static void InitializeSystem(void)
+{
+    #if (defined(__18CXX) & !defined(PIC18F87J50_PIM))
+        ADCON1 |= 0x0F;                 // Default all pins to digital
+    #elif defined(__C30__)
+        AD1PCFGL = 0xFFFF;
+    #elif defined(__C32__)
+        AD1PCFG = 0xFFFF;
+    #endif
+
+    #if defined(PIC18F87J50_PIM) || defined(PIC18F46J50_PIM)
+	//On the PIC18F87J50 Family of USB microcontrollers, the PLL will not power up and be enabled
+	//by default, even if a PLL enabled oscillator configuration is selected (such as HS+PLL).
+	//This allows the device to power up at a lower initial operating frequency, which can be
+	//advantageous when powered from a source which is not gauranteed to be adequate for 48MHz
+	//operation.  On these devices, user firmware needs to manually set the OSCTUNE<PLLEN> bit to
+	//power up the PLL.
+    {
+        unsigned int pll_startup_counter = 600;
+        OSCTUNEbits.PLLEN = 1;  //Enable the PLL and wait 2+ms until the PLL locks before enabling USB module
+        while(pll_startup_counter--);
+    }
+    //Device switches over automatically to PLL output after PLL is locked and ready.
+    #endif
+
+    #if defined(PIC18F87J50_PIM)
+	//Configure all I/O pins to use digital input buffers.  The PIC18F87J50 Family devices
+	//use the ANCONx registers to control this, which is different from other devices which
+	//use the ADCON1 register for this purpose.
+    WDTCONbits.ADSHR = 1;			// Select alternate SFR location to access ANCONx registers
+    ANCON0 = 0xFF;                  // Default all pins to digital
+    ANCON1 = 0xFF;                  // Default all pins to digital
+    WDTCONbits.ADSHR = 0;			// Select normal SFR locations
+    #endif
+
+    #if defined(PIC18F46J50_PIM)
+	//Configure all I/O pins to use digital input buffers.  The PIC18F87J50 Family devices
+	//use the ANCONx registers to control this, which is different from other devices which
+	//use the ADCON1 register for this purpose.
+    ANCON0 = 0xFF;                  // Default all pins to digital
+    ANCON1 = 0xFF;                  // Default all pins to digital
+    #endif
+    
+   #if defined(PIC24FJ64GB004_PIM)
+	//On the PIC24FJ64GB004 Family of USB microcontrollers, the PLL will not power up and be enabled
+	//by default, even if a PLL enabled oscillator configuration is selected (such as HS+PLL).
+	//This allows the device to power up at a lower initial operating frequency, which can be
+	//advantageous when powered from a source which is not gauranteed to be adequate for 32MHz
+	//operation.  On these devices, user firmware needs to manually set the CLKDIV<PLLEN> bit to
+	//power up the PLL.
+    {
+        unsigned int pll_startup_counter = 600;
+        CLKDIVbits.PLLEN = 1;
+        while(pll_startup_counter--);
+    }
+
+    //Device switches over automatically to PLL output after PLL is locked and ready.
+    #endif
+
+
+//	The USB specifications require that USB peripheral devices must never source
+//	current onto the Vbus pin.  Additionally, USB peripherals should not source
+//	current on D+ or D- when the host/hub is not actively powering the Vbus line.
+//	When designing a self powered (as opposed to bus powered) USB peripheral
+//	device, the firmware should make sure not to turn on the USB module and D+
+//	or D- pull up resistor unless Vbus is actively powered.  Therefore, the
+//	firmware needs some means to detect when Vbus is being powered by the host.
+//	A 5V tolerant I/O pin can be connected to Vbus (through a resistor), and
+// 	can be used to detect when Vbus is high (host actively powering), or low
+//	(host is shut down or otherwise not supplying power).  The USB firmware
+// 	can then periodically poll this I/O pin to know when it is okay to turn on
+//	the USB module/D+/D- pull up resistor.  When designing a purely bus powered
+//	peripheral device, it is not possible to source current on D+ or D- when the
+//	host is not actively providing power on Vbus. Therefore, implementing this
+//	bus sense feature is optional.  This firmware can be made to use this bus
+//	sense feature by making sure "USE_USB_BUS_SENSE_IO" has been defined in the
+//	HardwareProfile.h file.    
+    #if defined(USE_USB_BUS_SENSE_IO)
+    tris_usb_bus_sense = INPUT_PIN; // See HardwareProfile.h
+    #endif
+    
+//	If the host PC sends a GetStatus (device) request, the firmware must respond
+//	and let the host know if the USB peripheral device is currently bus powered
+//	or self powered.  See chapter 9 in the official USB specifications for details
+//	regarding this request.  If the peripheral device is capable of being both
+//	self and bus powered, it should not return a hard coded value for this request.
+//	Instead, firmware should check if it is currently self or bus powered, and
+//	respond accordingly.  If the hardware has been configured like demonstrated
+//	on the PICDEM FS USB Demo Board, an I/O pin can be polled to determine the
+//	currently selected power source.  On the PICDEM FS USB Demo Board, "RA2" 
+//	is used for	this purpose.  If using this feature, make sure "USE_SELF_POWER_SENSE_IO"
+//	has been defined in HardwareProfile.h, and that an appropriate I/O pin has been mapped
+//	to it in HardwareProfile.h.
+    #if defined(USE_SELF_POWER_SENSE_IO)
+    tris_self_power = INPUT_PIN;	// See HardwareProfile.h
+    #endif
+/*
+	USBGenericOutHandle = 0;	
+	USBGenericInHandle = 0;		
+*/
+    UserInit();			//Application related initialization.  See user.c
+
+    USBDeviceInit();	//usb_device.c.  Initializes USB module SFRs and firmware
+    					//variables to known states.
+}//end InitializeSystem
+
+
+
+void UserInit(void)
+{
+    mInitAllLEDs();
+    mInitAllSwitches();
+
+	blinkStatusValid = TRUE;	//Blink the normal USB state on the LEDs.
+	Benchmark_Init();
+
+}//end UserInit
+
+
+/******************************************************************************
+ * Function:        void ProcessIO(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        This function is a place holder for other user routines.
+ *                  It is a mixture of both USB and non-USB tasks.
+ *
+ * Note:            None
+ *****************************************************************************/
+/*
+void ProcessIO(void)
+{   
+    //Blink the LEDs according to the USB device status, but only do so if the PC application isn't connected and controlling the LEDs.
+    if(blinkStatusValid)
+    {
+        BlinkUSBStatus();
+    }
+
+    //User Application USB tasks below.
+    //Note: The user application should not begin attempting to read/write over the USB
+    //until after the device has been fully enumerated.  After the device is fully
+    //enumerated, the USBDeviceState will be set to "CONFIGURED_STATE".
+    if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return;
+    
+    //As the device completes the enumeration process, the USBCBInitEP() function will
+    //get called.  In this function, we initialize the user application endpoints (in this
+    //example code, the user application makes use of endpoint 1 IN and endpoint 1 OUT).
+    //The USBGenRead() function call in the USBCBInitEP() function initializes endpoint 1 OUT
+    //and "arms" it so that it can receive a packet of data from the host.  Once the endpoint
+    //has been armed, the host can then send data to it (assuming some kind of application software
+    //is running on the host, and the application software tries to send data to the USB device).
+    
+    //If the host sends a packet of data to the endpoint 1 OUT buffer, the hardware of the SIE will
+    //automatically receive it and store the data at the memory location pointed to when we called
+    //USBGenRead().  Additionally, the endpoint handle (in this case USBGenericOutHandle) will indicate
+    //that the endpoint is no longer busy.  At this point, it is safe for this firmware to begin reading
+    //from the endpoint buffer, and processing the data.  In this example, we have implemented a few very
+    //simple commands.  For example, if the host sends a packet of data to the endpoint 1 OUT buffer, with the
+    //first byte = 0x80, this is being used as a command to indicate that the firmware should "Toggle LED(s)".
+    if(!USBHandleBusy(USBGenericOutHandle))		//Check if the endpoint has received any data from the host.
+    {   
+        switch(OUTPacket[0])					//Data arrived, check what kind of command might be in the packet of data.
+        {
+            case 0x80:  //Toggle LED(s) command from PC application.
+		        blinkStatusValid = FALSE;		//Disable the regular LED blink pattern indicating USB state, PC application is controlling the LEDs.
+                if(mGetLED_1() == mGetLED_2())
+                {
+                    mLED_1_Toggle();
+                    mLED_2_Toggle();
+                }
+                else
+                {
+                    mLED_1_On();
+                    mLED_2_On();
+                }
+                break;
+            case 0x81:  //Get push button state command from PC application.
+                INPacket[0] = 0x81;				//Echo back to the host PC the command we are fulfilling in the first byte.  In this case, the Get Pushbutton State command.
+				if(sw2 == 1)					//pushbutton not pressed, pull up resistor on circuit board is pulling the PORT pin high
+				{
+					INPacket[1] = 0x01;			
+				}
+				else							//sw2 must be == 0, pushbutton is pressed and overpowering the pull up resistor
+				{
+					INPacket[1] = 0x00;
+				}				
+				//Now check to make sure no previous attempts to send data to the host are still pending.  If any attemps are still
+				//pending, we do not want to write to the endpoint 1 IN buffer again, until the previous transaction is complete.
+				//Otherwise the unsent data waiting in the buffer will get overwritten and will result in unexpected behavior.    
+                if(!USBHandleBusy(USBGenericInHandle))		
+	            {	
+		            //The endpoint was not "busy", therefore it is safe to write to the buffer and arm the endpoint.					
+	                //The USBGenWrite() function call "arms" the endpoint (and makes the handle indicate the endpoint is busy).
+	                //Once armed, the data will be automatically sent to the host (in hardware by the SIE) the next time the 
+	                //host polls the endpoint.  Once the data is successfully sent, the handle (in this case USBGenericInHandle) 
+	                //will indicate the the endpoint is no longer busy.
+					USBGenericInHandle = USBGenWrite(USBGEN_EP_NUM,(BYTE*)&INPacket,USBGEN_EP_SIZE);	
+                }
+                break;
+        }
+        
+        //Re-arm the OUT endpoint for the next packet:
+	    //The USBGenRead() function call "arms" the endpoint (and makes it "busy").  If the endpoint is armed, the SIE will 
+	    //automatically accept data from the host, if the host tries to send a packet of data to the endpoint.  Once a data 
+	    //packet addressed to this endpoint is received from the host, the endpoint will no longer be busy, and the application
+	    //can read the data which will be sitting in the buffer.
+        USBGenericOutHandle = USBGenRead(USBGEN_EP_NUM,(BYTE*)&OUTPacket,USBGEN_EP_SIZE);
+    }
+}//end ProcessIO
+
+*/
+
+/********************************************************************
+ * Function:        void BlinkUSBStatus(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        BlinkUSBStatus turns on and off LEDs 
+ *                  corresponding to the USB device state.
+ *
+ * Note:            mLED macros can be found in HardwareProfile.h
+ *                  USBDeviceState is declared and updated in
+ *                  usb_device.c.
+ *******************************************************************/
+void BlinkUSBStatus(void)
+{
+    static WORD led_count=0;
+    
+    if(led_count == 0)led_count = 10000U;
+    led_count--;
+
+    #define mLED_Both_Off()         {mLED_1_Off();mLED_2_Off();}
+    #define mLED_Both_On()          {mLED_1_On();mLED_2_On();}
+    #define mLED_Only_1_On()        {mLED_1_On();mLED_2_Off();}
+    #define mLED_Only_2_On()        {mLED_1_Off();mLED_2_On();}
+
+    if(USBSuspendControl == 1)
+    {
+        if(led_count==0)
+        {
+            mLED_1_Toggle();
+            if(mGetLED_1())
+            {
+                mLED_2_On();
+            }
+            else
+            {
+                mLED_2_Off();
+            }
+        }//end if
+    }
+    else
+    {
+        if(USBDeviceState == DETACHED_STATE)
+        {
+            mLED_Both_Off();
+        }
+        else if(USBDeviceState == ATTACHED_STATE)
+        {
+            mLED_Both_On();
+        }
+        else if(USBDeviceState == POWERED_STATE)
+        {
+            mLED_Only_1_On();
+        }
+        else if(USBDeviceState == DEFAULT_STATE)
+        {
+            mLED_Only_2_On();
+        }
+        else if(USBDeviceState == ADDRESS_STATE)
+        {
+            if(led_count == 0)
+            {
+                mLED_1_Toggle();
+                mLED_2_Off();
+            }//end if
+        }
+        else if(USBDeviceState == CONFIGURED_STATE)
+        {
+            if(led_count==0)
+            {
+                mLED_1_Toggle();
+                if(mGetLED_1())
+                {
+                    mLED_2_Off();
+                }
+                else
+                {
+                    mLED_2_On();
+                }
+            }//end if
+        }//end if(...)
+    }//end if(UCONbits.SUSPND...)
+
+}//end BlinkUSBStatus
+
+
+
+
+// ******************************************************************************************************
+// ************** USB Callback Functions ****************************************************************
+// ******************************************************************************************************
+// The USB firmware stack will call the callback functions USBCBxxx() in response to certain USB related
+// events.  For example, if the host PC is powering down, it will stop sending out Start of Frame (SOF)
+// packets to your device.  In response to this, all USB devices are supposed to decrease their power
+// consumption from the USB Vbus to <2.5mA each.  The USB module detects this condition (which according
+// to the USB specifications is 3+ms of no bus activity/SOF packets) and then calls the USBCBSuspend()
+// function.  You should modify these callback functions to take appropriate actions for each of these
+// conditions.  For example, in the USBCBSuspend(), you may wish to add code that will decrease power
+// consumption from Vbus to <2.5mA (such as by clock switching, turning off LEDs, putting the
+// microcontroller to sleep, etc.).  Then, in the USBCBWakeFromSuspend() function, you may then wish to
+// add code that undoes the power saving things done in the USBCBSuspend() function.
+
+// The USBCBSendResume() function is special, in that the USB stack will not automatically call this
+// function.  This function is meant to be called from the application firmware instead.  See the
+// additional comments near the function.
+
+/******************************************************************************
+ * Function:        void USBCBSuspend(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        Call back that is invoked when a USB suspend is detected
+ *
+ * Note:            None
+ *****************************************************************************/
+void USBCBSuspend(void)
+{
+	//Example power saving code.  Insert appropriate code here for the desired
+	//application behavior.  If the microcontroller will be put to sleep, a
+	//process similar to that shown below may be used:
+	
+	//ConfigureIOPinsForLowPower();
+	//SaveStateOfAllInterruptEnableBits();
+	//DisableAllInterruptEnableBits();
+	//EnableOnlyTheInterruptsWhichWillBeUsedToWakeTheMicro();	//should enable at least USBActivityIF as a wake source
+	//Sleep();
+	//RestoreStateOfAllPreviouslySavedInterruptEnableBits();	//Preferrably, this should be done in the USBCBWakeFromSuspend() function instead.
+	//RestoreIOPinsToNormal();									//Preferrably, this should be done in the USBCBWakeFromSuspend() function instead.
+
+	//IMPORTANT NOTE: Do not clear the USBActivityIF (ACTVIF) bit here.  This bit is 
+	//cleared inside the usb_device.c file.  Clearing USBActivityIF here will cause 
+	//things to not work as intended.	
+	
+
+    #if defined(__C30__)
+    #if 0
+        U1EIR = 0xFFFF;
+        U1IR = 0xFFFF;
+        U1OTGIR = 0xFFFF;
+        IFS5bits.USB1IF = 0;
+        IEC5bits.USB1IE = 1;
+        U1OTGIEbits.ACTVIE = 1;
+        U1OTGIRbits.ACTVIF = 1;
+        Sleep();
+    #endif
+    #endif
+}
+
+
+/******************************************************************************
+ * Function:        void _USB1Interrupt(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        This function is called when the USB interrupt bit is set
+ *					In this example the interrupt is only used when the device
+ *					goes to sleep when it receives a USB suspend command
+ *
+ * Note:            None
+ *****************************************************************************/
+#if 0
+void __attribute__ ((interrupt)) _USB1Interrupt(void)
+{
+    #if !defined(self_powered)
+        if(U1OTGIRbits.ACTVIF)
+        {
+            IEC5bits.USB1IE = 0;
+            U1OTGIEbits.ACTVIE = 0;
+            IFS5bits.USB1IF = 0;
+        
+            //USBClearInterruptFlag(USBActivityIFReg,USBActivityIFBitNum);
+            USBClearInterruptFlag(USBIdleIFReg,USBIdleIFBitNum);
+            //USBSuspendControl = 0;
+        }
+    #endif
+}
+#endif
+
+/******************************************************************************
+ * Function:        void USBCBWakeFromSuspend(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        The host may put USB peripheral devices in low power
+ *					suspend mode (by "sending" 3+ms of idle).  Once in suspend
+ *					mode, the host may wake the device back up by sending non-
+ *					idle state signalling.
+ *					
+ *					This call back is invoked when a wakeup from USB suspend 
+ *					is detected.
+ *
+ * Note:            None
+ *****************************************************************************/
+void USBCBWakeFromSuspend(void)
+{
+	// If clock switching or other power savings measures were taken when
+	// executing the USBCBSuspend() function, now would be a good time to
+	// switch back to normal full power run mode conditions.  The host allows
+	// a few milliseconds of wakeup time, after which the device must be 
+	// fully back to normal, and capable of receiving and processing USB
+	// packets.  In order to do this, the USB module must receive proper
+	// clocking (IE: 48MHz clock must be available to SIE for full speed USB
+	// operation).
+}
+
+/********************************************************************
+ * Function:        void USBCB_SOF_Handler(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        The USB host sends out a SOF packet to full-speed
+ *                  devices every 1 ms. This interrupt may be useful
+ *                  for isochronous pipes. End designers should
+ *                  implement callback routine as necessary.
+ *
+ * Note:            None
+ *******************************************************************/
+void USBCB_SOF_Handler(void)
+{
+    // No need to clear UIRbits.SOFIF to 0 here.
+    // Callback caller is already doing that.
+}
+
+/*******************************************************************
+ * Function:        void USBCBErrorHandler(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        The purpose of this callback is mainly for
+ *                  debugging during development. Check UEIR to see
+ *                  which error causes the interrupt.
+ *
+ * Note:            None
+ *******************************************************************/
+void USBCBErrorHandler(void)
+{
+    // No need to clear UEIR to 0 here.
+    // Callback caller is already doing that.
+
+	// Typically, user firmware does not need to do anything special
+	// if a USB error occurs.  For example, if the host sends an OUT
+	// packet to your device, but the packet gets corrupted (ex:
+	// because of a bad connection, or the user unplugs the
+	// USB cable during the transmission) this will typically set
+	// one or more USB error interrupt flags.  Nothing specific
+	// needs to be done however, since the SIE will automatically
+	// send a "NAK" packet to the host.  In response to this, the
+	// host will normally retry to send the packet again, and no
+	// data loss occurs.  The system will typically recover
+	// automatically, without the need for application firmware
+	// intervention.
+	
+	// Nevertheless, this callback function is provided, such as
+	// for debugging purposes.
+}
+
+
+/*******************************************************************
+ * Function:        void USBCBCheckOtherReq(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        When SETUP packets arrive from the host, some
+ * 					firmware must process the request and respond
+ *					appropriately to fulfill the request.  Some of
+ *					the SETUP packets will be for standard
+ *					USB "chapter 9" (as in, fulfilling chapter 9 of
+ *					the official USB specifications) requests, while
+ *					others may be specific to the USB device class
+ *					that is being implemented.  For example, a HID
+ *					class device needs to be able to respond to
+ *					"GET REPORT" type of requests.  This
+ *					is not a standard USB chapter 9 request, and 
+ *					therefore not handled by usb_device.c.  Instead
+ *					this request should be handled by class specific 
+ *					firmware, such as that contained in usb_function_hid.c.
+ *
+ * Note:            None
+ *****************************************************************************
+void USBCBCheckOtherReq(void)
+{
+}//end
+*/
+
+/*******************************************************************
+ * Function:        void USBCBStdSetDscHandler(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        The USBCBStdSetDscHandler() callback function is
+ *					called when a SETUP, bRequest: SET_DESCRIPTOR request
+ *					arrives.  Typically SET_DESCRIPTOR requests are
+ *					not used in most applications, and it is
+ *					optional to support this type of request.
+ *
+ * Note:            None
+ *****************************************************************************/
+void USBCBStdSetDscHandler(void)
+{
+    // Must claim session ownership if supporting this request
+}//end
+
+
+/******************************************************************************
+ * Function:        void USBCBInitEP(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        This function is called when the device becomes
+ *                  initialized, which occurs after the host sends a
+ * 					SET_CONFIGURATION (wValue not = 0) request.  This 
+ *					callback function should initialize the endpoints 
+ *					for the device's usage according to the current 
+ *					configuration.
+ *
+ * Note:            None
+ *****************************************************************************
+void USBCBInitEP(void)
+{
+    USBEnableEndpoint(USBGEN_EP_NUM,USB_OUT_ENABLED|USB_IN_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP);
+    USBGenericOutHandle = USBGenRead(USBGEN_EP_NUM,(BYTE*)&OUTPacket,USBGEN_EP_SIZE);
+}
+*/
+/********************************************************************
+ * Function:        void USBCBSendResume(void)
+ *
+ * PreCondition:    None
+ *
+ * Input:           None
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        The USB specifications allow some types of USB
+ * 					peripheral devices to wake up a host PC (such
+ *					as if it is in a low power suspend to RAM state).
+ *					This can be a very useful feature in some
+ *					USB applications, such as an Infrared remote
+ *					control	receiver.  If a user presses the "power"
+ *					button on a remote control, it is nice that the
+ *					IR receiver can detect this signalling, and then
+ *					send a USB "command" to the PC to wake up.
+ *					
+ *					The USBCBSendResume() "callback" function is used
+ *					to send this special USB signalling which wakes 
+ *					up the PC.  This function may be called by
+ *					application firmware to wake up the PC.  This
+ *					function should only be called when:
+ *					
+ *					1.  The USB driver used on the host PC supports
+ *						the remote wakeup capability.
+ *					2.  The USB configuration descriptor indicates
+ *						the device is remote wakeup capable in the
+ *						bmAttributes field.
+ *					3.  The USB host PC is currently sleeping,
+ *						and has previously sent your device a SET 
+ *						FEATURE setup packet which "armed" the
+ *						remote wakeup capability.   
+ *
+ *					This callback should send a RESUME signal that
+ *                  has the period of 1-15ms.
+ *
+ * Note:            Interrupt vs. Polling
+ *                  -Primary clock
+ *                  -Secondary clock ***** MAKE NOTES ABOUT THIS *******
+ *                   > Can switch to primary first by calling USBCBWakeFromSuspend()
+ 
+ *                  The modifiable section in this routine should be changed
+ *                  to meet the application needs. Current implementation
+ *                  temporary blocks other functions from executing for a
+ *                  period of 1-13 ms depending on the core frequency.
+ *
+ *                  According to USB 2.0 specification section 7.1.7.7,
+ *                  "The remote wakeup device must hold the resume signaling
+ *                  for at lest 1 ms but for no more than 15 ms."
+ *                  The idea here is to use a delay counter loop, using a
+ *                  common value that would work over a wide range of core
+ *                  frequencies.
+ *                  That value selected is 1800. See table below:
+ *                  ==========================================================
+ *                  Core Freq(MHz)      MIP         RESUME Signal Period (ms)
+ *                  ==========================================================
+ *                      48              12          1.05
+ *                       4              1           12.6
+ *                  ==========================================================
+ *                  * These timing could be incorrect when using code
+ *                    optimization or extended instruction mode,
+ *                    or when having other interrupts enabled.
+ *                    Make sure to verify using the MPLAB SIM's Stopwatch
+ *                    and verify the actual signal on an oscilloscope.
+ *******************************************************************/
+void USBCBSendResume(void)
+{
+    static WORD delay_count;
+    
+    USBResumeControl = 1;                // Start RESUME signaling
+    
+    delay_count = 1800U;                // Set RESUME line for 1-13 ms
+    do
+    {
+        delay_count--;
+    }while(delay_count);
+    USBResumeControl = 0;
+}
+
+
+/*******************************************************************
+ * Function:        BOOL USER_USB_CALLBACK_EVENT_HANDLER(
+ *                        USB_EVENT event, void *pdata, WORD size)
+ *
+ * PreCondition:    None
+ *
+ * Input:           USB_EVENT event - the type of event
+ *                  void *pdata - pointer to the event data
+ *                  WORD size - size of the event data
+ *
+ * Output:          None
+ *
+ * Side Effects:    None
+ *
+ * Overview:        This function is called from the USB stack to
+ *                  notify a user application that a USB event
+ *                  occured.  This callback is in interrupt context
+ *                  when the USB_INTERRUPT option is selected.
+ *
+ * Note:            None
+ *******************************************************************/
+BOOL USER_USB_CALLBACK_EVENT_HANDLER(USB_EVENT event, void *pdata, WORD size)
+{
+    switch(event)
+    {
+        case EVENT_CONFIGURED: 
+            USBCBInitEP();
+            break;
+        case EVENT_SET_DESCRIPTOR:
+            USBCBStdSetDscHandler();
+            break;
+        case EVENT_EP0_REQUEST:
+            USBCBCheckOtherReq();
+            break;
+        case EVENT_SOF:
+            USBCB_SOF_Handler();
+            break;
+        case EVENT_SUSPEND:
+            USBCBSuspend();
+            break;
+        case EVENT_RESUME:
+            USBCBWakeFromSuspend();
+            break;
+        case EVENT_BUS_ERROR:
+            USBCBErrorHandler();
+            break;
+        case EVENT_TRANSFER:
+            Nop();
+            break;
+        default:
+            break;
+    }      
+    return TRUE; 
+}
+/** EOF main.c ***************************************************************/

+ 1287 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/p24FJ256GB110 - HID Bootloader.gld

@@ -0,0 +1,1287 @@
+/*
+** Linker script for PIC24FJ256GB110
+*/
+
+OUTPUT_ARCH("24FJ256GB110")
+EXTERN(__resetPRI)
+EXTERN(__resetALT)
+
+/* OPTIONAL(-lpPIC24Fxxx) */
+
+/*
+** Memory Regions
+*/
+MEMORY
+{
+  data  (a!xr) : ORIGIN = 0x800,         LENGTH = 0x4000
+  reset        : ORIGIN = 0x0,           LENGTH = 0x4
+  ivt          : ORIGIN = 0x4,           LENGTH = 0xFC
+  aivt         : ORIGIN = 0x104,         LENGTH = 0xFC
+  program (xr) : ORIGIN = 0x200,         LENGTH = 0x2A9F8
+  config4      : ORIGIN = 0x2ABF8,       LENGTH = 0x2
+  config3      : ORIGIN = 0x2ABFA,       LENGTH = 0x2
+  config2      : ORIGIN = 0x2ABFC,       LENGTH = 0x2
+  config1      : ORIGIN = 0x2ABFE,       LENGTH = 0x2
+}
+
+__CONFIG3 = 0x2ABFA;
+__CONFIG2 = 0x2ABFC;
+__CONFIG1 = 0x2ABFE;
+
+__IVT_BASE  = 0x4;
+__AIVT_BASE = 0x104;
+__DATA_BASE = 0x800;
+__CODE_BASE = 0x200;
+
+
+/*
+** ==================== Section Map ======================
+*/
+SECTIONS
+{
+  /*
+  ** ========== Program Memory ==========
+  */
+
+
+  /*
+  ** Reset Instruction
+  */
+  .reset :
+  {
+        SHORT(ABSOLUTE(__reset));
+        SHORT(0x04);
+        SHORT((ABSOLUTE(__reset) >> 16) & 0x7F);
+        SHORT(0);
+  } >reset
+
+
+  /*
+  ** Interrupt Vector Tables
+  **
+  ** The primary and alternate tables are loaded
+  ** here, between sections .reset and .text.
+  ** Vector table source code appears below.
+  */
+
+
+  /*
+  ** User Code and Library Code
+  **
+  ** This section must not be assigned to __CODE_BASE,
+  ** because CodeGuard(tm) sections may be located there.
+  **
+  ** Note that input sections *(.text) are not mapped here.
+  ** The best-fit allocator locates them, so that .text
+  ** may flow around PSV sections as needed.
+  */
+  .text :
+  {
+        *(.init);
+        *(.user_init);
+        *(.handle);
+        *(.libc) *(.libm) *(.libdsp);  /* keep together in this order */
+        *(.lib*);
+  } >program
+
+
+  /*
+  ** Configuration Words
+  */
+  __CONFIG3 :
+  { *(__CONFIG3.sec)    } >config3
+  __CONFIG2 :
+  { *(__CONFIG2.sec)    } >config2
+  __CONFIG1 :
+  { *(__CONFIG1.sec)    } >config1
+
+
+  /*
+  ** =========== Data Memory ===========
+  */
+
+
+  /*
+  ** ICD Debug Exec
+  **
+  ** This section provides optional storage for
+  ** the ICD2 debugger. Define a global symbol
+  ** named __ICD2RAM to enable ICD2. This section
+  ** must be loaded at data address 0x800.
+  */
+  .icd __DATA_BASE (NOLOAD):
+  {
+    . += (DEFINED (__ICD2RAM) ? 0x50 : 0 );
+  } > data
+
+
+  /*
+  ** Other sections in data memory are not explicitly mapped.
+  ** Instead they are allocated according to their section
+  ** attributes, which is most efficient.
+  ** 
+  ** If a specific arrangement of sections is required
+  ** (other than what can be achieved using attributes)
+  ** additional sections may be defined here. See chapter
+  ** 10.5 in the MPLAB ASM30/LINK30 User's Guide (DS51317)
+  ** for more information.
+  */
+
+
+  /*
+  ** ========== Debug Info ==============
+  */
+
+  .comment        0 : { *(.comment) }
+
+  /*
+  ** DWARF-2
+  */
+  .debug_info     0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
+  .debug_abbrev   0 : { *(.debug_abbrev) }
+  .debug_line     0 : { *(.debug_line) }
+  .debug_frame    0 : { *(.debug_frame) }
+  .debug_str      0 : { *(.debug_str) }
+  .debug_loc      0 : { *(.debug_loc) }
+  .debug_macinfo  0 : { *(.debug_macinfo) }
+  .debug_pubnames 0 : { *(.debug_pubnames) }
+  .debug_ranges   0 : { *(.debug_ranges) }
+  .debug_aranges  0 : { *(.debug_aranges) }
+
+} /* SECTIONS */
+
+/*
+** ================= End of Section Map ================
+*/
+
+/*
+** Section Map for Interrupt Vector Tables
+*/
+SECTIONS
+{
+
+/*
+** Interrupt Vector Table
+*/
+.ivt __IVT_BASE :
+  {
+  } >ivt
+
+
+/*
+** Alternate Interrupt Vector Table
+*/
+.aivt __AIVT_BASE :
+  {
+  } >aivt
+} /* SECTIONS */
+
+
+/*
+** ============== Equates for SFR Addresses =============
+*/
+
+ WREG0        = 0x0;
+_WREG0        = 0x0;
+ WREG1        = 0x2;
+_WREG1        = 0x2;
+ WREG2        = 0x4;
+_WREG2        = 0x4;
+ WREG3        = 0x6;
+_WREG3        = 0x6;
+ WREG4        = 0x8;
+_WREG4        = 0x8;
+ WREG5        = 0xA;
+_WREG5        = 0xA;
+ WREG6        = 0xC;
+_WREG6        = 0xC;
+ WREG7        = 0xE;
+_WREG7        = 0xE;
+ WREG8        = 0x10;
+_WREG8        = 0x10;
+ WREG9        = 0x12;
+_WREG9        = 0x12;
+ WREG10       = 0x14;
+_WREG10       = 0x14;
+ WREG11       = 0x16;
+_WREG11       = 0x16;
+ WREG12       = 0x18;
+_WREG12       = 0x18;
+ WREG13       = 0x1A;
+_WREG13       = 0x1A;
+ WREG14       = 0x1C;
+_WREG14       = 0x1C;
+ WREG15       = 0x1E;
+_WREG15       = 0x1E;
+ SPLIM        = 0x20;
+_SPLIM        = 0x20;
+ PCL          = 0x2E;
+_PCL          = 0x2E;
+ PCH          = 0x30;
+_PCH          = 0x30;
+ TBLPAG       = 0x32;
+_TBLPAG       = 0x32;
+ PSVPAG       = 0x34;
+_PSVPAG       = 0x34;
+ RCOUNT       = 0x36;
+_RCOUNT       = 0x36;
+ SR           = 0x42;
+_SR           = 0x42;
+_SRbits       = 0x42;
+ CORCON       = 0x44;
+_CORCON       = 0x44;
+_CORCONbits   = 0x44;
+ DISICNT      = 0x52;
+_DISICNT      = 0x52;
+ CNPD1        = 0x54;
+_CNPD1        = 0x54;
+_CNPD1bits    = 0x54;
+ CNPD2        = 0x56;
+_CNPD2        = 0x56;
+_CNPD2bits    = 0x56;
+ CNPD3        = 0x58;
+_CNPD3        = 0x58;
+_CNPD3bits    = 0x58;
+ CNPD4        = 0x5A;
+_CNPD4        = 0x5A;
+_CNPD4bits    = 0x5A;
+ CNPD5        = 0x5C;
+_CNPD5        = 0x5C;
+_CNPD5bits    = 0x5C;
+ CNPD6        = 0x5E;
+_CNPD6        = 0x5E;
+_CNPD6bits    = 0x5E;
+ CNEN1        = 0x60;
+_CNEN1        = 0x60;
+_CNEN1bits    = 0x60;
+ CNEN2        = 0x62;
+_CNEN2        = 0x62;
+_CNEN2bits    = 0x62;
+ CNEN3        = 0x64;
+_CNEN3        = 0x64;
+_CNEN3bits    = 0x64;
+ CNEN4        = 0x66;
+_CNEN4        = 0x66;
+_CNEN4bits    = 0x66;
+ CNEN5        = 0x68;
+_CNEN5        = 0x68;
+_CNEN5bits    = 0x68;
+ CNEN6        = 0x6A;
+_CNEN6        = 0x6A;
+_CNEN6bits    = 0x6A;
+ CNPU1        = 0x6C;
+_CNPU1        = 0x6C;
+_CNPU1bits    = 0x6C;
+ CNPU2        = 0x6E;
+_CNPU2        = 0x6E;
+_CNPU2bits    = 0x6E;
+ CNPU3        = 0x70;
+_CNPU3        = 0x70;
+_CNPU3bits    = 0x70;
+ CNPU4        = 0x72;
+_CNPU4        = 0x72;
+_CNPU4bits    = 0x72;
+ CNPU5        = 0x74;
+_CNPU5        = 0x74;
+_CNPU5bits    = 0x74;
+ CNPU6        = 0x76;
+_CNPU6        = 0x76;
+_CNPU6bits    = 0x76;
+ INTCON1      = 0x80;
+_INTCON1      = 0x80;
+_INTCON1bits  = 0x80;
+ INTCON2      = 0x82;
+_INTCON2      = 0x82;
+_INTCON2bits  = 0x82;
+ IFS0         = 0x84;
+_IFS0         = 0x84;
+_IFS0bits     = 0x84;
+ IFS1         = 0x86;
+_IFS1         = 0x86;
+_IFS1bits     = 0x86;
+ IFS2         = 0x88;
+_IFS2         = 0x88;
+_IFS2bits     = 0x88;
+ IFS3         = 0x8A;
+_IFS3         = 0x8A;
+_IFS3bits     = 0x8A;
+ IFS4         = 0x8C;
+_IFS4         = 0x8C;
+_IFS4bits     = 0x8C;
+ IFS5         = 0x8E;
+_IFS5         = 0x8E;
+_IFS5bits     = 0x8E;
+ IEC0         = 0x94;
+_IEC0         = 0x94;
+_IEC0bits     = 0x94;
+ IEC1         = 0x96;
+_IEC1         = 0x96;
+_IEC1bits     = 0x96;
+ IEC2         = 0x98;
+_IEC2         = 0x98;
+_IEC2bits     = 0x98;
+ IEC3         = 0x9A;
+_IEC3         = 0x9A;
+_IEC3bits     = 0x9A;
+ IEC4         = 0x9C;
+_IEC4         = 0x9C;
+_IEC4bits     = 0x9C;
+ IEC5         = 0x9E;
+_IEC5         = 0x9E;
+_IEC5bits     = 0x9E;
+ IPC0         = 0xA4;
+_IPC0         = 0xA4;
+_IPC0bits     = 0xA4;
+ IPC1         = 0xA6;
+_IPC1         = 0xA6;
+_IPC1bits     = 0xA6;
+ IPC2         = 0xA8;
+_IPC2         = 0xA8;
+_IPC2bits     = 0xA8;
+ IPC3         = 0xAA;
+_IPC3         = 0xAA;
+_IPC3bits     = 0xAA;
+ IPC4         = 0xAC;
+_IPC4         = 0xAC;
+_IPC4bits     = 0xAC;
+ IPC5         = 0xAE;
+_IPC5         = 0xAE;
+_IPC5bits     = 0xAE;
+ IPC6         = 0xB0;
+_IPC6         = 0xB0;
+_IPC6bits     = 0xB0;
+ IPC7         = 0xB2;
+_IPC7         = 0xB2;
+_IPC7bits     = 0xB2;
+ IPC8         = 0xB4;
+_IPC8         = 0xB4;
+_IPC8bits     = 0xB4;
+ IPC9         = 0xB6;
+_IPC9         = 0xB6;
+_IPC9bits     = 0xB6;
+ IPC10        = 0xB8;
+_IPC10        = 0xB8;
+_IPC10bits    = 0xB8;
+ IPC11        = 0xBA;
+_IPC11        = 0xBA;
+_IPC11bits    = 0xBA;
+ IPC12        = 0xBC;
+_IPC12        = 0xBC;
+_IPC12bits    = 0xBC;
+ IPC13        = 0xBE;
+_IPC13        = 0xBE;
+_IPC13bits    = 0xBE;
+ IPC15        = 0xC2;
+_IPC15        = 0xC2;
+_IPC15bits    = 0xC2;
+ IPC16        = 0xC4;
+_IPC16        = 0xC4;
+_IPC16bits    = 0xC4;
+ IPC18        = 0xC8;
+_IPC18        = 0xC8;
+_IPC18bits    = 0xC8;
+ IPC19        = 0xCA;
+_IPC19        = 0xCA;
+_IPC19bits    = 0xCA;
+ IPC20        = 0xCC;
+_IPC20        = 0xCC;
+_IPC20bits    = 0xCC;
+ IPC21        = 0xCE;
+_IPC21        = 0xCE;
+_IPC21bits    = 0xCE;
+ IPC22        = 0xD0;
+_IPC22        = 0xD0;
+_IPC22bits    = 0xD0;
+ IPC23        = 0xD2;
+_IPC23        = 0xD2;
+_IPC23bits    = 0xD2;
+ TMR1         = 0x100;
+_TMR1         = 0x100;
+ PR1          = 0x102;
+_PR1          = 0x102;
+ T1CON        = 0x104;
+_T1CON        = 0x104;
+_T1CONbits    = 0x104;
+ TMR2         = 0x106;
+_TMR2         = 0x106;
+ TMR3HLD      = 0x108;
+_TMR3HLD      = 0x108;
+ TMR3         = 0x10A;
+_TMR3         = 0x10A;
+ PR2          = 0x10C;
+_PR2          = 0x10C;
+ PR3          = 0x10E;
+_PR3          = 0x10E;
+ T2CON        = 0x110;
+_T2CON        = 0x110;
+_T2CONbits    = 0x110;
+ T3CON        = 0x112;
+_T3CON        = 0x112;
+_T3CONbits    = 0x112;
+ TMR4         = 0x114;
+_TMR4         = 0x114;
+ TMR5HLD      = 0x116;
+_TMR5HLD      = 0x116;
+ TMR5         = 0x118;
+_TMR5         = 0x118;
+ PR4          = 0x11A;
+_PR4          = 0x11A;
+ PR5          = 0x11C;
+_PR5          = 0x11C;
+ T4CON        = 0x11E;
+_T4CON        = 0x11E;
+_T4CONbits    = 0x11E;
+ T5CON        = 0x120;
+_T5CON        = 0x120;
+_T5CONbits    = 0x120;
+ IC1CON1      = 0x140;
+_IC1CON1      = 0x140;
+_IC1CON1bits  = 0x140;
+ IC1CON2      = 0x142;
+_IC1CON2      = 0x142;
+_IC1CON2bits  = 0x142;
+ IC1BUF       = 0x144;
+_IC1BUF       = 0x144;
+ IC1TMR       = 0x146;
+_IC1TMR       = 0x146;
+ IC2CON1      = 0x148;
+_IC2CON1      = 0x148;
+_IC2CON1bits  = 0x148;
+ IC2CON2      = 0x14A;
+_IC2CON2      = 0x14A;
+_IC2CON2bits  = 0x14A;
+ IC2BUF       = 0x14C;
+_IC2BUF       = 0x14C;
+ IC2TMR       = 0x14E;
+_IC2TMR       = 0x14E;
+ IC3CON1      = 0x150;
+_IC3CON1      = 0x150;
+_IC3CON1bits  = 0x150;
+ IC3CON2      = 0x152;
+_IC3CON2      = 0x152;
+_IC3CON2bits  = 0x152;
+ IC3BUF       = 0x154;
+_IC3BUF       = 0x154;
+ IC3TMR       = 0x156;
+_IC3TMR       = 0x156;
+ IC4CON1      = 0x158;
+_IC4CON1      = 0x158;
+_IC4CON1bits  = 0x158;
+ IC4CON2      = 0x15A;
+_IC4CON2      = 0x15A;
+_IC4CON2bits  = 0x15A;
+ IC4BUF       = 0x15C;
+_IC4BUF       = 0x15C;
+ IC4TMR       = 0x15E;
+_IC4TMR       = 0x15E;
+ IC5CON1      = 0x160;
+_IC5CON1      = 0x160;
+_IC5CON1bits  = 0x160;
+ IC5CON2      = 0x162;
+_IC5CON2      = 0x162;
+_IC5CON2bits  = 0x162;
+ IC5BUF       = 0x164;
+_IC5BUF       = 0x164;
+ IC5TMR       = 0x166;
+_IC5TMR       = 0x166;
+ IC6CON1      = 0x168;
+_IC6CON1      = 0x168;
+_IC6CON1bits  = 0x168;
+ IC6CON2      = 0x16A;
+_IC6CON2      = 0x16A;
+_IC6CON2bits  = 0x16A;
+ IC6BUF       = 0x16C;
+_IC6BUF       = 0x16C;
+ IC6TMR       = 0x16E;
+_IC6TMR       = 0x16E;
+ IC7CON1      = 0x170;
+_IC7CON1      = 0x170;
+_IC7CON1bits  = 0x170;
+ IC7CON2      = 0x172;
+_IC7CON2      = 0x172;
+_IC7CON2bits  = 0x172;
+ IC7BUF       = 0x174;
+_IC7BUF       = 0x174;
+ IC7TMR       = 0x176;
+_IC7TMR       = 0x176;
+ IC8CON1      = 0x178;
+_IC8CON1      = 0x178;
+_IC8CON1bits  = 0x178;
+ IC8CON2      = 0x17A;
+_IC8CON2      = 0x17A;
+_IC8CON2bits  = 0x17A;
+ IC8BUF       = 0x17C;
+_IC8BUF       = 0x17C;
+ IC8TMR       = 0x17E;
+_IC8TMR       = 0x17E;
+ IC9CON1      = 0x180;
+_IC9CON1      = 0x180;
+_IC9CON1bits  = 0x180;
+ IC9CON2      = 0x182;
+_IC9CON2      = 0x182;
+_IC9CON2bits  = 0x182;
+ IC9BUF       = 0x184;
+_IC9BUF       = 0x184;
+ IC9TMR       = 0x186;
+_IC9TMR       = 0x186;
+ OC1CON1      = 0x190;
+_OC1CON1      = 0x190;
+_OC1CON1bits  = 0x190;
+ OC1CON2      = 0x192;
+_OC1CON2      = 0x192;
+_OC1CON2bits  = 0x192;
+ OC1RS        = 0x194;
+_OC1RS        = 0x194;
+ OC1R         = 0x196;
+_OC1R         = 0x196;
+ OC1TMR       = 0x198;
+_OC1TMR       = 0x198;
+ OC2CON1      = 0x19A;
+_OC2CON1      = 0x19A;
+_OC2CON1bits  = 0x19A;
+ OC2CON2      = 0x19C;
+_OC2CON2      = 0x19C;
+_OC2CON2bits  = 0x19C;
+ OC2RS        = 0x19E;
+_OC2RS        = 0x19E;
+ OC2R         = 0x1A0;
+_OC2R         = 0x1A0;
+ OC2TMR       = 0x1A2;
+_OC2TMR       = 0x1A2;
+ OC3CON1      = 0x1A4;
+_OC3CON1      = 0x1A4;
+_OC3CON1bits  = 0x1A4;
+ OC3CON2      = 0x1A6;
+_OC3CON2      = 0x1A6;
+_OC3CON2bits  = 0x1A6;
+ OC3RS        = 0x1A8;
+_OC3RS        = 0x1A8;
+ OC3R         = 0x1AA;
+_OC3R         = 0x1AA;
+ OC3TMR       = 0x1AC;
+_OC3TMR       = 0x1AC;
+ OC4CON1      = 0x1AE;
+_OC4CON1      = 0x1AE;
+_OC4CON1bits  = 0x1AE;
+ OC4CON2      = 0x1B0;
+_OC4CON2      = 0x1B0;
+_OC4CON2bits  = 0x1B0;
+ OC4RS        = 0x1B2;
+_OC4RS        = 0x1B2;
+ OC4R         = 0x1B4;
+_OC4R         = 0x1B4;
+ OC4TMR       = 0x1B6;
+_OC4TMR       = 0x1B6;
+ OC5CON1      = 0x1B8;
+_OC5CON1      = 0x1B8;
+_OC5CON1bits  = 0x1B8;
+ OC5CON2      = 0x1BA;
+_OC5CON2      = 0x1BA;
+_OC5CON2bits  = 0x1BA;
+ OC5RS        = 0x1BC;
+_OC5RS        = 0x1BC;
+ OC5R         = 0x1BE;
+_OC5R         = 0x1BE;
+ OC5TMR       = 0x1C0;
+_OC5TMR       = 0x1C0;
+ OC6CON1      = 0x1C2;
+_OC6CON1      = 0x1C2;
+_OC6CON1bits  = 0x1C2;
+ OC6CON2      = 0x1C4;
+_OC6CON2      = 0x1C4;
+_OC6CON2bits  = 0x1C4;
+ OC6RS        = 0x1C6;
+_OC6RS        = 0x1C6;
+ OC6R         = 0x1C8;
+_OC6R         = 0x1C8;
+ OC6TMR       = 0x1CA;
+_OC6TMR       = 0x1CA;
+ OC7CON1      = 0x1CC;
+_OC7CON1      = 0x1CC;
+_OC7CON1bits  = 0x1CC;
+ OC7CON2      = 0x1CE;
+_OC7CON2      = 0x1CE;
+_OC7CON2bits  = 0x1CE;
+ OC7RS        = 0x1D0;
+_OC7RS        = 0x1D0;
+ OC7R         = 0x1D2;
+_OC7R         = 0x1D2;
+ OC7TMR       = 0x1D4;
+_OC7TMR       = 0x1D4;
+ OC8CON1      = 0x1D6;
+_OC8CON1      = 0x1D6;
+_OC8CON1bits  = 0x1D6;
+ OC8CON2      = 0x1D8;
+_OC8CON2      = 0x1D8;
+_OC8CON2bits  = 0x1D8;
+ OC8RS        = 0x1DA;
+_OC8RS        = 0x1DA;
+ OC8R         = 0x1DC;
+_OC8R         = 0x1DC;
+ OC8TMR       = 0x1DE;
+_OC8TMR       = 0x1DE;
+ OC9CON1      = 0x1E0;
+_OC9CON1      = 0x1E0;
+_OC9CON1bits  = 0x1E0;
+ OC9CON2      = 0x1E2;
+_OC9CON2      = 0x1E2;
+_OC9CON2bits  = 0x1E2;
+ OC9RS        = 0x1E4;
+_OC9RS        = 0x1E4;
+ OC9R         = 0x1E6;
+_OC9R         = 0x1E6;
+ OC9TMR       = 0x1E8;
+_OC9TMR       = 0x1E8;
+ I2C1RCV      = 0x200;
+_I2C1RCV      = 0x200;
+ I2C1TRN      = 0x202;
+_I2C1TRN      = 0x202;
+ I2C1BRG      = 0x204;
+_I2C1BRG      = 0x204;
+ I2C1CON      = 0x206;
+_I2C1CON      = 0x206;
+_I2C1CONbits  = 0x206;
+ I2C1STAT     = 0x208;
+_I2C1STAT     = 0x208;
+_I2C1STATbits = 0x208;
+ I2C1ADD      = 0x20A;
+_I2C1ADD      = 0x20A;
+ I2C1MSK      = 0x20C;
+_I2C1MSK      = 0x20C;
+ I2C2RCV      = 0x210;
+_I2C2RCV      = 0x210;
+ I2C2TRN      = 0x212;
+_I2C2TRN      = 0x212;
+ I2C2BRG      = 0x214;
+_I2C2BRG      = 0x214;
+ I2C2CON      = 0x216;
+_I2C2CON      = 0x216;
+_I2C2CONbits  = 0x216;
+ I2C2STAT     = 0x218;
+_I2C2STAT     = 0x218;
+_I2C2STATbits = 0x218;
+ I2C2ADD      = 0x21A;
+_I2C2ADD      = 0x21A;
+ I2C2MSK      = 0x21C;
+_I2C2MSK      = 0x21C;
+ U1MODE       = 0x220;
+_U1MODE       = 0x220;
+_U1MODEbits   = 0x220;
+ U1STA        = 0x222;
+_U1STA        = 0x222;
+_U1STAbits    = 0x222;
+ U1TXREG      = 0x224;
+_U1TXREG      = 0x224;
+ U1RXREG      = 0x226;
+_U1RXREG      = 0x226;
+ U1BRG        = 0x228;
+_U1BRG        = 0x228;
+ U2MODE       = 0x230;
+_U2MODE       = 0x230;
+_U2MODEbits   = 0x230;
+ U2STA        = 0x232;
+_U2STA        = 0x232;
+_U2STAbits    = 0x232;
+ U2TXREG      = 0x234;
+_U2TXREG      = 0x234;
+ U2RXREG      = 0x236;
+_U2RXREG      = 0x236;
+ U2BRG        = 0x238;
+_U2BRG        = 0x238;
+ SPI1STAT     = 0x240;
+_SPI1STAT     = 0x240;
+_SPI1STATbits = 0x240;
+ SPI1CON1     = 0x242;
+_SPI1CON1     = 0x242;
+_SPI1CON1bits = 0x242;
+ SPI1CON2     = 0x244;
+_SPI1CON2     = 0x244;
+_SPI1CON2bits = 0x244;
+ SPI1BUF      = 0x248;
+_SPI1BUF      = 0x248;
+ U3MODE       = 0x250;
+_U3MODE       = 0x250;
+_U3MODEbits   = 0x250;
+ U3STA        = 0x252;
+_U3STA        = 0x252;
+_U3STAbits    = 0x252;
+ U3TXREG      = 0x254;
+_U3TXREG      = 0x254;
+ U3RXREG      = 0x256;
+_U3RXREG      = 0x256;
+ U3BRG        = 0x258;
+_U3BRG        = 0x258;
+ SPI2STAT     = 0x260;
+_SPI2STAT     = 0x260;
+_SPI2STATbits = 0x260;
+ SPI2CON1     = 0x262;
+_SPI2CON1     = 0x262;
+_SPI2CON1bits = 0x262;
+ SPI2CON2     = 0x264;
+_SPI2CON2     = 0x264;
+_SPI2CON2bits = 0x264;
+ SPI2BUF      = 0x268;
+_SPI2BUF      = 0x268;
+ I2C3RCV      = 0x270;
+_I2C3RCV      = 0x270;
+ I2C3TRN      = 0x272;
+_I2C3TRN      = 0x272;
+ I2C3BRG      = 0x274;
+_I2C3BRG      = 0x274;
+ I2C3CON      = 0x276;
+_I2C3CON      = 0x276;
+_I2C3CONbits  = 0x276;
+ I2C3STAT     = 0x278;
+_I2C3STAT     = 0x278;
+_I2C3STATbits = 0x278;
+ I2C3ADD      = 0x27A;
+_I2C3ADD      = 0x27A;
+ I2C3MSK      = 0x27C;
+_I2C3MSK      = 0x27C;
+ SPI3STAT     = 0x280;
+_SPI3STAT     = 0x280;
+_SPI3STATbits = 0x280;
+ SPI3CON1     = 0x282;
+_SPI3CON1     = 0x282;
+_SPI3CON1bits = 0x282;
+ SPI3CON2     = 0x284;
+_SPI3CON2     = 0x284;
+_SPI3CON2bits = 0x284;
+ SPI3BUF      = 0x288;
+_SPI3BUF      = 0x288;
+ U4MODE       = 0x2B0;
+_U4MODE       = 0x2B0;
+_U4MODEbits   = 0x2B0;
+ U4STA        = 0x2B2;
+_U4STA        = 0x2B2;
+_U4STAbits    = 0x2B2;
+ U4TXREG      = 0x2B4;
+_U4TXREG      = 0x2B4;
+ U4RXREG      = 0x2B6;
+_U4RXREG      = 0x2B6;
+ U4BRG        = 0x2B8;
+_U4BRG        = 0x2B8;
+ TRISA        = 0x2C0;
+_TRISA        = 0x2C0;
+_TRISAbits    = 0x2C0;
+ PORTA        = 0x2C2;
+_PORTA        = 0x2C2;
+_PORTAbits    = 0x2C2;
+ LATA         = 0x2C4;
+_LATA         = 0x2C4;
+_LATAbits     = 0x2C4;
+ ODCA         = 0x2C6;
+_ODCA         = 0x2C6;
+_ODCAbits     = 0x2C6;
+ TRISB        = 0x2C8;
+_TRISB        = 0x2C8;
+_TRISBbits    = 0x2C8;
+ PORTB        = 0x2CA;
+_PORTB        = 0x2CA;
+_PORTBbits    = 0x2CA;
+ LATB         = 0x2CC;
+_LATB         = 0x2CC;
+_LATBbits     = 0x2CC;
+ ODCB         = 0x2CE;
+_ODCB         = 0x2CE;
+_ODCBbits     = 0x2CE;
+ TRISC        = 0x2D0;
+_TRISC        = 0x2D0;
+_TRISCbits    = 0x2D0;
+ PORTC        = 0x2D2;
+_PORTC        = 0x2D2;
+_PORTCbits    = 0x2D2;
+ LATC         = 0x2D4;
+_LATC         = 0x2D4;
+_LATCbits     = 0x2D4;
+ ODCC         = 0x2D6;
+_ODCC         = 0x2D6;
+_ODCCbits     = 0x2D6;
+ TRISD        = 0x2D8;
+_TRISD        = 0x2D8;
+_TRISDbits    = 0x2D8;
+ PORTD        = 0x2DA;
+_PORTD        = 0x2DA;
+_PORTDbits    = 0x2DA;
+ LATD         = 0x2DC;
+_LATD         = 0x2DC;
+_LATDbits     = 0x2DC;
+ ODCD         = 0x2DE;
+_ODCD         = 0x2DE;
+_ODCDbits     = 0x2DE;
+ TRISE        = 0x2E0;
+_TRISE        = 0x2E0;
+_TRISEbits    = 0x2E0;
+ PORTE        = 0x2E2;
+_PORTE        = 0x2E2;
+_PORTEbits    = 0x2E2;
+ LATE         = 0x2E4;
+_LATE         = 0x2E4;
+_LATEbits     = 0x2E4;
+ ODCE         = 0x2E6;
+_ODCE         = 0x2E6;
+_ODCEbits     = 0x2E6;
+ TRISF        = 0x2E8;
+_TRISF        = 0x2E8;
+_TRISFbits    = 0x2E8;
+ PORTF        = 0x2EA;
+_PORTF        = 0x2EA;
+_PORTFbits    = 0x2EA;
+ LATF         = 0x2EC;
+_LATF         = 0x2EC;
+_LATFbits     = 0x2EC;
+ ODCF         = 0x2EE;
+_ODCF         = 0x2EE;
+_ODCFbits     = 0x2EE;
+ TRISG        = 0x2F0;
+_TRISG        = 0x2F0;
+_TRISGbits    = 0x2F0;
+ PORTG        = 0x2F2;
+_PORTG        = 0x2F2;
+_PORTGbits    = 0x2F2;
+ LATG         = 0x2F4;
+_LATG         = 0x2F4;
+_LATGbits     = 0x2F4;
+ ODCG         = 0x2F6;
+_ODCG         = 0x2F6;
+_ODCGbits     = 0x2F6;
+ PADCFG1      = 0x2FC;
+_PADCFG1      = 0x2FC;
+_PADCFG1bits  = 0x2FC;
+ ADC1BUF0     = 0x300;
+_ADC1BUF0     = 0x300;
+ ADC1BUF1     = 0x302;
+_ADC1BUF1     = 0x302;
+ ADC1BUF2     = 0x304;
+_ADC1BUF2     = 0x304;
+ ADC1BUF3     = 0x306;
+_ADC1BUF3     = 0x306;
+ ADC1BUF4     = 0x308;
+_ADC1BUF4     = 0x308;
+ ADC1BUF5     = 0x30A;
+_ADC1BUF5     = 0x30A;
+ ADC1BUF6     = 0x30C;
+_ADC1BUF6     = 0x30C;
+ ADC1BUF7     = 0x30E;
+_ADC1BUF7     = 0x30E;
+ ADC1BUF8     = 0x310;
+_ADC1BUF8     = 0x310;
+ ADC1BUF9     = 0x312;
+_ADC1BUF9     = 0x312;
+ ADC1BUFA     = 0x314;
+_ADC1BUFA     = 0x314;
+ ADC1BUFB     = 0x316;
+_ADC1BUFB     = 0x316;
+ ADC1BUFC     = 0x318;
+_ADC1BUFC     = 0x318;
+ ADC1BUFD     = 0x31A;
+_ADC1BUFD     = 0x31A;
+ ADC1BUFE     = 0x31C;
+_ADC1BUFE     = 0x31C;
+ ADC1BUFF     = 0x31E;
+_ADC1BUFF     = 0x31E;
+ AD1CON1      = 0x320;
+_AD1CON1      = 0x320;
+_AD1CON1bits  = 0x320;
+ AD1CON2      = 0x322;
+_AD1CON2      = 0x322;
+_AD1CON2bits  = 0x322;
+ AD1CON3      = 0x324;
+_AD1CON3      = 0x324;
+_AD1CON3bits  = 0x324;
+ AD1CHS       = 0x328;
+_AD1CHS       = 0x328;
+_AD1CHSbits   = 0x328;
+ AD1CHS0      = 0x328;
+_AD1CHS0      = 0x328;
+_AD1CHS0bits  = 0x328;
+ AD1PCFGH     = 0x32A;
+_AD1PCFGH     = 0x32A;
+_AD1PCFGHbits = 0x32A;
+ AD1PCFG      = 0x32C;
+_AD1PCFG      = 0x32C;
+_AD1PCFGbits  = 0x32C;
+ AD1PCFGL     = 0x32C;
+_AD1PCFGL     = 0x32C;
+_AD1PCFGLbits = 0x32C;
+ AD1CSSL      = 0x330;
+_AD1CSSL      = 0x330;
+_AD1CSSLbits  = 0x330;
+ AD1CSSH      = 0x332;
+_AD1CSSH      = 0x332;
+_AD1CSSHbits  = 0x332;
+ CTMUCON      = 0x33C;
+_CTMUCON      = 0x33C;
+_CTMUCONbits  = 0x33C;
+ CTMUICON     = 0x33E;
+_CTMUICON     = 0x33E;
+_CTMUICONbits = 0x33E;
+ U1OTGIR      = 0x480;
+_U1OTGIR      = 0x480;
+_U1OTGIRbits  = 0x480;
+ U1OTGIE      = 0x482;
+_U1OTGIE      = 0x482;
+_U1OTGIEbits  = 0x482;
+ U1OTGSTAT    = 0x484;
+_U1OTGSTAT    = 0x484;
+_U1OTGSTATbits = 0x484;
+ U1OTGCON     = 0x486;
+_U1OTGCON     = 0x486;
+_U1OTGCONbits = 0x486;
+ U1PWRC       = 0x488;
+_U1PWRC       = 0x488;
+_U1PWRCbits   = 0x488;
+ U1IR         = 0x48A;
+_U1IR         = 0x48A;
+_U1IRbits     = 0x48A;
+ U1IE         = 0x48C;
+_U1IE         = 0x48C;
+_U1IEbits     = 0x48C;
+ U1EIR        = 0x48E;
+_U1EIR        = 0x48E;
+_U1EIRbits    = 0x48E;
+ U1EIE        = 0x490;
+_U1EIE        = 0x490;
+_U1EIEbits    = 0x490;
+ U1STAT       = 0x492;
+_U1STAT       = 0x492;
+_U1STATbits   = 0x492;
+ U1CON        = 0x494;
+_U1CON        = 0x494;
+_U1CONbits    = 0x494;
+ U1ADDR       = 0x496;
+_U1ADDR       = 0x496;
+_U1ADDRbits   = 0x496;
+ U1BDTP1      = 0x498;
+_U1BDTP1      = 0x498;
+_U1BDTP1bits  = 0x498;
+ U1FRML       = 0x49A;
+_U1FRML       = 0x49A;
+_U1FRMLbits   = 0x49A;
+ U1FRMH       = 0x49C;
+_U1FRMH       = 0x49C;
+_U1FRMHbits   = 0x49C;
+ U1TOK        = 0x49E;
+_U1TOK        = 0x49E;
+_U1TOKbits    = 0x49E;
+ U1SOF        = 0x4A0;
+_U1SOF        = 0x4A0;
+_U1SOFbits    = 0x4A0;
+ U1BDTP2      = 0x4A2;
+_U1BDTP2      = 0x4A2;
+_U1BDTP2bits  = 0x4A2;
+ U1BDTP3      = 0x4A4;
+_U1BDTP3      = 0x4A4;
+_U1BDTP3bits  = 0x4A4;
+ U1CNFG1      = 0x4A6;
+_U1CNFG1      = 0x4A6;
+_U1CNFG1bits  = 0x4A6;
+ U1CNFG2      = 0x4A8;
+_U1CNFG2      = 0x4A8;
+_U1CNFG2bits  = 0x4A8;
+ U1EP0        = 0x4AA;
+_U1EP0        = 0x4AA;
+_U1EP0bits    = 0x4AA;
+ U1EP1        = 0x4AC;
+_U1EP1        = 0x4AC;
+_U1EP1bits    = 0x4AC;
+ U1EP2        = 0x4AE;
+_U1EP2        = 0x4AE;
+_U1EP2bits    = 0x4AE;
+ U1EP3        = 0x4B0;
+_U1EP3        = 0x4B0;
+_U1EP3bits    = 0x4B0;
+ U1EP4        = 0x4B2;
+_U1EP4        = 0x4B2;
+_U1EP4bits    = 0x4B2;
+ U1EP5        = 0x4B4;
+_U1EP5        = 0x4B4;
+_U1EP5bits    = 0x4B4;
+ U1EP6        = 0x4B6;
+_U1EP6        = 0x4B6;
+_U1EP6bits    = 0x4B6;
+ U1EP7        = 0x4B8;
+_U1EP7        = 0x4B8;
+_U1EP7bits    = 0x4B8;
+ U1EP8        = 0x4BA;
+_U1EP8        = 0x4BA;
+_U1EP8bits    = 0x4BA;
+ U1EP9        = 0x4BC;
+_U1EP9        = 0x4BC;
+_U1EP9bits    = 0x4BC;
+ U1EP10       = 0x4BE;
+_U1EP10       = 0x4BE;
+_U1EP10bits   = 0x4BE;
+ U1EP11       = 0x4C0;
+_U1EP11       = 0x4C0;
+_U1EP11bits   = 0x4C0;
+ U1EP12       = 0x4C2;
+_U1EP12       = 0x4C2;
+_U1EP12bits   = 0x4C2;
+ U1EP13       = 0x4C4;
+_U1EP13       = 0x4C4;
+_U1EP13bits   = 0x4C4;
+ U1EP14       = 0x4C6;
+_U1EP14       = 0x4C6;
+_U1EP14bits   = 0x4C6;
+ U1EP15       = 0x4C8;
+_U1EP15       = 0x4C8;
+_U1EP15bits   = 0x4C8;
+ U1PWMRRS     = 0x4CC;
+_U1PWMRRS     = 0x4CC;
+_U1PWMRRSbits = 0x4CC;
+ U1PWMCON     = 0x4CE;
+_U1PWMCON     = 0x4CE;
+_U1PWMCONbits = 0x4CE;
+ PMCON        = 0x600;
+_PMCON        = 0x600;
+_PMCONbits    = 0x600;
+ PMMODE       = 0x602;
+_PMMODE       = 0x602;
+_PMMODEbits   = 0x602;
+ PMADDR       = 0x604;
+_PMADDR       = 0x604;
+_PMADDRbits   = 0x604;
+ PMDOUT1      = 0x604;
+_PMDOUT1      = 0x604;
+_PMDOUT1bits  = 0x604;
+ PMDOUT2      = 0x606;
+_PMDOUT2      = 0x606;
+ PMDIN1       = 0x608;
+_PMDIN1       = 0x608;
+ PMDIN2       = 0x60A;
+_PMDIN2       = 0x60A;
+ PMAEN        = 0x60C;
+_PMAEN        = 0x60C;
+_PMAENbits    = 0x60C;
+ PMSTAT       = 0x60E;
+_PMSTAT       = 0x60E;
+_PMSTATbits   = 0x60E;
+ ALRMVAL      = 0x620;
+_ALRMVAL      = 0x620;
+ ALCFGRPT     = 0x622;
+_ALCFGRPT     = 0x622;
+_ALCFGRPTbits = 0x622;
+ RTCVAL       = 0x624;
+_RTCVAL       = 0x624;
+ RCFGCAL      = 0x626;
+_RCFGCAL      = 0x626;
+_RCFGCALbits  = 0x626;
+ CMSTAT       = 0x630;
+_CMSTAT       = 0x630;
+_CMSTATbits   = 0x630;
+ CVRCON       = 0x632;
+_CVRCON       = 0x632;
+_CVRCONbits   = 0x632;
+ CM1CON       = 0x634;
+_CM1CON       = 0x634;
+_CM1CONbits   = 0x634;
+ CM2CON       = 0x636;
+_CM2CON       = 0x636;
+_CM2CONbits   = 0x636;
+ CM3CON       = 0x638;
+_CM3CON       = 0x638;
+_CM3CONbits   = 0x638;
+ CRCCON       = 0x640;
+_CRCCON       = 0x640;
+_CRCCONbits   = 0x640;
+ CRCXOR       = 0x642;
+_CRCXOR       = 0x642;
+_CRCXORbits   = 0x642;
+ CRCDAT       = 0x644;
+_CRCDAT       = 0x644;
+ CRCWDAT      = 0x646;
+_CRCWDAT      = 0x646;
+ RPINR0       = 0x680;
+_RPINR0       = 0x680;
+_RPINR0bits   = 0x680;
+ RPINR1       = 0x682;
+_RPINR1       = 0x682;
+_RPINR1bits   = 0x682;
+ RPINR2       = 0x684;
+_RPINR2       = 0x684;
+_RPINR2bits   = 0x684;
+ RPINR3       = 0x686;
+_RPINR3       = 0x686;
+_RPINR3bits   = 0x686;
+ RPINR4       = 0x688;
+_RPINR4       = 0x688;
+_RPINR4bits   = 0x688;
+ RPINR7       = 0x68E;
+_RPINR7       = 0x68E;
+_RPINR7bits   = 0x68E;
+ RPINR8       = 0x690;
+_RPINR8       = 0x690;
+_RPINR8bits   = 0x690;
+ RPINR9       = 0x692;
+_RPINR9       = 0x692;
+_RPINR9bits   = 0x692;
+ RPINR10      = 0x694;
+_RPINR10      = 0x694;
+_RPINR10bits  = 0x694;
+ RPINR11      = 0x696;
+_RPINR11      = 0x696;
+_RPINR11bits  = 0x696;
+ RPINR15      = 0x69E;
+_RPINR15      = 0x69E;
+_RPINR15bits  = 0x69E;
+ RPINR17      = 0x6A2;
+_RPINR17      = 0x6A2;
+_RPINR17bits  = 0x6A2;
+ RPINR18      = 0x6A4;
+_RPINR18      = 0x6A4;
+_RPINR18bits  = 0x6A4;
+ RPINR19      = 0x6A6;
+_RPINR19      = 0x6A6;
+_RPINR19bits  = 0x6A6;
+ RPINR20      = 0x6A8;
+_RPINR20      = 0x6A8;
+_RPINR20bits  = 0x6A8;
+ RPINR21      = 0x6AA;
+_RPINR21      = 0x6AA;
+_RPINR21bits  = 0x6AA;
+ RPINR22      = 0x6AC;
+_RPINR22      = 0x6AC;
+_RPINR22bits  = 0x6AC;
+ RPINR23      = 0x6AE;
+_RPINR23      = 0x6AE;
+_RPINR23bits  = 0x6AE;
+ RPINR27      = 0x6B6;
+_RPINR27      = 0x6B6;
+_RPINR27bits  = 0x6B6;
+ RPINR28      = 0x6B8;
+_RPINR28      = 0x6B8;
+_RPINR28bits  = 0x6B8;
+ RPINR29      = 0x6BA;
+_RPINR29      = 0x6BA;
+_RPINR29bits  = 0x6BA;
+ RPOR0        = 0x6C0;
+_RPOR0        = 0x6C0;
+_RPOR0bits    = 0x6C0;
+ RPOR1        = 0x6C2;
+_RPOR1        = 0x6C2;
+_RPOR1bits    = 0x6C2;
+ RPOR2        = 0x6C4;
+_RPOR2        = 0x6C4;
+_RPOR2bits    = 0x6C4;
+ RPOR3        = 0x6C6;
+_RPOR3        = 0x6C6;
+_RPOR3bits    = 0x6C6;
+ RPOR4        = 0x6C8;
+_RPOR4        = 0x6C8;
+_RPOR4bits    = 0x6C8;
+ RPOR5        = 0x6CA;
+_RPOR5        = 0x6CA;
+_RPOR5bits    = 0x6CA;
+ RPOR6        = 0x6CC;
+_RPOR6        = 0x6CC;
+_RPOR6bits    = 0x6CC;
+ RPOR7        = 0x6CE;
+_RPOR7        = 0x6CE;
+_RPOR7bits    = 0x6CE;
+ RPOR8        = 0x6D0;
+_RPOR8        = 0x6D0;
+_RPOR8bits    = 0x6D0;
+ RPOR9        = 0x6D2;
+_RPOR9        = 0x6D2;
+_RPOR9bits    = 0x6D2;
+ RPOR10       = 0x6D4;
+_RPOR10       = 0x6D4;
+_RPOR10bits   = 0x6D4;
+ RPOR11       = 0x6D6;
+_RPOR11       = 0x6D6;
+_RPOR11bits   = 0x6D6;
+ RPOR12       = 0x6D8;
+_RPOR12       = 0x6D8;
+_RPOR12bits   = 0x6D8;
+ RPOR13       = 0x6DA;
+_RPOR13       = 0x6DA;
+_RPOR13bits   = 0x6DA;
+ RPOR14       = 0x6DC;
+_RPOR14       = 0x6DC;
+_RPOR14bits   = 0x6DC;
+ RPOR15       = 0x6DE;
+_RPOR15       = 0x6DE;
+_RPOR15bits   = 0x6DE;
+ RCON         = 0x740;
+_RCON         = 0x740;
+_RCONbits     = 0x740;
+ OSCCON       = 0x742;
+_OSCCON       = 0x742;
+_OSCCONbits   = 0x742;
+ CLKDIV       = 0x744;
+_CLKDIV       = 0x744;
+_CLKDIVbits   = 0x744;
+ OSCTUN       = 0x748;
+_OSCTUN       = 0x748;
+_OSCTUNbits   = 0x748;
+ REFOCON      = 0x74E;
+_REFOCON      = 0x74E;
+_REFOCONbits  = 0x74E;
+ NVMCON       = 0x760;
+_NVMCON       = 0x760;
+_NVMCONbits   = 0x760;
+ NVMKEY       = 0x766;
+_NVMKEY       = 0x766;
+ PMD1         = 0x770;
+_PMD1         = 0x770;
+_PMD1bits     = 0x770;
+ PMD2         = 0x772;
+_PMD2         = 0x772;
+_PMD2bits     = 0x772;
+ PMD3         = 0x774;
+_PMD3         = 0x774;
+_PMD3bits     = 0x774;
+ PMD4         = 0x776;
+_PMD4         = 0x776;
+_PMD4bits     = 0x776;
+ PMD5         = 0x778;
+_PMD5         = 0x778;
+_PMD5bits     = 0x778;
+ PMD6         = 0x77A;
+_PMD6         = 0x77A;
+_PMD6bits     = 0x77A;
+/*
+** ======= Base Addresses for Various Peripherals ======
+*/
+
+ IC1          = 0x144;
+_IC1          = 0x144;
+ IC2          = 0x14C;
+_IC2          = 0x14C;
+ IC3          = 0x154;
+_IC3          = 0x154;
+ IC4          = 0x15C;
+_IC4          = 0x15C;
+ IC5          = 0x164;
+_IC5          = 0x164;
+ IC6          = 0x16C;
+_IC6          = 0x16C;
+ IC7          = 0x174;
+_IC7          = 0x174;
+ IC8          = 0x17C;
+_IC8          = 0x17C;
+ OC1          = 0x194;
+_OC1          = 0x194;
+ OC2          = 0x19E;
+_OC2          = 0x19E;
+ OC3          = 0x1A8;
+_OC3          = 0x1A8;
+ OC4          = 0x1B2;
+_OC4          = 0x1B2;
+ OC5          = 0x1BC;
+_OC5          = 0x1BC;
+ OC6          = 0x1C6;
+_OC6          = 0x1C6;
+ OC7          = 0x1D0;
+_OC7          = 0x1D0;
+ OC8          = 0x1DA;
+_OC8          = 0x1DA;
+ SPI1         = 0x240;
+_SPI1         = 0x240;
+ SPI2         = 0x260;
+_SPI2         = 0x260;
+ UART1        = 0x220;
+_UART1        = 0x220;
+ UART2        = 0x230;
+_UART2        = 0x230;

+ 56 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/procdefs.ld.boot

@@ -0,0 +1,56 @@
+/*************************************************************************
+ * Processor-specific object file.  Contains SFR definitions.
+ *************************************************************************/
+INPUT("processor.o")
+
+/*************************************************************************
+ * For interrupt vector handling
+ *************************************************************************/
+PROVIDE(_vector_spacing = 0x00000001);
+_ebase_address  = 0x9D005000;
+
+/*************************************************************************
+ * Memory Address Equates
+ *************************************************************************/
+_RESET_ADDR              = 0x9D006000;
+_BEV_EXCPT_ADDR          = 0x9D006380;
+_DBG_EXCPT_ADDR          = 0x9D006480;
+_DBG_CODE_ADDR           = 0xBFC02000;
+_GEN_EXCPT_ADDR          = _ebase_address + 0x180;
+
+/*************************************************************************
+ * Memory Regions
+ *
+ * Memory regions without attributes cannot be used for orphaned sections.
+ * Only sections specifically assigned to these regions can be allocated
+ * into these regions.
+ *************************************************************************/
+MEMORY
+{
+  kseg0_program_mem    (rx)  : ORIGIN = 0x9D006A00, LENGTH = 0x7A600
+  kseg0_boot_mem             : ORIGIN = 0x9D006490, LENGTH = 0x970
+  exception_mem              : ORIGIN = 0x9D005000, LENGTH = 0x1000
+  kseg1_boot_mem             : ORIGIN = 0x9D006000, LENGTH = 0x490
+  debug_exec_mem             : ORIGIN = 0xBFC02000, LENGTH = 0xFF0
+  config3                    : ORIGIN = 0xBFC02FF0, LENGTH = 0x4
+  config2                    : ORIGIN = 0xBFC02FF4, LENGTH = 0x4
+  config1                    : ORIGIN = 0xBFC02FF8, LENGTH = 0x4
+  config0                    : ORIGIN = 0xBFC02FFC, LENGTH = 0x4
+  kseg1_data_mem       (w!x) : ORIGIN = 0xA0000000, LENGTH = 0x8000
+  sfrs                       : ORIGIN = 0xBF800000, LENGTH = 0x100000
+}
+SECTIONS
+{
+  .config_BFC02FF0 : {
+    KEEP(*(.config_BFC02FF0))
+  } > config3
+  .config_BFC02FF4 : {
+    KEEP(*(.config_BFC02FF4))
+  } > config2
+  .config_BFC02FF8 : {
+    KEEP(*(.config_BFC02FF8))
+  } > config1
+  .config_BFC02FFC : {
+    KEEP(*(.config_BFC02FFC))
+  } > config0
+}

+ 24 - 0
pyusb/tests/pic18f4550/Microchip Solutions/TestFirmware/Firmware/projects/VStudio/CompilerSettings.txt

@@ -0,0 +1,24 @@
+REM ///////////////////////////////////////////////////////////////////////
+REM // MCC18 Compiler Options (see mcc18.exe --help)
+REM ///////////////////////////////////////////////////////////////////////
+SET DisableWarning=2106
+SET WarningLevel=2
+SET IntDir="$(ProjectDir)temp"
+SET TargetProcessor=18F4550
+
+REM ///////////////////////////////////////////////////////////////////////
+REM // Include Directories
+REM ///////////////////////////////////////////////////////////////////////
+SET IncludeDirs=              -I"$(MCC_INCLUDE)"
+SET IncludeDirs=%IncludeDirs% -I"$(ProjectDir)"
+SET IncludeDirs=%IncludeDirs% -I"C:\MCC18\h"
+SET IncludeDirs=%IncludeDirs% -I"..\..\..\Microchip\Include"
+SET IncludeDirs=%IncludeDirs% -I"..\..\..\Microchip\Include\Usb"
+SET IncludeDirs=%IncludeDirs% -I"..\..\..\..\Microchip\Include"
+SET IncludeDirs=%IncludeDirs% -I"..\..\..\..\Microchip\Include\Usb"
+SET IncludeDirs=%IncludeDirs% -I"..\..\"
+
+REM ///////////////////////////////////////////////////////////////////////
+REM // Build all source files (*.c) in the Win32|Release Configuration
+REM ///////////////////////////////////////////////////////////////////////
+.\Utility\MPlabMake.exe -vc="$(ProjectPath)" -IntDir=%IntDir% -args=` -p=%TargetProcessor%  -nw=%DisableWarning% -w=%WarningLevel% %IncludeDirs% `

Some files were not shown because too many files changed in this diff